@putout/plugin-remove-duplicate-keys 5.1.0 → 7.0.0
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 +11 -0
- package/lib/remove-duplicate-keys.js +9 -9
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -44,6 +44,17 @@ const a = {
|
|
|
44
44
|
};
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
+
> SyntaxError: Duplicate parameter name not allowed in this context
|
|
48
|
+
>
|
|
49
|
+
> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Duplicate_parameter)
|
|
50
|
+
|
|
51
|
+
Argument name clash:
|
|
52
|
+
|
|
53
|
+
```diff
|
|
54
|
+
-const a = ({b, b, ...c}) => {};
|
|
55
|
+
+const a = ({b, ...c}) => {};
|
|
56
|
+
```
|
|
57
|
+
|
|
47
58
|
## License
|
|
48
59
|
|
|
49
60
|
MIT
|
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
const {types, operator} = require('putout');
|
|
4
4
|
const fullstore = require('fullstore');
|
|
5
|
+
const {
|
|
6
|
+
compare,
|
|
7
|
+
traverseProperties,
|
|
8
|
+
extract,
|
|
9
|
+
} = operator;
|
|
5
10
|
|
|
6
11
|
const {
|
|
7
12
|
isSpreadElement,
|
|
8
13
|
isIdentifier,
|
|
9
14
|
isMemberExpression,
|
|
10
15
|
isObjectProperty,
|
|
11
|
-
isObjectPattern,
|
|
12
16
|
isStringLiteral,
|
|
17
|
+
isObjectPattern,
|
|
13
18
|
} = types;
|
|
14
19
|
|
|
15
|
-
const {
|
|
16
|
-
traverseProperties,
|
|
17
|
-
extract,
|
|
18
|
-
} = operator;
|
|
19
|
-
|
|
20
20
|
const isSpreadId = (name) => (a) => isSpreadElement(a) && isIdentifier(a.argument, {
|
|
21
21
|
name,
|
|
22
22
|
});
|
|
@@ -54,14 +54,14 @@ module.exports.match = () => ({
|
|
|
54
54
|
const newProperties = [];
|
|
55
55
|
const {properties} = __object;
|
|
56
56
|
|
|
57
|
-
if (isObjectPattern(__object))
|
|
58
|
-
return false;
|
|
59
|
-
|
|
60
57
|
const reversed = properties
|
|
61
58
|
.slice()
|
|
62
59
|
.reverse();
|
|
63
60
|
|
|
64
61
|
for (const prop of reversed) {
|
|
62
|
+
if (isObjectPattern(path) && !compare(prop.key, prop.value))
|
|
63
|
+
continue;
|
|
64
|
+
|
|
65
65
|
if (isSpreadElement(prop) && isIdentifier(prop.argument)) {
|
|
66
66
|
const {name} = prop.argument;
|
|
67
67
|
const isFirst = checkIfFirst(properties, newProperties, isSpreadId, name);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-remove-duplicate-keys",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊Putout plugin adds ability to find and remove duplicate keys",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"changelog": false,
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "git://github.com/coderaiser/putout.git"
|
|
14
|
+
"url": "git+https://github.com/coderaiser/putout.git"
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"test": "madrun test",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"fullstore": "^3.0.0"
|
|
28
28
|
},
|
|
29
|
-
"
|
|
29
|
+
"keywords": [
|
|
30
30
|
"putout",
|
|
31
31
|
"putout-plugin",
|
|
32
32
|
"putout-plugin-remove",
|
|
@@ -35,17 +35,17 @@
|
|
|
35
35
|
"key"
|
|
36
36
|
],
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@putout/
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"eslint
|
|
42
|
-
"eslint-plugin-
|
|
43
|
-
"
|
|
38
|
+
"@putout/eslint-flat": "^2.0.0",
|
|
39
|
+
"@putout/test": "^12.0.0",
|
|
40
|
+
"c8": "^10.0.0",
|
|
41
|
+
"eslint": "^9.0.0",
|
|
42
|
+
"eslint-plugin-n": "^17.0.0",
|
|
43
|
+
"eslint-plugin-putout": "^25.0.1",
|
|
44
44
|
"madrun": "^10.0.0",
|
|
45
45
|
"nodemon": "^3.0.1"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"putout": ">=
|
|
48
|
+
"putout": ">=38"
|
|
49
49
|
},
|
|
50
50
|
"license": "MIT",
|
|
51
51
|
"engines": {
|