@typescript-eslint/eslint-plugin 6.0.1-alpha.3 → 6.0.1-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -7
- package/rules.d.ts +44 -0
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/eslint-plugin",
|
|
3
|
-
"version": "6.0.1-alpha.
|
|
3
|
+
"version": "6.0.1-alpha.5+a3da11d09",
|
|
4
4
|
"description": "TypeScript plugin for ESLint",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
7
7
|
"docs",
|
|
8
8
|
"index.d.ts",
|
|
9
|
+
"rules.d.ts",
|
|
9
10
|
"package.json",
|
|
10
11
|
"README.md",
|
|
11
12
|
"LICENSE"
|
|
@@ -56,10 +57,10 @@
|
|
|
56
57
|
},
|
|
57
58
|
"dependencies": {
|
|
58
59
|
"@eslint-community/regexpp": "^4.5.1",
|
|
59
|
-
"@typescript-eslint/scope-manager": "6.0.1-alpha.
|
|
60
|
-
"@typescript-eslint/type-utils": "6.0.1-alpha.
|
|
61
|
-
"@typescript-eslint/utils": "6.0.1-alpha.
|
|
62
|
-
"@typescript-eslint/visitor-keys": "6.0.1-alpha.
|
|
60
|
+
"@typescript-eslint/scope-manager": "6.0.1-alpha.5+a3da11d09",
|
|
61
|
+
"@typescript-eslint/type-utils": "6.0.1-alpha.5+a3da11d09",
|
|
62
|
+
"@typescript-eslint/utils": "6.0.1-alpha.5+a3da11d09",
|
|
63
|
+
"@typescript-eslint/visitor-keys": "6.0.1-alpha.5+a3da11d09",
|
|
63
64
|
"debug": "^4.3.4",
|
|
64
65
|
"graphemer": "^1.4.0",
|
|
65
66
|
"ignore": "^5.2.4",
|
|
@@ -74,7 +75,7 @@
|
|
|
74
75
|
"@types/natural-compare": "*",
|
|
75
76
|
"@types/prettier": "*",
|
|
76
77
|
"@typescript-eslint/rule-schema-to-typescript-types": "6.0.0",
|
|
77
|
-
"@typescript-eslint/rule-tester": "6.0.1-alpha.
|
|
78
|
+
"@typescript-eslint/rule-tester": "6.0.1-alpha.5+a3da11d09",
|
|
78
79
|
"ajv": "^6.12.6",
|
|
79
80
|
"chalk": "^5.3.0",
|
|
80
81
|
"cross-fetch": "*",
|
|
@@ -99,5 +100,5 @@
|
|
|
99
100
|
"type": "opencollective",
|
|
100
101
|
"url": "https://opencollective.com/typescript-eslint"
|
|
101
102
|
},
|
|
102
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "a3da11d09b1d119fd5bc4cd776474e2520d7fefd"
|
|
103
104
|
}
|
package/rules.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
We purposely don't generate types for our plugin because TL;DR:
|
|
3
|
+
1) there's no real reason that anyone should do a typed import of our rules,
|
|
4
|
+
2) it would require us to change our code so there aren't as many inferred types
|
|
5
|
+
|
|
6
|
+
This type declaration exists as a hacky way to add a type to the export for our
|
|
7
|
+
internal packages that require it.
|
|
8
|
+
|
|
9
|
+
*** Long reason ***
|
|
10
|
+
|
|
11
|
+
When you turn on declaration files, TS requires all types to be "fully resolvable"
|
|
12
|
+
without changes to the code.
|
|
13
|
+
All of our lint rules `export default createRule(...)`, which means they all
|
|
14
|
+
implicitly reference the `TSESLint.Rule` type for the export.
|
|
15
|
+
|
|
16
|
+
TS wants to transpile each rule file to this `.d.ts` file:
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import type { TSESLint } from '@typescript-eslint/utils';
|
|
20
|
+
declare const _default: TSESLint.RuleModule<TMessageIds, TOptions, TSESLint.RuleListener>;
|
|
21
|
+
export default _default;
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Because we don't import `TSESLint` in most files, it means that TS would have to
|
|
25
|
+
insert a new import during the declaration emit to make this work.
|
|
26
|
+
However TS wants to avoid adding new imports to the file because a new module
|
|
27
|
+
could have type side-effects (like global augmentation) which could cause weird
|
|
28
|
+
type side-effects in the decl file that wouldn't exist in source TS file.
|
|
29
|
+
|
|
30
|
+
So TS errors on most of our rules with the following error:
|
|
31
|
+
```
|
|
32
|
+
The inferred type of 'default' cannot be named without a reference to
|
|
33
|
+
'../../../../node_modules/@typescript-eslint/utils/src/ts-eslint/Rule'.
|
|
34
|
+
This is likely not portable. A type annotation is necessary. ts(2742)
|
|
35
|
+
```
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
import type { RuleModule } from '@typescript-eslint/utils/ts-eslint';
|
|
39
|
+
|
|
40
|
+
export interface TypeScriptESLintRules {
|
|
41
|
+
[ruleName: string]: RuleModule<string, unknown[]>;
|
|
42
|
+
}
|
|
43
|
+
declare const rules: TypeScriptESLintRules;
|
|
44
|
+
export = rules;
|