@angular-eslint/utils 22.0.1-alpha.15 → 22.0.1-alpha.17
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/eslint-plugin/get-native-event-names.d.ts +1 -1
- package/dist/eslint-plugin/get-native-event-names.d.ts.map +1 -1
- package/dist/eslint-plugin/get-native-event-names.js +1 -4
- package/dist/eslint-plugin/rule-fixes.d.ts +18 -0
- package/dist/eslint-plugin/rule-fixes.d.ts.map +1 -1
- package/dist/eslint-plugin/rule-fixes.js +53 -3
- package/package.json +2 -2
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
/**
|
|
7
7
|
* Check MDN events page for details https://developer.mozilla.org/en-US/docs/Web/Events
|
|
8
8
|
*
|
|
9
|
-
* Event names sourced from @mdn/browser-compat-data@8.0.
|
|
9
|
+
* Event names sourced from @mdn/browser-compat-data@8.0.5
|
|
10
10
|
*/
|
|
11
11
|
export declare function getNativeEventNames(): ReadonlySet<string>;
|
|
12
12
|
//# sourceMappingURL=get-native-event-names.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-native-event-names.d.ts","sourceRoot":"","sources":["../../src/eslint-plugin/get-native-event-names.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,WAAW,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"get-native-event-names.d.ts","sourceRoot":"","sources":["../../src/eslint-plugin/get-native-event-names.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,WAAW,CAAC,MAAM,CAAC,CAwLzD"}
|
|
@@ -10,7 +10,7 @@ let nativeEventNames = null;
|
|
|
10
10
|
/**
|
|
11
11
|
* Check MDN events page for details https://developer.mozilla.org/en-US/docs/Web/Events
|
|
12
12
|
*
|
|
13
|
-
* Event names sourced from @mdn/browser-compat-data@8.0.
|
|
13
|
+
* Event names sourced from @mdn/browser-compat-data@8.0.5
|
|
14
14
|
*/
|
|
15
15
|
function getNativeEventNames() {
|
|
16
16
|
return (nativeEventNames ??
|
|
@@ -34,7 +34,6 @@ function getNativeEventNames() {
|
|
|
34
34
|
'beforexrselect',
|
|
35
35
|
'beginEvent',
|
|
36
36
|
'blur',
|
|
37
|
-
'bounce',
|
|
38
37
|
'cancel',
|
|
39
38
|
'canplay',
|
|
40
39
|
'canplaythrough',
|
|
@@ -74,7 +73,6 @@ function getNativeEventNames() {
|
|
|
74
73
|
'endEvent',
|
|
75
74
|
'enterpictureinpicture',
|
|
76
75
|
'error',
|
|
77
|
-
'finish',
|
|
78
76
|
'focus',
|
|
79
77
|
'focusin',
|
|
80
78
|
'focusout',
|
|
@@ -162,7 +160,6 @@ function getNativeEventNames() {
|
|
|
162
160
|
'selectstart',
|
|
163
161
|
'slotchange',
|
|
164
162
|
'stalled',
|
|
165
|
-
'start',
|
|
166
163
|
'storage',
|
|
167
164
|
'submit',
|
|
168
165
|
'suspend',
|
|
@@ -7,11 +7,29 @@ export declare function getImportAddFix({ compatibleWithTypeOnlyImport, fixer, i
|
|
|
7
7
|
node: TSESTree.Node;
|
|
8
8
|
}): TSESLint.RuleFix | undefined;
|
|
9
9
|
export declare function getImportRemoveFix(sourceCode: Readonly<TSESLint.SourceCode>, importDeclarations: readonly TSESTree.ImportDeclaration[], importName: string, fixer: TSESLint.RuleFixer): TSESLint.RuleFix | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Migrates a named import from `fromName` to `toName` for the given module:
|
|
12
|
+
* renames the specifier in place when possible, otherwise adds `toName` and
|
|
13
|
+
* removes `fromName` once it is no longer used.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getImportReplaceFix({ fixer, fromName, moduleName, node, sourceCode, toName, }: {
|
|
16
|
+
fixer: TSESLint.RuleFixer;
|
|
17
|
+
fromName: string;
|
|
18
|
+
moduleName: string;
|
|
19
|
+
node: TSESTree.Node;
|
|
20
|
+
sourceCode: Readonly<TSESLint.SourceCode>;
|
|
21
|
+
toName: string;
|
|
22
|
+
}): (TSESLint.RuleFix | undefined)[];
|
|
10
23
|
export declare function getImplementsSchemaFixer({ id, superClass, implements: classImplements, typeParameters, }: TSESTree.ClassDeclaration, interfaceName: string): {
|
|
11
24
|
readonly implementsNodeReplace: TSESTree.TSClassImplements | TSESTree.Identifier | TSESTree.TSTypeParameterDeclaration;
|
|
12
25
|
readonly implementsTextReplace: string;
|
|
13
26
|
};
|
|
14
27
|
export declare function getDecoratorPropertyAddFix({ expression }: TSESTree.Decorator, fixer: TSESLint.RuleFixer, text: string): TSESLint.RuleFix | undefined;
|
|
15
28
|
export declare function getImplementsRemoveFix(sourceCode: Readonly<TSESLint.SourceCode>, classDeclaration: TSESTree.ClassDeclaration, interfaceName: string, fixer: TSESLint.RuleFixer): TSESLint.RuleFix | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Removes an element of a comma-separated list (object property, array element,
|
|
31
|
+
* call argument) along with its own trailing comma and surrounding whitespace.
|
|
32
|
+
* The preceding comma is kept so an existing trailing-comma style is preserved.
|
|
33
|
+
*/
|
|
16
34
|
export declare function getNodeToCommaRemoveFix(sourceCode: Readonly<TSESLint.SourceCode>, node: TSESTree.Node, fixer: TSESLint.RuleFixer): TSESLint.RuleFix;
|
|
17
35
|
//# sourceMappingURL=rule-fixes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-fixes.d.ts","sourceRoot":"","sources":["../../src/eslint-plugin/rule-fixes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAcnE,wBAAgB,eAAe,CAAC,EAC9B,4BAAoC,EACpC,KAAK,EACL,UAAU,EACV,UAAU,EACV,IAAI,GACL,EAAE;IACD,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC;IAC1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BAAqB,EAC1B,QAAQ,CAAC,iBAAiB,GAC1B,QAAQ,CAAC,UAAU,GACnB,QAAQ,CAAC,0BAA0B,CAAC;IACxC,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;CACxC,CA2BA;AAED,wBAAgB,0BAA0B,CACxC,EAAE,UAAU,EAAE,EAAE,QAAQ,CAAC,SAAS,EAClC,KAAK,EAAE,QAAQ,CAAC,SAAS,EACzB,IAAI,EAAE,MAAM,GACX,QAAQ,CAAC,OAAO,GAAG,SAAS,CA0B9B;AAED,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,EACzC,gBAAgB,EAAE,QAAQ,CAAC,gBAAgB,EAC3C,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,QAAQ,CAAC,SAAS,GACxB,QAAQ,CAAC,OAAO,GAAG,SAAS,CAkC9B;AAUD;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,EACzC,IAAI,EAAE,QAAQ,CAAC,IAAI,EACnB,KAAK,EAAE,QAAQ,CAAC,SAAS,GACxB,QAAQ,CAAC,OAAO,CAwBlB"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getImportAddFix = getImportAddFix;
|
|
4
4
|
exports.getImportRemoveFix = getImportRemoveFix;
|
|
5
|
+
exports.getImportReplaceFix = getImportReplaceFix;
|
|
5
6
|
exports.getImplementsSchemaFixer = getImplementsSchemaFixer;
|
|
6
7
|
exports.getDecoratorPropertyAddFix = getDecoratorPropertyAddFix;
|
|
7
8
|
exports.getImplementsRemoveFix = getImplementsRemoveFix;
|
|
@@ -53,6 +54,31 @@ function getImportRemoveFix(sourceCode, importDeclarations, importName, fixer) {
|
|
|
53
54
|
importSpecifier.range[1],
|
|
54
55
|
]);
|
|
55
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Migrates a named import from `fromName` to `toName` for the given module:
|
|
59
|
+
* renames the specifier in place when possible, otherwise adds `toName` and
|
|
60
|
+
* removes `fromName` once it is no longer used.
|
|
61
|
+
*/
|
|
62
|
+
function getImportReplaceFix({ fixer, fromName, moduleName, node, sourceCode, toName, }) {
|
|
63
|
+
const importDeclarations = (0, ast_utils_1.getImportDeclarations)(node, moduleName);
|
|
64
|
+
const toAlreadyImported = Boolean(importDeclarations &&
|
|
65
|
+
(0, ast_utils_1.getImportDeclarationSpecifier)(importDeclarations, toName));
|
|
66
|
+
const fromSpecifier = importDeclarations
|
|
67
|
+
? (0, ast_utils_1.getImportDeclarationSpecifier)(importDeclarations, fromName)
|
|
68
|
+
: undefined;
|
|
69
|
+
const fromUsedOnce = utils_1.ASTUtils.findVariable(sourceCode.getScope(node), fromName)?.references
|
|
70
|
+
.length === 1;
|
|
71
|
+
if (fromUsedOnce && !toAlreadyImported && fromSpecifier) {
|
|
72
|
+
return [fixer.replaceText(fromSpecifier.importSpecifier, toName)];
|
|
73
|
+
}
|
|
74
|
+
const addFix = toAlreadyImported
|
|
75
|
+
? undefined
|
|
76
|
+
: getImportAddFix({ fixer, importName: toName, moduleName, node });
|
|
77
|
+
const removeFix = fromUsedOnce && importDeclarations
|
|
78
|
+
? getImportRemoveFix(sourceCode, importDeclarations, fromName, fixer)
|
|
79
|
+
: undefined;
|
|
80
|
+
return [addFix, removeFix];
|
|
81
|
+
}
|
|
56
82
|
function getImplementsSchemaFixer({ id, superClass, implements: classImplements, typeParameters, }, interfaceName) {
|
|
57
83
|
if (Array.isArray(classImplements) && classImplements.length > 0) {
|
|
58
84
|
return {
|
|
@@ -126,9 +152,33 @@ function getImplementsRemoveFix(sourceCode, classDeclaration, interfaceName, fix
|
|
|
126
152
|
? undefined
|
|
127
153
|
: fixer.removeRange([tokenBeforeInterface.range[0], identifier.range[1]]);
|
|
128
154
|
}
|
|
155
|
+
function isClosingDelimiterToken(token) {
|
|
156
|
+
return (utils_1.ASTUtils.isClosingBraceToken(token) ||
|
|
157
|
+
utils_1.ASTUtils.isClosingBracketToken(token) ||
|
|
158
|
+
utils_1.ASTUtils.isClosingParenToken(token));
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Removes an element of a comma-separated list (object property, array element,
|
|
162
|
+
* call argument) along with its own trailing comma and surrounding whitespace.
|
|
163
|
+
* The preceding comma is kept so an existing trailing-comma style is preserved.
|
|
164
|
+
*/
|
|
129
165
|
function getNodeToCommaRemoveFix(sourceCode, node, fixer) {
|
|
130
166
|
const tokenAfterNode = sourceCode.getTokenAfter(node);
|
|
131
|
-
|
|
132
|
-
?
|
|
133
|
-
:
|
|
167
|
+
const commaAfterNode = tokenAfterNode && utils_1.ASTUtils.isCommaToken(tokenAfterNode)
|
|
168
|
+
? tokenAfterNode
|
|
169
|
+
: undefined;
|
|
170
|
+
// When another element follows, remove up to it so it keeps its indentation.
|
|
171
|
+
if (commaAfterNode) {
|
|
172
|
+
const tokenAfterComma = sourceCode.getTokenAfter(commaAfterNode);
|
|
173
|
+
if (tokenAfterComma && !isClosingDelimiterToken(tokenAfterComma)) {
|
|
174
|
+
return fixer.removeRange([node.range[0], tokenAfterComma.range[0]]);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
// Last element: also remove the whitespace before it, but keep the preceding
|
|
178
|
+
// comma.
|
|
179
|
+
const tokenBeforeNode = sourceCode.getTokenBefore(node);
|
|
180
|
+
const start = tokenBeforeNode && utils_1.ASTUtils.isCommaToken(tokenBeforeNode)
|
|
181
|
+
? tokenBeforeNode.range[1]
|
|
182
|
+
: node.range[0];
|
|
183
|
+
return fixer.removeRange([start, commaAfterNode?.range[1] ?? node.range[1]]);
|
|
134
184
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-eslint/utils",
|
|
3
|
-
"version": "22.0.1-alpha.
|
|
3
|
+
"version": "22.0.1-alpha.17",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"typescript": "*"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@angular-eslint/bundled-angular-compiler": "22.0.1-alpha.
|
|
25
|
+
"@angular-eslint/bundled-angular-compiler": "22.0.1-alpha.17"
|
|
26
26
|
},
|
|
27
27
|
"nx": {
|
|
28
28
|
"namedInputs": {
|