@typescript-eslint/eslint-plugin 6.0.0-alpha.80 → 6.0.0-alpha.81
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/configs/recommended-requiring-type-checking.js +27 -0
- package/dist/configs/recommended-requiring-type-checking.js.map +1 -0
- package/dist/rules/no-duplicate-imports.js +124 -0
- package/dist/rules/no-duplicate-imports.js.map +1 -0
- package/dist/rules/no-implicit-any-catch.js +102 -0
- package/dist/rules/no-implicit-any-catch.js.map +1 -0
- package/dist/rules/no-parameter-properties.js +111 -0
- package/dist/rules/no-parameter-properties.js.map +1 -0
- package/dist/rules/sort-type-union-intersection-members.js +247 -0
- package/dist/rules/sort-type-union-intersection-members.js.map +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// THIS CODE WAS AUTOMATICALLY GENERATED
|
|
3
|
+
// DO NOT EDIT THIS CODE BY HAND
|
|
4
|
+
// YOU CAN REGENERATE IT USING yarn generate:configs
|
|
5
|
+
module.exports = {
|
|
6
|
+
extends: ['./configs/base', './configs/eslint-recommended'],
|
|
7
|
+
rules: {
|
|
8
|
+
'@typescript-eslint/await-thenable': 'error',
|
|
9
|
+
'@typescript-eslint/no-floating-promises': 'error',
|
|
10
|
+
'@typescript-eslint/no-for-in-array': 'error',
|
|
11
|
+
'no-implied-eval': 'off',
|
|
12
|
+
'@typescript-eslint/no-implied-eval': 'error',
|
|
13
|
+
'@typescript-eslint/no-misused-promises': 'error',
|
|
14
|
+
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
|
|
15
|
+
'@typescript-eslint/no-unsafe-argument': 'error',
|
|
16
|
+
'@typescript-eslint/no-unsafe-assignment': 'error',
|
|
17
|
+
'@typescript-eslint/no-unsafe-call': 'error',
|
|
18
|
+
'@typescript-eslint/no-unsafe-member-access': 'error',
|
|
19
|
+
'@typescript-eslint/no-unsafe-return': 'error',
|
|
20
|
+
'require-await': 'off',
|
|
21
|
+
'@typescript-eslint/require-await': 'error',
|
|
22
|
+
'@typescript-eslint/restrict-plus-operands': 'error',
|
|
23
|
+
'@typescript-eslint/restrict-template-expressions': 'error',
|
|
24
|
+
'@typescript-eslint/unbound-method': 'error',
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=recommended-requiring-type-checking.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recommended-requiring-type-checking.js","sourceRoot":"","sources":["../../src/configs/recommended-requiring-type-checking.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,oDAAoD;AAEpD,iBAAS;IACP,OAAO,EAAE,CAAC,gBAAgB,EAAE,8BAA8B,CAAC;IAC3D,KAAK,EAAE;QACL,mCAAmC,EAAE,OAAO;QAC5C,yCAAyC,EAAE,OAAO;QAClD,oCAAoC,EAAE,OAAO;QAC7C,iBAAiB,EAAE,KAAK;QACxB,oCAAoC,EAAE,OAAO;QAC7C,wCAAwC,EAAE,OAAO;QACjD,kDAAkD,EAAE,OAAO;QAC3D,uCAAuC,EAAE,OAAO;QAChD,yCAAyC,EAAE,OAAO;QAClD,mCAAmC,EAAE,OAAO;QAC5C,4CAA4C,EAAE,OAAO;QACrD,qCAAqC,EAAE,OAAO;QAC9C,eAAe,EAAE,KAAK;QACtB,kCAAkC,EAAE,OAAO;QAC3C,2CAA2C,EAAE,OAAO;QACpD,kDAAkD,EAAE,OAAO;QAC3D,mCAAmC,EAAE,OAAO;KAC7C;CACF,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
27
|
+
const util = __importStar(require("../util"));
|
|
28
|
+
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
|
|
29
|
+
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('no-duplicate-imports');
|
|
30
|
+
exports.default = util.createRule({
|
|
31
|
+
name: 'no-duplicate-imports',
|
|
32
|
+
meta: {
|
|
33
|
+
deprecated: true,
|
|
34
|
+
replacedBy: ['import/no-duplicates'],
|
|
35
|
+
type: 'problem',
|
|
36
|
+
docs: {
|
|
37
|
+
description: 'Disallow duplicate imports',
|
|
38
|
+
recommended: false,
|
|
39
|
+
extendsBaseRule: true,
|
|
40
|
+
},
|
|
41
|
+
hasSuggestions: baseRule.meta.hasSuggestions,
|
|
42
|
+
schema: baseRule.meta.schema,
|
|
43
|
+
messages: Object.assign(Object.assign({}, baseRule.meta.messages), { importType: '{{module}} type import is duplicated.', importTypeAs: '{{module}} type import is duplicated as type export.', exportType: '{{module}} type export is duplicated.', exportTypeAs: '{{module}} type export is duplicated as type import.' }),
|
|
44
|
+
},
|
|
45
|
+
defaultOptions: [
|
|
46
|
+
{
|
|
47
|
+
includeExports: false,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
create(context, [{ includeExports }]) {
|
|
51
|
+
const rules = baseRule.create(context);
|
|
52
|
+
const typeMemberImports = new Set();
|
|
53
|
+
const typeDefaultImports = new Set();
|
|
54
|
+
const typeExports = new Set();
|
|
55
|
+
function report(messageId, node, module) {
|
|
56
|
+
context.report({
|
|
57
|
+
messageId,
|
|
58
|
+
node,
|
|
59
|
+
data: {
|
|
60
|
+
module,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
function isAllMemberImport(node) {
|
|
65
|
+
return node.specifiers.every(specifier => specifier.type === utils_1.AST_NODE_TYPES.ImportSpecifier);
|
|
66
|
+
}
|
|
67
|
+
function checkTypeImport(node) {
|
|
68
|
+
if (node.source) {
|
|
69
|
+
const value = node.source.value;
|
|
70
|
+
const isMemberImport = isAllMemberImport(node);
|
|
71
|
+
if (isMemberImport
|
|
72
|
+
? typeMemberImports.has(value)
|
|
73
|
+
: typeDefaultImports.has(value)) {
|
|
74
|
+
report('importType', node, value);
|
|
75
|
+
}
|
|
76
|
+
if (includeExports && typeExports.has(value)) {
|
|
77
|
+
report('importTypeAs', node, value);
|
|
78
|
+
}
|
|
79
|
+
if (isMemberImport) {
|
|
80
|
+
typeMemberImports.add(value);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
typeDefaultImports.add(value);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function checkTypeExport(node) {
|
|
88
|
+
if (node.source) {
|
|
89
|
+
const value = node.source.value;
|
|
90
|
+
if (typeExports.has(value)) {
|
|
91
|
+
report('exportType', node, value);
|
|
92
|
+
}
|
|
93
|
+
if (typeMemberImports.has(value) || typeDefaultImports.has(value)) {
|
|
94
|
+
report('exportTypeAs', node, value);
|
|
95
|
+
}
|
|
96
|
+
typeExports.add(value);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return Object.assign(Object.assign({}, rules), { ImportDeclaration(node) {
|
|
100
|
+
if (node.importKind === 'type') {
|
|
101
|
+
checkTypeImport(node);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
rules.ImportDeclaration(node);
|
|
105
|
+
},
|
|
106
|
+
ExportNamedDeclaration(node) {
|
|
107
|
+
var _a;
|
|
108
|
+
if (includeExports && node.exportKind === 'type') {
|
|
109
|
+
checkTypeExport(node);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
(_a = rules.ExportNamedDeclaration) === null || _a === void 0 ? void 0 : _a.call(rules, node);
|
|
113
|
+
},
|
|
114
|
+
ExportAllDeclaration(node) {
|
|
115
|
+
var _a;
|
|
116
|
+
if (includeExports && node.exportKind === 'type') {
|
|
117
|
+
checkTypeExport(node);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
(_a = rules.ExportAllDeclaration) === null || _a === void 0 ? void 0 : _a.call(rules, node);
|
|
121
|
+
} });
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
//# sourceMappingURL=no-duplicate-imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-duplicate-imports.js","sourceRoot":"","sources":["../../src/rules/no-duplicate-imports.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAA0D;AAE1D,8CAAgC;AAChC,iEAA8D;AAE9D,MAAM,QAAQ,GAAG,IAAA,qCAAiB,EAAC,sBAAsB,CAAC,CAAC;AAK3D,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,sBAAsB;IAC5B,IAAI,EAAE;QACJ,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,CAAC,sBAAsB,CAAC;QACpC,IAAI,EAAE,SAAS;QAC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;gBACzB,IAAI,cAAc,IAAI,IAAI,CAAC,UAAU,KAAK,MAAM,EAAE;oBAChD,eAAe,CAAC,IAAI,CAAC,CAAC;oBACtB,OAAO;iBACR;gBACD,MAAA,KAAK,CAAC,sBAAsB,sDAAG,IAAI,CAAC,CAAC;YACvC,CAAC;YACD,oBAAoB,CAAC,IAAI;;gBACvB,IAAI,cAAc,IAAI,IAAI,CAAC,UAAU,KAAK,MAAM,EAAE;oBAChD,eAAe,CAAC,IAAI,CAAC,CAAC;oBACtB,OAAO;iBACR;gBACD,MAAA,KAAK,CAAC,oBAAoB,sDAAG,IAAI,CAAC,CAAC;YACrC,CAAC,IACD;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
27
|
+
const util = __importStar(require("../util"));
|
|
28
|
+
exports.default = util.createRule({
|
|
29
|
+
name: 'no-implicit-any-catch',
|
|
30
|
+
meta: {
|
|
31
|
+
deprecated: true,
|
|
32
|
+
type: 'suggestion',
|
|
33
|
+
docs: {
|
|
34
|
+
description: 'Disallow usage of the implicit `any` type in catch clauses',
|
|
35
|
+
recommended: false,
|
|
36
|
+
},
|
|
37
|
+
fixable: 'code',
|
|
38
|
+
hasSuggestions: true,
|
|
39
|
+
messages: {
|
|
40
|
+
implicitAnyInCatch: 'Implicit any in catch clause.',
|
|
41
|
+
explicitAnyInCatch: 'Explicit any in catch clause.',
|
|
42
|
+
suggestExplicitUnknown: 'Use `unknown` instead, this will force you to explicitly, and safely assert the type is correct.',
|
|
43
|
+
},
|
|
44
|
+
schema: [
|
|
45
|
+
{
|
|
46
|
+
type: 'object',
|
|
47
|
+
additionalProperties: false,
|
|
48
|
+
properties: {
|
|
49
|
+
allowExplicitAny: {
|
|
50
|
+
description: 'Whether to disallow specifying `: any` as the error type as well. See also `no-explicit-any`.',
|
|
51
|
+
type: 'boolean',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
defaultOptions: [
|
|
58
|
+
{
|
|
59
|
+
allowExplicitAny: false,
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
create(context, [{ allowExplicitAny }]) {
|
|
63
|
+
return {
|
|
64
|
+
CatchClause(node) {
|
|
65
|
+
if (!node.param) {
|
|
66
|
+
return; // ignore catch without variable
|
|
67
|
+
}
|
|
68
|
+
if (!node.param.typeAnnotation) {
|
|
69
|
+
context.report({
|
|
70
|
+
node,
|
|
71
|
+
messageId: 'implicitAnyInCatch',
|
|
72
|
+
suggest: [
|
|
73
|
+
{
|
|
74
|
+
messageId: 'suggestExplicitUnknown',
|
|
75
|
+
fix(fixer) {
|
|
76
|
+
return fixer.insertTextAfter(node.param, ': unknown');
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
else if (!allowExplicitAny &&
|
|
83
|
+
node.param.typeAnnotation.typeAnnotation.type ===
|
|
84
|
+
utils_1.AST_NODE_TYPES.TSAnyKeyword) {
|
|
85
|
+
context.report({
|
|
86
|
+
node,
|
|
87
|
+
messageId: 'explicitAnyInCatch',
|
|
88
|
+
suggest: [
|
|
89
|
+
{
|
|
90
|
+
messageId: 'suggestExplicitUnknown',
|
|
91
|
+
fix(fixer) {
|
|
92
|
+
return fixer.replaceText(node.param.typeAnnotation, ': unknown');
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
//# sourceMappingURL=no-implicit-any-catch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-implicit-any-catch.js","sourceRoot":"","sources":["../../src/rules/no-implicit-any-catch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAA0D;AAE1D,8CAAgC;AAYhC,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,uBAAuB;IAC7B,IAAI,EAAE;QACJ,UAAU,EAAE,IAAI;QAChB,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,4DAA4D;YACzE,WAAW,EAAE,KAAK;SACnB;QACD,OAAO,EAAE,MAAM;QACf,cAAc,EAAE,IAAI;QACpB,QAAQ,EAAE;YACR,kBAAkB,EAAE,+BAA+B;YACnD,kBAAkB,EAAE,+BAA+B;YACnD,sBAAsB,EACpB,kGAAkG;SAC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@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
27
|
+
const util = __importStar(require("../util"));
|
|
28
|
+
exports.default = util.createRule({
|
|
29
|
+
name: 'no-parameter-properties',
|
|
30
|
+
meta: {
|
|
31
|
+
deprecated: true,
|
|
32
|
+
replacedBy: ['@typescript-eslint/parameter-properties'],
|
|
33
|
+
type: 'problem',
|
|
34
|
+
docs: {
|
|
35
|
+
description: 'Disallow the use of parameter properties in class constructors',
|
|
36
|
+
// too opinionated to be recommended
|
|
37
|
+
recommended: false,
|
|
38
|
+
},
|
|
39
|
+
messages: {
|
|
40
|
+
noParamProp: 'Property {{parameter}} cannot be declared in the constructor.',
|
|
41
|
+
},
|
|
42
|
+
schema: [
|
|
43
|
+
{
|
|
44
|
+
type: 'object',
|
|
45
|
+
properties: {
|
|
46
|
+
allows: {
|
|
47
|
+
type: 'array',
|
|
48
|
+
items: {
|
|
49
|
+
enum: [
|
|
50
|
+
'readonly',
|
|
51
|
+
'private',
|
|
52
|
+
'protected',
|
|
53
|
+
'public',
|
|
54
|
+
'private readonly',
|
|
55
|
+
'protected readonly',
|
|
56
|
+
'public readonly',
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
minItems: 1,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
additionalProperties: false,
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
defaultOptions: [
|
|
67
|
+
{
|
|
68
|
+
allows: [],
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
create(context, [{ allows }]) {
|
|
72
|
+
/**
|
|
73
|
+
* Gets the modifiers of `node`.
|
|
74
|
+
* @param node the node to be inspected.
|
|
75
|
+
*/
|
|
76
|
+
function getModifiers(node) {
|
|
77
|
+
const modifiers = [];
|
|
78
|
+
if (node.accessibility) {
|
|
79
|
+
modifiers.push(node.accessibility);
|
|
80
|
+
}
|
|
81
|
+
if (node.readonly) {
|
|
82
|
+
modifiers.push('readonly');
|
|
83
|
+
}
|
|
84
|
+
return modifiers.filter(Boolean).join(' ');
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
TSParameterProperty(node) {
|
|
88
|
+
const modifiers = getModifiers(node);
|
|
89
|
+
if (!allows.includes(modifiers)) {
|
|
90
|
+
// HAS to be an identifier or assignment or TSC will throw
|
|
91
|
+
if (node.parameter.type !== utils_1.AST_NODE_TYPES.Identifier &&
|
|
92
|
+
node.parameter.type !== utils_1.AST_NODE_TYPES.AssignmentPattern) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const name = node.parameter.type === utils_1.AST_NODE_TYPES.Identifier
|
|
96
|
+
? node.parameter.name
|
|
97
|
+
: // has to be an Identifier or TSC will throw an error
|
|
98
|
+
node.parameter.left.name;
|
|
99
|
+
context.report({
|
|
100
|
+
node,
|
|
101
|
+
messageId: 'noParamProp',
|
|
102
|
+
data: {
|
|
103
|
+
parameter: name,
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
//# sourceMappingURL=no-parameter-properties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-parameter-properties.js","sourceRoot":"","sources":["../../src/rules/no-parameter-properties.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAA0D;AAE1D,8CAAgC;AAiBhC,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,yBAAyB;IAC/B,IAAI,EAAE;QACJ,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,CAAC,yCAAyC,CAAC;QACvD,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,gEAAgE;YAClE,oCAAoC;YACpC,WAAW,EAAE,KAAK;SACnB;QACD,QAAQ,EAAE;YACR,WAAW,EACT,+DAA+D;SAClE;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,MAAM,EAAE;wBACN,IAAI,EAAE,OAAO;wBACb,KAAK,EAAE;4BACL,IAAI,EAAE;gCACJ,UAAU;gCACV,SAAS;gCACT,WAAW;gCACX,QAAQ;gCACR,kBAAkB;gCAClB,oBAAoB;gCACpB,iBAAiB;6BAClB;yBACF;wBACD,QAAQ,EAAE,CAAC;qBACZ;iBACF;gBACD,oBAAoB,EAAE,KAAK;aAC5B;SACF;KACF;IACD,cAAc,EAAE;QACd;YACE,MAAM,EAAE,EAAE;SAC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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
27
|
+
const util = __importStar(require("../util"));
|
|
28
|
+
const util_1 = require("../util");
|
|
29
|
+
var Group;
|
|
30
|
+
(function (Group) {
|
|
31
|
+
Group["conditional"] = "conditional";
|
|
32
|
+
Group["function"] = "function";
|
|
33
|
+
Group["import"] = "import";
|
|
34
|
+
Group["intersection"] = "intersection";
|
|
35
|
+
Group["keyword"] = "keyword";
|
|
36
|
+
Group["nullish"] = "nullish";
|
|
37
|
+
Group["literal"] = "literal";
|
|
38
|
+
Group["named"] = "named";
|
|
39
|
+
Group["object"] = "object";
|
|
40
|
+
Group["operator"] = "operator";
|
|
41
|
+
Group["tuple"] = "tuple";
|
|
42
|
+
Group["union"] = "union";
|
|
43
|
+
})(Group || (Group = {}));
|
|
44
|
+
function getGroup(node) {
|
|
45
|
+
switch (node.type) {
|
|
46
|
+
case utils_1.AST_NODE_TYPES.TSConditionalType:
|
|
47
|
+
return Group.conditional;
|
|
48
|
+
case utils_1.AST_NODE_TYPES.TSConstructorType:
|
|
49
|
+
case utils_1.AST_NODE_TYPES.TSFunctionType:
|
|
50
|
+
return Group.function;
|
|
51
|
+
case utils_1.AST_NODE_TYPES.TSImportType:
|
|
52
|
+
return Group.import;
|
|
53
|
+
case utils_1.AST_NODE_TYPES.TSIntersectionType:
|
|
54
|
+
return Group.intersection;
|
|
55
|
+
case utils_1.AST_NODE_TYPES.TSAnyKeyword:
|
|
56
|
+
case utils_1.AST_NODE_TYPES.TSBigIntKeyword:
|
|
57
|
+
case utils_1.AST_NODE_TYPES.TSBooleanKeyword:
|
|
58
|
+
case utils_1.AST_NODE_TYPES.TSNeverKeyword:
|
|
59
|
+
case utils_1.AST_NODE_TYPES.TSNumberKeyword:
|
|
60
|
+
case utils_1.AST_NODE_TYPES.TSObjectKeyword:
|
|
61
|
+
case utils_1.AST_NODE_TYPES.TSStringKeyword:
|
|
62
|
+
case utils_1.AST_NODE_TYPES.TSSymbolKeyword:
|
|
63
|
+
case utils_1.AST_NODE_TYPES.TSThisType:
|
|
64
|
+
case utils_1.AST_NODE_TYPES.TSUnknownKeyword:
|
|
65
|
+
case utils_1.AST_NODE_TYPES.TSIntrinsicKeyword:
|
|
66
|
+
return Group.keyword;
|
|
67
|
+
case utils_1.AST_NODE_TYPES.TSNullKeyword:
|
|
68
|
+
case utils_1.AST_NODE_TYPES.TSUndefinedKeyword:
|
|
69
|
+
case utils_1.AST_NODE_TYPES.TSVoidKeyword:
|
|
70
|
+
return Group.nullish;
|
|
71
|
+
case utils_1.AST_NODE_TYPES.TSLiteralType:
|
|
72
|
+
case utils_1.AST_NODE_TYPES.TSTemplateLiteralType:
|
|
73
|
+
return Group.literal;
|
|
74
|
+
case utils_1.AST_NODE_TYPES.TSArrayType:
|
|
75
|
+
case utils_1.AST_NODE_TYPES.TSIndexedAccessType:
|
|
76
|
+
case utils_1.AST_NODE_TYPES.TSInferType:
|
|
77
|
+
case utils_1.AST_NODE_TYPES.TSTypeReference:
|
|
78
|
+
case utils_1.AST_NODE_TYPES.TSQualifiedName:
|
|
79
|
+
return Group.named;
|
|
80
|
+
case utils_1.AST_NODE_TYPES.TSMappedType:
|
|
81
|
+
case utils_1.AST_NODE_TYPES.TSTypeLiteral:
|
|
82
|
+
return Group.object;
|
|
83
|
+
case utils_1.AST_NODE_TYPES.TSTypeOperator:
|
|
84
|
+
case utils_1.AST_NODE_TYPES.TSTypeQuery:
|
|
85
|
+
return Group.operator;
|
|
86
|
+
case utils_1.AST_NODE_TYPES.TSTupleType:
|
|
87
|
+
return Group.tuple;
|
|
88
|
+
case utils_1.AST_NODE_TYPES.TSUnionType:
|
|
89
|
+
return Group.union;
|
|
90
|
+
// These types should never occur as part of a union/intersection
|
|
91
|
+
case utils_1.AST_NODE_TYPES.TSAbstractKeyword:
|
|
92
|
+
case utils_1.AST_NODE_TYPES.TSAsyncKeyword:
|
|
93
|
+
case utils_1.AST_NODE_TYPES.TSDeclareKeyword:
|
|
94
|
+
case utils_1.AST_NODE_TYPES.TSExportKeyword:
|
|
95
|
+
case utils_1.AST_NODE_TYPES.TSNamedTupleMember:
|
|
96
|
+
case utils_1.AST_NODE_TYPES.TSOptionalType:
|
|
97
|
+
case utils_1.AST_NODE_TYPES.TSPrivateKeyword:
|
|
98
|
+
case utils_1.AST_NODE_TYPES.TSProtectedKeyword:
|
|
99
|
+
case utils_1.AST_NODE_TYPES.TSPublicKeyword:
|
|
100
|
+
case utils_1.AST_NODE_TYPES.TSReadonlyKeyword:
|
|
101
|
+
case utils_1.AST_NODE_TYPES.TSRestType:
|
|
102
|
+
case utils_1.AST_NODE_TYPES.TSStaticKeyword:
|
|
103
|
+
case utils_1.AST_NODE_TYPES.TSTypePredicate:
|
|
104
|
+
/* istanbul ignore next */
|
|
105
|
+
throw new Error(`Unexpected Type ${node.type}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.default = util.createRule({
|
|
109
|
+
name: 'sort-type-union-intersection-members',
|
|
110
|
+
meta: {
|
|
111
|
+
deprecated: true,
|
|
112
|
+
type: 'suggestion',
|
|
113
|
+
docs: {
|
|
114
|
+
description: 'Enforce members of a type union/intersection to be sorted alphabetically',
|
|
115
|
+
recommended: false,
|
|
116
|
+
},
|
|
117
|
+
fixable: 'code',
|
|
118
|
+
hasSuggestions: true,
|
|
119
|
+
messages: {
|
|
120
|
+
notSorted: '{{type}} type members must be sorted.',
|
|
121
|
+
notSortedNamed: '{{type}} type {{name}} members must be sorted.',
|
|
122
|
+
suggestFix: 'Sort members of type (removes all comments).',
|
|
123
|
+
},
|
|
124
|
+
replacedBy: ['@typescript-eslint/sort-type-constituents'],
|
|
125
|
+
schema: [
|
|
126
|
+
{
|
|
127
|
+
type: 'object',
|
|
128
|
+
properties: {
|
|
129
|
+
checkIntersections: {
|
|
130
|
+
description: 'Whether to check intersection types.',
|
|
131
|
+
type: 'boolean',
|
|
132
|
+
},
|
|
133
|
+
checkUnions: {
|
|
134
|
+
description: 'Whether to check union types.',
|
|
135
|
+
type: 'boolean',
|
|
136
|
+
},
|
|
137
|
+
groupOrder: {
|
|
138
|
+
description: 'Ordering of the groups.',
|
|
139
|
+
type: 'array',
|
|
140
|
+
items: {
|
|
141
|
+
type: 'string',
|
|
142
|
+
enum: (0, util_1.getEnumNames)(Group),
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
},
|
|
149
|
+
defaultOptions: [
|
|
150
|
+
{
|
|
151
|
+
checkIntersections: true,
|
|
152
|
+
checkUnions: true,
|
|
153
|
+
groupOrder: [
|
|
154
|
+
Group.named,
|
|
155
|
+
Group.keyword,
|
|
156
|
+
Group.operator,
|
|
157
|
+
Group.literal,
|
|
158
|
+
Group.function,
|
|
159
|
+
Group.import,
|
|
160
|
+
Group.conditional,
|
|
161
|
+
Group.object,
|
|
162
|
+
Group.tuple,
|
|
163
|
+
Group.intersection,
|
|
164
|
+
Group.union,
|
|
165
|
+
Group.nullish,
|
|
166
|
+
],
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
create(context, [{ checkIntersections, checkUnions, groupOrder }]) {
|
|
170
|
+
const sourceCode = context.getSourceCode();
|
|
171
|
+
const collator = new Intl.Collator('en', {
|
|
172
|
+
sensitivity: 'base',
|
|
173
|
+
numeric: true,
|
|
174
|
+
});
|
|
175
|
+
function checkSorting(node) {
|
|
176
|
+
var _a;
|
|
177
|
+
const sourceOrder = node.types.map(type => {
|
|
178
|
+
var _a;
|
|
179
|
+
const group = (_a = groupOrder === null || groupOrder === void 0 ? void 0 : groupOrder.indexOf(getGroup(type))) !== null && _a !== void 0 ? _a : -1;
|
|
180
|
+
return {
|
|
181
|
+
group: group === -1 ? Number.MAX_SAFE_INTEGER : group,
|
|
182
|
+
node: type,
|
|
183
|
+
text: sourceCode.getText(type),
|
|
184
|
+
};
|
|
185
|
+
});
|
|
186
|
+
const expectedOrder = [...sourceOrder].sort((a, b) => {
|
|
187
|
+
if (a.group !== b.group) {
|
|
188
|
+
return a.group - b.group;
|
|
189
|
+
}
|
|
190
|
+
return (collator.compare(a.text, b.text) ||
|
|
191
|
+
(a.text < b.text ? -1 : a.text > b.text ? 1 : 0));
|
|
192
|
+
});
|
|
193
|
+
const hasComments = node.types.some(type => {
|
|
194
|
+
const count = sourceCode.getCommentsBefore(type).length +
|
|
195
|
+
sourceCode.getCommentsAfter(type).length;
|
|
196
|
+
return count > 0;
|
|
197
|
+
});
|
|
198
|
+
for (let i = 0; i < expectedOrder.length; i += 1) {
|
|
199
|
+
if (expectedOrder[i].node !== sourceOrder[i].node) {
|
|
200
|
+
let messageId = 'notSorted';
|
|
201
|
+
const data = {
|
|
202
|
+
name: '',
|
|
203
|
+
type: node.type === utils_1.AST_NODE_TYPES.TSIntersectionType
|
|
204
|
+
? 'Intersection'
|
|
205
|
+
: 'Union',
|
|
206
|
+
};
|
|
207
|
+
if (((_a = node.parent) === null || _a === void 0 ? void 0 : _a.type) === utils_1.AST_NODE_TYPES.TSTypeAliasDeclaration) {
|
|
208
|
+
messageId = 'notSortedNamed';
|
|
209
|
+
data.name = node.parent.id.name;
|
|
210
|
+
}
|
|
211
|
+
const fix = fixer => {
|
|
212
|
+
const sorted = expectedOrder
|
|
213
|
+
.map(t => (0, util_1.typeNodeRequiresParentheses)(t.node, t.text) ||
|
|
214
|
+
(node.type === utils_1.AST_NODE_TYPES.TSIntersectionType &&
|
|
215
|
+
t.node.type === utils_1.AST_NODE_TYPES.TSUnionType)
|
|
216
|
+
? `(${t.text})`
|
|
217
|
+
: t.text)
|
|
218
|
+
.join(node.type === utils_1.AST_NODE_TYPES.TSIntersectionType ? ' & ' : ' | ');
|
|
219
|
+
return fixer.replaceText(node, sorted);
|
|
220
|
+
};
|
|
221
|
+
return context.report(Object.assign({ node,
|
|
222
|
+
messageId,
|
|
223
|
+
data }, (hasComments
|
|
224
|
+
? {
|
|
225
|
+
suggest: [
|
|
226
|
+
{
|
|
227
|
+
messageId: 'suggestFix',
|
|
228
|
+
fix,
|
|
229
|
+
},
|
|
230
|
+
],
|
|
231
|
+
}
|
|
232
|
+
: { fix })));
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return Object.assign(Object.assign({}, (checkIntersections && {
|
|
237
|
+
TSIntersectionType(node) {
|
|
238
|
+
checkSorting(node);
|
|
239
|
+
},
|
|
240
|
+
})), (checkUnions && {
|
|
241
|
+
TSUnionType(node) {
|
|
242
|
+
checkSorting(node);
|
|
243
|
+
},
|
|
244
|
+
}));
|
|
245
|
+
},
|
|
246
|
+
});
|
|
247
|
+
//# sourceMappingURL=sort-type-union-intersection-members.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sort-type-union-intersection-members.js","sourceRoot":"","sources":["../../src/rules/sort-type-union-intersection-members.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAA0D;AAE1D,8CAAgC;AAChC,kCAAoE;AAEpE,IAAK,KAaJ;AAbD,WAAK,KAAK;IACR,oCAA2B,CAAA;IAC3B,8BAAqB,CAAA;IACrB,0BAAiB,CAAA;IACjB,sCAA6B,CAAA;IAC7B,4BAAmB,CAAA;IACnB,4BAAmB,CAAA;IACnB,4BAAmB,CAAA;IACnB,wBAAe,CAAA;IACf,0BAAiB,CAAA;IACjB,8BAAqB,CAAA;IACrB,wBAAe,CAAA;IACf,wBAAe,CAAA;AACjB,CAAC,EAbI,KAAK,KAAL,KAAK,QAaT;AAED,SAAS,QAAQ,CAAC,IAAuB;IACvC,QAAQ,IAAI,CAAC,IAAI,EAAE;QACjB,KAAK,sBAAc,CAAC,iBAAiB;YACnC,OAAO,KAAK,CAAC,WAAW,CAAC;QAE3B,KAAK,sBAAc,CAAC,iBAAiB,CAAC;QACtC,KAAK,sBAAc,CAAC,cAAc;YAChC,OAAO,KAAK,CAAC,QAAQ,CAAC;QAExB,KAAK,sBAAc,CAAC,YAAY;YAC9B,OAAO,KAAK,CAAC,MAAM,CAAC;QAEtB,KAAK,sBAAc,CAAC,kBAAkB;YACpC,OAAO,KAAK,CAAC,YAAY,CAAC;QAE5B,KAAK,sBAAc,CAAC,YAAY,CAAC;QACjC,KAAK,sBAAc,CAAC,eAAe,CAAC;QACpC,KAAK,sBAAc,CAAC,gBAAgB,CAAC;QACrC,KAAK,sBAAc,CAAC,cAAc,CAAC;QACnC,KAAK,sBAAc,CAAC,eAAe,CAAC;QACpC,KAAK,sBAAc,CAAC,eAAe,CAAC;QACpC,KAAK,sBAAc,CAAC,eAAe,CAAC;QACpC,KAAK,sBAAc,CAAC,eAAe,CAAC;QACpC,KAAK,s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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/eslint-plugin",
|
|
3
|
-
"version": "6.0.0-alpha.
|
|
3
|
+
"version": "6.0.0-alpha.81+f0f45a9d3",
|
|
4
4
|
"description": "TypeScript plugin for ESLint",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@typescript-eslint/scope-manager": "6.0.0-alpha.
|
|
58
|
-
"@typescript-eslint/type-utils": "6.0.0-alpha.
|
|
59
|
-
"@typescript-eslint/utils": "6.0.0-alpha.
|
|
57
|
+
"@typescript-eslint/scope-manager": "6.0.0-alpha.81+f0f45a9d3",
|
|
58
|
+
"@typescript-eslint/type-utils": "6.0.0-alpha.81+f0f45a9d3",
|
|
59
|
+
"@typescript-eslint/utils": "6.0.0-alpha.81+f0f45a9d3",
|
|
60
60
|
"debug": "^4.3.4",
|
|
61
61
|
"grapheme-splitter": "^1.0.4",
|
|
62
62
|
"ignore": "^5.2.0",
|
|
@@ -92,5 +92,5 @@
|
|
|
92
92
|
"type": "opencollective",
|
|
93
93
|
"url": "https://opencollective.com/typescript-eslint"
|
|
94
94
|
},
|
|
95
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "f0f45a9d35453c3ec601df770092d236c72d447b"
|
|
96
96
|
}
|