Skip to content

Commit

Permalink
[eslint] enable and autofix arrow-parens
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed May 19, 2019
1 parent 04d65bb commit e14f2b8
Show file tree
Hide file tree
Showing 47 changed files with 89 additions and 90 deletions.
1 change: 0 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"object-shorthand": 1,
"import/order": 1,
"no-useless-escape": 1,
"arrow-parens": 1,
"import/newline-after-import": 1,
"operator-linebreak": 1,
"function-paren-newline": 0,
Expand Down
10 changes: 5 additions & 5 deletions lib/rules/boolean-prop-naming.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ module.exports = {
function runCheck(proptypes, addInvalidProp) {
proptypes = proptypes || [];

proptypes.forEach(prop => {
proptypes.forEach((prop) => {
if (config.validateNested && nestedPropTypes(prop)) {
runCheck(prop.value.arguments[0].properties, addInvalidProp);
return;
Expand All @@ -176,7 +176,7 @@ module.exports = {
const component = components.get(node) || node;
const invalidProps = component.invalidProps || [];

runCheck(proptypes, prop => {
runCheck(proptypes, (prop) => {
invalidProps.push(prop);
});

Expand All @@ -190,7 +190,7 @@ module.exports = {
* @param {Object} component The component to process
*/
function reportInvalidNaming(component) {
component.invalidProps.forEach(propNode => {
component.invalidProps.forEach((propNode) => {
const propName = getPropName(propNode);
context.report({
node: propNode,
Expand Down Expand Up @@ -253,7 +253,7 @@ module.exports = {
}

// Search for the proptypes declaration
node.properties.forEach(property => {
node.properties.forEach((property) => {
if (!propsUtil.isPropTypesDeclaration(property)) {
return;
}
Expand All @@ -274,7 +274,7 @@ module.exports = {
}

const list = components.list();
Object.keys(list).forEach(component => {
Object.keys(list).forEach((component) => {
// If this is a functional component that uses a global type, check it
if (
list[component].node.type === 'FunctionDeclaration' &&
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/default-props-match-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = {
return;
}

Object.keys(defaultProps).forEach(defaultPropName => {
Object.keys(defaultProps).forEach((defaultPropName) => {
const defaultProp = defaultProps[defaultPropName];
const prop = propTypes[defaultPropName];

Expand Down Expand Up @@ -84,7 +84,7 @@ module.exports = {
const list = components.list();

// If no defaultProps could be found, we don't report anything.
Object.keys(list).filter(component => list[component].defaultProps).forEach(component => {
Object.keys(list).filter(component => list[component].defaultProps).forEach((component) => {
reportInvalidDefaultProps(
list[component].declaredPropTypes,
list[component].defaultProps || {}
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/display-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ module.exports = {
ObjectExpression: function (node) {
if (ignoreTranspilerName || !hasTranspilerName(node)) {
// Search for the displayName declaration
node.properties.forEach(property => {
node.properties.forEach((property) => {
if (!property.key || !propsUtil.isDisplayNameDeclaration(property.key)) {
return;
}
Expand All @@ -205,7 +205,7 @@ module.exports = {
'Program:exit': function () {
const list = components.list();
// Report missing display name for all components
Object.keys(list).filter(component => !list[component].hasDisplayName).forEach(component => {
Object.keys(list).filter(component => !list[component].hasDisplayName).forEach((component) => {
reportMissingDisplayName(list[component]);
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/forbid-component-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module.exports = {

create: function (context) {
const configuration = context.options[0] || {};
const forbid = new Map((configuration.forbid || DEFAULTS).map(value => {
const forbid = new Map((configuration.forbid || DEFAULTS).map((value) => {
const propName = typeof value === 'string' ? value : value.propName;
const whitelist = typeof value === 'string' ? [] : (value.allowedFor || []);
return [propName, whitelist];
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/forbid-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module.exports = {

const indexedForbidConfigs = {};

forbidConfiguration.forEach(item => {
forbidConfiguration.forEach((item) => {
if (typeof item === 'string') {
indexedForbidConfigs[item] = {element: item};
} else {
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/forbid-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ module.exports = {
* @returns {void}
*/
function checkProperties(declarations) {
declarations.forEach(declaration => {
declarations.forEach((declaration) => {
if (declaration.type !== 'Property') {
return;
}
Expand Down Expand Up @@ -178,7 +178,7 @@ module.exports = {
},

ObjectExpression: function (node) {
node.properties.forEach(property => {
node.properties.forEach((property) => {
if (!property.key) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/jsx-child-element-spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ module.exports = {
INLINE_ELEMENTS.has(elementName(node))
);

const handleJSX = node => {
const handleJSX = (node) => {
let lastChild = null;
let child = null;
(node.children.concat([null])).forEach(nextChild => {
(node.children.concat([null])).forEach((nextChild) => {
if (
(lastChild || nextChild) &&
(!lastChild || isInlineElement(lastChild)) &&
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/jsx-curly-brace-presence.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,13 @@ module.exports = {
// --------------------------------------------------------------------------

return {
JSXExpressionContainer: node => {
JSXExpressionContainer: (node) => {
if (shouldCheckForUnnecessaryCurly(node.parent, userConfig)) {
lintUnnecessaryCurly(node);
}
},

'Literal, JSXText': node => {
'Literal, JSXText': (node) => {
if (shouldCheckForMissingCurly(node.parent, userConfig)) {
reportMissingCurly(node);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-equals-spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module.exports = {

return {
JSXOpeningElement: function (node) {
node.attributes.forEach(attrNode => {
node.attributes.forEach((attrNode) => {
if (!hasEqual(attrNode)) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-first-prop-new-line.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports = {
(configuration === 'multiline-multiprop' && isMultilineJSX(node) && node.attributes.length > 1) ||
(configuration === 'always')
) {
node.attributes.some(decl => {
node.attributes.some((decl) => {
if (decl.loc.start.line === node.loc.start.line) {
context.report({
node: decl,
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/jsx-fragments.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ module.exports = {

ImportDeclaration(node) {
if (node.source && node.source.value === 'react') {
node.specifiers.forEach(spec => {
node.specifiers.forEach((spec) => {
if (spec.imported && spec.imported.name === fragmentPragma) {
if (spec.local) {
fragmentNames.add(spec.local.name);
Expand All @@ -164,7 +164,7 @@ module.exports = {
},

'Program:exit'() {
jsxElements.forEach(node => {
jsxElements.forEach((node) => {
const openingEl = node.openingElement;
const elName = elementType(openingEl);

Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-indent-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ module.exports = {
* @param {Number} indent needed indent
*/
function checkNodesIndent(nodes, indent) {
nodes.forEach(node => {
nodes.forEach((node) => {
const nodeIndent = getNodeIndent(node);
if (
node.type !== 'ArrayExpression' && node.type !== 'ObjectExpression' &&
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-max-depth.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ module.exports = {

function checkDescendant(baseDepth, children) {
baseDepth++;
(children || []).forEach(node => {
(children || []).forEach((node) => {
if (!hasJSX(node)) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-max-props-per-line.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ module.exports = {
return decl;
});

linePartitionedProps.forEach(propsInLine => {
linePartitionedProps.forEach((propsInLine) => {
if (propsInLine.length > maximum) {
const name = getPropName(propsInLine[maximum]);
context.report({
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/jsx-no-bind.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module.exports = {
}]
},

create: Components.detect(context => {
create: Components.detect((context) => {
const configuration = context.options[0] || {};

// Keep track of all the variable names pointing to a bind call,
Expand Down Expand Up @@ -120,7 +120,7 @@ module.exports = {
const blockSets = blockVariableNameSets[blockStart];
const violationTypes = Object.keys(blockSets);

return violationTypes.find(type => {
return violationTypes.find((type) => {
if (blockSets[type].has(name)) {
context.report({node: node, message: violationMessageStore[type]});
return true;
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-no-duplicate-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports = {
JSXOpeningElement: function (node) {
const props = {};

node.attributes.forEach(decl => {
node.attributes.forEach((decl) => {
if (decl.type === 'JSXSpreadAttribute') {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-no-target-blank.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function hasDynamicLink(element, linkAttribute) {
}

function hasSecureRel(element) {
return element.attributes.find(attr => {
return element.attributes.find((attr) => {
if (attr.type === 'JSXAttribute' && attr.name.name === 'rel') {
const tags = attr.value && attr.value.type === 'Literal' && attr.value.value.toLowerCase().split(' ');
return tags && (tags.indexOf('noopener') >= 0 && tags.indexOf('noreferrer') >= 0);
Expand Down
6 changes: 3 additions & 3 deletions lib/rules/jsx-one-expression-per-line.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ module.exports = {
const childrenGroupedByLine = {};
const fixDetailsByNode = {};

children.forEach(child => {
children.forEach((child) => {
let countNewLinesBeforeContent = 0;
let countNewLinesAfterContent = 0;

Expand Down Expand Up @@ -118,7 +118,7 @@ module.exports = {
}
});

Object.keys(childrenGroupedByLine).forEach(_line => {
Object.keys(childrenGroupedByLine).forEach((_line) => {
const line = parseInt(_line, 10);
const firstIndex = 0;
const lastIndex = childrenGroupedByLine[line].length - 1;
Expand Down Expand Up @@ -191,7 +191,7 @@ module.exports = {
});
});

Object.keys(fixDetailsByNode).forEach(key => {
Object.keys(fixDetailsByNode).forEach((key) => {
const details = fixDetailsByNode[key];

const nodeToReport = details.node;
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/jsx-sort-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const generateFixerFunction = (node, context, reservedList) => {
const rangeStart = fixers[fixers.length - 1].range[0];
const rangeEnd = fixers[0].range[1];

fixers.forEach(fix => {
fixers.forEach((fix) => {
source = `${source.substr(0, fix.range[0])}${fix.text}${source.substr(fix.range[1])}`;
});

Expand All @@ -168,7 +168,7 @@ function validateReservedFirstConfig(context, reservedFirst) {
if (Array.isArray(reservedFirst)) {
// Only allow a subset of reserved words in customized lists
// eslint-disable-next-line consistent-return
const nonReservedWords = reservedFirst.filter(word => {
const nonReservedWords = reservedFirst.filter((word) => {
if (!isReservedPropName(word, RESERVED_PROPS_LIST)) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-wrap-multilines.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ module.exports = {
const needsOpening = needsOpeningNewLine(node);
const needsClosing = needsClosingNewLine(node);
if (needsOpening || needsClosing) {
report(node, PARENS_NEW_LINES, fixer => {
report(node, PARENS_NEW_LINES, (fixer) => {
const text = sourceCode.getText(node);
let fixed = text;
if (needsOpening) {
Expand Down
6 changes: 3 additions & 3 deletions lib/rules/no-access-state-in-setstate.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module.exports = {
CallExpression(node) {
// Appends all the methods that are calling another
// method containing this.state to the methods array
methods.map(method => {
methods.map((method) => {
if (node.callee.name === method.methodName) {
let current = node.parent;
while (current.type !== 'Program') {
Expand All @@ -70,7 +70,7 @@ module.exports = {
while (current.type !== 'Program') {
if (isFirstArgumentInSetStateCall(current, node)) {
const methodName = node.callee.name;
methods.map(method => {
methods.map((method) => {
if (method.methodName === methodName) {
context.report(
method.node,
Expand Down Expand Up @@ -157,7 +157,7 @@ module.exports = {

ObjectPattern(node) {
const isDerivedFromThis = node.parent.init && node.parent.init.type === 'ThisExpression';
node.properties.forEach(property => {
node.properties.forEach((property) => {
if (property && property.key && property.key.name === 'state' && isDerivedFromThis) {
vars.push({
node: property.key,
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-array-index-key.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ module.exports = {
return;
}

props.properties.forEach(prop => {
props.properties.forEach((prop) => {
if (!prop.key || prop.key.name !== 'key') {
// { ...foo }
// { foo: bar }
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-danger-with-children.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = {
if (!node.properties) {
return false;
}
return node.properties.find(prop => {
return node.properties.find((prop) => {
if (prop.type === 'Property') {
return prop.key.name === propName;
}
Expand All @@ -60,7 +60,7 @@ module.exports = {
*/
function findJsxProp(node, propName) {
const attributes = node.openingElement.attributes;
return attributes.find(attribute => {
return attributes.find((attribute) => {
if (attribute.type === 'JSXSpreadAttribute') {
const variable = findSpreadVariable(attribute.argument.name);
if (variable && variable.defs.length && variable.defs[0].node.init) {
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ module.exports = {
if (!isReactImport) {
return;
}
node.specifiers.forEach(specifier => {
node.specifiers.forEach((specifier) => {
if (!specifier.imported) {
return;
}
Expand All @@ -212,7 +212,7 @@ module.exports = {
) {
return;
}
node.id.properties.forEach(property => {
node.id.properties.forEach((property) => {
checkDeprecation(node, `${reactModuleName || pragma}.${property.key.name}`);
});
},
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-direct-mutation-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ module.exports = {
'Program:exit': function () {
const list = components.list();

Object.keys(list).forEach(key => {
Object.keys(list).forEach((key) => {
if (!isValid(list[key])) {
reportMutations(list[key]);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-redundant-should-component-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = {
*/
function hasShouldComponentUpdate(node) {
const properties = astUtil.getComponentProperties(node);
return properties.some(property => {
return properties.some((property) => {
const name = astUtil.getPropertyName(property);
return name === 'shouldComponentUpdate';
});
Expand Down

0 comments on commit e14f2b8

Please sign in to comment.