@typescript-eslint/eslint-plugin 6.8.1-alpha.4 → 6.8.1-alpha.6
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/dist/rules/no-restricted-imports.js +35 -13
- package/dist/rules/no-restricted-imports.js.map +1 -1
- package/docs/rules/default-param-last.md +16 -4
- package/docs/rules/explicit-function-return-type.md +3 -3
- package/docs/rules/explicit-member-accessibility.md +12 -3
- package/docs/rules/explicit-module-boundary-types.md +2 -2
- package/docs/rules/no-restricted-imports.md +22 -12
- package/package.json +9 -9
|
@@ -168,22 +168,44 @@ exports.default = (0, util_1.createRule)({
|
|
|
168
168
|
// As long as there's one matching pattern that allows type import
|
|
169
169
|
allowedImportTypeMatchers.some(matcher => matcher.ignores(importSource)));
|
|
170
170
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
!isAllowedTypeImportPattern(importSource)) {
|
|
180
|
-
return rules.ImportDeclaration(node);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
171
|
+
function checkImportNode(node) {
|
|
172
|
+
if (node.importKind === 'type' ||
|
|
173
|
+
(node.specifiers.length > 0 &&
|
|
174
|
+
node.specifiers.every(specifier => specifier.type === utils_1.AST_NODE_TYPES.ImportSpecifier &&
|
|
175
|
+
specifier.importKind === 'type'))) {
|
|
176
|
+
const importSource = node.source.value.trim();
|
|
177
|
+
if (!isAllowedTypeImportPath(importSource) &&
|
|
178
|
+
!isAllowedTypeImportPattern(importSource)) {
|
|
184
179
|
return rules.ImportDeclaration(node);
|
|
185
180
|
}
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
return rules.ImportDeclaration(node);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
TSImportEqualsDeclaration(node) {
|
|
188
|
+
if (node.moduleReference.type ===
|
|
189
|
+
utils_1.AST_NODE_TYPES.TSExternalModuleReference &&
|
|
190
|
+
node.moduleReference.expression.type === utils_1.AST_NODE_TYPES.Literal &&
|
|
191
|
+
typeof node.moduleReference.expression.value === 'string') {
|
|
192
|
+
const synthesizedImport = {
|
|
193
|
+
...node,
|
|
194
|
+
type: utils_1.AST_NODE_TYPES.ImportDeclaration,
|
|
195
|
+
source: node.moduleReference.expression,
|
|
196
|
+
assertions: [],
|
|
197
|
+
specifiers: [
|
|
198
|
+
{
|
|
199
|
+
...node.id,
|
|
200
|
+
type: utils_1.AST_NODE_TYPES.ImportDefaultSpecifier,
|
|
201
|
+
local: node.id,
|
|
202
|
+
},
|
|
203
|
+
],
|
|
204
|
+
};
|
|
205
|
+
return checkImportNode(synthesizedImport);
|
|
206
|
+
}
|
|
186
207
|
},
|
|
208
|
+
ImportDeclaration: checkImportNode,
|
|
187
209
|
'ExportNamedDeclaration[source]'(node) {
|
|
188
210
|
if (node.exportKind === 'type' ||
|
|
189
211
|
(node.specifiers.length > 0 &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-restricted-imports.js","sourceRoot":"","sources":["../../src/rules/no-restricted-imports.ts"],"names":[],"mappings":";;;;;AACA,oDAA0D;AAW1D,oDAA4B;AAM5B,kCAAqC;AACrC,iEAA8D;AAE9D,MAAM,QAAQ,GAAG,IAAA,qCAAiB,EAAC,uBAAuB,CAAC,CAAC;AAK5D,iFAAiF;AACjF,gFAAgF;AAChF,kDAAkD;AAClD,MAAM,SAAS,GAAG,CAAI,MAAe,EAAE,QAAW,EAAK,EAAE;IACvD,IAAI;QACF,OAAO,MAAM,EAAE,CAAC;KACjB;IAAC,MAAM;QACN,OAAO,QAAQ,CAAC;KACjB;AACH,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,MAwChC,CAAC;AAEF,MAAM,4BAA4B,GAA0C;IAC1E,gBAAgB,EAAE;QAChB,IAAI,EAAE,SAAS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AAC;QAED,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAC1D,MAAM,yBAAyB,GAAa,EAAE,CAAC;QAC/C,KAAK,MAAM,iBAAiB,IAAI,kBAAkB,EAAE;YAClD,IACE,OAAO,iBAAiB,KAAK,QAAQ;gBACrC,iBAAiB,CAAC,gBAAgB,EAClC;gBACA,sDAAsD;gBACtD,yBAAyB,CAAC,IAAI,CAC5B,IAAA,gBAAM,EAAC;oBACL,kBAAkB,EAAE,IAAI;oBACxB,UAAU,EAAE,CAAC,iBAAiB,CAAC,aAAa;iBAC7C,CAAC,CAAC,GAAG,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAChC,CAAC;aACH;SACF;QACD,SAAS,0BAA0B,CAAC,YAAoB;YACtD,OAAO;YACL,kEAAkE;YAClE,yBAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CACzE,CAAC;QACJ,CAAC;QAED,
|
|
1
|
+
{"version":3,"file":"no-restricted-imports.js","sourceRoot":"","sources":["../../src/rules/no-restricted-imports.ts"],"names":[],"mappings":";;;;;AACA,oDAA0D;AAW1D,oDAA4B;AAM5B,kCAAqC;AACrC,iEAA8D;AAE9D,MAAM,QAAQ,GAAG,IAAA,qCAAiB,EAAC,uBAAuB,CAAC,CAAC;AAK5D,iFAAiF;AACjF,gFAAgF;AAChF,kDAAkD;AAClD,MAAM,SAAS,GAAG,CAAI,MAAe,EAAE,QAAW,EAAK,EAAE;IACvD,IAAI;QACF,OAAO,MAAM,EAAE,CAAC;KACjB;IAAC,MAAM;QACN,OAAO,QAAQ,CAAC;KACjB;AACH,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,MAwChC,CAAC;AAEF,MAAM,4BAA4B,GAA0C;IAC1E,gBAAgB,EAAE;QAChB,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,sDAAsD;KACpE;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AAC,oBAAoB;SACjD,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -20,10 +20,16 @@ function f(a = 0, b: number) {}
|
|
|
20
20
|
function f(a: number, b = 0, c: number) {}
|
|
21
21
|
function f(a: number, b?: number, c: number) {}
|
|
22
22
|
class Foo {
|
|
23
|
-
constructor(
|
|
23
|
+
constructor(
|
|
24
|
+
public a = 10,
|
|
25
|
+
private b: number,
|
|
26
|
+
) {}
|
|
24
27
|
}
|
|
25
28
|
class Foo {
|
|
26
|
-
constructor(
|
|
29
|
+
constructor(
|
|
30
|
+
public a?: number,
|
|
31
|
+
private b: number,
|
|
32
|
+
) {}
|
|
27
33
|
}
|
|
28
34
|
```
|
|
29
35
|
|
|
@@ -38,9 +44,15 @@ function f(a: number, b?: number) {}
|
|
|
38
44
|
function f(a: number, b?: number, c = 0) {}
|
|
39
45
|
function f(a: number, b = 0, c?: number) {}
|
|
40
46
|
class Foo {
|
|
41
|
-
constructor(
|
|
47
|
+
constructor(
|
|
48
|
+
public a,
|
|
49
|
+
private b = 0,
|
|
50
|
+
) {}
|
|
42
51
|
}
|
|
43
52
|
class Foo {
|
|
44
|
-
constructor(
|
|
53
|
+
constructor(
|
|
54
|
+
public a,
|
|
55
|
+
private b?: number,
|
|
56
|
+
) {}
|
|
45
57
|
}
|
|
46
58
|
```
|
|
@@ -209,14 +209,14 @@ Examples of code for this rule with `{ allowDirectConstAssertionInArrowFunctions
|
|
|
209
209
|
#### ❌ Incorrect
|
|
210
210
|
|
|
211
211
|
```ts
|
|
212
|
-
const func = (value: number) => ({ type: 'X', value } as any
|
|
213
|
-
const func = (value: number) => ({ type: 'X', value } as Action
|
|
212
|
+
const func = (value: number) => ({ type: 'X', value }) as any;
|
|
213
|
+
const func = (value: number) => ({ type: 'X', value }) as Action;
|
|
214
214
|
```
|
|
215
215
|
|
|
216
216
|
#### ✅ Correct
|
|
217
217
|
|
|
218
218
|
```ts
|
|
219
|
-
const func = (value: number) => ({ foo: 'bar', value } as const
|
|
219
|
+
const func = (value: number) => ({ foo: 'bar', value }) as const;
|
|
220
220
|
const func = () => x as const;
|
|
221
221
|
```
|
|
222
222
|
|
|
@@ -90,7 +90,10 @@ The following patterns are considered correct with the default options `{ access
|
|
|
90
90
|
|
|
91
91
|
```ts
|
|
92
92
|
class Animal {
|
|
93
|
-
public constructor(
|
|
93
|
+
public constructor(
|
|
94
|
+
public breed,
|
|
95
|
+
name,
|
|
96
|
+
) {
|
|
94
97
|
// Parameter property and constructor
|
|
95
98
|
this.animalName = name;
|
|
96
99
|
}
|
|
@@ -113,7 +116,10 @@ The following patterns are considered incorrect with the accessibility set to **
|
|
|
113
116
|
|
|
114
117
|
```ts
|
|
115
118
|
class Animal {
|
|
116
|
-
public constructor(
|
|
119
|
+
public constructor(
|
|
120
|
+
public breed,
|
|
121
|
+
name,
|
|
122
|
+
) {
|
|
117
123
|
// Parameter property and constructor
|
|
118
124
|
this.animalName = name;
|
|
119
125
|
}
|
|
@@ -136,7 +142,10 @@ The following patterns are considered correct with the accessibility set to **no
|
|
|
136
142
|
|
|
137
143
|
```ts
|
|
138
144
|
class Animal {
|
|
139
|
-
constructor(
|
|
145
|
+
constructor(
|
|
146
|
+
protected breed,
|
|
147
|
+
name,
|
|
148
|
+
) {
|
|
140
149
|
// Parameter property and constructor
|
|
141
150
|
this.name = name;
|
|
142
151
|
}
|
|
@@ -131,11 +131,11 @@ export const bar = () => 1;
|
|
|
131
131
|
#### ✅ Correct
|
|
132
132
|
|
|
133
133
|
```ts
|
|
134
|
-
export const func = (value: number) => ({ type: 'X', value } as const
|
|
134
|
+
export const func = (value: number) => ({ type: 'X', value }) as const;
|
|
135
135
|
export const foo = () =>
|
|
136
136
|
({
|
|
137
137
|
bar: true,
|
|
138
|
-
} as const
|
|
138
|
+
}) as const;
|
|
139
139
|
export const bar = () => 1 as const;
|
|
140
140
|
```
|
|
141
141
|
|
|
@@ -6,7 +6,7 @@ description: 'Disallow specified modules when loaded by `import`.'
|
|
|
6
6
|
>
|
|
7
7
|
> See **https://typescript-eslint.io/rules/no-restricted-imports** for documentation.
|
|
8
8
|
|
|
9
|
-
This rule extends the base [`eslint/no-restricted-imports`](https://eslint.org/docs/rules/no-restricted-imports) rule.
|
|
9
|
+
This rule extends the base [`eslint/no-restricted-imports`](https://eslint.org/docs/rules/no-restricted-imports) rule. It adds support for the type import (`import type X from "..."`, `import { type X } from "..."`) and `import x = require("...")` syntaxes.
|
|
10
10
|
|
|
11
11
|
## Options
|
|
12
12
|
|
|
@@ -19,17 +19,27 @@ This rule adds the following options:
|
|
|
19
19
|
You can specify this option for a specific path or pattern as follows:
|
|
20
20
|
|
|
21
21
|
```jsonc
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
22
|
+
{
|
|
23
|
+
"rules": {
|
|
24
|
+
"@typescript-eslint/no-restricted-imports": [
|
|
25
|
+
"error",
|
|
26
|
+
{
|
|
27
|
+
"paths": [
|
|
28
|
+
{
|
|
29
|
+
"name": "import-foo",
|
|
30
|
+
"message": "Please use import-bar instead.",
|
|
31
|
+
"allowTypeImports": true
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "import-baz",
|
|
35
|
+
"message": "Please use import-quux instead.",
|
|
36
|
+
"allowTypeImports": true
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
33
43
|
```
|
|
34
44
|
|
|
35
45
|
When set to `true`, the rule will allow [Type-Only Imports](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/eslint-plugin",
|
|
3
|
-
"version": "6.8.1-alpha.
|
|
3
|
+
"version": "6.8.1-alpha.6+4c8edcfb7",
|
|
4
4
|
"description": "TypeScript plugin for ESLint",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -57,10 +57,10 @@
|
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@eslint-community/regexpp": "^4.5.1",
|
|
60
|
-
"@typescript-eslint/scope-manager": "6.8.1-alpha.
|
|
61
|
-
"@typescript-eslint/type-utils": "6.8.1-alpha.
|
|
62
|
-
"@typescript-eslint/utils": "6.8.1-alpha.
|
|
63
|
-
"@typescript-eslint/visitor-keys": "6.8.1-alpha.
|
|
60
|
+
"@typescript-eslint/scope-manager": "6.8.1-alpha.6+4c8edcfb7",
|
|
61
|
+
"@typescript-eslint/type-utils": "6.8.1-alpha.6+4c8edcfb7",
|
|
62
|
+
"@typescript-eslint/utils": "6.8.1-alpha.6+4c8edcfb7",
|
|
63
|
+
"@typescript-eslint/visitor-keys": "6.8.1-alpha.6+4c8edcfb7",
|
|
64
64
|
"debug": "^4.3.4",
|
|
65
65
|
"graphemer": "^1.4.0",
|
|
66
66
|
"ignore": "^5.2.4",
|
|
@@ -69,12 +69,12 @@
|
|
|
69
69
|
"ts-api-utils": "^1.0.1"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
+
"@prettier/sync": "*",
|
|
72
73
|
"@types/debug": "*",
|
|
73
74
|
"@types/marked": "*",
|
|
74
75
|
"@types/natural-compare": "*",
|
|
75
|
-
"@types/prettier": "*",
|
|
76
76
|
"@typescript-eslint/rule-schema-to-typescript-types": "6.8.0",
|
|
77
|
-
"@typescript-eslint/rule-tester": "6.8.1-alpha.
|
|
77
|
+
"@typescript-eslint/rule-tester": "6.8.1-alpha.6+4c8edcfb7",
|
|
78
78
|
"ajv": "^6.12.6",
|
|
79
79
|
"chalk": "^5.3.0",
|
|
80
80
|
"cross-fetch": "*",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"json-schema": "*",
|
|
85
85
|
"markdown-table": "^3.0.3",
|
|
86
86
|
"marked": "^5.1.1",
|
|
87
|
-
"prettier": "^
|
|
87
|
+
"prettier": "^3.0.3",
|
|
88
88
|
"rimraf": "*",
|
|
89
89
|
"title-case": "^3.0.3",
|
|
90
90
|
"tsx": "*",
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
"type": "opencollective",
|
|
104
104
|
"url": "https://opencollective.com/typescript-eslint"
|
|
105
105
|
},
|
|
106
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "4c8edcfb7d3cc02d07d2329c87da4377c1cbf969"
|
|
107
107
|
}
|