@typescript-eslint/eslint-plugin 8.64.1-alpha.5 → 8.64.1-alpha.7
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/eslintrc/all.d.ts +0 -2
- package/dist/configs/eslintrc/all.js +0 -2
- package/dist/configs/flat/all.js +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +47 -0
- package/dist/raw-plugin.d.ts +0 -2
- package/dist/rules/no-restricted-imports.js +12 -0
- package/dist/rules/unbound-method.js +36 -9
- package/package.json +8 -8
|
@@ -73,8 +73,6 @@ declare const _default: {
|
|
|
73
73
|
'@typescript-eslint/no-redeclare': "error";
|
|
74
74
|
'@typescript-eslint/no-redundant-type-constituents': "error";
|
|
75
75
|
'@typescript-eslint/no-require-imports': "error";
|
|
76
|
-
'no-restricted-imports': "off";
|
|
77
|
-
'@typescript-eslint/no-restricted-imports': "error";
|
|
78
76
|
'@typescript-eslint/no-restricted-types': "error";
|
|
79
77
|
'no-shadow': "off";
|
|
80
78
|
'@typescript-eslint/no-shadow': "error";
|
|
@@ -80,8 +80,6 @@ module.exports = {
|
|
|
80
80
|
'@typescript-eslint/no-redeclare': 'error',
|
|
81
81
|
'@typescript-eslint/no-redundant-type-constituents': 'error',
|
|
82
82
|
'@typescript-eslint/no-require-imports': 'error',
|
|
83
|
-
'no-restricted-imports': 'off',
|
|
84
|
-
'@typescript-eslint/no-restricted-imports': 'error',
|
|
85
83
|
'@typescript-eslint/no-restricted-types': 'error',
|
|
86
84
|
'no-shadow': 'off',
|
|
87
85
|
'@typescript-eslint/no-shadow': 'error',
|
package/dist/configs/flat/all.js
CHANGED
|
@@ -93,8 +93,6 @@ exports.default = (plugin, parser) => [
|
|
|
93
93
|
'@typescript-eslint/no-redeclare': 'error',
|
|
94
94
|
'@typescript-eslint/no-redundant-type-constituents': 'error',
|
|
95
95
|
'@typescript-eslint/no-require-imports': 'error',
|
|
96
|
-
'no-restricted-imports': 'off',
|
|
97
|
-
'@typescript-eslint/no-restricted-imports': 'error',
|
|
98
96
|
'@typescript-eslint/no-restricted-types': 'error',
|
|
99
97
|
'no-shadow': 'off',
|
|
100
98
|
'@typescript-eslint/no-shadow': 'error',
|
package/dist/index.d.ts
CHANGED
|
@@ -75,8 +75,6 @@ declare const _default: {
|
|
|
75
75
|
'@typescript-eslint/no-redeclare': "error";
|
|
76
76
|
'@typescript-eslint/no-redundant-type-constituents': "error";
|
|
77
77
|
'@typescript-eslint/no-require-imports': "error";
|
|
78
|
-
'no-restricted-imports': "off";
|
|
79
|
-
'@typescript-eslint/no-restricted-imports': "error";
|
|
80
78
|
'@typescript-eslint/no-restricted-types': "error";
|
|
81
79
|
'no-shadow': "off";
|
|
82
80
|
'@typescript-eslint/no-shadow': "error";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/* eslint-disable import/first -- intentionally executing code before rest of the require()s. This will not work with ESM. */
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
2
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
38
|
};
|
|
39
|
+
const ts = __importStar(require("typescript"));
|
|
40
|
+
const [versionMajor, _versionMinor] = ts.versionMajorMinor
|
|
41
|
+
.split('.')
|
|
42
|
+
.map(Number);
|
|
43
|
+
if (versionMajor >= 7) {
|
|
44
|
+
// eslint-disable-next-line no-console
|
|
45
|
+
console.error([
|
|
46
|
+
'typescript-eslint does not support TS 7.0.',
|
|
47
|
+
'Please see https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/#running-side-by-side-with-typescript-6.0 to run typescript-eslint using the TS 6 API.',
|
|
48
|
+
"See also https://github.com/typescript-eslint/typescript-eslint/issues/10940 for tracking typescript-eslint's support for TS >=7.1",
|
|
49
|
+
].join('\n'));
|
|
50
|
+
throw new Error('typescript-eslint does not support TS 7.0.');
|
|
51
|
+
}
|
|
5
52
|
const raw_plugin_1 = __importDefault(require("./raw-plugin"));
|
|
6
53
|
module.exports = raw_plugin_1.default.plugin;
|
package/dist/raw-plugin.d.ts
CHANGED
|
@@ -97,8 +97,6 @@ declare const _default: {
|
|
|
97
97
|
'@typescript-eslint/no-redeclare': "error";
|
|
98
98
|
'@typescript-eslint/no-redundant-type-constituents': "error";
|
|
99
99
|
'@typescript-eslint/no-require-imports': "error";
|
|
100
|
-
'no-restricted-imports': "off";
|
|
101
|
-
'@typescript-eslint/no-restricted-imports': "error";
|
|
102
100
|
'@typescript-eslint/no-restricted-types': "error";
|
|
103
101
|
'no-shadow': "off";
|
|
104
102
|
'@typescript-eslint/no-shadow': "error";
|
|
@@ -135,6 +135,18 @@ exports.default = (0, util_1.createRule)({
|
|
|
135
135
|
meta: {
|
|
136
136
|
type: 'suggestion',
|
|
137
137
|
// defaultOptions, -- base rule does not use defaultOptions
|
|
138
|
+
deprecated: {
|
|
139
|
+
deprecatedSince: '8.64.0',
|
|
140
|
+
replacedBy: [
|
|
141
|
+
{
|
|
142
|
+
rule: {
|
|
143
|
+
name: 'no-restricted-imports',
|
|
144
|
+
url: 'https://eslint.org/docs/latest/rules/no-restricted-imports',
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
url: 'https://github.com/typescript-eslint/typescript-eslint/pull/12527',
|
|
149
|
+
},
|
|
138
150
|
docs: {
|
|
139
151
|
description: 'Disallow specified modules when loaded by `import`',
|
|
140
152
|
extendsBaseRule: true,
|
|
@@ -153,6 +153,31 @@ exports.default = (0, util_1.createRule)({
|
|
|
153
153
|
}
|
|
154
154
|
return false;
|
|
155
155
|
}
|
|
156
|
+
function checkUnionConstituentsAndReport(reportNode, propertyName, type) {
|
|
157
|
+
for (const intersectionPart of tsutils
|
|
158
|
+
.unionConstituents(type)
|
|
159
|
+
.flatMap(unionPart => tsutils.intersectionConstituents(unionPart))) {
|
|
160
|
+
const reported = checkIfMethodAndReport(reportNode, intersectionPart.getProperty(propertyName));
|
|
161
|
+
if (reported) {
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
function getAccessedPropertyNames(node) {
|
|
168
|
+
if (!node.computed) {
|
|
169
|
+
return node.property.type === utils_1.AST_NODE_TYPES.Identifier
|
|
170
|
+
? [node.property.name]
|
|
171
|
+
: [];
|
|
172
|
+
}
|
|
173
|
+
return tsutils
|
|
174
|
+
.unionConstituents(services.getTypeAtLocation(node.property))
|
|
175
|
+
.flatMap(part => {
|
|
176
|
+
return part.isStringLiteral() || part.isNumberLiteral()
|
|
177
|
+
? [part.value.toString()]
|
|
178
|
+
: [];
|
|
179
|
+
});
|
|
180
|
+
}
|
|
156
181
|
function isNativelyBound(object, property) {
|
|
157
182
|
// We can't rely entirely on the type-level checks made at the end of this
|
|
158
183
|
// function, because sometimes type declarations don't come from the
|
|
@@ -181,7 +206,16 @@ exports.default = (0, util_1.createRule)({
|
|
|
181
206
|
if (isSafeUse(node) || isNativelyBound(node.object, node.property)) {
|
|
182
207
|
return;
|
|
183
208
|
}
|
|
184
|
-
|
|
209
|
+
const propertyNames = getAccessedPropertyNames(node);
|
|
210
|
+
if (propertyNames.length === 0) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const objectType = services.getTypeAtLocation(node.object);
|
|
214
|
+
for (const propertyName of propertyNames) {
|
|
215
|
+
if (checkUnionConstituentsAndReport(node, propertyName, objectType)) {
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
185
219
|
},
|
|
186
220
|
ObjectPattern(node) {
|
|
187
221
|
if (isNodeInsideTypeDeclaration(node)) {
|
|
@@ -217,14 +251,7 @@ exports.default = (0, util_1.createRule)({
|
|
|
217
251
|
continue;
|
|
218
252
|
}
|
|
219
253
|
}
|
|
220
|
-
|
|
221
|
-
.unionConstituents(services.getTypeAtLocation(node))
|
|
222
|
-
.flatMap(unionPart => tsutils.intersectionConstituents(unionPart))) {
|
|
223
|
-
const reported = checkIfMethodAndReport(property.key, intersectionPart.getProperty(property.key.name));
|
|
224
|
-
if (reported) {
|
|
225
|
-
break;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
254
|
+
checkUnionConstituentsAndReport(property.key, property.key.name, services.getTypeAtLocation(node));
|
|
228
255
|
}
|
|
229
256
|
},
|
|
230
257
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/eslint-plugin",
|
|
3
|
-
"version": "8.64.1-alpha.
|
|
3
|
+
"version": "8.64.1-alpha.7",
|
|
4
4
|
"description": "TypeScript plugin for ESLint",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"ignore": "^7.0.5",
|
|
50
50
|
"natural-compare": "^1.4.0",
|
|
51
51
|
"ts-api-utils": "^2.5.0",
|
|
52
|
-
"@typescript-eslint/scope-manager": "8.64.1-alpha.
|
|
53
|
-
"@typescript-eslint/
|
|
54
|
-
"@typescript-eslint/
|
|
55
|
-
"@typescript-eslint/utils": "8.64.1-alpha.
|
|
52
|
+
"@typescript-eslint/scope-manager": "8.64.1-alpha.7",
|
|
53
|
+
"@typescript-eslint/utils": "8.64.1-alpha.7",
|
|
54
|
+
"@typescript-eslint/visitor-keys": "8.64.1-alpha.7",
|
|
55
|
+
"@typescript-eslint/type-utils": "8.64.1-alpha.7"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/json-schema": "^7.0.15",
|
|
@@ -76,13 +76,13 @@
|
|
|
76
76
|
"typescript": ">=4.8.4 <6.1.0",
|
|
77
77
|
"unist-util-visit": "^5.0.0",
|
|
78
78
|
"vitest": "^4.0.18",
|
|
79
|
-
"@typescript-eslint/rule-schema-to-typescript-types": "8.64.1-alpha.
|
|
80
|
-
"@typescript-eslint/rule-tester": "8.64.1-alpha.
|
|
79
|
+
"@typescript-eslint/rule-schema-to-typescript-types": "8.64.1-alpha.7",
|
|
80
|
+
"@typescript-eslint/rule-tester": "8.64.1-alpha.7"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
|
|
84
84
|
"typescript": ">=4.8.4 <6.1.0",
|
|
85
|
-
"@typescript-eslint/parser": "^8.64.1-alpha.
|
|
85
|
+
"@typescript-eslint/parser": "^8.64.1-alpha.7"
|
|
86
86
|
},
|
|
87
87
|
"funding": {
|
|
88
88
|
"type": "opencollective",
|