From 2598b1ee64df6f1814a5084075da9cd45deb8b8f Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 12 May 2020 19:15:06 -0700 Subject: [PATCH] [Dev Deps] update `@types/eslint`, `@types/estree`, `@types/node`, `@typescript-eslint/parser`, `coveralls`, `eslint-config-airbnb-base`, `eslint-plugin-import`, `typescript` - `npm run lint -- --quiet --fix` --- .eslintrc | 3 ++- index.js | 8 ++++---- lib/rules/boolean-prop-naming.js | 2 +- lib/rules/button-has-type.js | 4 ++-- lib/rules/default-props-match-prop-types.js | 2 +- lib/rules/display-name.js | 2 +- lib/rules/forbid-foreign-prop-types.js | 2 +- lib/rules/function-component-definition.js | 2 +- lib/rules/jsx-boolean-value.js | 2 +- lib/rules/jsx-child-element-spacing.js | 4 ++-- lib/rules/jsx-curly-brace-presence.js | 10 +++++----- lib/rules/jsx-curly-newline.js | 4 ++-- lib/rules/jsx-filename-extension.js | 2 +- lib/rules/jsx-indent.js | 4 ++-- lib/rules/jsx-key.js | 2 +- lib/rules/jsx-no-bind.js | 4 ++-- lib/rules/jsx-no-script-url.js | 4 ++-- lib/rules/jsx-no-target-blank.js | 4 ++-- lib/rules/jsx-props-no-spreading.js | 4 ++-- lib/rules/jsx-sort-default-props.js | 2 +- lib/rules/jsx-sort-props.js | 6 +++--- lib/rules/jsx-wrap-multilines.js | 6 +++--- lib/rules/no-access-state-in-setstate.js | 2 +- lib/rules/no-children-prop.js | 2 +- lib/rules/no-danger-with-children.js | 4 ++-- lib/rules/no-deprecated.js | 6 +++--- lib/rules/no-multi-comp.js | 2 +- lib/rules/no-set-state.js | 2 +- lib/rules/no-typos.js | 8 ++++---- lib/rules/no-unescaped-entities.js | 2 +- lib/rules/no-unknown-property.js | 2 +- lib/rules/no-unsafe.js | 4 ++-- lib/rules/no-unused-prop-types.js | 2 +- lib/rules/no-will-update-set-state.js | 2 +- lib/rules/prop-types.js | 4 ++-- lib/rules/require-optimization.js | 4 ++-- lib/rules/require-render-return.js | 4 ++-- lib/rules/sort-comp.js | 2 +- lib/rules/static-property-placement.js | 8 ++++---- lib/rules/style-prop-object.js | 4 ++-- lib/util/Components.js | 16 ++++++++-------- lib/util/defaultProps.js | 8 ++++---- lib/util/pragma.js | 2 +- lib/util/propTypes.js | 6 +++--- lib/util/usedPropTypes.js | 4 ++-- lib/util/variable.js | 4 ++-- lib/util/version.js | 6 +++--- markdown.config.js | 4 ++-- package.json | 16 ++++++++-------- tests/index.js | 2 +- tests/lib/rules/no-typos.js | 2 +- tests/lib/rules/no-unused-state.js | 2 +- 52 files changed, 110 insertions(+), 109 deletions(-) diff --git a/.eslintrc b/.eslintrc index 4b3233d2cd..c324fcd75b 100644 --- a/.eslintrc +++ b/.eslintrc @@ -26,12 +26,13 @@ "consistent-return": 0, "prefer-destructuring": [2, { "array": false, "object": false }, { "enforceForRenamedProperties": false }], - + "prefer-object-spread": 0, "function-paren-newline": 0, "no-plusplus": 1, "no-param-reassign": 1, "no-mixed-operators": 1, "no-restricted-syntax": 1, + "strict": [2, "safe"], "valid-jsdoc": [2, { "requireReturn": false, "requireParamDescription": false, diff --git a/index.js b/index.js index 53b50230f4..bc0c30a43d 100644 --- a/index.js +++ b/index.js @@ -96,17 +96,17 @@ const allRules = { /* eslint-enable */ function filterRules(rules, predicate) { - return fromEntries(entries(rules).filter(entry => predicate(entry[1]))); + return fromEntries(entries(rules).filter((entry) => predicate(entry[1]))); } function configureAsError(rules) { - return fromEntries(Object.keys(rules).map(key => [`react/${key}`, 2])); + return fromEntries(Object.keys(rules).map((key) => [`react/${key}`, 2])); } -const activeRules = filterRules(allRules, rule => !rule.meta.deprecated); +const activeRules = filterRules(allRules, (rule) => !rule.meta.deprecated); const activeRulesConfig = configureAsError(activeRules); -const deprecatedRules = filterRules(allRules, rule => rule.meta.deprecated); +const deprecatedRules = filterRules(allRules, (rule) => rule.meta.deprecated); module.exports = { deprecatedRules, diff --git a/lib/rules/boolean-prop-naming.js b/lib/rules/boolean-prop-naming.js index 71f39ea8fb..e61415b969 100644 --- a/lib/rules/boolean-prop-naming.js +++ b/lib/rules/boolean-prop-naming.js @@ -209,7 +209,7 @@ module.exports = { if (!node || !Array.isArray(args)) { return; } - args.filter(arg => arg.type === 'ObjectExpression').forEach(object => validatePropNaming(node, object.properties)); + args.filter((arg) => arg.type === 'ObjectExpression').forEach((object) => validatePropNaming(node, object.properties)); } // -------------------------------------------------------------------------- diff --git a/lib/rules/button-has-type.js b/lib/rules/button-has-type.js index 30cf7305e1..76e09c605b 100644 --- a/lib/rules/button-has-type.js +++ b/lib/rules/button-has-type.js @@ -73,7 +73,7 @@ module.exports = { } function checkValue(node, value) { - const q = x => `"${x}"`; + const q = (x) => `"${x}"`; if (!(value in configuration)) { context.report({ node, @@ -126,7 +126,7 @@ module.exports = { } const props = node.arguments[1].properties; - const typeProp = props.find(prop => prop.key && prop.key.name === 'type'); + const typeProp = props.find((prop) => prop.key && prop.key.name === 'type'); if (!typeProp || typeProp.value.type !== 'Literal') { reportMissing(node); diff --git a/lib/rules/default-props-match-prop-types.js b/lib/rules/default-props-match-prop-types.js index 988949bc42..4d096416d8 100644 --- a/lib/rules/default-props-match-prop-types.js +++ b/lib/rules/default-props-match-prop-types.js @@ -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 || {} diff --git a/lib/rules/display-name.js b/lib/rules/display-name.js index 51a992c16a..55ecd9a389 100644 --- a/lib/rules/display-name.js +++ b/lib/rules/display-name.js @@ -230,7 +230,7 @@ module.exports = { 'Program:exit'() { 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]); }); } diff --git a/lib/rules/forbid-foreign-prop-types.js b/lib/rules/forbid-foreign-prop-types.js index a83a913fe9..630e21a634 100644 --- a/lib/rules/forbid-foreign-prop-types.js +++ b/lib/rules/forbid-foreign-prop-types.js @@ -115,7 +115,7 @@ module.exports = { }, ObjectPattern(node) { - const propTypesNode = node.properties.find(property => property.type === 'Property' && property.key.name === 'propTypes'); + const propTypesNode = node.properties.find((property) => property.type === 'Property' && property.key.name === 'propTypes'); if (propTypesNode) { context.report({ diff --git a/lib/rules/function-component-definition.js b/lib/rules/function-component-definition.js index 8c02ae76a1..3833188a81 100644 --- a/lib/rules/function-component-definition.js +++ b/lib/rules/function-component-definition.js @@ -136,7 +136,7 @@ module.exports = { if (isUnfixableBecauseOfExport(node)) return; if (isFunctionExpressionWithName(node)) return; - return fixer => fixer.replaceTextRange(options.range, buildFunction(options.template, { + return (fixer) => fixer.replaceTextRange(options.range, buildFunction(options.template, { typeAnnotation, typeParams: getNodeText(node.typeParameters, source), params: getParams(node, source), diff --git a/lib/rules/jsx-boolean-value.js b/lib/rules/jsx-boolean-value.js index 50768b5875..be3cb57d5a 100644 --- a/lib/rules/jsx-boolean-value.js +++ b/lib/rules/jsx-boolean-value.js @@ -23,7 +23,7 @@ const NEVER = 'never'; const errorData = new WeakMap(); function getErrorData(exceptions) { if (!errorData.has(exceptions)) { - const exceptionProps = Array.from(exceptions, name => `\`${name}\``).join(', '); + const exceptionProps = Array.from(exceptions, (name) => `\`${name}\``).join(', '); const exceptionsMessage = exceptions.size > 0 ? ` for the following props: ${exceptionProps}` : ''; errorData.set(exceptions, {exceptionsMessage}); } diff --git a/lib/rules/jsx-child-element-spacing.js b/lib/rules/jsx-child-element-spacing.js index c5067d0516..fcde13bc74 100644 --- a/lib/rules/jsx-child-element-spacing.js +++ b/lib/rules/jsx-child-element-spacing.js @@ -59,14 +59,14 @@ module.exports = { const TEXT_FOLLOWING_ELEMENT_PATTERN = /^\s*\n\s*\S/; const TEXT_PRECEDING_ELEMENT_PATTERN = /\S\s*\n\s*$/; - const elementName = node => ( + const elementName = (node) => ( node.openingElement && node.openingElement.name && node.openingElement.name.type === 'JSXIdentifier' && node.openingElement.name.name ); - const isInlineElement = node => ( + const isInlineElement = (node) => ( node.type === 'JSXElement' && INLINE_ELEMENTS.has(elementName(node)) ); diff --git a/lib/rules/jsx-curly-brace-presence.js b/lib/rules/jsx-curly-brace-presence.js index 0fa27d1cb0..f3c3f7e25d 100755 --- a/lib/rules/jsx-curly-brace-presence.js +++ b/lib/rules/jsx-curly-brace-presence.js @@ -122,7 +122,7 @@ module.exports = { function wrapNonHTMLEntities(text) { const HTML_ENTITY = ''; - const withCurlyBraces = text.split(HTML_ENTITY_REGEX()).map(word => ( + const withCurlyBraces = text.split(HTML_ENTITY_REGEX()).map((word) => ( word === '' ? '' : `{${JSON.stringify(word)}}` )).join(HTML_ENTITY); @@ -292,19 +292,19 @@ module.exports = { if (!children) { return false; } - const childrenExcludingWhitespaceLiteral = children.filter(child => !isWhiteSpaceLiteral(child)); + const childrenExcludingWhitespaceLiteral = children.filter((child) => !isWhiteSpaceLiteral(child)); const adjSiblings = getAdjacentSiblings(node, childrenExcludingWhitespaceLiteral); - return adjSiblings.some(x => x.type && x.type === 'JSXExpressionContainer'); + return adjSiblings.some((x) => x.type && x.type === 'JSXExpressionContainer'); } function hasAdjacentJsx(node, children) { if (!children) { return false; } - const childrenExcludingWhitespaceLiteral = children.filter(child => !isWhiteSpaceLiteral(child)); + const childrenExcludingWhitespaceLiteral = children.filter((child) => !isWhiteSpaceLiteral(child)); const adjSiblings = getAdjacentSiblings(node, childrenExcludingWhitespaceLiteral); - return adjSiblings.some(x => x.type && arrayIncludes(['JSXExpressionContainer', 'JSXElement'], x.type)); + return adjSiblings.some((x) => x.type && arrayIncludes(['JSXExpressionContainer', 'JSXElement'], x.type)); } function shouldCheckForUnnecessaryCurly(parent, node, config) { // Bail out if the parent is a JSXAttribute & its contents aren't diff --git a/lib/rules/jsx-curly-newline.js b/lib/rules/jsx-curly-newline.js index 68ec1f2fad..57448fb9fa 100644 --- a/lib/rules/jsx-curly-newline.js +++ b/lib/rules/jsx-curly-newline.js @@ -140,7 +140,7 @@ module.exports = { context.report({ node: leftCurly, messageId: 'expectedAfter', - fix: fixer => fixer.insertTextAfter(leftCurly, '\n') + fix: (fixer) => fixer.insertTextAfter(leftCurly, '\n') }); } @@ -164,7 +164,7 @@ module.exports = { context.report({ node: rightCurly, messageId: 'expectedBefore', - fix: fixer => fixer.insertTextBefore(rightCurly, '\n') + fix: (fixer) => fixer.insertTextBefore(rightCurly, '\n') }); } } diff --git a/lib/rules/jsx-filename-extension.js b/lib/rules/jsx-filename-extension.js index 3d23cb4dc6..fe433d6ecb 100644 --- a/lib/rules/jsx-filename-extension.js +++ b/lib/rules/jsx-filename-extension.js @@ -62,7 +62,7 @@ module.exports = { } const allowedExtensions = getExtensionsConfig(); - const isAllowedExtension = allowedExtensions.some(extension => filename.slice(-extension.length) === extension); + const isAllowedExtension = allowedExtensions.some((extension) => filename.slice(-extension.length) === extension); if (isAllowedExtension) { return; diff --git a/lib/rules/jsx-indent.js b/lib/rules/jsx-indent.js index 1bc2e130c4..9e11f60afa 100644 --- a/lib/rules/jsx-indent.js +++ b/lib/rules/jsx-indent.js @@ -307,12 +307,12 @@ module.exports = { const regExp = indentType === 'space' ? /\n( *)[\t ]*\S/g : /\n(\t*)[\t ]*\S/g; const nodeIndentsPerLine = Array.from( matchAll(String(value), regExp), - match => (match[1] ? match[1].length : 0) + (match) => (match[1] ? match[1].length : 0) ); const hasFirstInLineNode = nodeIndentsPerLine.length > 0; if ( hasFirstInLineNode - && !nodeIndentsPerLine.every(actualIndent => actualIndent === indent) + && !nodeIndentsPerLine.every((actualIndent) => actualIndent === indent) ) { nodeIndentsPerLine.forEach((nodeIndent) => { report(node, indent, nodeIndent); diff --git a/lib/rules/jsx-key.js b/lib/rules/jsx-key.js index d5ebd0a4ac..25405bb13b 100644 --- a/lib/rules/jsx-key.js +++ b/lib/rules/jsx-key.js @@ -59,7 +59,7 @@ module.exports = { } function getReturnStatement(body) { - return body.filter(item => item.type === 'ReturnStatement')[0]; + return body.filter((item) => item.type === 'ReturnStatement')[0]; } return { diff --git a/lib/rules/jsx-no-bind.js b/lib/rules/jsx-no-bind.js index d49b964222..0ddee24996 100644 --- a/lib/rules/jsx-no-bind.js +++ b/lib/rules/jsx-no-bind.js @@ -112,7 +112,7 @@ module.exports = { function getBlockStatementAncestors(node) { return context.getAncestors(node).reverse().filter( - ancestor => ancestor.type === 'BlockStatement' + (ancestor) => ancestor.type === 'BlockStatement' ); } @@ -132,7 +132,7 @@ module.exports = { function findVariableViolation(node, name) { getBlockStatementAncestors(node).find( - block => reportVariableViolation(node, name, block.range[0]) + (block) => reportVariableViolation(node, name, block.range[0]) ); } diff --git a/lib/rules/jsx-no-script-url.js b/lib/rules/jsx-no-script-url.js index aa628f9149..6e42f93df4 100644 --- a/lib/rules/jsx-no-script-url.js +++ b/lib/rules/jsx-no-script-url.js @@ -22,7 +22,7 @@ function hasJavaScriptProtocol(attr) { function shouldVerifyElement(node, config) { const name = node.name && node.name.name; - return name === 'a' || config.find(i => i.name === name); + return name === 'a' || config.find((i) => i.name === name); } function shouldVerifyProp(node, config) { @@ -33,7 +33,7 @@ function shouldVerifyProp(node, config) { return true; } - const el = config.find(i => i.name === parentName); + const el = config.find((i) => i.name === parentName); if (!el) { return false; } diff --git a/lib/rules/jsx-no-target-blank.js b/lib/rules/jsx-no-target-blank.js index fbb5c9b553..9b4794dcb2 100644 --- a/lib/rules/jsx-no-target-blank.js +++ b/lib/rules/jsx-no-target-blank.js @@ -28,14 +28,14 @@ function isTargetBlank(attr) { } function hasExternalLink(element, linkAttribute) { - return element.attributes.some(attr => attr.name + return element.attributes.some((attr) => attr.name && attr.name.name === linkAttribute && attr.value.type === 'Literal' && /^(?:\w+:|\/\/)/.test(attr.value.value)); } function hasDynamicLink(element, linkAttribute) { - return element.attributes.some(attr => attr.name + return element.attributes.some((attr) => attr.name && attr.name.name === linkAttribute && attr.value.type === 'JSXExpressionContainer'); } diff --git a/lib/rules/jsx-props-no-spreading.js b/lib/rules/jsx-props-no-spreading.js index beed4fcd85..3d54a8e665 100644 --- a/lib/rules/jsx-props-no-spreading.js +++ b/lib/rules/jsx-props-no-spreading.js @@ -78,8 +78,8 @@ module.exports = { const ignoreExplicitSpread = (configuration.explicitSpread || DEFAULTS.explicitSpread) === OPTIONS.ignore; const exceptions = configuration.exceptions || DEFAULTS.exceptions; const isException = (tag, allExceptions) => allExceptions.indexOf(tag) !== -1; - const isProperty = property => property.type === 'Property'; - const getTagNameFromMemberExpression = node => `${node.property.parent.object.name}.${node.property.name}`; + const isProperty = (property) => property.type === 'Property'; + const getTagNameFromMemberExpression = (node) => `${node.property.parent.object.name}.${node.property.name}`; return { JSXSpreadAttribute(node) { const jsxOpeningElement = node.parent.name; diff --git a/lib/rules/jsx-sort-default-props.js b/lib/rules/jsx-sort-default-props.js index 88f230ae6d..d45ca94e1f 100644 --- a/lib/rules/jsx-sort-default-props.js +++ b/lib/rules/jsx-sort-default-props.js @@ -81,7 +81,7 @@ module.exports = { * @returns {ASTNode|null} Return null if the variable could not be found, ASTNode otherwise. */ function findVariableByName(name) { - const variable = variableUtil.variablesInScope(context).find(item => item.name === name); + const variable = variableUtil.variablesInScope(context).find((item) => item.name === name); if (!variable || !variable.defs[0] || !variable.defs[0].node) { return null; diff --git a/lib/rules/jsx-sort-props.js b/lib/rules/jsx-sort-props.js index b3c01389e8..5eb9206b97 100644 --- a/lib/rules/jsx-sort-props.js +++ b/lib/rules/jsx-sort-props.js @@ -134,7 +134,7 @@ const generateFixerFunction = (node, context, reservedList) => { const sortableAttributeGroups = getGroupsOfSortableAttributes(attributes); const sortedAttributeGroups = sortableAttributeGroups .slice(0) - .map(group => group.slice(0).sort((a, b) => contextCompare(a, b, options))); + .map((group) => group.slice(0).sort((a, b) => contextCompare(a, b, options))); return function fixFunction(fixer) { const fixers = []; @@ -176,7 +176,7 @@ function validateReservedFirstConfig(context, reservedFirst) { if (reservedFirst) { if (Array.isArray(reservedFirst)) { // Only allow a subset of reserved words in customized lists - const nonReservedWords = reservedFirst.filter(word => !isReservedPropName( + const nonReservedWords = reservedFirst.filter((word) => !isReservedPropName( word, RESERVED_PROPS_LIST )); @@ -260,7 +260,7 @@ module.exports = { JSXOpeningElement(node) { // `dangerouslySetInnerHTML` is only "reserved" on DOM components if (reservedFirst && !jsxUtil.isDOMComponent(node)) { - reservedList = reservedList.filter(prop => prop !== 'dangerouslySetInnerHTML'); + reservedList = reservedList.filter((prop) => prop !== 'dangerouslySetInnerHTML'); } node.attributes.reduce((memo, decl, idx, attrs) => { diff --git a/lib/rules/jsx-wrap-multilines.js b/lib/rules/jsx-wrap-multilines.js index 141de2c5f7..4a8eb65f53 100644 --- a/lib/rules/jsx-wrap-multilines.js +++ b/lib/rules/jsx-wrap-multilines.js @@ -150,7 +150,7 @@ module.exports = { const option = getOption(type); if ((option === true || option === 'parens') && !isParenthesised(node) && isMultilines(node)) { - report(node, MISSING_PARENS, fixer => fixer.replaceText(node, `(${sourceCode.getText(node)})`)); + report(node, MISSING_PARENS, (fixer) => fixer.replaceText(node, `(${sourceCode.getText(node)})`)); } if (option === 'parens-new-line' && isMultilines(node)) { @@ -162,13 +162,13 @@ module.exports = { report( node, MISSING_PARENS, - fixer => fixer.replaceTextRange( + (fixer) => fixer.replaceTextRange( [tokenBefore.range[0], tokenAfter && (tokenAfter.value === ';' || tokenAfter.value === '}') ? tokenAfter.range[0] : node.range[1]], `${trimTokenBeforeNewline(node, tokenBefore)}(\n${' '.repeat(node.loc.start.column)}${sourceCode.getText(node)}\n${' '.repeat(node.loc.start.column - 2)})` ) ); } else { - report(node, MISSING_PARENS, fixer => fixer.replaceText(node, `(\n${sourceCode.getText(node)}\n)`)); + report(node, MISSING_PARENS, (fixer) => fixer.replaceText(node, `(\n${sourceCode.getText(node)}\n)`)); } } else { const needsOpening = needsOpeningNewLine(node); diff --git a/lib/rules/no-access-state-in-setstate.js b/lib/rules/no-access-state-in-setstate.js index 9712b8a359..8bbf3ba56d 100644 --- a/lib/rules/no-access-state-in-setstate.js +++ b/lib/rules/no-access-state-in-setstate.js @@ -144,7 +144,7 @@ module.exports = { while (current.type !== 'Program') { if (isFirstArgumentInSetStateCall(current, node)) { vars - .filter(v => v.scope === context.getScope() && v.variableName === node.name) + .filter((v) => v.scope === context.getScope() && v.variableName === node.name) .forEach((v) => { context.report({ node: v.node, diff --git a/lib/rules/no-children-prop.js b/lib/rules/no-children-prop.js index 67161fc9fa..7bc650cffd 100644 --- a/lib/rules/no-children-prop.js +++ b/lib/rules/no-children-prop.js @@ -57,7 +57,7 @@ module.exports = { } const props = node.arguments[1].properties; - const childrenProp = props.find(prop => prop.key && prop.key.name === 'children'); + const childrenProp = props.find((prop) => prop.key && prop.key.name === 'children'); if (childrenProp) { context.report({ diff --git a/lib/rules/no-danger-with-children.js b/lib/rules/no-danger-with-children.js index aff104fe58..95c15e460e 100644 --- a/lib/rules/no-danger-with-children.js +++ b/lib/rules/no-danger-with-children.js @@ -24,7 +24,7 @@ module.exports = { }, create(context) { function findSpreadVariable(name) { - return variableUtil.variablesInScope(context).find(item => item.name === name); + return variableUtil.variablesInScope(context).find((item) => item.name === name); } /** * Takes a ObjectExpression and returns the value of the prop if it has it @@ -120,7 +120,7 @@ module.exports = { let props = node.arguments[1]; if (props.type === 'Identifier') { - const variable = variableUtil.variablesInScope(context).find(item => item.name === props.name); + const variable = variableUtil.variablesInScope(context).find((item) => item.name === props.name); if (variable && variable.defs.length && variable.defs[0].node.init) { props = variable.defs[0].node.init; } diff --git a/lib/rules/no-deprecated.js b/lib/rules/no-deprecated.js index 9f7619b8e4..a630c4d12f 100644 --- a/lib/rules/no-deprecated.js +++ b/lib/rules/no-deprecated.js @@ -139,7 +139,7 @@ module.exports = { } values(MODULES).some((moduleNames) => { - moduleName = moduleNames.find(name => name === node.init.name); + moduleName = moduleNames.find((name) => name === node.init.name); return moduleName; }); @@ -153,7 +153,7 @@ module.exports = { */ function getLifeCycleMethods(node) { const properties = astUtil.getComponentProperties(node); - return properties.map(property => ({ + return properties.map((property) => ({ name: astUtil.getPropertyName(property), node: astUtil.getPropertyNameNode(property) })); @@ -166,7 +166,7 @@ module.exports = { function checkLifeCycleMethods(node) { if (utils.isES5Component(node) || utils.isES6Component(node)) { const methods = getLifeCycleMethods(node); - methods.forEach(method => checkDeprecation(node, method.name, method.node)); + methods.forEach((method) => checkDeprecation(node, method.name, method.node)); } } diff --git a/lib/rules/no-multi-comp.js b/lib/rules/no-multi-comp.js index de4e04a7d6..304314bb3c 100644 --- a/lib/rules/no-multi-comp.js +++ b/lib/rules/no-multi-comp.js @@ -65,7 +65,7 @@ module.exports = { const list = components.list(); - Object.keys(list).filter(component => !isIgnored(list[component])).forEach((component, i) => { + Object.keys(list).filter((component) => !isIgnored(list[component])).forEach((component, i) => { if (i >= 1) { context.report({ node: list[component].node, diff --git a/lib/rules/no-set-state.js b/lib/rules/no-set-state.js index 0ad87f7cee..269cb6f6ed 100644 --- a/lib/rules/no-set-state.js +++ b/lib/rules/no-set-state.js @@ -74,7 +74,7 @@ module.exports = { 'Program:exit'() { const list = components.list(); - Object.keys(list).filter(component => !isValid(list[component])).forEach((component) => { + Object.keys(list).filter((component) => !isValid(list[component])).forEach((component) => { reportSetStateUsages(list[component]); }); } diff --git a/lib/rules/no-typos.js b/lib/rules/no-typos.js index aaf52fc4f3..1f59133b1c 100644 --- a/lib/rules/no-typos.js +++ b/lib/rules/no-typos.js @@ -57,7 +57,7 @@ module.exports = { } function checkValidPropType(node) { - if (node.name && !PROP_TYPES.some(propTypeName => propTypeName === node.name)) { + if (node.name && !PROP_TYPES.some((propTypeName) => propTypeName === node.name)) { context.report({ node, message: 'Typo in declared prop type: {{name}}', @@ -123,7 +123,7 @@ module.exports = { function checkValidPropObject(node) { if (node && node.type === 'ObjectExpression') { - node.properties.forEach(prop => checkValidProp(prop.value)); + node.properties.forEach((prop) => checkValidProp(prop.value)); } } @@ -180,7 +180,7 @@ module.exports = { reactPackageName = node.specifiers[0].local.name; // guard against accidental anonymous `import "react"` } if (node.specifiers.length >= 1) { - const propTypesSpecifier = node.specifiers.find(specifier => ( + const propTypesSpecifier = node.specifiers.find((specifier) => ( specifier.imported && specifier.imported.name === 'PropTypes' )); if (propTypesSpecifier) { @@ -203,7 +203,7 @@ module.exports = { if ( !propertyName - || STATIC_CLASS_PROPERTIES.map(prop => prop.toLocaleLowerCase()).indexOf(propertyName.toLowerCase()) === -1 + || STATIC_CLASS_PROPERTIES.map((prop) => prop.toLocaleLowerCase()).indexOf(propertyName.toLowerCase()) === -1 ) { return; } diff --git a/lib/rules/no-unescaped-entities.js b/lib/rules/no-unescaped-entities.js index e42e140a68..db3ca2c0e8 100644 --- a/lib/rules/no-unescaped-entities.js +++ b/lib/rules/no-unescaped-entities.js @@ -99,7 +99,7 @@ module.exports = { } else if (c === entities[j].char) { context.report({ loc: {line: i, column: start + index}, - message: `\`${entities[j].char}\` can be escaped with ${entities[j].alternatives.map(alt => `\`${alt}\``).join(', ')}.`, + message: `\`${entities[j].char}\` can be escaped with ${entities[j].alternatives.map((alt) => `\`${alt}\``).join(', ')}.`, node }); } diff --git a/lib/rules/no-unknown-property.js b/lib/rules/no-unknown-property.js index a1a14d5859..18634951c3 100644 --- a/lib/rules/no-unknown-property.js +++ b/lib/rules/no-unknown-property.js @@ -155,7 +155,7 @@ const tagConvention = /^[a-z][^-]*$/; function isTagName(node) { if (tagConvention.test(node.parent.name.name)) { // http://www.w3.org/TR/custom-elements/#type-extension-semantics - return !node.parent.attributes.some(attrNode => ( + return !node.parent.attributes.some((attrNode) => ( attrNode.type === 'JSXAttribute' && attrNode.name.type === 'JSXIdentifier' && attrNode.name.name === 'is' diff --git a/lib/rules/no-unsafe.js b/lib/rules/no-unsafe.js index 59b691b461..81c7eccacc 100644 --- a/lib/rules/no-unsafe.js +++ b/lib/rules/no-unsafe.js @@ -113,7 +113,7 @@ module.exports = { */ function getLifeCycleMethods(node) { const properties = astUtil.getComponentProperties(node); - return properties.map(property => astUtil.getPropertyName(property)); + return properties.map((property) => astUtil.getPropertyName(property)); } /** @@ -123,7 +123,7 @@ module.exports = { function checkLifeCycleMethods(node) { if (utils.isES5Component(node) || utils.isES6Component(node)) { const methods = getLifeCycleMethods(node); - methods.forEach(method => checkUnsafe(node, method)); + methods.forEach((method) => checkUnsafe(node, method)); } } diff --git a/lib/rules/no-unused-prop-types.js b/lib/rules/no-unused-prop-types.js index c9b46e970f..f6a95aca0a 100644 --- a/lib/rules/no-unused-prop-types.js +++ b/lib/rules/no-unused-prop-types.js @@ -134,7 +134,7 @@ module.exports = { 'Program:exit'() { const list = components.list(); // Report undeclared proptypes for all classes - Object.keys(list).filter(component => mustBeValidated(list[component])).forEach((component) => { + Object.keys(list).filter((component) => mustBeValidated(list[component])).forEach((component) => { if (!mustBeValidated(list[component])) { return; } diff --git a/lib/rules/no-will-update-set-state.js b/lib/rules/no-will-update-set-state.js index 0267227a73..4283fa036f 100644 --- a/lib/rules/no-will-update-set-state.js +++ b/lib/rules/no-will-update-set-state.js @@ -10,5 +10,5 @@ const versionUtil = require('../util/version'); module.exports = makeNoMethodSetStateRule( 'componentWillUpdate', - context => versionUtil.testReactVersion(context, '16.3.0') + (context) => versionUtil.testReactVersion(context, '16.3.0') ); diff --git a/lib/rules/prop-types.js b/lib/rules/prop-types.js index a201dc6d4b..b1538193fb 100644 --- a/lib/rules/prop-types.js +++ b/lib/rules/prop-types.js @@ -162,7 +162,7 @@ module.exports = { * @param {Object} component The component to process */ function reportUndeclaredPropTypes(component) { - const undeclareds = component.usedPropTypes.filter(propType => ( + const undeclareds = component.usedPropTypes.filter((propType) => ( propType.node && !isIgnored(propType.allNames[0]) && !isDeclaredInComponent(component.node, propType.allNames) @@ -186,7 +186,7 @@ module.exports = { 'Program:exit'() { const list = components.list(); // Report undeclared proptypes for all classes - Object.keys(list).filter(component => mustBeValidated(list[component])).forEach((component) => { + Object.keys(list).filter((component) => mustBeValidated(list[component])).forEach((component) => { reportUndeclaredPropTypes(list[component]); }); } diff --git a/lib/rules/require-optimization.js b/lib/rules/require-optimization.js index 142aecc3a5..54f633fd0c 100644 --- a/lib/rules/require-optimization.js +++ b/lib/rules/require-optimization.js @@ -208,7 +208,7 @@ module.exports = { ObjectExpression(node) { // Search for the shouldComponentUpdate declaration - const found = node.properties.some(property => ( + const found = node.properties.some((property) => ( property.key && (isSCUDeclared(property.key) || isPureRenderDeclared(property)) )); @@ -221,7 +221,7 @@ module.exports = { const list = components.list(); // Report missing shouldComponentUpdate for all components - Object.keys(list).filter(component => !list[component].hasSCU).forEach((component) => { + Object.keys(list).filter((component) => !list[component].hasSCU).forEach((component) => { reportMissingOptimization(list[component]); }); } diff --git a/lib/rules/require-render-return.js b/lib/rules/require-render-return.js index 4540fe4e48..106ae6b8fb 100644 --- a/lib/rules/require-render-return.js +++ b/lib/rules/require-render-return.js @@ -43,8 +43,8 @@ module.exports = { function findRenderMethod(node) { const properties = astUtil.getComponentProperties(node); return properties - .filter(property => astUtil.getPropertyName(property) === 'render' && property.value) - .find(property => astUtil.isFunctionLikeExpression(property.value)); + .filter((property) => astUtil.getPropertyName(property) === 'render' && property.value) + .find((property) => astUtil.isFunctionLikeExpression(property.value)); } return { diff --git a/lib/rules/sort-comp.js b/lib/rules/sort-comp.js index 13d1974d2c..7d1f725866 100644 --- a/lib/rules/sort-comp.js +++ b/lib/rules/sort-comp.js @@ -380,7 +380,7 @@ module.exports = { * @param {Array} properties Array containing all the properties. */ function checkPropsOrder(properties) { - const propertiesInfos = properties.map(node => ({ + const propertiesInfos = properties.map((node) => ({ name: getPropertyName(node), getter: node.kind === 'get', setter: node.kind === 'set', diff --git a/lib/rules/static-property-placement.js b/lib/rules/static-property-placement.js index 8e2a89a55a..69bc6b0d98 100644 --- a/lib/rules/static-property-placement.js +++ b/lib/rules/static-property-placement.js @@ -37,11 +37,11 @@ const propertiesToCheck = { childContextTypes: propsUtil.isChildContextTypesDeclaration, contextTypes: propsUtil.isContextTypesDeclaration, contextType: propsUtil.isContextTypeDeclaration, - displayName: node => propsUtil.isDisplayNameDeclaration(astUtil.getPropertyNameNode(node)) + displayName: (node) => propsUtil.isDisplayNameDeclaration(astUtil.getPropertyNameNode(node)) }; const classProperties = Object.keys(propertiesToCheck); -const schemaProperties = fromEntries(classProperties.map(property => [property, {enum: POSITION_SETTINGS}])); +const schemaProperties = fromEntries(classProperties.map((property) => [property, {enum: POSITION_SETTINGS}])); // ------------------------------------------------------------------------------ // Rule Definition @@ -74,7 +74,7 @@ module.exports = { const additionalConfig = hasAdditionalConfig ? options[1] : {}; // Set config - const config = fromEntries(classProperties.map(property => [ + const config = fromEntries(classProperties.map((property) => [ property, additionalConfig[property] || defaultCheckType ])); @@ -131,7 +131,7 @@ module.exports = { // Public // ---------------------------------------------------------------------- return { - ClassProperty: node => reportNodeIncorrectlyPositioned(node, STATIC_PUBLIC_FIELD), + ClassProperty: (node) => reportNodeIncorrectlyPositioned(node, STATIC_PUBLIC_FIELD), MemberExpression: (node) => { // If definition type is undefined then it must not be a defining expression or if the definition is inside a diff --git a/lib/rules/style-prop-object.js b/lib/rules/style-prop-object.js index 5e6e14846b..0e6f968b18 100644 --- a/lib/rules/style-prop-object.js +++ b/lib/rules/style-prop-object.js @@ -52,7 +52,7 @@ module.exports = { * @param {object} node A Identifier node */ function checkIdentifiers(node) { - const variable = variableUtil.variablesInScope(context).find(item => item.name === node.name); + const variable = variableUtil.variablesInScope(context).find((item) => item.name === node.name); if (!variable || !variable.defs[0] || !variable.defs[0].node.init) { return; @@ -85,7 +85,7 @@ module.exports = { } } if (node.arguments[1].type === 'ObjectExpression') { - const style = node.arguments[1].properties.find(property => property.key && property.key.name === 'style' && !property.computed); + const style = node.arguments[1].properties.find((property) => property.key && property.key.name === 'style' && !property.computed); if (style) { if (style.value.type === 'Identifier') { checkIdentifiers(style.value); diff --git a/lib/util/Components.js b/lib/util/Components.js index fad124ce65..3ded3e39f4 100644 --- a/lib/util/Components.js +++ b/lib/util/Components.js @@ -37,7 +37,7 @@ function usedPropTypesAreEquivalent(propA, propB) { function mergeUsedPropTypes(propsList, newPropsList) { const propsToAdd = []; newPropsList.forEach((newProp) => { - const newPropisAlreadyInTheList = propsList.some(prop => usedPropTypesAreEquivalent(prop, newProp)); + const newPropisAlreadyInTheList = propsList.some((prop) => usedPropTypesAreEquivalent(prop, newProp)); if (!newPropisAlreadyInTheList) { propsToAdd.push(newProp); } @@ -161,7 +161,7 @@ class Components { const usedPropTypes = {}; // Find props used in components for which we are not confident - Object.keys(thisList).filter(i => thisList[i].confidence < 2).forEach((i) => { + Object.keys(thisList).filter((i) => thisList[i].confidence < 2).forEach((i) => { let component = null; let node = null; node = thisList[i].node; @@ -174,7 +174,7 @@ class Components { component = this.get(node); } if (component) { - const newUsedProps = (thisList[i].usedPropTypes || []).filter(propType => !propType.node || propType.node.kind !== 'init'); + const newUsedProps = (thisList[i].usedPropTypes || []).filter((propType) => !propType.node || propType.node.kind !== 'init'); const componentId = getId(component.node); @@ -183,7 +183,7 @@ class Components { }); // Assign used props in not confident components to the parent component - Object.keys(thisList).filter(j => thisList[j].confidence >= 2).forEach((j) => { + Object.keys(thisList).filter((j) => thisList[j].confidence >= 2).forEach((j) => { const id = getId(thisList[j].node); list[j] = thisList[j]; if (usedPropTypes[id]) { @@ -201,7 +201,7 @@ class Components { */ length() { const list = Lists.get(this); - return Object.keys(list).filter(i => list[i].confidence >= 2).length; + return Object.keys(list).filter((i) => list[i].confidence >= 2).length; } } @@ -271,7 +271,7 @@ function componentRule(rule, context) { tags: ['extends', 'augments'] }); - const relevantTags = commentAst.tags.filter(tag => tag.name === 'React.Component' || tag.name === 'React.PureComponent'); + const relevantTags = commentAst.tags.filter((tag) => tag.name === 'React.Component' || tag.name === 'React.PureComponent'); return relevantTags.length > 0; }, @@ -482,7 +482,7 @@ function componentRule(rule, context) { return this.getComponentNameFromJSXElement(body); } if (body.type === 'BlockStatement') { - const jsxElement = body.body.find(item => item.type === 'ReturnStatement'); + const jsxElement = body.body.find((item) => item.type === 'ReturnStatement'); return jsxElement && jsxElement.argument && this.getComponentNameFromJSXElement(jsxElement.argument); @@ -736,7 +736,7 @@ function componentRule(rule, context) { // Try to find the component using variable declarations const defs = variableInScope.defs; - const defInScope = defs.find(def => ( + const defInScope = defs.find((def) => ( def.type === 'ClassName' || def.type === 'FunctionName' || def.type === 'Variable' diff --git a/lib/util/defaultProps.js b/lib/util/defaultProps.js index ec8250627c..5c1a7ec205 100644 --- a/lib/util/defaultProps.js +++ b/lib/util/defaultProps.js @@ -8,7 +8,7 @@ const fromEntries = require('object.fromentries'); const astUtil = require('./ast'); const propsUtil = require('./props'); const variableUtil = require('./variable'); -const propWrapperUtil = require('../util/propWrapper'); +const propWrapperUtil = require('./propWrapper'); const QUOTES_REGEX = /^["']|["']$/g; @@ -43,13 +43,13 @@ module.exports = function defaultPropsInstructions(context, components, utils) { * from this ObjectExpression can't be resolved. */ function getDefaultPropsFromObjectExpression(objectExpression) { - const hasSpread = objectExpression.properties.find(property => property.type === 'ExperimentalSpreadProperty' || property.type === 'SpreadElement'); + const hasSpread = objectExpression.properties.find((property) => property.type === 'ExperimentalSpreadProperty' || property.type === 'SpreadElement'); if (hasSpread) { return 'unresolved'; } - return objectExpression.properties.map(defaultProp => ({ + return objectExpression.properties.map((defaultProp) => ({ name: sourceCode.getText(defaultProp.key).replace(QUOTES_REGEX, ''), node: defaultProp })); @@ -90,7 +90,7 @@ module.exports = function defaultPropsInstructions(context, components, utils) { const newDefaultProps = Object.assign( {}, defaults, - fromEntries(defaultProps.map(prop => [prop.name, prop])) + fromEntries(defaultProps.map((prop) => [prop.name, prop])) ); components.set(component.node, { diff --git a/lib/util/pragma.js b/lib/util/pragma.js index 47682847d5..4a49ac52d2 100644 --- a/lib/util/pragma.js +++ b/lib/util/pragma.js @@ -38,7 +38,7 @@ function getFromContext(context) { let pragma = 'React'; const sourceCode = context.getSourceCode(); - const pragmaNode = sourceCode.getAllComments().find(node => JSX_ANNOTATION_REGEX.test(node.value)); + const pragmaNode = sourceCode.getAllComments().find((node) => JSX_ANNOTATION_REGEX.test(node.value)); if (pragmaNode) { const matches = JSX_ANNOTATION_REGEX.exec(pragmaNode.value); diff --git a/lib/util/propTypes.js b/lib/util/propTypes.js index a3dcdbb0da..7cd4bc05a4 100644 --- a/lib/util/propTypes.js +++ b/lib/util/propTypes.js @@ -170,7 +170,7 @@ module.exports = function propTypesInstructions(context, components, utils) { /** @type {UnionTypeDefinition} */ const unionTypeDefinition = { type: 'union', - children: annotation.types.map(type => buildTypeAnnotationDeclarationTypes(type, parentName, seen)) + children: annotation.types.map((type) => buildTypeAnnotationDeclarationTypes(type, parentName, seen)) }; if (unionTypeDefinition.children.length === 0) { // no complex type found, simply accept everything @@ -406,7 +406,7 @@ module.exports = function propTypesInstructions(context, components, utils) { /** @type {UnionTypeDefinition} */ const unionTypeDefinition = { type: 'union', - children: argument.elements.map(element => buildReactDeclarationTypes(element, parentName)) + children: argument.elements.map((element) => buildReactDeclarationTypes(element, parentName)) }; if (unionTypeDefinition.children.length === 0) { // no complex type found, simply accept everything @@ -513,7 +513,7 @@ module.exports = function propTypesInstructions(context, components, utils) { case 'Identifier': { const variablesInScope = variableUtil.variablesInScope(context); const firstMatchingVariable = variablesInScope - .find(variableInScope => variableInScope.name === propTypes.name); + .find((variableInScope) => variableInScope.name === propTypes.name); if (firstMatchingVariable) { const defInScope = firstMatchingVariable.defs[firstMatchingVariable.defs.length - 1]; markPropTypesAsDeclared(node, defInScope.node && defInScope.node.init); diff --git a/lib/util/usedPropTypes.js b/lib/util/usedPropTypes.js index 4a8ae7996b..94f56c36d4 100755 --- a/lib/util/usedPropTypes.js +++ b/lib/util/usedPropTypes.js @@ -465,7 +465,7 @@ module.exports = function usedPropTypesInstructions(context, components, utils) } // let {props: {firstname}} = this - const propsProperty = node.id.properties.find(property => ( + const propsProperty = node.id.properties.find((property) => ( property.key && (property.key.name === 'props' || property.key.value === 'props') )); @@ -544,7 +544,7 @@ module.exports = function usedPropTypesInstructions(context, components, utils) 'Program:exit'() { const list = components.list(); - Object.keys(list).filter(component => mustBeValidated(list[component])).forEach((component) => { + Object.keys(list).filter((component) => mustBeValidated(list[component])).forEach((component) => { handleCustomValidators(list[component]); }); } diff --git a/lib/util/variable.js b/lib/util/variable.js index cbc30f4ad0..0575c75d50 100644 --- a/lib/util/variable.js +++ b/lib/util/variable.js @@ -12,7 +12,7 @@ * @returns {Boolean} True if the variable was found, false if not. */ function findVariable(variables, name) { - return variables.some(variable => variable.name === name); + return variables.some((variable) => variable.name === name); } /** @@ -22,7 +22,7 @@ function findVariable(variables, name) { * @returns {Object} Variable if the variable was found, null if not. */ function getVariable(variables, name) { - return variables.find(variable => variable.name === name); + return variables.find((variable) => variable.name === name); } /** diff --git a/lib/util/version.js b/lib/util/version.js index 669b4a8fbf..a919fb4646 100644 --- a/lib/util/version.js +++ b/lib/util/version.js @@ -51,7 +51,7 @@ function getReactVersionFromContext(context) { warnedForMissingVersion = true; } confVer = /^[0-9]+\.[0-9]+$/.test(confVer) ? `${confVer}.0` : confVer; - return confVer.split('.').map(part => Number(part)); + return confVer.split('.').map((part) => Number(part)); } function detectFlowVersion() { @@ -86,7 +86,7 @@ function getFlowVersionFromContext(context) { throw 'Could not retrieve flowVersion from settings'; // eslint-disable-line no-throw-literal } confVer = /^[0-9]+\.[0-9]+$/.test(confVer) ? `${confVer}.0` : confVer; - return confVer.split('.').map(part => Number(part)); + return confVer.split('.').map((part) => Number(part)); } function normalizeParts(parts) { @@ -94,7 +94,7 @@ function normalizeParts(parts) { } function test(context, methodVer, confVer) { - const methodVers = normalizeParts(String(methodVer || '').split('.').map(part => Number(part))); + const methodVers = normalizeParts(String(methodVer || '').split('.').map((part) => Number(part))); const confVers = normalizeParts(confVer); const higherMajor = methodVers[0] < confVers[0]; const higherMinor = methodVers[0] === confVers[0] && methodVers[1] < confVers[1]; diff --git a/markdown.config.js b/markdown.config.js index 1dae91db15..d1bc849983 100644 --- a/markdown.config.js +++ b/markdown.config.js @@ -10,8 +10,8 @@ const ruleListItems = Object.keys(rules) return `* [react/${id}](docs/rules/${id}.md): ${docs.description}${fixable ? ' (fixable)' : ''}`; }); -const BASIC_RULES = () => ruleListItems.filter(rule => !rule.includes('react/jsx-')).join('\n'); -const JSX_RULES = () => ruleListItems.filter(rule => rule.includes('react/jsx-')).join('\n'); +const BASIC_RULES = () => ruleListItems.filter((rule) => !rule.includes('react/jsx-')).join('\n'); +const JSX_RULES = () => ruleListItems.filter((rule) => rule.includes('react/jsx-')).join('\n'); module.exports = { transforms: { diff --git a/package.json b/package.json index acf6a24f0d..c530c53ddf 100644 --- a/package.json +++ b/package.json @@ -41,22 +41,22 @@ "xregexp": "^4.3.0" }, "devDependencies": { - "@types/eslint": "^6.1.8", - "@types/estree": "0.0.42", - "@types/node": "^13.7.4", - "@typescript-eslint/parser": "^2.24.0", + "@types/eslint": "^6.8.0", + "@types/estree": "0.0.44", + "@types/node": "^13.13.6", + "@typescript-eslint/parser": "^2.33.0", "babel-eslint": "^8.2.6", - "coveralls": "^3.0.9", + "coveralls": "^3.1.0", "eslint": "^3 || ^4 || ^5 || ^6 || ^7", - "eslint-config-airbnb-base": "^13.2.0", + "eslint-config-airbnb-base": "^14.1.0", "eslint-plugin-eslint-plugin": "^2.2.1", - "eslint-plugin-import": "^2.20.1", + "eslint-plugin-import": "^2.20.2", "istanbul": "^0.4.5", "markdown-magic": "^1.0.0", "mocha": "^5.2.0", "semver": "^6.3.0", "sinon": "^7.5.0", - "typescript": "^3.8.2", + "typescript": "^3.9.2", "typescript-eslint-parser": "^20.1.1" }, "peerDependencies": { diff --git a/tests/index.js b/tests/index.js index 12f6f88286..ef18b6d3cc 100644 --- a/tests/index.js +++ b/tests/index.js @@ -9,7 +9,7 @@ const path = require('path'); const plugin = require('..'); const ruleFiles = fs.readdirSync(path.resolve(__dirname, '../lib/rules/')) - .map(f => path.basename(f, '.js')); + .map((f) => path.basename(f, '.js')); describe('all rule files should be exported by the plugin', () => { ruleFiles.forEach((ruleName) => { diff --git a/tests/lib/rules/no-typos.js b/tests/lib/rules/no-typos.js index 62c156e125..c814c4826e 100644 --- a/tests/lib/rules/no-typos.js +++ b/tests/lib/rules/no-typos.js @@ -28,7 +28,7 @@ const parserOptions = { const ERROR_MESSAGE = 'Typo in static class property declaration'; const ERROR_MESSAGE_ES5 = 'Typo in property declaration'; const ERROR_MESSAGE_LIFECYCLE_METHOD = (actual, expected) => `Typo in component lifecycle method declaration: ${actual} should be ${expected}`; -const ERROR_MESSAGE_STATIC = method => `Lifecycle method should be static: ${method}`; +const ERROR_MESSAGE_STATIC = (method) => `Lifecycle method should be static: ${method}`; const ruleTester = new RuleTester(); ruleTester.run('no-typos', rule, { diff --git a/tests/lib/rules/no-unused-state.js b/tests/lib/rules/no-unused-state.js index bc6b4caf55..eada128aa9 100644 --- a/tests/lib/rules/no-unused-state.js +++ b/tests/lib/rules/no-unused-state.js @@ -19,7 +19,7 @@ const parserOptions = { const eslintTester = new RuleTester({parserOptions}); function getErrorMessages(unusedFields) { - return unusedFields.map(field => ({ + return unusedFields.map((field) => ({ message: `Unused state field: '${field}'` })); }