Skip to content

Commit 83ac4c0

Browse files
golopotljharb
authored andcommitted
[eslint] fix func-names and change object-shorthand to 'always'
1 parent 225b433 commit 83ac4c0

28 files changed

+59
-57
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"rules": {
1717
"comma-dangle": [2, "never"],
1818
"object-curly-spacing": [2, "never"],
19+
"object-shorthand": [2, "always"],
1920
"array-bracket-spacing": [2, "never"],
2021
"max-len": [2, 120, {
2122
"ignoreStrings": true,

lib/rules/boolean-prop-naming.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ module.exports = {
282282
}
283283
},
284284

285-
'Program:exit': function () {
285+
// eslint-disable-next-line object-shorthand
286+
'Program:exit'() {
286287
if (!rule) {
287288
return;
288289
}

lib/rules/default-props-match-prop-types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ module.exports = {
8080
// --------------------------------------------------------------------------
8181

8282
return {
83-
'Program:exit': function () {
83+
'Program:exit'() {
8484
const list = components.list();
8585

8686
// If no defaultProps could be found, we don't report anything.

lib/rules/display-name.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ module.exports = {
227227
}
228228
},
229229

230-
'Program:exit': function () {
230+
'Program:exit'() {
231231
const list = components.list();
232232
// Report missing display name for all components
233233
Object.keys(list).filter(component => !list[component].hasDisplayName).forEach((component) => {

lib/rules/jsx-closing-bracket-location.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ module.exports = {
236236
lastAttributeNode[getOpeningElementId(node.parent)] = node;
237237
},
238238

239-
'JSXOpeningElement:exit': function (node) {
239+
'JSXOpeningElement:exit'(node) {
240240
const attributeNode = lastAttributeNode[getOpeningElementId(node)];
241241
const cachedLastAttributeEndPos = attributeNode ? attributeNode.range[1] : null;
242242
let expectedNextLine;

lib/rules/jsx-filename-extension.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ module.exports = {
8080
JSXElement: handleJSX,
8181
JSXFragment: handleJSX,
8282

83-
'Program:exit': function () {
83+
'Program:exit'() {
8484
if (!invalidNode) {
8585
return;
8686
}

lib/rules/jsx-fragments.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ module.exports = {
5858

5959
function getFixerToLong(jsxFragment) {
6060
const sourceCode = context.getSourceCode();
61-
return function (fixer) {
61+
return function fix(fixer) {
6262
let source = sourceCode.getText();
6363
source = replaceNode(source, jsxFragment.closingFragment, closeFragLong);
6464
source = replaceNode(source, jsxFragment.openingFragment, openFragLong);
@@ -71,7 +71,7 @@ module.exports = {
7171

7272
function getFixerToShort(jsxElement) {
7373
const sourceCode = context.getSourceCode();
74-
return function (fixer) {
74+
return function fix(fixer) {
7575
let source = sourceCode.getText();
7676
let lengthDiff;
7777
if (jsxElement.closingElement) {
@@ -164,7 +164,7 @@ module.exports = {
164164
}
165165
},
166166

167-
'Program:exit': function () {
167+
'Program:exit'() {
168168
jsxElements.forEach((node) => {
169169
const openingEl = node.openingElement;
170170
const elName = elementType(openingEl);

lib/rules/jsx-indent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ module.exports = {
9595
* @private
9696
*/
9797
function getFixerFunction(node, needed) {
98-
return function (fixer) {
98+
return function fix(fixer) {
9999
const indent = Array(needed + 1).join(indentChar);
100100
return fixer.replaceTextRange(
101101
[node.range[0] - node.loc.start.column, node.range[0]],

lib/rules/jsx-max-props-per-line.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ module.exports = {
6262
}, ''));
6363
}
6464
const code = output.join('\n');
65-
return function (fixer) {
65+
return function fix(fixer) {
6666
return fixer.replaceTextRange([front, back], code);
6767
};
6868
}

lib/rules/jsx-sort-props.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ const generateFixerFunction = (node, context, reservedList) => {
132132
.slice(0)
133133
.map(group => group.slice(0).sort((a, b) => contextCompare(a, b, options)));
134134

135-
return function (fixer) {
135+
return function fixFunction(fixer) {
136136
const fixers = [];
137137
let source = sourceCode.getText();
138138

@@ -178,15 +178,15 @@ function validateReservedFirstConfig(context, reservedFirst) {
178178
));
179179

180180
if (reservedFirst.length === 0) {
181-
return function (decl) {
181+
return function report(decl) {
182182
context.report({
183183
node: decl,
184184
message: 'A customized reserved first list must not be empty'
185185
});
186186
};
187187
}
188188
if (nonReservedWords.length > 0) {
189-
return function (decl) {
189+
return function report(decl) {
190190
context.report({
191191
node: decl,
192192
message: 'A customized reserved first list must only contain a subset of React reserved props.' +

lib/rules/no-array-index-key.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ module.exports = {
213213
checkPropValue(value.expression);
214214
},
215215

216-
'CallExpression:exit': function (node) {
216+
'CallExpression:exit'(node) {
217217
const mapIndexParamName = getMapIndexParamName(node);
218218
if (!mapIndexParamName) {
219219
return;

lib/rules/no-direct-mutation-state.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,21 +119,21 @@ module.exports = {
119119
}
120120
},
121121

122-
'CallExpression:exit': function (node) {
122+
'CallExpression:exit'(node) {
123123
components.set(node, {
124124
inCallExpression: false
125125
});
126126
},
127127

128-
'MethodDefinition:exit': function (node) {
128+
'MethodDefinition:exit'(node) {
129129
if (node.kind === 'constructor') {
130130
components.set(node, {
131131
inConstructor: false
132132
});
133133
}
134134
},
135135

136-
'Program:exit': function () {
136+
'Program:exit'() {
137137
const list = components.list();
138138

139139
Object.keys(list).forEach((key) => {

lib/rules/no-multi-comp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ module.exports = {
5858
// --------------------------------------------------------------------------
5959

6060
return {
61-
'Program:exit': function () {
61+
'Program:exit'() {
6262
if (components.length() <= 1) {
6363
return;
6464
}

lib/rules/no-set-state.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ module.exports = {
7272
});
7373
},
7474

75-
'Program:exit': function () {
75+
'Program:exit'() {
7676
const list = components.list();
7777
Object.keys(list).filter(component => !isValid(list[component])).forEach((component) => {
7878
reportSetStateUsages(list[component]);

lib/rules/no-unescaped-entities.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ module.exports = {
109109
}
110110

111111
return {
112-
'Literal, JSXText': function (node) {
112+
'Literal, JSXText'(node) {
113113
if (jsxUtil.isJSX(node.parent)) {
114114
reportInvalidEntity(node);
115115
}

lib/rules/no-unused-prop-types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ module.exports = {
131131
// --------------------------------------------------------------------------
132132

133133
return {
134-
'Program:exit': function () {
134+
'Program:exit'() {
135135
const list = components.list();
136136
// Report undeclared proptypes for all classes
137137
Object.keys(list).filter(component => mustBeValidated(list[component])).forEach((component) => {

lib/rules/no-unused-state.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ module.exports = {
231231
}
232232
},
233233

234-
'ObjectExpression:exit': function (node) {
234+
'ObjectExpression:exit'(node) {
235235
if (!classInfo) {
236236
return;
237237
}
@@ -242,7 +242,7 @@ module.exports = {
242242
}
243243
},
244244

245-
'ClassDeclaration:exit': function () {
245+
'ClassDeclaration:exit'() {
246246
if (!classInfo) {
247247
return;
248248
}
@@ -306,7 +306,7 @@ module.exports = {
306306
}
307307
},
308308

309-
'ClassProperty:exit': function (node) {
309+
'ClassProperty:exit'(node) {
310310
if (
311311
classInfo &&
312312
!node.static &&
@@ -326,7 +326,7 @@ module.exports = {
326326
classInfo.aliases = new Set();
327327
},
328328

329-
'MethodDefinition:exit': function () {
329+
'MethodDefinition:exit'() {
330330
if (!classInfo) {
331331
return;
332332
}
@@ -422,7 +422,7 @@ module.exports = {
422422
}
423423
},
424424

425-
'ExperimentalSpreadProperty, SpreadElement': function (node) {
425+
'ExperimentalSpreadProperty, SpreadElement'(node) {
426426
if (classInfo && isStateReference(node.argument)) {
427427
classInfo = null;
428428
}

lib/rules/prefer-read-only-props.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module.exports = {
3333
},
3434

3535
create: Components.detect((context, components) => ({
36-
'Program:exit': function () {
36+
'Program:exit'() {
3737
const list = components.list();
3838

3939
Object.keys(list).forEach((key) => {

lib/rules/prefer-stateless-function.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,21 +196,21 @@ module.exports = {
196196
* Mark component as pure as declared
197197
* @param {ASTNode} node The AST node being checked.
198198
*/
199-
const markSCUAsDeclared = function (node) {
199+
function markSCUAsDeclared(node) {
200200
components.set(node, {
201201
hasSCU: true
202202
});
203-
};
203+
}
204204

205205
/**
206206
* Mark childContextTypes as declared
207207
* @param {ASTNode} node The AST node being checked.
208208
*/
209-
const markChildContextTypesAsDeclared = function (node) {
209+
function markChildContextTypesAsDeclared(node) {
210210
components.set(node, {
211211
hasChildContextTypes: true
212212
});
213-
};
213+
}
214214

215215
/**
216216
* Mark a setState as used
@@ -351,7 +351,7 @@ module.exports = {
351351
markReturnAsInvalid(node);
352352
},
353353

354-
'Program:exit': function () {
354+
'Program:exit'() {
355355
const list = components.list();
356356
Object.keys(list).forEach((component) => {
357357
if (

lib/rules/prop-types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ module.exports = {
183183
// --------------------------------------------------------------------------
184184

185185
return {
186-
'Program:exit': function () {
186+
'Program:exit'() {
187187
const list = components.list();
188188
// Report undeclared proptypes for all classes
189189
Object.keys(list).filter(component => mustBeValidated(list[component])).forEach((component) => {

lib/rules/require-default-props.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ module.exports = {
8080
// --------------------------------------------------------------------------
8181

8282
return {
83-
'Program:exit': function () {
83+
'Program:exit'() {
8484
const list = components.list();
8585

8686
Object.keys(list).filter(component => list[component].declaredPropTypes).forEach((component) => {

0 commit comments

Comments
 (0)