@putout/plugin-remove-duplicate-keys 9.0.0 → 9.1.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.
@@ -20,19 +20,6 @@ const isSpreadId = (name) => (a) => isSpreadElement(a) && isIdentifier(a.argumen
20
20
  name,
21
21
  });
22
22
 
23
- const isObjectPropertyId = (name, computed) => (a) => {
24
- if (!isObjectProperty(a, {computed}))
25
- return false;
26
-
27
- return isIdentifier(a.key, {
28
- name,
29
- });
30
- };
31
-
32
- const isMemberExpressionId = (name, computed) => (a) => isObjectProperty(a, {
33
- computed,
34
- }) && name === extract(a.key);
35
-
36
23
  const isObjectPropertyLiteral = (value) => (a) => isObjectProperty(a) && isStringLiteral(a.key, {
37
24
  value,
38
25
  });
@@ -40,15 +27,11 @@ const isObjectPropertyLiteral = (value) => (a) => isObjectProperty(a) && isStrin
40
27
  const addQuote = (a) => `'${a}'`;
41
28
 
42
29
  export const report = ({names}) => {
43
- const {length} = names;
44
30
  const quotedNames = names
45
- .reverse()
46
31
  .map(addQuote)
47
32
  .join(', ');
48
33
 
49
- const suffix = !length ? '' : `: ${quotedNames}`;
50
-
51
- return `Avoid duplicate keys${suffix}`;
34
+ return `Avoid duplicate keys: ${quotedNames}`;
52
35
  };
53
36
 
54
37
  export const fix = ({path, newProperties}) => {
@@ -77,6 +60,7 @@ export const traverse = ({push}) => ({
77
60
 
78
61
  if (!isFirst) {
79
62
  is = true;
63
+ names.unshift(name);
80
64
  continue;
81
65
  }
82
66
  }
@@ -96,7 +80,7 @@ export const traverse = ({push}) => ({
96
80
 
97
81
  if (!isFirst) {
98
82
  is = true;
99
- names.push(name);
83
+ names.unshift(name);
100
84
  continue;
101
85
  }
102
86
  }
@@ -108,7 +92,7 @@ export const traverse = ({push}) => ({
108
92
 
109
93
  if (!isFirst) {
110
94
  is = true;
111
- names.push(value);
95
+ names.unshift(value);
112
96
  continue;
113
97
  }
114
98
  }
@@ -131,6 +115,7 @@ export const traverse = ({push}) => ({
131
115
 
132
116
  if (!isFirst) {
133
117
  is = true;
118
+ names.unshift(name);
134
119
  continue;
135
120
  }
136
121
  }
@@ -154,3 +139,19 @@ function checkIfFirst(properties, newProperties, isFn, str, {computed} = {}) {
154
139
 
155
140
  return !newLength || oldLength <= 1;
156
141
  }
142
+
143
+ const isObjectPropertyId = (name, computed) => (a) => {
144
+ if (!isObjectProperty(a, {computed}))
145
+ return false;
146
+
147
+ return isIdentifier(a.key, {
148
+ name,
149
+ });
150
+ };
151
+
152
+ const isMemberExpressionId = (name, computed) => (a) => {
153
+ if (!isObjectProperty(a, {computed}))
154
+ return false;
155
+
156
+ return name === extract(a.key);
157
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-remove-duplicate-keys",
3
- "version": "9.0.0",
3
+ "version": "9.1.0",
4
4
  "type": "module",
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",