Skip to content

Commit dba095d

Browse files
committed
Eslint --fix for arrow functions
1 parent b9d70e8 commit dba095d

12 files changed

+103
-127
lines changed

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

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ module.exports = {
9191
* @returns {ASTNode|null} Return null if the variable could not be found, ASTNode otherwise.
9292
*/
9393
function findVariableByName(name) {
94-
const variable = variableUtil.variablesInScope(context).find((item) => item.name === name);
94+
const variable = variableUtil.variablesInScope(context).find(item => item.name === name);
9595

9696
if (!variable || !variable.defs[0] || !variable.defs[0].node) {
9797
return null;
@@ -156,13 +156,11 @@ module.exports = {
156156
function getPropTypesFromObjectExpression(objectExpression) {
157157
const props = objectExpression.properties.filter(property => property.type !== 'ExperimentalSpreadProperty');
158158

159-
return props.map(property => {
160-
return {
161-
name: property.key.name,
162-
isRequired: isRequiredPropType(property.value),
163-
node: property
164-
};
165-
});
159+
return props.map(property => ({
160+
name: property.key.name,
161+
isRequired: isRequiredPropType(property.value),
162+
node: property
163+
}));
166164
}
167165

168166
/**
@@ -233,12 +231,10 @@ module.exports = {
233231
return 'unresolved';
234232
}
235233

236-
return objectExpression.properties.map(defaultProp => {
237-
return {
238-
name: defaultProp.key.name,
239-
node: defaultProp
240-
};
241-
});
234+
return objectExpression.properties.map(defaultProp => ({
235+
name: defaultProp.key.name,
236+
node: defaultProp
237+
}));
242238
}
243239

244240
/**

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ module.exports = {
4545
},
4646

4747
ObjectPattern: function(node) {
48-
const propTypesNode = node.properties.find(property => {
49-
return property.type === 'Property' && property.key.name === 'propTypes';
50-
});
48+
const propTypesNode = node.properties.find(property => property.type === 'Property' && property.key.name === 'propTypes');
5149

5250
if (propTypesNode) {
5351
context.report({

lib/rules/jsx-boolean-value.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const NEVER = 'never';
2020
const errorData = new WeakMap();
2121
function getErrorData(exceptions) {
2222
if (!errorData.has(exceptions)) {
23-
const exceptionProps = Array.from(exceptions, (name) => `\`${name}\``).join(', ');
23+
const exceptionProps = Array.from(exceptions, name => `\`${name}\``).join(', ');
2424
const exceptionsMessage = exceptions.size > 0 ? ` for the following props: ${exceptionProps}` : '';
2525
errorData.set(exceptions, {exceptionsMessage: exceptionsMessage});
2626
}

lib/rules/jsx-filename-extension.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ module.exports = {
6464
}
6565

6666
const allowedExtensions = getExtensionsConfig();
67-
const isAllowedExtension = allowedExtensions.some(extension => {
68-
return filename.slice(-extension.length) === extension;
69-
});
67+
const isAllowedExtension = allowedExtensions.some(extension => filename.slice(-extension.length) === extension);
7068

7169
if (isAllowedExtension) {
7270
return;

lib/rules/jsx-no-target-blank.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ function isTargetBlank(attr) {
1515
}
1616

1717
function hasExternalLink(element) {
18-
return element.attributes.some(attr => {
19-
return attr.name &&
18+
return element.attributes.some(attr => attr.name &&
2019
attr.name.name === 'href' &&
2120
attr.value.type === 'Literal' &&
22-
/^(?:\w+:|\/\/)/.test(attr.value.value);
23-
});
21+
/^(?:\w+:|\/\/)/.test(attr.value.value));
2422
}
2523

2624
function hasSecureRel(element) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ module.exports = {
9898
'Program:exit': function () {
9999
const list = components.list();
100100

101-
Object.keys(list).forEach((key) => {
101+
Object.keys(list).forEach(key => {
102102
if (!isValid(list[key])) {
103103
reportMutations(list[key]);
104104
}

lib/rules/no-unknown-property.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,11 @@ const tagConvention = /^[a-z][^-]*$/;
138138
function isTagName(node) {
139139
if (tagConvention.test(node.parent.name.name)) {
140140
// http://www.w3.org/TR/custom-elements/#type-extension-semantics
141-
return !node.parent.attributes.some(attrNode => {
142-
return (
143-
attrNode.type === 'JSXAttribute' &&
141+
return !node.parent.attributes.some(attrNode => (
142+
attrNode.type === 'JSXAttribute' &&
144143
attrNode.name.type === 'JSXIdentifier' &&
145144
attrNode.name.name === 'is'
146-
);
147-
});
145+
));
148146
}
149147
return false;
150148
}

lib/rules/require-default-props.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,11 @@ module.exports = {
147147
function getPropTypesFromObjectExpression(objectExpression) {
148148
const props = objectExpression.properties.filter(property => property.type !== 'ExperimentalSpreadProperty');
149149

150-
return props.map(property => {
151-
return {
152-
name: sourceCode.getText(property.key).replace(QUOTES_REGEX, ''),
153-
isRequired: isRequiredPropType(property.value),
154-
node: property
155-
};
156-
});
150+
return props.map(property => ({
151+
name: sourceCode.getText(property.key).replace(QUOTES_REGEX, ''),
152+
isRequired: isRequiredPropType(property.value),
153+
node: property
154+
}));
157155
}
158156

159157
/**

lib/rules/sort-comp.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,11 @@ module.exports = {
361361
* @param {Array} properties Array containing all the properties.
362362
*/
363363
function checkPropsOrder(properties) {
364-
const propertiesInfos = properties.map(node => {
365-
return {
366-
name: getPropertyName(node),
367-
static: node.static,
368-
typeAnnotation: !!node.typeAnnotation && node.value === null
369-
};
370-
});
364+
const propertiesInfos = properties.map(node => ({
365+
name: getPropertyName(node),
366+
static: node.static,
367+
typeAnnotation: !!node.typeAnnotation && node.value === null
368+
}));
371369

372370
let i;
373371
let j;

lib/rules/style-prop-object.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ module.exports = {
5252
&& node.arguments.length > 1
5353
) {
5454
if (node.arguments[1].type === 'ObjectExpression') {
55-
const style = node.arguments[1].properties.find(property => {
56-
return property.key && property.key.name === 'style' && !property.computed;
57-
});
55+
const style = node.arguments[1].properties.find(property => property.key && property.key.name === 'style' && !property.computed);
5856
if (style) {
5957
if (style.value.type === 'Identifier') {
6058
checkIdentifiers(style.value);

0 commit comments

Comments
 (0)