@typescript-eslint/eslint-plugin 8.31.2-alpha.1 → 8.31.2-alpha.2
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.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"no-unnecessary-type-parameters.d.ts","sourceRoot":"","sources":["../../src/rules/no-unnecessary-type-parameters.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAY,MAAM,0BAA0B,CAAC;;
|
1
|
+
{"version":3,"file":"no-unnecessary-type-parameters.d.ts","sourceRoot":"","sources":["../../src/rules/no-unnecessary-type-parameters.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAY,MAAM,0BAA0B,CAAC;;AAqBnE,wBA0MG"}
|
@@ -101,7 +101,28 @@ exports.default = (0, util_1.createRule)({
|
|
101
101
|
for (const reference of smTypeParameterVariable.references) {
|
102
102
|
if (reference.isTypeReference) {
|
103
103
|
const referenceNode = reference.identifier;
|
104
|
-
|
104
|
+
const isComplexType = constraint?.type === utils_1.AST_NODE_TYPES.TSUnionType ||
|
105
|
+
constraint?.type === utils_1.AST_NODE_TYPES.TSIntersectionType ||
|
106
|
+
constraint?.type === utils_1.AST_NODE_TYPES.TSConditionalType;
|
107
|
+
const hasMatchingAncestorType = [
|
108
|
+
utils_1.AST_NODE_TYPES.TSArrayType,
|
109
|
+
utils_1.AST_NODE_TYPES.TSIndexedAccessType,
|
110
|
+
utils_1.AST_NODE_TYPES.TSIntersectionType,
|
111
|
+
utils_1.AST_NODE_TYPES.TSUnionType,
|
112
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
113
|
+
].some(type => referenceNode.parent.parent.type === type);
|
114
|
+
if (isComplexType && hasMatchingAncestorType) {
|
115
|
+
const fixResult = (0, util_1.getWrappingFixer)({
|
116
|
+
node: referenceNode,
|
117
|
+
innerNode: constraint,
|
118
|
+
sourceCode: context.sourceCode,
|
119
|
+
wrap: constraintNode => constraintNode,
|
120
|
+
})(fixer);
|
121
|
+
yield fixResult;
|
122
|
+
}
|
123
|
+
else {
|
124
|
+
yield fixer.replaceText(referenceNode, constraintText);
|
125
|
+
}
|
105
126
|
}
|
106
127
|
}
|
107
128
|
// ...and remove the type parameter itself from the declaration.
|
@@ -22,7 +22,7 @@ interface WrappingFixerParams {
|
|
22
22
|
* Wraps node with some code. Adds parenthesis as necessary.
|
23
23
|
* @returns Fixer which adds the specified code and parens if necessary.
|
24
24
|
*/
|
25
|
-
export declare function getWrappingFixer(params: WrappingFixerParams): TSESLint.
|
25
|
+
export declare function getWrappingFixer(params: WrappingFixerParams): (fixer: TSESLint.RuleFixer) => TSESLint.RuleFix;
|
26
26
|
/**
|
27
27
|
* If the node to be moved and the destination node require parentheses, include parentheses in the node to be moved.
|
28
28
|
* @param sourceCode Source code of current file
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getWrappingFixer.d.ts","sourceRoot":"","sources":["../../src/util/getWrappingFixer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAQnE,UAAU,mBAAmB;IAC3B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC5C,kCAAkC;IAClC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC;IACpB,mBAAmB;IACnB,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC1C;;;;OAIG;IACH,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,KAAK,MAAM,CAAC;CACrC;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,mBAAmB,GAC1B,QAAQ,CAAC,
|
1
|
+
{"version":3,"file":"getWrappingFixer.d.ts","sourceRoot":"","sources":["../../src/util/getWrappingFixer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAQnE,UAAU,mBAAmB;IAC3B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC5C,kCAAkC;IAClC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC;IACpB,mBAAmB;IACnB,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC1C;;;;OAIG;IACH,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,KAAK,MAAM,CAAC;CACrC;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,mBAAmB,GAC1B,CAAC,KAAK,EAAE,QAAQ,CAAC,SAAS,KAAK,QAAQ,CAAC,OAAO,CA2CjD;AACD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IACvC,eAAe,EAAE,QAAQ,CAAC,IAAI,CAAC;IAC/B,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC;IAC1B,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;CAC3C,GAAG,MAAM,CAeT;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,QAAQ,CAAC,IAAI,GAAG,OAAO,CAcxE"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@typescript-eslint/eslint-plugin",
|
3
|
-
"version": "8.31.2-alpha.
|
3
|
+
"version": "8.31.2-alpha.2",
|
4
4
|
"description": "TypeScript plugin for ESLint",
|
5
5
|
"files": [
|
6
6
|
"dist",
|
@@ -62,10 +62,10 @@
|
|
62
62
|
},
|
63
63
|
"dependencies": {
|
64
64
|
"@eslint-community/regexpp": "^4.10.0",
|
65
|
-
"@typescript-eslint/scope-manager": "8.31.2-alpha.
|
66
|
-
"@typescript-eslint/type-utils": "8.31.2-alpha.
|
67
|
-
"@typescript-eslint/utils": "8.31.2-alpha.
|
68
|
-
"@typescript-eslint/visitor-keys": "8.31.2-alpha.
|
65
|
+
"@typescript-eslint/scope-manager": "8.31.2-alpha.2",
|
66
|
+
"@typescript-eslint/type-utils": "8.31.2-alpha.2",
|
67
|
+
"@typescript-eslint/utils": "8.31.2-alpha.2",
|
68
|
+
"@typescript-eslint/visitor-keys": "8.31.2-alpha.2",
|
69
69
|
"graphemer": "^1.4.0",
|
70
70
|
"ignore": "^5.3.1",
|
71
71
|
"natural-compare": "^1.4.0",
|
@@ -75,8 +75,8 @@
|
|
75
75
|
"@types/marked": "^5.0.2",
|
76
76
|
"@types/mdast": "^4.0.3",
|
77
77
|
"@types/natural-compare": "*",
|
78
|
-
"@typescript-eslint/rule-schema-to-typescript-types": "8.31.2-alpha.
|
79
|
-
"@typescript-eslint/rule-tester": "8.31.2-alpha.
|
78
|
+
"@typescript-eslint/rule-schema-to-typescript-types": "8.31.2-alpha.2",
|
79
|
+
"@typescript-eslint/rule-tester": "8.31.2-alpha.2",
|
80
80
|
"@vitest/coverage-v8": "^3.1.1",
|
81
81
|
"ajv": "^6.12.6",
|
82
82
|
"cross-fetch": "*",
|