@typescript-eslint/eslint-plugin 6.0.1-alpha.28 → 6.0.1-alpha.30
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.
|
@@ -24,6 +24,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
const utils_1 = require("@typescript-eslint/utils");
|
|
27
|
+
const path_1 = require("path");
|
|
28
|
+
const ts = __importStar(require("typescript"));
|
|
27
29
|
const util = __importStar(require("../util"));
|
|
28
30
|
exports.default = util.createRule({
|
|
29
31
|
name: 'no-unnecessary-type-constraint',
|
|
@@ -49,12 +51,23 @@ exports.default = util.createRule({
|
|
|
49
51
|
[utils_1.AST_NODE_TYPES.TSAnyKeyword, 'any'],
|
|
50
52
|
[utils_1.AST_NODE_TYPES.TSUnknownKeyword, 'unknown'],
|
|
51
53
|
]);
|
|
52
|
-
|
|
54
|
+
function checkRequiresGenericDeclarationDisambiguation(filename) {
|
|
55
|
+
const pathExt = (0, path_1.extname)(filename).toLocaleLowerCase();
|
|
56
|
+
switch (pathExt) {
|
|
57
|
+
case ts.Extension.Cts:
|
|
58
|
+
case ts.Extension.Mts:
|
|
59
|
+
case ts.Extension.Tsx:
|
|
60
|
+
return true;
|
|
61
|
+
default:
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const requiresGenericDeclarationDisambiguation = checkRequiresGenericDeclarationDisambiguation(context.getFilename());
|
|
53
66
|
const source = context.getSourceCode();
|
|
54
67
|
const checkNode = (node, inArrowFunction) => {
|
|
55
68
|
const constraint = unnecessaryConstraints.get(node.constraint.type);
|
|
56
69
|
function shouldAddTrailingComma() {
|
|
57
|
-
if (!inArrowFunction || !
|
|
70
|
+
if (!inArrowFunction || !requiresGenericDeclarationDisambiguation) {
|
|
58
71
|
return false;
|
|
59
72
|
}
|
|
60
73
|
// Only <T>() => {} would need trailing comma
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-unnecessary-type-constraint.js","sourceRoot":"","sources":["../../src/rules/no-unnecessary-type-constraint.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAA0D;
|
|
1
|
+
{"version":3,"file":"no-unnecessary-type-constraint.js","sourceRoot":"","sources":["../../src/rules/no-unnecessary-type-constraint.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAA0D;AAC1D,+BAA+B;AAC/B,+CAAiC;AAEjC,8CAAgC;AAUhC,kBAAe,IAAI,CAAC,UAAU,CAAC;IAC7B,IAAI,EAAE,gCAAgC;IACtC,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,WAAW,EAAE,mDAAmD;YAChE,WAAW,EAAE,aAAa;SAC3B;QACD,cAAc,EAAE,IAAI;QACpB,QAAQ,EAAE;YACR,qBAAqB,EACnB,+FAA+F;YACjG,2BAA2B,EACzB,qDAAqD;SACxD;QACD,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,YAAY;KACnB;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,iFAAiF;QACjF,sFAAsF;QACtF,yFAAyF;QACzF,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC;YACrC,CAAC,sBAAc,CAAC,YAAY,EAAE,KAAK,CAAC;YACpC,CAAC,sBAAc,CAAC,gBAAgB,EAAE,SAAS,CAAC;SAC7C,CAAC,CAAC;QAEH,SAAS,6CAA6C,CACpD,QAAgB;YAEhB,MAAM,OAAO,GAAG,IAAA,cAAO,EAAC,QAAQ,CAAC,CAAC,iBAAiB,EAAE,CAAC;YACtD,QAAQ,OAAO,EAAE;gBACf,KAAK,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC;gBACtB,KAAK,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC;gBACtB,KAAK,EAAE,CAAC,SAAS,CAAC,GAAG;oBACnB,OA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C,IAAI;iBACL,CAAC,CAAC;aACJ;QACH,CAAC,CAAC;QAEF,OAAO;YACL,0FAA0F,CACxF,IAAiC;gBAEjC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YACzB,CAAC;YACD,oFAAoF,CAClF,IAAiC;gBAEjC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACxB,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/eslint-plugin",
|
|
3
|
-
"version": "6.0.1-alpha.
|
|
3
|
+
"version": "6.0.1-alpha.30+14047963d",
|
|
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.0.1-alpha.
|
|
61
|
-
"@typescript-eslint/type-utils": "6.0.1-alpha.
|
|
62
|
-
"@typescript-eslint/utils": "6.0.1-alpha.
|
|
63
|
-
"@typescript-eslint/visitor-keys": "6.0.1-alpha.
|
|
60
|
+
"@typescript-eslint/scope-manager": "6.0.1-alpha.30+14047963d",
|
|
61
|
+
"@typescript-eslint/type-utils": "6.0.1-alpha.30+14047963d",
|
|
62
|
+
"@typescript-eslint/utils": "6.0.1-alpha.30+14047963d",
|
|
63
|
+
"@typescript-eslint/visitor-keys": "6.0.1-alpha.30+14047963d",
|
|
64
64
|
"debug": "^4.3.4",
|
|
65
65
|
"graphemer": "^1.4.0",
|
|
66
66
|
"ignore": "^5.2.4",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@types/natural-compare": "*",
|
|
76
76
|
"@types/prettier": "*",
|
|
77
77
|
"@typescript-eslint/rule-schema-to-typescript-types": "6.0.0",
|
|
78
|
-
"@typescript-eslint/rule-tester": "6.0.1-alpha.
|
|
78
|
+
"@typescript-eslint/rule-tester": "6.0.1-alpha.30+14047963d",
|
|
79
79
|
"ajv": "^6.12.6",
|
|
80
80
|
"chalk": "^5.3.0",
|
|
81
81
|
"cross-fetch": "*",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"type": "opencollective",
|
|
101
101
|
"url": "https://opencollective.com/typescript-eslint"
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "14047963d79e4d4a783854e2826a30004fa34570"
|
|
104
104
|
}
|