eslint-plugin-no-excess-properties 0.0.5 → 0.0.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/README.md +76 -76
- package/dist/object-literal.js +58 -45
- package/dist/object-literal.js.map +1 -1
- package/eslint.config.mjs +19 -19
- package/package.json +2 -1
- package/src/index.ts +31 -31
- package/src/object-literal.test.ts +296 -201
- package/src/object-literal.ts +235 -225
package/README.md
CHANGED
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
# eslint-plugin-no-excess-properties
|
|
2
|
-
|
|
3
|
-
ESLint plugin for TypeScript that warns when there are excess properties on object literals
|
|
4
|
-
|
|
5
|
-
Currently has a single rule `no-excess-properties/object-literal` that uses [typed linting](https://typescript-eslint.io/getting-started/typed-linting)
|
|
6
|
-
|
|
7
|
-
## Install
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
npm install --save-dev eslint-plugin-no-excess-properties
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Config
|
|
14
|
-
|
|
15
|
-
In the `eslint.config.mjs` file:
|
|
16
|
-
|
|
17
|
-
### Basic
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
import tseslint from "typescript-eslint";
|
|
21
|
-
import noExcessProperties from "eslint-plugin-no-excess-properties";
|
|
22
|
-
|
|
23
|
-
export default tseslint.config({
|
|
24
|
-
extends: [
|
|
25
|
-
noExcessProperties.configs.recommended,
|
|
26
|
-
],
|
|
27
|
-
})
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### Fancy
|
|
31
|
-
|
|
32
|
-
```
|
|
33
|
-
import tseslint from "typescript-eslint";
|
|
34
|
-
import noExcessProperties from "eslint-plugin-no-excess-properties";
|
|
35
|
-
|
|
36
|
-
export default tseslint.config({
|
|
37
|
-
plugins: {
|
|
38
|
-
"no-excess-properties": noExcessProperties,
|
|
39
|
-
},
|
|
40
|
-
rules: {
|
|
41
|
-
"no-excess-properties/object-literal": "error",
|
|
42
|
-
},
|
|
43
|
-
})
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Example Linted Code
|
|
47
|
-
|
|
48
|
-
See the [test file](https://bitbucket.org/unimorphic/eslint-plugin-no-excess-properties/src/master/src/object-literal.test.ts) for more examples
|
|
49
|
-
|
|
50
|
-
### Incorrect
|
|
51
|
-
|
|
52
|
-
```
|
|
53
|
-
let test1: { prop1: number; } = { prop1: 1 };
|
|
54
|
-
const test2 = { prop1: 2, extraPropertyNotInTest1: 3 };
|
|
55
|
-
test1 = test2; // Error
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### Correct
|
|
59
|
-
|
|
60
|
-
```
|
|
61
|
-
let test1: { prop1: number; } = { prop1: 1 };
|
|
62
|
-
const test2 = { prop1: 2 };
|
|
63
|
-
test1 = test2; // OK
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## More Info
|
|
67
|
-
|
|
68
|
-
Related typescript-eslint issue: https://github.com/typescript-eslint/typescript-eslint/issues/10234
|
|
69
|
-
|
|
70
|
-
## Feedback
|
|
71
|
-
|
|
72
|
-
[Submit](https://bitbucket.org/unimorphic/eslint-plugin-no-excess-properties/issues/new) bug reports and other feedback in the [issues](https://bitbucket.org/unimorphic/eslint-plugin-no-excess-properties/issues?status=new&status=open) section
|
|
73
|
-
|
|
74
|
-
## License
|
|
75
|
-
|
|
76
|
-
MIT
|
|
1
|
+
# eslint-plugin-no-excess-properties
|
|
2
|
+
|
|
3
|
+
ESLint plugin for TypeScript that warns when there are excess properties on object literals
|
|
4
|
+
|
|
5
|
+
Currently has a single rule `no-excess-properties/object-literal` that uses [typed linting](https://typescript-eslint.io/getting-started/typed-linting)
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npm install --save-dev eslint-plugin-no-excess-properties
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Config
|
|
14
|
+
|
|
15
|
+
In the `eslint.config.mjs` file:
|
|
16
|
+
|
|
17
|
+
### Basic
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
import tseslint from "typescript-eslint";
|
|
21
|
+
import noExcessProperties from "eslint-plugin-no-excess-properties";
|
|
22
|
+
|
|
23
|
+
export default tseslint.config({
|
|
24
|
+
extends: [
|
|
25
|
+
noExcessProperties.configs.recommended,
|
|
26
|
+
],
|
|
27
|
+
})
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Fancy
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
import tseslint from "typescript-eslint";
|
|
34
|
+
import noExcessProperties from "eslint-plugin-no-excess-properties";
|
|
35
|
+
|
|
36
|
+
export default tseslint.config({
|
|
37
|
+
plugins: {
|
|
38
|
+
"no-excess-properties": noExcessProperties,
|
|
39
|
+
},
|
|
40
|
+
rules: {
|
|
41
|
+
"no-excess-properties/object-literal": "error",
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Example Linted Code
|
|
47
|
+
|
|
48
|
+
See the [test file](https://bitbucket.org/unimorphic/eslint-plugin-no-excess-properties/src/master/src/object-literal.test.ts) for more examples
|
|
49
|
+
|
|
50
|
+
### Incorrect
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
let test1: { prop1: number; } = { prop1: 1 };
|
|
54
|
+
const test2 = { prop1: 2, extraPropertyNotInTest1: 3 };
|
|
55
|
+
test1 = test2; // Error
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Correct
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
let test1: { prop1: number; } = { prop1: 1 };
|
|
62
|
+
const test2 = { prop1: 2 };
|
|
63
|
+
test1 = test2; // OK
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## More Info
|
|
67
|
+
|
|
68
|
+
Related typescript-eslint issue: https://github.com/typescript-eslint/typescript-eslint/issues/10234
|
|
69
|
+
|
|
70
|
+
## Feedback
|
|
71
|
+
|
|
72
|
+
[Submit](https://bitbucket.org/unimorphic/eslint-plugin-no-excess-properties/issues/new) bug reports and other feedback in the [issues](https://bitbucket.org/unimorphic/eslint-plugin-no-excess-properties/issues?status=new&status=open) section
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
MIT
|
package/dist/object-literal.js
CHANGED
|
@@ -40,56 +40,62 @@ const utils_1 = require("@typescript-eslint/utils");
|
|
|
40
40
|
const typescript_1 = __importDefault(require("typescript"));
|
|
41
41
|
const tsutils = __importStar(require("ts-api-utils"));
|
|
42
42
|
const createRule = utils_1.ESLintUtils.RuleCreator(() => "https://bitbucket.org/unimorphic/eslint-plugin-no-excess-properties");
|
|
43
|
-
function getAllPropertyNames(type) {
|
|
44
|
-
const allTypes = tsutils.typeConstituents(type);
|
|
45
|
-
return allTypes.reduce((all, t) => all.concat(...t.getProperties().map((p) => p.name)), []);
|
|
46
|
-
}
|
|
47
43
|
function isObjectLiteral(type) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
tsutils.isSymbolFlagSet(t.symbol, typescript_1.default.SymbolFlags.ObjectLiteral));
|
|
44
|
+
return (type.symbol !== undefined &&
|
|
45
|
+
tsutils.isSymbolFlagSet(type.symbol, typescript_1.default.SymbolFlags.ObjectLiteral));
|
|
51
46
|
}
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
function resolveType(type) {
|
|
48
|
+
let resolvedType = type;
|
|
49
|
+
const callSignatures = resolvedType.getCallSignatures();
|
|
50
|
+
if (callSignatures.length === 1) {
|
|
51
|
+
resolvedType = callSignatures[0].getReturnType();
|
|
55
52
|
}
|
|
56
|
-
const
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
data: { excessPropertyNames: excessPropertyNames.join(", ") },
|
|
60
|
-
messageId: "noExcessProperties",
|
|
61
|
-
node: rightNode,
|
|
62
|
-
});
|
|
53
|
+
const arrayType = resolvedType.getNumberIndexType();
|
|
54
|
+
if (arrayType) {
|
|
55
|
+
resolvedType = arrayType;
|
|
63
56
|
}
|
|
57
|
+
return resolvedType;
|
|
64
58
|
}
|
|
65
|
-
function
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
t.getNumberIndexType() !== undefined
|
|
59
|
+
function compareTypes(leftType, rightType, rightNode, context) {
|
|
60
|
+
const allLeftTypes = tsutils.unionConstituents(leftType);
|
|
61
|
+
const allRightTypes = tsutils.unionConstituents(rightType);
|
|
62
|
+
if (allLeftTypes.some((t) => t.getStringIndexType() !== undefined ||
|
|
63
|
+
(t.getNumberIndexType() !== undefined &&
|
|
64
|
+
t.symbol?.name !== "Array"))) {
|
|
70
65
|
return;
|
|
71
66
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
rightPropertyNames = getAllPropertyNames(rightType);
|
|
77
|
-
}
|
|
78
|
-
if (leftPropertyNames.length <= 0 || rightPropertyNames.length <= 0) {
|
|
79
|
-
const leftCallSignatures = leftType.getCallSignatures();
|
|
80
|
-
if (leftCallSignatures.length === 1) {
|
|
81
|
-
const returnType = leftCallSignatures[0].getReturnType();
|
|
82
|
-
leftPropertyNames = getAllPropertyNames(returnType);
|
|
67
|
+
for (const rightType of allRightTypes) {
|
|
68
|
+
const rightResolvedType = resolveType(rightType);
|
|
69
|
+
if (!isObjectLiteral(rightResolvedType)) {
|
|
70
|
+
continue;
|
|
83
71
|
}
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
72
|
+
const rightPropertyNames = rightResolvedType
|
|
73
|
+
.getProperties()
|
|
74
|
+
.map((p) => p.name);
|
|
75
|
+
let bestMatchExcessPropertyNames = null;
|
|
76
|
+
for (const leftType of allLeftTypes) {
|
|
77
|
+
const leftResolvedType = resolveType(leftType);
|
|
78
|
+
const leftPropertyNames = leftResolvedType
|
|
79
|
+
.getProperties()
|
|
80
|
+
.map((p) => p.name);
|
|
81
|
+
const excessPropertyNames = rightPropertyNames.filter((n) => !leftPropertyNames.includes(n));
|
|
82
|
+
if (leftPropertyNames.length > 0 &&
|
|
83
|
+
(bestMatchExcessPropertyNames === null ||
|
|
84
|
+
excessPropertyNames.length < bestMatchExcessPropertyNames.length)) {
|
|
85
|
+
bestMatchExcessPropertyNames = excessPropertyNames;
|
|
89
86
|
}
|
|
90
87
|
}
|
|
88
|
+
if (bestMatchExcessPropertyNames &&
|
|
89
|
+
bestMatchExcessPropertyNames.length > 0) {
|
|
90
|
+
context.report({
|
|
91
|
+
data: {
|
|
92
|
+
excessPropertyNames: bestMatchExcessPropertyNames.join(", "),
|
|
93
|
+
},
|
|
94
|
+
messageId: "noExcessProperties",
|
|
95
|
+
node: rightNode,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
91
98
|
}
|
|
92
|
-
compareNames(leftPropertyNames, rightPropertyNames, rightNode, context);
|
|
93
99
|
}
|
|
94
100
|
const noExcessProperties = createRule({
|
|
95
101
|
create: function (context) {
|
|
@@ -99,7 +105,7 @@ const noExcessProperties = createRule({
|
|
|
99
105
|
AssignmentExpression(node) {
|
|
100
106
|
const leftType = services.getTypeAtLocation(node.left);
|
|
101
107
|
const rightType = services.getTypeAtLocation(node.right);
|
|
102
|
-
|
|
108
|
+
compareTypes(leftType, rightType, node.right, context);
|
|
103
109
|
},
|
|
104
110
|
CallExpression(node) {
|
|
105
111
|
if (node.arguments.length <= 0) {
|
|
@@ -115,8 +121,15 @@ const noExcessProperties = createRule({
|
|
|
115
121
|
break;
|
|
116
122
|
}
|
|
117
123
|
const argType = services.getTypeAtLocation(node.arguments[i]);
|
|
118
|
-
|
|
119
|
-
|
|
124
|
+
let paramType = typeChecker.getTypeOfSymbolAtLocation(functionSignature.parameters[i], functionNode);
|
|
125
|
+
const declarations = functionSignature.parameters[i].declarations;
|
|
126
|
+
if (declarations?.some((d) => typescript_1.default.isParameter(d) && d.dotDotDotToken)) {
|
|
127
|
+
const arrayType = paramType.getNumberIndexType();
|
|
128
|
+
if (arrayType) {
|
|
129
|
+
paramType = arrayType;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
compareTypes(paramType, argType, node.arguments[i], context);
|
|
120
133
|
}
|
|
121
134
|
},
|
|
122
135
|
Property(node) {
|
|
@@ -129,7 +142,7 @@ const noExcessProperties = createRule({
|
|
|
129
142
|
if (!leftType) {
|
|
130
143
|
return;
|
|
131
144
|
}
|
|
132
|
-
|
|
145
|
+
compareTypes(leftType, rightType, node, context);
|
|
133
146
|
},
|
|
134
147
|
ReturnStatement(node) {
|
|
135
148
|
if (!node.argument) {
|
|
@@ -151,7 +164,7 @@ const noExcessProperties = createRule({
|
|
|
151
164
|
}
|
|
152
165
|
}
|
|
153
166
|
const argType = services.getTypeAtLocation(node.argument);
|
|
154
|
-
|
|
167
|
+
compareTypes(returnType, argType, node.argument, context);
|
|
155
168
|
},
|
|
156
169
|
VariableDeclarator(node) {
|
|
157
170
|
if (!node.id.typeAnnotation || !node.init) {
|
|
@@ -159,7 +172,7 @@ const noExcessProperties = createRule({
|
|
|
159
172
|
}
|
|
160
173
|
const leftType = services.getTypeAtLocation(node.id.typeAnnotation.typeAnnotation);
|
|
161
174
|
const rightType = services.getTypeAtLocation(node.init);
|
|
162
|
-
|
|
175
|
+
compareTypes(leftType, rightType, node.init, context);
|
|
163
176
|
},
|
|
164
177
|
};
|
|
165
178
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-literal.js","sourceRoot":"","sources":["../src/object-literal.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA2E;AAE3E,4DAA4B;AAC5B,sDAAwC;AAYxC,MAAM,UAAU,GAAG,mBAAW,CAAC,WAAW,CACxC,GAAG,EAAE,CAAC,qEAAqE,CAC5E,CAAC;AAEF,SAAS,
|
|
1
|
+
{"version":3,"file":"object-literal.js","sourceRoot":"","sources":["../src/object-literal.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;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AC;IACD,cAAc,EAAE,EAAE;IAClB,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,WAAW,EAAE,0DAA0D;YACvE,WAAW,EAAE,IAAI;YACjB,oBAAoB,EAAE,IAAI;SAC3B;QACD,QAAQ,EAAE;YACR,kBAAkB,EAAE,qDAAqD;SAC1E;QACD,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,YAAY;KACnB;IACD,IAAI,EAAE,gBAAgB;CACvB,CAAC,CAAC;AAEH,kBAAe,kBAAkB,CAAC"}
|
package/eslint.config.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import eslint from "@eslint/js";
|
|
2
|
-
import tseslint from "typescript-eslint";
|
|
3
|
-
import eslintPlugin from "eslint-plugin-eslint-plugin";
|
|
4
|
-
|
|
5
|
-
export default tseslint.config({
|
|
6
|
-
extends: [
|
|
7
|
-
eslint.configs.recommended,
|
|
8
|
-
eslintPlugin.configs["flat/recommended"],
|
|
9
|
-
tseslint.configs.strictTypeChecked,
|
|
10
|
-
tseslint.configs.stylisticTypeChecked,
|
|
11
|
-
],
|
|
12
|
-
ignores: ["dist/**", "*.mjs", "vitest.config.ts"],
|
|
13
|
-
languageOptions: {
|
|
14
|
-
parserOptions: {
|
|
15
|
-
projectService: true,
|
|
16
|
-
tsconfigRootDir: import.meta.dirname,
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
});
|
|
1
|
+
import eslint from "@eslint/js";
|
|
2
|
+
import tseslint from "typescript-eslint";
|
|
3
|
+
import eslintPlugin from "eslint-plugin-eslint-plugin";
|
|
4
|
+
|
|
5
|
+
export default tseslint.config({
|
|
6
|
+
extends: [
|
|
7
|
+
eslint.configs.recommended,
|
|
8
|
+
eslintPlugin.configs["flat/recommended"],
|
|
9
|
+
tseslint.configs.strictTypeChecked,
|
|
10
|
+
tseslint.configs.stylisticTypeChecked,
|
|
11
|
+
],
|
|
12
|
+
ignores: ["dist/**", "*.mjs", "vitest.config.ts"],
|
|
13
|
+
languageOptions: {
|
|
14
|
+
parserOptions: {
|
|
15
|
+
projectService: true,
|
|
16
|
+
tsconfigRootDir: import.meta.dirname,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
});
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "eslint-plugin-no-excess-properties",
|
|
3
3
|
"description": "Excess properties are not allowed on object literals",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.7",
|
|
6
6
|
"homepage": "https://bitbucket.org/unimorphic/eslint-plugin-no-excess-properties",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"eslint-plugin",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"main": "dist/index.js",
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "tsc -p tsconfig.build.json",
|
|
26
|
+
"format": "prettier --write .",
|
|
26
27
|
"lint": "eslint .",
|
|
27
28
|
"prepare": "npm run build",
|
|
28
29
|
"test": "vitest"
|
package/src/index.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import objectLiteral from "./object-literal";
|
|
3
|
-
|
|
4
|
-
const pkg = JSON.parse(fs.readFileSync("./package.json", "utf8")) as {
|
|
5
|
-
name: string;
|
|
6
|
-
version: string;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const plugin = {
|
|
10
|
-
configs: {
|
|
11
|
-
get recommended() {
|
|
12
|
-
return {
|
|
13
|
-
plugins: {
|
|
14
|
-
"no-excess-properties": plugin,
|
|
15
|
-
},
|
|
16
|
-
rules: {
|
|
17
|
-
"no-excess-properties/object-literal": "warn",
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
meta: {
|
|
23
|
-
name: pkg.name,
|
|
24
|
-
version: pkg.version,
|
|
25
|
-
},
|
|
26
|
-
rules: {
|
|
27
|
-
"object-literal": objectLiteral,
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export = plugin;
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import objectLiteral from "./object-literal";
|
|
3
|
+
|
|
4
|
+
const pkg = JSON.parse(fs.readFileSync("./package.json", "utf8")) as {
|
|
5
|
+
name: string;
|
|
6
|
+
version: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const plugin = {
|
|
10
|
+
configs: {
|
|
11
|
+
get recommended() {
|
|
12
|
+
return {
|
|
13
|
+
plugins: {
|
|
14
|
+
"no-excess-properties": plugin,
|
|
15
|
+
},
|
|
16
|
+
rules: {
|
|
17
|
+
"no-excess-properties/object-literal": "warn",
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
meta: {
|
|
23
|
+
name: pkg.name,
|
|
24
|
+
version: pkg.version,
|
|
25
|
+
},
|
|
26
|
+
rules: {
|
|
27
|
+
"object-literal": objectLiteral,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export = plugin;
|