Skip to content

Commit 28914aa

Browse files
committed
[eslint] enable and autofix object-shorthand
1 parent e14f2b8 commit 28914aa

File tree

99 files changed

+598
-599
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+598
-599
lines changed

.eslintrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
"prefer-destructuring": [2, { "array": false, "object": false }, { "enforceForRenamedProperties": false }],
2626

27-
"object-shorthand": 1,
2827
"import/order": 1,
2928
"no-useless-escape": 1,
3029
"import/newline-after-import": 1,

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ const activeRulesConfig = configureAsError(activeRules);
114114
const deprecatedRules = filterRules(allRules, rule => rule.meta.deprecated);
115115

116116
module.exports = {
117-
deprecatedRules: deprecatedRules,
117+
deprecatedRules,
118118
rules: allRules,
119119
configs: {
120120
recommended: {

lib/rules/boolean-prop-naming.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ module.exports = {
181181
});
182182

183183
components.set(node, {
184-
invalidProps: invalidProps
184+
invalidProps
185185
});
186186
}
187187

@@ -197,7 +197,7 @@ module.exports = {
197197
message: config.message || 'Prop name ({{ propName }}) doesn\'t match rule ({{ pattern }})',
198198
data: {
199199
component: propName,
200-
propName: propName,
200+
propName,
201201
pattern: config.rule
202202
}
203203
});
@@ -216,7 +216,7 @@ module.exports = {
216216
// --------------------------------------------------------------------------
217217

218218
return {
219-
ClassProperty: function (node) {
219+
ClassProperty(node) {
220220
if (!rule || !propsUtil.isPropTypesDeclaration(node)) {
221221
return;
222222
}
@@ -231,7 +231,7 @@ module.exports = {
231231
}
232232
},
233233

234-
MemberExpression: function (node) {
234+
MemberExpression(node) {
235235
if (!rule || !propsUtil.isPropTypesDeclaration(node)) {
236236
return;
237237
}
@@ -247,7 +247,7 @@ module.exports = {
247247
validatePropNaming(component.node, node.parent.right.properties);
248248
},
249249

250-
ObjectExpression: function (node) {
250+
ObjectExpression(node) {
251251
if (!rule) {
252252
return;
253253
}
@@ -261,7 +261,7 @@ module.exports = {
261261
});
262262
},
263263

264-
TypeAlias: function (node) {
264+
TypeAlias(node) {
265265
// Cache all ObjectType annotations, we will check them at the end
266266
if (node.right.type === 'ObjectTypeAnnotation') {
267267
objectTypeAnnotations.set(node.id.name, node.right);

lib/rules/button-has-type.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ module.exports = {
6262
}]
6363
},
6464

65-
create: function (context) {
65+
create(context) {
6666
const configuration = Object.assign({}, optionDefaults, context.options[0]);
6767

6868
function reportMissing(node) {
6969
context.report({
70-
node: node,
70+
node,
7171
message: 'Missing an explicit type attribute for button'
7272
});
7373
}
@@ -76,19 +76,19 @@ module.exports = {
7676
const q = quoteFn || (x => `"${x}"`);
7777
if (!(value in configuration)) {
7878
context.report({
79-
node: node,
79+
node,
8080
message: `${q(value)} is an invalid value for button type attribute`
8181
});
8282
} else if (!configuration[value]) {
8383
context.report({
84-
node: node,
84+
node,
8585
message: `${q(value)} is a forbidden value for button type attribute`
8686
});
8787
}
8888
}
8989

9090
return {
91-
JSXElement: function (node) {
91+
JSXElement(node) {
9292
if (node.openingElement.name.name !== 'button') {
9393
return;
9494
}
@@ -107,7 +107,7 @@ module.exports = {
107107
checkValue(node, propValue);
108108
}
109109
},
110-
CallExpression: function (node) {
110+
CallExpression(node) {
111111
if (!isCreateElement(node, context)) {
112112
return;
113113
}

lib/rules/destructuring-assignment.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ module.exports = {
6161

6262
if (destructuringProps && components.get(node) && configuration === 'never') {
6363
context.report({
64-
node: node,
64+
node,
6565
message: 'Must never use destructuring props assignment in SFC argument'
6666
});
6767
} else if (destructuringContext && components.get(node) && configuration === 'never') {
6868
context.report({
69-
node: node,
69+
node,
7070
message: 'Must never use destructuring context assignment in SFC argument'
7171
});
7272
}
@@ -77,7 +77,7 @@ module.exports = {
7777
const isPropUsed = (node.object.name === 'props' || node.object.name === 'context') && !isAssignmentToProp(node);
7878
if (isPropUsed && configuration === 'always') {
7979
context.report({
80-
node: node,
80+
node,
8181
message: `Must use destructuring ${node.object.name} assignment`
8282
});
8383
}
@@ -107,7 +107,7 @@ module.exports = {
107107
!(ignoreClassFields && isInClassProperty(node))
108108
) {
109109
context.report({
110-
node: node,
110+
node,
111111
message: `Must use destructuring ${node.object.property.name} assignment`
112112
});
113113
}
@@ -121,7 +121,7 @@ module.exports = {
121121

122122
FunctionExpression: handleStatelessComponent,
123123

124-
MemberExpression: function (node) {
124+
MemberExpression(node) {
125125
const SFCComponent = components.get(context.getScope(node).block);
126126
const classComponent = utils.getParentComponent(node);
127127
if (SFCComponent) {
@@ -132,7 +132,7 @@ module.exports = {
132132
}
133133
},
134134

135-
VariableDeclarator: function (node) {
135+
VariableDeclarator(node) {
136136
const classComponent = utils.getParentComponent(node);
137137
const SFCComponent = components.get(context.getScope(node).block);
138138

@@ -146,7 +146,7 @@ module.exports = {
146146

147147
if (SFCComponent && destructuringSFC && configuration === 'never') {
148148
context.report({
149-
node: node,
149+
node,
150150
message: `Must never use destructuring ${node.init.name} assignment`
151151
});
152152
}
@@ -156,7 +156,7 @@ module.exports = {
156156
!(ignoreClassFields && node.parent.type === 'ClassProperty')
157157
) {
158158
context.report({
159-
node: node,
159+
node,
160160
message: `Must never use destructuring ${node.init.property.name} assignment`
161161
});
162162
}

lib/rules/display-name.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,14 @@ module.exports = {
122122

123123
return {
124124

125-
ClassProperty: function (node) {
125+
ClassProperty(node) {
126126
if (!propsUtil.isDisplayNameDeclaration(node)) {
127127
return;
128128
}
129129
markDisplayNameAsDeclared(node);
130130
},
131131

132-
MemberExpression: function (node) {
132+
MemberExpression(node) {
133133
if (!propsUtil.isDisplayNameDeclaration(node.property)) {
134134
return;
135135
}
@@ -140,7 +140,7 @@ module.exports = {
140140
markDisplayNameAsDeclared(component.node);
141141
},
142142

143-
FunctionExpression: function (node) {
143+
FunctionExpression(node) {
144144
if (ignoreTranspilerName || !hasTranspilerName(node)) {
145145
return;
146146
}
@@ -149,7 +149,7 @@ module.exports = {
149149
}
150150
},
151151

152-
FunctionDeclaration: function (node) {
152+
FunctionDeclaration(node) {
153153
if (ignoreTranspilerName || !hasTranspilerName(node)) {
154154
return;
155155
}
@@ -158,7 +158,7 @@ module.exports = {
158158
}
159159
},
160160

161-
ArrowFunctionExpression: function (node) {
161+
ArrowFunctionExpression(node) {
162162
if (ignoreTranspilerName || !hasTranspilerName(node)) {
163163
return;
164164
}
@@ -167,28 +167,28 @@ module.exports = {
167167
}
168168
},
169169

170-
MethodDefinition: function (node) {
170+
MethodDefinition(node) {
171171
if (!propsUtil.isDisplayNameDeclaration(node.key)) {
172172
return;
173173
}
174174
markDisplayNameAsDeclared(node);
175175
},
176176

177-
ClassExpression: function (node) {
177+
ClassExpression(node) {
178178
if (ignoreTranspilerName || !hasTranspilerName(node)) {
179179
return;
180180
}
181181
markDisplayNameAsDeclared(node);
182182
},
183183

184-
ClassDeclaration: function (node) {
184+
ClassDeclaration(node) {
185185
if (ignoreTranspilerName || !hasTranspilerName(node)) {
186186
return;
187187
}
188188
markDisplayNameAsDeclared(node);
189189
},
190190

191-
ObjectExpression: function (node) {
191+
ObjectExpression(node) {
192192
if (ignoreTranspilerName || !hasTranspilerName(node)) {
193193
// Search for the displayName declaration
194194
node.properties.forEach((property) => {

lib/rules/forbid-component-props.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ module.exports = {
5555
}]
5656
},
5757

58-
create: function (context) {
58+
create(context) {
5959
const configuration = context.options[0] || {};
6060
const forbid = new Map((configuration.forbid || DEFAULTS).map((value) => {
6161
const propName = typeof value === 'string' ? value : value.propName;
@@ -70,7 +70,7 @@ module.exports = {
7070
}
7171

7272
return {
73-
JSXAttribute: function (node) {
73+
JSXAttribute(node) {
7474
const tag = node.parent.name.name;
7575
if (tag && tag[0] !== tag[0].toUpperCase()) {
7676
// This is a DOM node, not a Component, so exit.
@@ -84,7 +84,7 @@ module.exports = {
8484
}
8585

8686
context.report({
87-
node: node,
87+
node,
8888
message: `Prop \`${prop}\` is forbidden on Components`
8989
});
9090
}

lib/rules/forbid-dom-props.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module.exports = {
4242
}]
4343
},
4444

45-
create: function (context) {
45+
create(context) {
4646
function isForbidden(prop) {
4747
const configuration = context.options[0] || {};
4848

@@ -51,7 +51,7 @@ module.exports = {
5151
}
5252

5353
return {
54-
JSXAttribute: function (node) {
54+
JSXAttribute(node) {
5555
const tag = node.parent.name.name;
5656
if (!(tag && tag[0] !== tag[0].toUpperCase())) {
5757
// This is a Component, not a DOM node, so exit.
@@ -65,7 +65,7 @@ module.exports = {
6565
}
6666

6767
context.report({
68-
node: node,
68+
node,
6969
message: `Prop \`${prop}\` is forbidden on DOM Nodes`
7070
});
7171
}

lib/rules/forbid-elements.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ module.exports = {
4646
}]
4747
},
4848

49-
create: function (context) {
49+
create(context) {
5050
const sourceCode = context.getSourceCode();
5151
const configuration = context.options[0] || {};
5252
const forbidConfiguration = configuration.forbid || [];
@@ -83,18 +83,18 @@ module.exports = {
8383
function reportIfForbidden(element, node) {
8484
if (has(indexedForbidConfigs, element)) {
8585
context.report({
86-
node: node,
86+
node,
8787
message: errorMessageForElement(element)
8888
});
8989
}
9090
}
9191

9292
return {
93-
JSXOpeningElement: function (node) {
93+
JSXOpeningElement(node) {
9494
reportIfForbidden(sourceCode.getText(node.name), node.name);
9595
},
9696

97-
CallExpression: function (node) {
97+
CallExpression(node) {
9898
if (!isValidCreateElement(node)) {
9999
return;
100100
}

lib/rules/forbid-foreign-prop-types.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = {
2929
]
3030
},
3131

32-
create: function (context) {
32+
create(context) {
3333
const config = context.options[0] || {};
3434
const allowInPropTypes = config.allowInPropTypes || false;
3535

@@ -94,7 +94,7 @@ module.exports = {
9494
}
9595

9696
return {
97-
MemberExpression: function (node) {
97+
MemberExpression(node) {
9898
if (
9999
node.property &&
100100
(
@@ -117,7 +117,7 @@ module.exports = {
117117
}
118118
},
119119

120-
ObjectPattern: function (node) {
120+
ObjectPattern(node) {
121121
const propTypesNode = node.properties.find(property => property.type === 'Property' && property.key.name === 'propTypes');
122122

123123
if (propTypesNode) {

0 commit comments

Comments
 (0)