From 9dd1350c7d4066aa06693cfb5fe3ef85aa6e589e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 18 May 2019 21:43:15 -0700 Subject: [PATCH 01/28] [eslint] use the airbnb config; temporarily set failing rules to warnings --- .eslintrc | 199 +++++----------------- lib/rules/jsx-closing-bracket-location.js | 3 +- lib/util/version.js | 6 +- package.json | 2 + tests/index.js | 15 +- 5 files changed, 61 insertions(+), 164 deletions(-) diff --git a/.eslintrc b/.eslintrc index 998aebcf59..ad78fcbc1b 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,4 +1,6 @@ { + "root": true, + "extends": "airbnb-base", "env": { "es6": true, "node": true @@ -6,168 +8,57 @@ "parserOptions": { "ecmaVersion": 6, "ecmaFeatures": { - "jsx": true - } + "jsx": true + }, + "sourceType": "script", }, "rules": { - // Possible Errors "comma-dangle": [2, "never"], - "computed-property-spacing": [2, "never"], - "no-cond-assign": 2, - "no-console": 2, - "no-constant-condition": 2, - "no-control-regex": 2, - "no-debugger": 2, - "no-dupe-keys": 2, - "no-empty": 2, - "no-empty-character-class": 2, - "no-ex-assign": 2, - "no-extra-boolean-cast": 2, - "no-extra-parens": 0, - "no-extra-semi": 2, - "no-func-assign": 2, - "no-inner-declarations": 2, - "no-invalid-regexp": 2, - "no-irregular-whitespace": 2, - "no-negated-in-lhs": 2, - "no-obj-calls": 2, - "no-regex-spaces": 2, - "no-reserved-keys": 0, - "no-sparse-arrays": 2, - "no-unreachable": 2, - "use-isnan": 2, - "valid-jsdoc": 0, - "valid-typeof": 2, - // Best Practices - "block-scoped-var": 2, - "complexity": 0, - "consistent-return": 2, - "curly": 2, - "default-case": 2, - "dot-notation": 2, - "eqeqeq": 2, - "guard-for-in": 2, - "no-alert": 2, - "no-caller": 2, - "no-confusing-arrow": 2, - "no-div-regex": 2, - "no-else-return": 2, - "no-eq-null": 2, - "no-eval": 2, - "no-extend-native": 2, - "no-extra-bind": 2, - "no-fallthrough": 2, - "no-floating-decimal": 2, - "no-implied-eval": 2, - "no-iterator": 2, - "no-labels": 2, - "no-lone-blocks": 2, - "no-loop-func": 2, - "no-multi-spaces": 2, - "no-multi-str": 2, - "no-native-reassign": 2, - "no-new": 2, - "no-new-func": 2, - "no-new-wrappers": 2, - "no-octal": 2, - "no-octal-escape": 2, - "no-process-env": 2, - "no-proto": 2, - "no-redeclare": 2, - "no-return-assign": 2, - "no-script-url": 2, - "no-self-compare": 2, - "no-sequences": 2, - "no-unused-expressions": 2, - "no-void": 0, - "no-warning-comments": 2, - "no-with": 2, - "prefer-arrow-callback": 2, - "radix": 2, - "vars-on-top": 0, - "wrap-iife": 2, - "yoda": 2, - // Strict Mode - "strict": [2, "global"], - // Variables - "prefer-const": 2, - "no-catch-shadow": 2, - "no-const-assign": 2, - "no-delete-var": 2, - "no-label-var": 2, - "no-shadow": 2, - "no-shadow-restricted-names": 2, - "no-undef": 2, - "no-undef-init": 2, - "no-undefined": 2, - "no-unused-vars": 2, - "no-use-before-define": 2, - "no-var": 2, - // Stylistic Issues - "indent": [2, 2, { - "SwitchCase": 1 - }], - "arrow-body-style": [2, "as-needed"], - "arrow-parens": [2, "as-needed"], - "arrow-spacing": 2, - "brace-style": 2, - "camelcase": 0, - "comma-spacing": 2, - "comma-style": 2, - "consistent-this": 0, - "eol-last": 2, - "func-names": 0, - "func-style": 0, - "key-spacing": [2, { - "beforeColon": false, - "afterColon": true - }], - "max-nested-callbacks": 0, - "new-cap": 2, - "new-parens": 2, - "no-array-constructor": 2, - "no-inline-comments": 0, - "no-lonely-if": 2, - "no-mixed-spaces-and-tabs": 2, - "no-nested-ternary": 2, - "no-new-object": 2, - "semi-spacing": [2, { - "before": false, - "after": true - }], - "no-spaced-func": 2, - "no-ternary": 0, - "no-trailing-spaces": 2, - "no-multiple-empty-lines": 2, - "no-underscore-dangle": 0, - "one-var": 0, - "operator-assignment": [2, "always"], - "padded-blocks": [2, { "blocks": "never", "classes": "never", "switches": "never" }], - "quotes": [2, "single"], - "quote-props": [2, "as-needed"], - "semi": [2, "always"], - "sort-vars": [2, {"ignoreCase": true}], - "keyword-spacing": 2, - "space-before-blocks": 2, "object-curly-spacing": [2, "never"], "array-bracket-spacing": [2, "never"], - "space-in-parens": 2, - "space-infix-ops": 2, - "space-unary-ops": 2, - "spaced-comment": 2, - "wrap-regex": 0, - // Legacy - "max-depth": 0, "max-len": [2, 120, { "ignoreStrings": true, "ignoreTemplateLiterals": true, "ignoreComments": true, }], - "max-params": 0, - "max-statements": 0, - "no-plusplus": 0, - "no-prototype-builtins": 2, - "prefer-template": 2, - "template-curly-spacing": [2, "never"] - } + + "prefer-destructuring": [2, { "array": false, "object": false }, { "enforceForRenamedProperties": false }], + + "object-shorthand": 1, + "space-before-function-paren": 1, + "import/order": 1, + "lines-around-directive": 1, + "no-useless-escape": 1, + "arrow-parens": 1, + "import/newline-after-import": 1, + "operator-linebreak": 1, + "function-paren-newline": 0, + "no-plusplus": 1, + "no-param-reassign": 1, + "no-else-return": 1, + "object-curly-newline": 1, + "object-property-newline": 1, + "spaced-comment": 1, + "no-case-declarations": 1, + "no-underscore-dangle": 1, + "no-mixed-operators": 1, + "semi-style": 1, + "no-void": 1, + "no-continue": 1, + "no-tabs": 1, + "global-require": 1, + "array-callback-return": 1, + "no-restricted-syntax": 1, + "implicit-arrow-linebreak": 1, + "no-useless-return": 1, + "valid-jsdoc": 1, + }, + "overrides": [ + { + "files": "tests/**", + "rules": { + "no-template-curly-in-string": 1, + }, + }, + ], } diff --git a/lib/rules/jsx-closing-bracket-location.js b/lib/rules/jsx-closing-bracket-location.js index 860f6f3871..0a1f71a9bd 100644 --- a/lib/rules/jsx-closing-bracket-location.js +++ b/lib/rules/jsx-closing-bracket-location.js @@ -158,7 +158,8 @@ module.exports = { */ function getIndentation(tokens, expectedLocation, correctColumn) { correctColumn = correctColumn || 0; - let indentation, spaces = []; + let indentation; + let spaces = []; switch (expectedLocation) { case 'props-aligned': indentation = /^\s*/.exec(sourceCode.lines[tokens.lastProp.firstLine - 1])[0]; diff --git a/lib/util/version.js b/lib/util/version.js index f28288afd9..5836b86549 100644 --- a/lib/util/version.js +++ b/lib/util/version.js @@ -16,7 +16,7 @@ function resetWarningFlag() { function detectReactVersion() { try { const reactPath = resolve.sync('react', {basedir: process.cwd()}); - const react = require(reactPath); + const react = require(reactPath); // eslint-disable-line import/no-dynamic-require return react.version; } catch (e) { if (!warnedForMissingVersion && e.code === 'MODULE_NOT_FOUND') { @@ -54,7 +54,7 @@ function getReactVersionFromContext(context) { function detectFlowVersion() { try { const flowPackageJsonPath = resolve.sync('flow-bin/package.json', {basedir: process.cwd()}); - const flowPackageJson = require(flowPackageJsonPath); + const flowPackageJson = require(flowPackageJsonPath); // eslint-disable-line import/no-dynamic-require return flowPackageJson.version; } catch (e) { if (e.code === 'MODULE_NOT_FOUND') { @@ -80,7 +80,7 @@ function getFlowVersionFromContext(context) { } confVer = String(flowVersion); } else { - throw 'Could not retrieve flowVersion from settings'; + 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)); diff --git a/package.json b/package.json index 0c499017e3..461896c176 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,8 @@ "babel-eslint": "^8.2.6", "coveralls": "^3.0.2", "eslint": "^3.0.0 || ^4.0.0 || ^5.0.0", + "eslint-config-airbnb-base": "^13.1.0", + "eslint-plugin-import": "^2.17.2", "istanbul": "^0.4.5", "mocha": "^5.2.0", "sinon": "^7.2.2", diff --git a/tests/index.js b/tests/index.js index 69c8051fae..4c55676f51 100644 --- a/tests/index.js +++ b/tests/index.js @@ -15,7 +15,7 @@ describe('all rule files should be exported by the plugin', () => { it(`should export ${ruleName}`, () => { assert.equal( plugin.rules[ruleName], - require(path.join('../lib/rules', ruleName)) + require(path.join('../lib/rules', ruleName)) // eslint-disable-line import/no-dynamic-require ); }); }); @@ -36,16 +36,16 @@ describe('deprecated rules', () => { }); describe('configurations', () => { - it('should export a \'recommended\' configuration', () => { + it('should export a ‘recommended’ configuration', () => { assert(plugin.configs.recommended); Object.keys(plugin.configs.recommended.rules).forEach(configName => { assert.equal(configName.indexOf('react/'), 0); - const ruleName = configName.substring('react/'.length); + const ruleName = configName.slice('react/'.length); assert(plugin.rules[ruleName]); }); ruleFiles.forEach(ruleName => { - const inRecommendedConfig = Boolean(plugin.configs.recommended.rules[`react/${ruleName}`]); + const inRecommendedConfig = !!plugin.configs.recommended.rules[`react/${ruleName}`]; const isRecommended = plugin.rules[ruleName].meta.docs.recommended; if (inRecommendedConfig) { assert(isRecommended, `${ruleName} metadata should mark it as recommended`); @@ -54,16 +54,19 @@ describe('configurations', () => { } }); }); - it('should export a \'all\' configuration', () => { + + it('should export an ‘all’ configuration', () => { assert(plugin.configs.all); + Object.keys(plugin.configs.all.rules).forEach(configName => { assert.equal(configName.indexOf('react/'), 0); assert.equal(plugin.configs.all.rules[configName], 2); }); + ruleFiles.forEach(ruleName => { const inDeprecatedRules = Boolean(plugin.deprecatedRules[ruleName]); const inAllConfig = Boolean(plugin.configs.all.rules[`react/${ruleName}`]); - assert(inDeprecatedRules ^ inAllConfig); + assert(inDeprecatedRules ^ inAllConfig); // eslint-disable-line no-bitwise }); }); }); From ddd9b227f3bc0886b2fb4e97d28f97f9c66d1741 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 18 May 2019 21:54:17 -0700 Subject: [PATCH 02/28] [eslint] enable and autofix `space-before-function-paren` --- .eslintrc | 1 - lib/rules/boolean-prop-naming.js | 10 ++-- lib/rules/button-has-type.js | 6 +-- lib/rules/default-props-match-prop-types.js | 2 +- lib/rules/destructuring-assignment.js | 4 +- lib/rules/display-name.js | 20 ++++---- lib/rules/forbid-component-props.js | 4 +- lib/rules/forbid-dom-props.js | 4 +- lib/rules/forbid-elements.js | 6 +-- lib/rules/forbid-foreign-prop-types.js | 6 +-- lib/rules/forbid-prop-types.js | 10 ++-- lib/rules/jsx-closing-bracket-location.js | 10 ++-- lib/rules/jsx-closing-tag-location.js | 4 +- lib/rules/jsx-curly-brace-presence.js | 6 +-- lib/rules/jsx-curly-spacing.js | 14 +++--- lib/rules/jsx-equals-spacing.js | 12 ++--- lib/rules/jsx-filename-extension.js | 4 +- lib/rules/jsx-first-prop-new-line.js | 4 +- lib/rules/jsx-fragments.js | 6 +-- lib/rules/jsx-handler-names.js | 4 +- lib/rules/jsx-indent-props.js | 6 +-- lib/rules/jsx-indent.js | 6 +-- lib/rules/jsx-key.js | 4 +- lib/rules/jsx-max-depth.js | 4 +- lib/rules/jsx-max-props-per-line.js | 2 +- lib/rules/jsx-no-comment-textnodes.js | 4 +- lib/rules/jsx-no-literals.js | 8 ++-- lib/rules/jsx-no-target-blank.js | 4 +- lib/rules/jsx-no-undef.js | 4 +- lib/rules/jsx-one-expression-per-line.js | 8 ++-- lib/rules/jsx-pascal-case.js | 4 +- lib/rules/jsx-props-no-multi-spaces.js | 2 +- lib/rules/jsx-sort-default-props.js | 6 +-- lib/rules/jsx-sort-props.js | 10 ++-- lib/rules/jsx-space-before-closing.js | 10 ++-- lib/rules/jsx-tag-spacing.js | 20 ++++---- lib/rules/jsx-uses-react.js | 2 +- lib/rules/jsx-uses-vars.js | 4 +- lib/rules/jsx-wrap-multilines.js | 16 +++---- lib/rules/no-access-state-in-setstate.js | 2 +- lib/rules/no-array-index-key.js | 8 ++-- lib/rules/no-children-prop.js | 6 +-- lib/rules/no-danger-with-children.js | 2 +- lib/rules/no-danger.js | 4 +- lib/rules/no-deprecated.js | 6 +-- lib/rules/no-direct-mutation-state.js | 4 +- lib/rules/no-find-dom-node.js | 4 +- lib/rules/no-is-mounted.js | 4 +- lib/rules/no-multi-comp.js | 2 +- lib/rules/no-render-return-value.js | 4 +- lib/rules/no-set-state.js | 4 +- lib/rules/no-string-refs.js | 4 +- lib/rules/no-typos.js | 12 ++--- lib/rules/no-unescaped-entities.js | 4 +- lib/rules/no-unknown-property.js | 6 +-- lib/rules/no-unused-prop-types.js | 4 +- lib/rules/prefer-es6-class.js | 4 +- lib/rules/prefer-stateless-function.js | 10 ++-- lib/rules/prop-types.js | 2 +- lib/rules/react-in-jsx-scope.js | 2 +- lib/rules/require-default-props.js | 2 +- lib/rules/require-render-return.js | 6 +-- lib/rules/self-closing-comp.js | 6 +-- lib/rules/sort-comp.js | 2 +- lib/rules/sort-prop-types.js | 12 ++--- lib/rules/style-prop-object.js | 6 +-- lib/rules/void-dom-elements-no-children.js | 4 +- lib/util/Components.js | 48 +++++++++---------- lib/util/defaultProps.js | 8 ++-- lib/util/makeNoMethodSetStateRule.js | 4 +- lib/util/propTypes.js | 30 ++++++------ lib/util/usedPropTypes.js | 12 ++--- .../lib/rules/jsx-closing-bracket-location.js | 2 +- 73 files changed, 250 insertions(+), 251 deletions(-) diff --git a/.eslintrc b/.eslintrc index ad78fcbc1b..54464a0834 100644 --- a/.eslintrc +++ b/.eslintrc @@ -25,7 +25,6 @@ "prefer-destructuring": [2, { "array": false, "object": false }, { "enforceForRenamedProperties": false }], "object-shorthand": 1, - "space-before-function-paren": 1, "import/order": 1, "lines-around-directive": 1, "no-useless-escape": 1, diff --git a/lib/rules/boolean-prop-naming.js b/lib/rules/boolean-prop-naming.js index bc7394d327..5666e1878c 100644 --- a/lib/rules/boolean-prop-naming.js +++ b/lib/rules/boolean-prop-naming.js @@ -215,7 +215,7 @@ module.exports = { // -------------------------------------------------------------------------- return { - ClassProperty: function(node) { + ClassProperty: function (node) { if (!rule || !propsUtil.isPropTypesDeclaration(node)) { return; } @@ -230,7 +230,7 @@ module.exports = { } }, - MemberExpression: function(node) { + MemberExpression: function (node) { if (!rule || !propsUtil.isPropTypesDeclaration(node)) { return; } @@ -246,7 +246,7 @@ module.exports = { validatePropNaming(component.node, node.parent.right.properties); }, - ObjectExpression: function(node) { + ObjectExpression: function (node) { if (!rule) { return; } @@ -260,14 +260,14 @@ module.exports = { }); }, - TypeAlias: function(node) { + TypeAlias: function (node) { // Cache all ObjectType annotations, we will check them at the end if (node.right.type === 'ObjectTypeAnnotation') { objectTypeAnnotations.set(node.id.name, node.right); } }, - 'Program:exit': function() { + 'Program:exit': function () { if (!rule) { return; } diff --git a/lib/rules/button-has-type.js b/lib/rules/button-has-type.js index 2322a092a2..a0d999e07b 100644 --- a/lib/rules/button-has-type.js +++ b/lib/rules/button-has-type.js @@ -61,7 +61,7 @@ module.exports = { }] }, - create: function(context) { + create: function (context) { const configuration = Object.assign({}, optionDefaults, context.options[0]); function reportMissing(node) { @@ -87,7 +87,7 @@ module.exports = { } return { - JSXElement: function(node) { + JSXElement: function (node) { if (node.openingElement.name.name !== 'button') { return; } @@ -106,7 +106,7 @@ module.exports = { checkValue(node, propValue); } }, - CallExpression: function(node) { + CallExpression: function (node) { if (!isCreateElement(node, context)) { return; } diff --git a/lib/rules/default-props-match-prop-types.js b/lib/rules/default-props-match-prop-types.js index cf1597a311..0578226d99 100644 --- a/lib/rules/default-props-match-prop-types.js +++ b/lib/rules/default-props-match-prop-types.js @@ -79,7 +79,7 @@ module.exports = { // -------------------------------------------------------------------------- return { - 'Program:exit': function() { + 'Program:exit': function () { const list = components.list(); // If no defaultProps could be found, we don't report anything. diff --git a/lib/rules/destructuring-assignment.js b/lib/rules/destructuring-assignment.js index db1f675d5f..18616124ba 100644 --- a/lib/rules/destructuring-assignment.js +++ b/lib/rules/destructuring-assignment.js @@ -120,7 +120,7 @@ module.exports = { FunctionExpression: handleStatelessComponent, - MemberExpression: function(node) { + MemberExpression: function (node) { const SFCComponent = components.get(context.getScope(node).block); const classComponent = utils.getParentComponent(node); if (SFCComponent) { @@ -131,7 +131,7 @@ module.exports = { } }, - VariableDeclarator: function(node) { + VariableDeclarator: function (node) { const classComponent = utils.getParentComponent(node); const SFCComponent = components.get(context.getScope(node).block); diff --git a/lib/rules/display-name.js b/lib/rules/display-name.js index 97da4890a6..bf8a6d41a3 100644 --- a/lib/rules/display-name.js +++ b/lib/rules/display-name.js @@ -121,14 +121,14 @@ module.exports = { return { - ClassProperty: function(node) { + ClassProperty: function (node) { if (!propsUtil.isDisplayNameDeclaration(node)) { return; } markDisplayNameAsDeclared(node); }, - MemberExpression: function(node) { + MemberExpression: function (node) { if (!propsUtil.isDisplayNameDeclaration(node.property)) { return; } @@ -139,7 +139,7 @@ module.exports = { markDisplayNameAsDeclared(component.node); }, - FunctionExpression: function(node) { + FunctionExpression: function (node) { if (ignoreTranspilerName || !hasTranspilerName(node)) { return; } @@ -148,7 +148,7 @@ module.exports = { } }, - FunctionDeclaration: function(node) { + FunctionDeclaration: function (node) { if (ignoreTranspilerName || !hasTranspilerName(node)) { return; } @@ -157,7 +157,7 @@ module.exports = { } }, - ArrowFunctionExpression: function(node) { + ArrowFunctionExpression: function (node) { if (ignoreTranspilerName || !hasTranspilerName(node)) { return; } @@ -166,28 +166,28 @@ module.exports = { } }, - MethodDefinition: function(node) { + MethodDefinition: function (node) { if (!propsUtil.isDisplayNameDeclaration(node.key)) { return; } markDisplayNameAsDeclared(node); }, - ClassExpression: function(node) { + ClassExpression: function (node) { if (ignoreTranspilerName || !hasTranspilerName(node)) { return; } markDisplayNameAsDeclared(node); }, - ClassDeclaration: function(node) { + ClassDeclaration: function (node) { if (ignoreTranspilerName || !hasTranspilerName(node)) { return; } markDisplayNameAsDeclared(node); }, - ObjectExpression: function(node) { + ObjectExpression: function (node) { if (ignoreTranspilerName || !hasTranspilerName(node)) { // Search for the displayName declaration node.properties.forEach(property => { @@ -201,7 +201,7 @@ module.exports = { markDisplayNameAsDeclared(node); }, - 'Program:exit': function() { + 'Program:exit': function () { const list = components.list(); // Report missing display name for all components Object.keys(list).filter(component => !list[component].hasDisplayName).forEach(component => { diff --git a/lib/rules/forbid-component-props.js b/lib/rules/forbid-component-props.js index 7bf1431d83..33a312ca56 100644 --- a/lib/rules/forbid-component-props.js +++ b/lib/rules/forbid-component-props.js @@ -54,7 +54,7 @@ module.exports = { }] }, - create: function(context) { + create: function (context) { const configuration = context.options[0] || {}; const forbid = new Map((configuration.forbid || DEFAULTS).map(value => { const propName = typeof value === 'string' ? value : value.propName; @@ -69,7 +69,7 @@ module.exports = { } return { - JSXAttribute: function(node) { + JSXAttribute: function (node) { const tag = node.parent.name.name; if (tag && tag[0] !== tag[0].toUpperCase()) { // This is a DOM node, not a Component, so exit. diff --git a/lib/rules/forbid-dom-props.js b/lib/rules/forbid-dom-props.js index 1e3ac8668e..feda69c2af 100644 --- a/lib/rules/forbid-dom-props.js +++ b/lib/rules/forbid-dom-props.js @@ -41,7 +41,7 @@ module.exports = { }] }, - create: function(context) { + create: function (context) { function isForbidden(prop) { const configuration = context.options[0] || {}; @@ -50,7 +50,7 @@ module.exports = { } return { - JSXAttribute: function(node) { + JSXAttribute: function (node) { const tag = node.parent.name.name; if (!(tag && tag[0] !== tag[0].toUpperCase())) { // This is a Component, not a DOM node, so exit. diff --git a/lib/rules/forbid-elements.js b/lib/rules/forbid-elements.js index 482b27e864..fac71c7efa 100644 --- a/lib/rules/forbid-elements.js +++ b/lib/rules/forbid-elements.js @@ -45,7 +45,7 @@ module.exports = { }] }, - create: function(context) { + create: function (context) { const sourceCode = context.getSourceCode(); const configuration = context.options[0] || {}; const forbidConfiguration = configuration.forbid || []; @@ -89,11 +89,11 @@ module.exports = { } return { - JSXOpeningElement: function(node) { + JSXOpeningElement: function (node) { reportIfForbidden(sourceCode.getText(node.name), node.name); }, - CallExpression: function(node) { + CallExpression: function (node) { if (!isValidCreateElement(node)) { return; } diff --git a/lib/rules/forbid-foreign-prop-types.js b/lib/rules/forbid-foreign-prop-types.js index b5a829f631..3022517da2 100644 --- a/lib/rules/forbid-foreign-prop-types.js +++ b/lib/rules/forbid-foreign-prop-types.js @@ -28,7 +28,7 @@ module.exports = { ] }, - create: function(context) { + create: function (context) { const config = context.options[0] || {}; const allowInPropTypes = config.allowInPropTypes || false; @@ -93,7 +93,7 @@ module.exports = { } return { - MemberExpression: function(node) { + MemberExpression: function (node) { if ( node.property && ( @@ -116,7 +116,7 @@ module.exports = { } }, - ObjectPattern: function(node) { + ObjectPattern: function (node) { const propTypesNode = node.properties.find(property => property.type === 'Property' && property.key.name === 'propTypes'); if (propTypesNode) { diff --git a/lib/rules/forbid-prop-types.js b/lib/rules/forbid-prop-types.js index de60c84ea7..9dd2bc268e 100644 --- a/lib/rules/forbid-prop-types.js +++ b/lib/rules/forbid-prop-types.js @@ -48,7 +48,7 @@ module.exports = { }] }, - create: function(context) { + create: function (context) { const configuration = context.options[0] || {}; const checkContextTypes = configuration.checkContextTypes || false; const checkChildContextTypes = configuration.checkChildContextTypes || false; @@ -135,7 +135,7 @@ module.exports = { } return { - ClassProperty: function(node) { + ClassProperty: function (node) { if ( !propsUtil.isPropTypesDeclaration(node) && !shouldCheckContextTypes(node) && @@ -146,7 +146,7 @@ module.exports = { checkNode(node.value); }, - MemberExpression: function(node) { + MemberExpression: function (node) { if ( !propsUtil.isPropTypesDeclaration(node) && !shouldCheckContextTypes(node) && @@ -158,7 +158,7 @@ module.exports = { checkNode(node.parent.right); }, - MethodDefinition: function(node) { + MethodDefinition: function (node) { if ( !propsUtil.isPropTypesDeclaration(node) && !shouldCheckContextTypes(node) && @@ -174,7 +174,7 @@ module.exports = { } }, - ObjectExpression: function(node) { + ObjectExpression: function (node) { node.properties.forEach(property => { if (!property.key) { return; diff --git a/lib/rules/jsx-closing-bracket-location.js b/lib/rules/jsx-closing-bracket-location.js index 0a1f71a9bd..ebefada7b1 100644 --- a/lib/rules/jsx-closing-bracket-location.js +++ b/lib/rules/jsx-closing-bracket-location.js @@ -49,7 +49,7 @@ module.exports = { }] }, - create: function(context) { + create: function (context) { const MESSAGE = 'The closing bracket must be {{location}}{{details}}'; const MESSAGE_LOCATION = { 'after-props': 'placed after the last prop', @@ -226,15 +226,15 @@ module.exports = { const lastAttributeNode = {}; return { - JSXAttribute: function(node) { + JSXAttribute: function (node) { lastAttributeNode[getOpeningElementId(node.parent)] = node; }, - JSXSpreadAttribute: function(node) { + JSXSpreadAttribute: function (node) { lastAttributeNode[getOpeningElementId(node.parent)] = node; }, - 'JSXOpeningElement:exit': function(node) { + 'JSXOpeningElement:exit': function (node) { const attributeNode = lastAttributeNode[getOpeningElementId(node)]; const cachedLastAttributeEndPos = attributeNode ? attributeNode.range[1] : null; let expectedNextLine; @@ -259,7 +259,7 @@ module.exports = { loc: tokens.closing, message: MESSAGE, data: data, - fix: function(fixer) { + fix: function (fixer) { const closingTag = tokens.selfClosing ? '/>' : '>'; switch (expectedLocation) { case 'after-tag': diff --git a/lib/rules/jsx-closing-tag-location.js b/lib/rules/jsx-closing-tag-location.js index 244d3072f5..ea3cde7091 100644 --- a/lib/rules/jsx-closing-tag-location.js +++ b/lib/rules/jsx-closing-tag-location.js @@ -21,7 +21,7 @@ module.exports = { fixable: 'whitespace' }, - create: function(context) { + create: function (context) { function handleClosingElement(node) { if (!node.parent) { return; @@ -47,7 +47,7 @@ module.exports = { node: node, loc: node.loc, message, - fix: function(fixer) { + fix: function (fixer) { const indent = Array(opening.loc.start.column + 1).join(' '); if (astUtil.isNodeFirstInLine(context, node)) { return fixer.replaceTextRange( diff --git a/lib/rules/jsx-curly-brace-presence.js b/lib/rules/jsx-curly-brace-presence.js index 0020934b1a..8c98e966ab 100755 --- a/lib/rules/jsx-curly-brace-presence.js +++ b/lib/rules/jsx-curly-brace-presence.js @@ -58,7 +58,7 @@ module.exports = { ] }, - create: function(context) { + create: function (context) { const ruleOptions = context.options[0]; const userConfig = typeof ruleOptions === 'string' ? {props: ruleOptions, children: ruleOptions} : @@ -116,7 +116,7 @@ module.exports = { context.report({ node: JSXExpressionNode, message: 'Curly braces are unnecessary here.', - fix: function(fixer) { + fix: function (fixer) { const expression = JSXExpressionNode.expression; const expressionType = expression.type; const parentType = JSXExpressionNode.parent.type; @@ -141,7 +141,7 @@ module.exports = { context.report({ node: literalNode, message: 'Need to wrap this literal in a JSX expression.', - fix: function(fixer) { + fix: function (fixer) { // If a HTML entity name is found, bail out because it can be fixed // by either using the real character or the unicode equivalent. // If it contains any line terminator character, bail out as well. diff --git a/lib/rules/jsx-curly-spacing.js b/lib/rules/jsx-curly-spacing.js index c684ed6465..2a3a86daa2 100644 --- a/lib/rules/jsx-curly-spacing.js +++ b/lib/rules/jsx-curly-spacing.js @@ -101,7 +101,7 @@ module.exports = { } }, - create: function(context) { + create: function (context) { function normalizeConfig(configOrTrue, defaults, lastPass) { const config = configOrTrue === true ? {} : configOrTrue; const when = config.when || defaults.when; @@ -191,7 +191,7 @@ module.exports = { node: node, loc: token.loc.start, message: `There should be no newline after '${token.value}'`, - fix: function(fixer) { + fix: function (fixer) { const nextToken = sourceCode.getTokenAfter(token); return fixByTrimmingWhitespace(fixer, token.range[1], nextToken.range[0], 'start', spacing); } @@ -210,7 +210,7 @@ module.exports = { node: node, loc: token.loc.start, message: `There should be no newline before '${token.value}'`, - fix: function(fixer) { + fix: function (fixer) { const previousToken = sourceCode.getTokenBefore(token); return fixByTrimmingWhitespace(fixer, previousToken.range[1], token.range[0], 'end', spacing); } @@ -228,7 +228,7 @@ module.exports = { node: node, loc: token.loc.start, message: `There should be no space after '${token.value}'`, - fix: function(fixer) { + fix: function (fixer) { const nextToken = sourceCode.getTokenAfter(token); let nextComment; @@ -262,7 +262,7 @@ module.exports = { node: node, loc: token.loc.start, message: `There should be no space before '${token.value}'`, - fix: function(fixer) { + fix: function (fixer) { const previousToken = sourceCode.getTokenBefore(token); let previousComment; @@ -296,7 +296,7 @@ module.exports = { node: node, loc: token.loc.start, message: `A space is required after '${token.value}'`, - fix: function(fixer) { + fix: function (fixer) { return fixer.insertTextAfter(token, ' '); } }); @@ -313,7 +313,7 @@ module.exports = { node: node, loc: token.loc.start, message: `A space is required before '${token.value}'`, - fix: function(fixer) { + fix: function (fixer) { return fixer.insertTextBefore(token, ' '); } }); diff --git a/lib/rules/jsx-equals-spacing.js b/lib/rules/jsx-equals-spacing.js index 2c927496e1..6ed2b57889 100644 --- a/lib/rules/jsx-equals-spacing.js +++ b/lib/rules/jsx-equals-spacing.js @@ -25,7 +25,7 @@ module.exports = { }] }, - create: function(context) { + create: function (context) { const config = context.options[0]; const sourceCode = context.getSourceCode(); @@ -43,7 +43,7 @@ module.exports = { // -------------------------------------------------------------------------- return { - JSXOpeningElement: function(node) { + JSXOpeningElement: function (node) { node.attributes.forEach(attrNode => { if (!hasEqual(attrNode)) { return; @@ -61,7 +61,7 @@ module.exports = { node: attrNode, loc: equalToken.loc.start, message: 'There should be no space before \'=\'', - fix: function(fixer) { + fix: function (fixer) { return fixer.removeRange([attrNode.name.range[1], equalToken.range[0]]); } }); @@ -71,7 +71,7 @@ module.exports = { node: attrNode, loc: equalToken.loc.start, message: 'There should be no space after \'=\'', - fix: function(fixer) { + fix: function (fixer) { return fixer.removeRange([equalToken.range[1], attrNode.value.range[0]]); } }); @@ -83,7 +83,7 @@ module.exports = { node: attrNode, loc: equalToken.loc.start, message: 'A space is required before \'=\'', - fix: function(fixer) { + fix: function (fixer) { return fixer.insertTextBefore(equalToken, ' '); } }); @@ -93,7 +93,7 @@ module.exports = { node: attrNode, loc: equalToken.loc.start, message: 'A space is required after \'=\'', - fix: function(fixer) { + fix: function (fixer) { return fixer.insertTextAfter(equalToken, ' '); } }); diff --git a/lib/rules/jsx-filename-extension.js b/lib/rules/jsx-filename-extension.js index 7e7a7c1439..2686960564 100644 --- a/lib/rules/jsx-filename-extension.js +++ b/lib/rules/jsx-filename-extension.js @@ -42,7 +42,7 @@ module.exports = { }] }, - create: function(context) { + create: function (context) { let invalidExtension; let invalidNode; @@ -79,7 +79,7 @@ module.exports = { JSXElement: handleJSX, JSXFragment: handleJSX, - 'Program:exit': function() { + 'Program:exit': function () { if (!invalidNode) { return; } diff --git a/lib/rules/jsx-first-prop-new-line.js b/lib/rules/jsx-first-prop-new-line.js index dddc0cd993..1dd1aa62f2 100644 --- a/lib/rules/jsx-first-prop-new-line.js +++ b/lib/rules/jsx-first-prop-new-line.js @@ -44,7 +44,7 @@ module.exports = { context.report({ node: decl, message: 'Property should be placed on a new line', - fix: function(fixer) { + fix: function (fixer) { return fixer.replaceTextRange([node.name.range[1], decl.range[0]], '\n'); } }); @@ -57,7 +57,7 @@ module.exports = { context.report({ node: firstNode, message: 'Property should be placed on the same line as the component declaration', - fix: function(fixer) { + fix: function (fixer) { return fixer.replaceTextRange([node.name.range[1], firstNode.range[0]], ' '); } }); diff --git a/lib/rules/jsx-fragments.js b/lib/rules/jsx-fragments.js index 10060036e4..eab38a4f7a 100644 --- a/lib/rules/jsx-fragments.js +++ b/lib/rules/jsx-fragments.js @@ -33,7 +33,7 @@ module.exports = { }] }, - create: function(context) { + create: function (context) { const configuration = context.options[0] || 'syntax'; const sourceCode = context.getSourceCode(); const reactPragma = pragmaUtil.getFromContext(context); @@ -57,7 +57,7 @@ module.exports = { } function getFixerToLong(jsxFragment) { - return function(fixer) { + return function (fixer) { let source = sourceCode.getText(); source = replaceNode(source, jsxFragment.closingFragment, closeFragLong); source = replaceNode(source, jsxFragment.openingFragment, openFragLong); @@ -69,7 +69,7 @@ module.exports = { } function getFixerToShort(jsxElement) { - return function(fixer) { + return function (fixer) { let source = sourceCode.getText(); let lengthDiff; if (jsxElement.closingElement) { diff --git a/lib/rules/jsx-handler-names.js b/lib/rules/jsx-handler-names.js index 29a2db3d3b..cc683ac706 100644 --- a/lib/rules/jsx-handler-names.js +++ b/lib/rules/jsx-handler-names.js @@ -33,7 +33,7 @@ module.exports = { }] }, - create: function(context) { + create: function (context) { const sourceCode = context.getSourceCode(); const configuration = context.options[0] || {}; const eventHandlerPrefix = configuration.eventHandlerPrefix || 'handle'; @@ -43,7 +43,7 @@ module.exports = { const PROP_EVENT_HANDLER_REGEX = new RegExp(`^(${eventHandlerPropPrefix}[A-Z].*|ref)$`); return { - JSXAttribute: function(node) { + JSXAttribute: function (node) { if (!node.value || !node.value.expression || !node.value.expression.object) { return; } diff --git a/lib/rules/jsx-indent-props.js b/lib/rules/jsx-indent-props.js index 1509b64c89..fe30534e83 100644 --- a/lib/rules/jsx-indent-props.js +++ b/lib/rules/jsx-indent-props.js @@ -54,7 +54,7 @@ module.exports = { }] }, - create: function(context) { + create: function (context) { const MESSAGE = 'Expected indentation of {{needed}} {{type}} {{characters}} but found {{gotten}}.'; const extraColumnStart = 0; @@ -95,7 +95,7 @@ module.exports = { node: node, message: MESSAGE, data: msgContext, - fix: function(fixer) { + fix: function (fixer) { return fixer.replaceTextRange([node.range[0] - node.loc.start.column, node.range[0]], Array(needed + 1).join(indentType === 'space' ? ' ' : '\t')); } @@ -141,7 +141,7 @@ module.exports = { } return { - JSXOpeningElement: function(node) { + JSXOpeningElement: function (node) { if (!node.attributes.length) { return; } diff --git a/lib/rules/jsx-indent.js b/lib/rules/jsx-indent.js index 4b133fc364..9e97ccd8c8 100644 --- a/lib/rules/jsx-indent.js +++ b/lib/rules/jsx-indent.js @@ -64,7 +64,7 @@ module.exports = { }] }, - create: function(context) { + create: function (context) { const MESSAGE = 'Expected indentation of {{needed}} {{type}} {{characters}} but found {{gotten}}.'; const extraColumnStart = 0; @@ -96,7 +96,7 @@ module.exports = { * @private */ function getFixerFunction(node, needed) { - return function(fixer) { + return function (fixer) { const indent = Array(needed + 1).join(indentChar); return fixer.replaceTextRange( [node.range[0] - node.loc.start.column, node.range[0]], @@ -274,7 +274,7 @@ module.exports = { JSXClosingElement: handleClosingElement, JSXClosingFragment: handleClosingElement, JSXAttribute: handleAttribute, - JSXExpressionContainer: function(node) { + JSXExpressionContainer: function (node) { if (!node.parent) { return; } diff --git a/lib/rules/jsx-key.js b/lib/rules/jsx-key.js index 4583531f38..b468d19215 100644 --- a/lib/rules/jsx-key.js +++ b/lib/rules/jsx-key.js @@ -23,7 +23,7 @@ module.exports = { schema: [] }, - create: function(context) { + create: function (context) { function checkIteratorElement(node) { if (node.type === 'JSXElement' && !hasProp(node.openingElement.attributes, 'key')) { context.report({ @@ -38,7 +38,7 @@ module.exports = { } return { - JSXElement: function(node) { + JSXElement: function (node) { if (hasProp(node.openingElement.attributes, 'key')) { return; } diff --git a/lib/rules/jsx-max-depth.js b/lib/rules/jsx-max-depth.js index 7c64f93b64..04a32ae213 100644 --- a/lib/rules/jsx-max-depth.js +++ b/lib/rules/jsx-max-depth.js @@ -33,7 +33,7 @@ module.exports = { } ] }, - create: function(context) { + create: function (context) { const MESSAGE = 'Expected the depth of nested jsx elements to be <= {{needed}}, but found {{found}}.'; const DEFAULT_DEPTH = 2; @@ -131,7 +131,7 @@ module.exports = { JSXElement: handleJSX, JSXFragment: handleJSX, - JSXExpressionContainer: function(node) { + JSXExpressionContainer: function (node) { if (node.expression.type !== 'Identifier') { return; } diff --git a/lib/rules/jsx-max-props-per-line.js b/lib/rules/jsx-max-props-per-line.js index 2fa8d96423..96d900a5e1 100644 --- a/lib/rules/jsx-max-props-per-line.js +++ b/lib/rules/jsx-max-props-per-line.js @@ -62,7 +62,7 @@ module.exports = { }, '')); } const code = output.join('\n'); - return function(fixer) { + return function (fixer) { return fixer.replaceTextRange([front, back], code); }; } diff --git a/lib/rules/jsx-no-comment-textnodes.js b/lib/rules/jsx-no-comment-textnodes.js index 62da4e5b73..3ea2f9e395 100644 --- a/lib/rules/jsx-no-comment-textnodes.js +++ b/lib/rules/jsx-no-comment-textnodes.js @@ -26,7 +26,7 @@ module.exports = { }] }, - create: function(context) { + create: function (context) { function reportLiteralNode(node) { context.report(node, 'Comments inside children section of tag should be placed inside braces'); } @@ -36,7 +36,7 @@ module.exports = { // -------------------------------------------------------------------------- return { - Literal: function(node) { + Literal: function (node) { const sourceCode = context.getSourceCode(); // since babel-eslint has the wrong node.raw, we'll get the source text const rawValue = sourceCode.getText(node); diff --git a/lib/rules/jsx-no-literals.js b/lib/rules/jsx-no-literals.js index d6bff3ad00..2d645e7108 100644 --- a/lib/rules/jsx-no-literals.js +++ b/lib/rules/jsx-no-literals.js @@ -31,7 +31,7 @@ module.exports = { }] }, - create: function(context) { + create: function (context) { const isNoStrings = context.options[0] ? context.options[0].noStrings : false; const sourceCode = context.getSourceCode(); @@ -72,19 +72,19 @@ module.exports = { return { - Literal: function(node) { + Literal: function (node) { if (getValidation(node)) { reportLiteralNode(node); } }, - JSXText: function(node) { + JSXText: function (node) { if (getValidation(node)) { reportLiteralNode(node); } }, - TemplateLiteral: function(node) { + TemplateLiteral: function (node) { const parent = getParentIgnoringBinaryExpressions(node); if (isNoStrings && parent.type === 'JSXExpressionContainer') { reportLiteralNode(node); diff --git a/lib/rules/jsx-no-target-blank.js b/lib/rules/jsx-no-target-blank.js index 07aae2fa1c..ef5428603b 100644 --- a/lib/rules/jsx-no-target-blank.js +++ b/lib/rules/jsx-no-target-blank.js @@ -61,13 +61,13 @@ module.exports = { }] }, - create: function(context) { + create: function (context) { const configuration = context.options[0] || {}; const enforceDynamicLinks = configuration.enforceDynamicLinks || 'always'; const components = linkComponentsUtil.getLinkComponents(context); return { - JSXAttribute: function(node) { + JSXAttribute: function (node) { if (!components.has(node.parent.name.name) || !isTargetBlank(node) || hasSecureRel(node.parent)) { return; } diff --git a/lib/rules/jsx-no-undef.js b/lib/rules/jsx-no-undef.js index fc8a3bd2e5..76209fad93 100644 --- a/lib/rules/jsx-no-undef.js +++ b/lib/rules/jsx-no-undef.js @@ -31,7 +31,7 @@ module.exports = { }] }, - create: function(context) { + create: function (context) { const config = context.options[0] || {}; const allowGlobals = config.allowGlobals || false; @@ -83,7 +83,7 @@ module.exports = { } return { - JSXOpeningElement: function(node) { + JSXOpeningElement: function (node) { switch (node.name.type) { case 'JSXIdentifier': if (jsxUtil.isDOMComponent(node)) { diff --git a/lib/rules/jsx-one-expression-per-line.js b/lib/rules/jsx-one-expression-per-line.js index d733a03d79..b250cc4825 100644 --- a/lib/rules/jsx-one-expression-per-line.js +++ b/lib/rules/jsx-one-expression-per-line.js @@ -42,11 +42,11 @@ module.exports = { const options = Object.assign({}, optionDefaults, context.options[0]); const sourceCode = context.getSourceCode(); - function nodeKey (node) { + function nodeKey(node) { return `${node.loc.start.line},${node.loc.start.column}`; } - function nodeDescriptor (n) { + function nodeDescriptor(n) { return n.openingElement ? n.openingElement.name.name : sourceCode.getText(n).replace(/\n/g, ''); } @@ -144,13 +144,13 @@ module.exports = { // nextChild = childrenGroupedByLine[line][i + 1]; } - function spaceBetweenPrev () { + function spaceBetweenPrev() { return ((prevChild.type === 'Literal' || prevChild.type === 'JSXText') && / $/.test(prevChild.raw)) || ((child.type === 'Literal' || child.type === 'JSXText') && /^ /.test(child.raw)) || sourceCode.isSpaceBetweenTokens(prevChild, child); } - function spaceBetweenNext () { + function spaceBetweenNext() { return ((nextChild.type === 'Literal' || nextChild.type === 'JSXText') && /^ /.test(nextChild.raw)) || ((child.type === 'Literal' || child.type === 'JSXText') && / $/.test(child.raw)) || sourceCode.isSpaceBetweenTokens(child, nextChild); diff --git a/lib/rules/jsx-pascal-case.js b/lib/rules/jsx-pascal-case.js index e7629c57cd..9e6e83abe8 100644 --- a/lib/rules/jsx-pascal-case.js +++ b/lib/rules/jsx-pascal-case.js @@ -43,13 +43,13 @@ module.exports = { }] }, - create: function(context) { + create: function (context) { const configuration = context.options[0] || {}; const allowAllCaps = configuration.allowAllCaps || false; const ignore = configuration.ignore || []; return { - JSXOpeningElement: function(node) { + JSXOpeningElement: function (node) { let name = elementType(node); // Get namespace if the type is JSXNamespacedName or JSXMemberExpression diff --git a/lib/rules/jsx-props-no-multi-spaces.js b/lib/rules/jsx-props-no-multi-spaces.js index 8ce2cb48ff..efa4584abb 100644 --- a/lib/rules/jsx-props-no-multi-spaces.js +++ b/lib/rules/jsx-props-no-multi-spaces.js @@ -48,7 +48,7 @@ module.exports = { context.report({ node: node, message: `Expected only one space between "${getPropName(prev)}" and "${getPropName(node)}"`, - fix: function(fixer) { + fix: function (fixer) { return fixer.replaceTextRange([prev.range[1], node.range[0]], ' '); } }); diff --git a/lib/rules/jsx-sort-default-props.js b/lib/rules/jsx-sort-default-props.js index 13e869fec0..1138b15cc5 100644 --- a/lib/rules/jsx-sort-default-props.js +++ b/lib/rules/jsx-sort-default-props.js @@ -32,7 +32,7 @@ module.exports = { }] }, - create: function(context) { + create: function (context) { const sourceCode = context.getSourceCode(); const configuration = context.options[0] || {}; const ignoreCase = configuration.ignoreCase || false; @@ -148,7 +148,7 @@ module.exports = { // -------------------------------------------------------------------------- return { - ClassProperty: function(node) { + ClassProperty: function (node) { if (!isDefaultPropsDeclaration(node)) { return; } @@ -156,7 +156,7 @@ module.exports = { checkNode(node.value); }, - MemberExpression: function(node) { + MemberExpression: function (node) { if (!isDefaultPropsDeclaration(node)) { return; } diff --git a/lib/rules/jsx-sort-props.js b/lib/rules/jsx-sort-props.js index 75a5d45e78..d3a0df8225 100644 --- a/lib/rules/jsx-sort-props.js +++ b/lib/rules/jsx-sort-props.js @@ -123,7 +123,7 @@ const generateFixerFunction = (node, context, reservedList) => { ) ); - return function(fixer) { + return function (fixer) { const fixers = []; let source = sourceCode.getText(); @@ -171,14 +171,14 @@ function validateReservedFirstConfig(context, reservedFirst) { }); if (reservedFirst.length === 0) { - return function(decl) { + return function (decl) { context.report({ node: decl, message: 'A customized reserved first list must not be empty' }); }; } else if (nonReservedWords.length > 0) { - return function(decl) { + return function (decl) { context.report({ node: decl, message: 'A customized reserved first list must only contain a subset of React reserved props.' + @@ -233,7 +233,7 @@ module.exports = { }] }, - create: function(context) { + create: function (context) { const configuration = context.options[0] || {}; const ignoreCase = configuration.ignoreCase || false; const callbacksLast = configuration.callbacksLast || false; @@ -245,7 +245,7 @@ module.exports = { let reservedList = Array.isArray(reservedFirst) ? reservedFirst : RESERVED_PROPS_LIST; return { - JSXOpeningElement: function(node) { + JSXOpeningElement: function (node) { // `dangerouslySetInnerHTML` is only "reserved" on DOM components if (reservedFirst && !jsxUtil.isDOMComponent(node)) { reservedList = reservedList.filter(prop => prop !== 'dangerouslySetInnerHTML'); diff --git a/lib/rules/jsx-space-before-closing.js b/lib/rules/jsx-space-before-closing.js index a436fe9e09..2122b68177 100644 --- a/lib/rules/jsx-space-before-closing.js +++ b/lib/rules/jsx-space-before-closing.js @@ -31,7 +31,7 @@ module.exports = { }] }, - create: function(context) { + create: function (context) { const configuration = context.options[0] || 'always'; const sourceCode = context.getSourceCode(); @@ -43,7 +43,7 @@ module.exports = { // -------------------------------------------------------------------------- return { - JSXOpeningElement: function(node) { + JSXOpeningElement: function (node) { if (!node.selfClosing) { return; } @@ -59,7 +59,7 @@ module.exports = { context.report({ loc: closingSlash.loc.start, message: ALWAYS_MESSAGE, - fix: function(fixer) { + fix: function (fixer) { return fixer.insertTextBefore(closingSlash, ' '); } }); @@ -67,7 +67,7 @@ module.exports = { context.report({ loc: closingSlash.loc.start, message: NEVER_MESSAGE, - fix: function(fixer) { + fix: function (fixer) { const previousToken = sourceCode.getTokenBefore(closingSlash); return fixer.removeRange([previousToken.range[1], closingSlash.range[0]]); } @@ -75,7 +75,7 @@ module.exports = { } }, - Program: function() { + Program: function () { if (isWarnedForDeprecation) { return; } diff --git a/lib/rules/jsx-tag-spacing.js b/lib/rules/jsx-tag-spacing.js index 95ab10090e..872ebd6ca4 100644 --- a/lib/rules/jsx-tag-spacing.js +++ b/lib/rules/jsx-tag-spacing.js @@ -35,7 +35,7 @@ function validateClosingSlash(context, node, option) { end: lastTokens[1].loc.end }, message: SELF_CLOSING_NEVER_MESSAGE, - fix: function(fixer) { + fix: function (fixer) { return fixer.removeRange([lastTokens[0].range[1], lastTokens[1].range[0]]); } }); @@ -48,7 +48,7 @@ function validateClosingSlash(context, node, option) { end: lastTokens[1].loc.end }, message: SELF_CLOSING_ALWAYS_MESSAGE, - fix: function(fixer) { + fix: function (fixer) { return fixer.insertTextBefore(lastTokens[1], ' '); } }); @@ -67,7 +67,7 @@ function validateClosingSlash(context, node, option) { end: firstTokens[1].loc.end }, message: NEVER_MESSAGE, - fix: function(fixer) { + fix: function (fixer) { return fixer.removeRange([firstTokens[0].range[1], firstTokens[1].range[0]]); } }); @@ -80,7 +80,7 @@ function validateClosingSlash(context, node, option) { end: firstTokens[1].loc.end }, message: ALWAYS_MESSAGE, - fix: function(fixer) { + fix: function (fixer) { return fixer.insertTextBefore(firstTokens[1], ' '); } }); @@ -106,7 +106,7 @@ function validateBeforeSelfClosing(context, node, option) { node: node, loc: closingSlash.loc.start, message: ALWAYS_MESSAGE, - fix: function(fixer) { + fix: function (fixer) { return fixer.insertTextBefore(closingSlash, ' '); } }); @@ -115,7 +115,7 @@ function validateBeforeSelfClosing(context, node, option) { node: node, loc: closingSlash.loc.start, message: NEVER_MESSAGE, - fix: function(fixer) { + fix: function (fixer) { const previousToken = sourceCode.getTokenBefore(closingSlash); return fixer.removeRange([previousToken.range[1], closingSlash.range[0]]); } @@ -148,7 +148,7 @@ function validateAfterOpening(context, node, option) { end: node.name.loc.start }, message: NEVER_MESSAGE, - fix: function(fixer) { + fix: function (fixer) { return fixer.removeRange([openingToken.range[1], node.name.range[0]]); } }); @@ -161,7 +161,7 @@ function validateAfterOpening(context, node, option) { end: node.name.loc.start }, message: ALWAYS_MESSAGE, - fix: function(fixer) { + fix: function (fixer) { return fixer.insertTextBefore(node.name, ' '); } }); @@ -194,7 +194,7 @@ function validateBeforeClosing(context, node, option) { end: closingToken.loc.start }, message: NEVER_MESSAGE, - fix: function(fixer) { + fix: function (fixer) { return fixer.removeRange([leftToken.range[1], closingToken.range[0]]); } }); @@ -206,7 +206,7 @@ function validateBeforeClosing(context, node, option) { end: closingToken.loc.start }, message: ALWAYS_MESSAGE, - fix: function(fixer) { + fix: function (fixer) { return fixer.insertTextBefore(closingToken, ' '); } }); diff --git a/lib/rules/jsx-uses-react.js b/lib/rules/jsx-uses-react.js index ffafc4049d..3d3dfbef50 100644 --- a/lib/rules/jsx-uses-react.js +++ b/lib/rules/jsx-uses-react.js @@ -22,7 +22,7 @@ module.exports = { schema: [] }, - create: function(context) { + create: function (context) { const pragma = pragmaUtil.getFromContext(context); function handleOpeningElement() { diff --git a/lib/rules/jsx-uses-vars.js b/lib/rules/jsx-uses-vars.js index 8fb0967c37..184e7e1f75 100644 --- a/lib/rules/jsx-uses-vars.js +++ b/lib/rules/jsx-uses-vars.js @@ -21,9 +21,9 @@ module.exports = { schema: [] }, - create: function(context) { + create: function (context) { return { - JSXOpeningElement: function(node) { + JSXOpeningElement: function (node) { let name; if (node.name.namespace && node.name.namespace.name) { // diff --git a/lib/rules/jsx-wrap-multilines.js b/lib/rules/jsx-wrap-multilines.js index 53434daf3f..584a1d12f9 100644 --- a/lib/rules/jsx-wrap-multilines.js +++ b/lib/rules/jsx-wrap-multilines.js @@ -69,7 +69,7 @@ module.exports = { }] }, - create: function(context) { + create: function (context) { const sourceCode = context.getSourceCode(); function getOption(type) { @@ -195,7 +195,7 @@ module.exports = { return { - VariableDeclarator: function(node) { + VariableDeclarator: function (node) { const type = 'declaration'; if (!isEnabled(type)) { return; @@ -208,7 +208,7 @@ module.exports = { check(node.init, type); }, - AssignmentExpression: function(node) { + AssignmentExpression: function (node) { const type = 'assignment'; if (!isEnabled(type)) { return; @@ -221,14 +221,14 @@ module.exports = { check(node.right, type); }, - ReturnStatement: function(node) { + ReturnStatement: function (node) { const type = 'return'; if (isEnabled(type)) { check(node.argument, type); } }, - 'ArrowFunctionExpression:exit': function(node) { + 'ArrowFunctionExpression:exit': function (node) { const arrowBody = node.body; const type = 'arrow'; @@ -237,7 +237,7 @@ module.exports = { } }, - ConditionalExpression: function(node) { + ConditionalExpression: function (node) { const type = 'condition'; if (isEnabled(type)) { check(node.consequent, type); @@ -245,14 +245,14 @@ module.exports = { } }, - LogicalExpression: function(node) { + LogicalExpression: function (node) { const type = 'logical'; if (isEnabled(type)) { check(node.right, type); } }, - JSXAttribute: function(node) { + JSXAttribute: function (node) { const type = 'prop'; if (isEnabled(type) && node.value && node.value.type === 'JSXExpressionContainer') { check(node.value.expression, type); diff --git a/lib/rules/no-access-state-in-setstate.js b/lib/rules/no-access-state-in-setstate.js index e656d57f2b..027a4c4355 100644 --- a/lib/rules/no-access-state-in-setstate.js +++ b/lib/rules/no-access-state-in-setstate.js @@ -21,7 +21,7 @@ module.exports = { } }, - create: function(context) { + create: function (context) { function isSetStateCall(node) { return node.type === 'CallExpression' && node.callee.property && diff --git a/lib/rules/no-array-index-key.js b/lib/rules/no-array-index-key.js index 0d0a7f3fdc..cb8a9d8ee9 100644 --- a/lib/rules/no-array-index-key.js +++ b/lib/rules/no-array-index-key.js @@ -25,7 +25,7 @@ module.exports = { schema: [] }, - create: function(context) { + create: function (context) { // -------------------------------------------------------------------------- // Public // -------------------------------------------------------------------------- @@ -155,7 +155,7 @@ module.exports = { } return { - CallExpression: function(node) { + CallExpression: function (node) { if ( node.callee && node.callee.type === 'MemberExpression' @@ -194,7 +194,7 @@ module.exports = { indexParamNames.push(mapIndexParamName); }, - JSXAttribute: function(node) { + JSXAttribute: function (node) { if (node.name.name !== 'key') { // foo={bar} return; @@ -214,7 +214,7 @@ module.exports = { checkPropValue(value.expression); }, - 'CallExpression:exit': function(node) { + 'CallExpression:exit': function (node) { const mapIndexParamName = getMapIndexParamName(node); if (!mapIndexParamName) { return; diff --git a/lib/rules/no-children-prop.js b/lib/rules/no-children-prop.js index f8e341dab7..b3b426acba 100644 --- a/lib/rules/no-children-prop.js +++ b/lib/rules/no-children-prop.js @@ -38,9 +38,9 @@ module.exports = { }, schema: [] }, - create: function(context) { + create: function (context) { return { - JSXAttribute: function(node) { + JSXAttribute: function (node) { if (node.name.name !== 'children') { return; } @@ -50,7 +50,7 @@ module.exports = { message: 'Do not pass children as props. Instead, nest children between the opening and closing tags.' }); }, - CallExpression: function(node) { + CallExpression: function (node) { if (!isCreateElementWithProps(node)) { return; } diff --git a/lib/rules/no-danger-with-children.js b/lib/rules/no-danger-with-children.js index af2af06672..3645955387 100644 --- a/lib/rules/no-danger-with-children.js +++ b/lib/rules/no-danger-with-children.js @@ -20,7 +20,7 @@ module.exports = { }, schema: [] // no options }, - create: function(context) { + create: function (context) { function findSpreadVariable(name) { return variableUtil.variablesInScope(context).find(item => item.name === name); } diff --git a/lib/rules/no-danger.js b/lib/rules/no-danger.js index 8fca290438..f671771ef0 100644 --- a/lib/rules/no-danger.js +++ b/lib/rules/no-danger.js @@ -50,10 +50,10 @@ module.exports = { schema: [] }, - create: function(context) { + create: function (context) { return { - JSXAttribute: function(node) { + JSXAttribute: function (node) { if (jsxUtil.isDOMComponent(node.parent) && isDangerous(node.name.name)) { context.report({ node: node, diff --git a/lib/rules/no-deprecated.js b/lib/rules/no-deprecated.js index 401c8df5aa..c46891ae97 100644 --- a/lib/rules/no-deprecated.js +++ b/lib/rules/no-deprecated.js @@ -179,11 +179,11 @@ module.exports = { return { - MemberExpression: function(node) { + MemberExpression: function (node) { checkDeprecation(node, sourceCode.getText(node)); }, - ImportDeclaration: function(node) { + ImportDeclaration: function (node) { const isReactImport = typeof MODULES[node.source.value] !== 'undefined'; if (!isReactImport) { return; @@ -196,7 +196,7 @@ module.exports = { }); }, - VariableDeclarator: function(node) { + VariableDeclarator: function (node) { const reactModuleName = getReactModuleName(node); const isRequire = node.init && node.init.callee && node.init.callee.name === 'require'; const isReactRequire = node.init diff --git a/lib/rules/no-direct-mutation-state.js b/lib/rules/no-direct-mutation-state.js index bbb9c62a12..9b51cf32b5 100644 --- a/lib/rules/no-direct-mutation-state.js +++ b/lib/rules/no-direct-mutation-state.js @@ -80,7 +80,7 @@ module.exports = { } }, - CallExpression: function(node) { + CallExpression: function (node) { components.set(node, { inCallExpression: true }); @@ -118,7 +118,7 @@ module.exports = { } }, - 'CallExpression:exit': function(node) { + 'CallExpression:exit': function (node) { components.set(node, { inCallExpression: false }); diff --git a/lib/rules/no-find-dom-node.js b/lib/rules/no-find-dom-node.js index 1beb30c84e..7db149b299 100644 --- a/lib/rules/no-find-dom-node.js +++ b/lib/rules/no-find-dom-node.js @@ -21,14 +21,14 @@ module.exports = { schema: [] }, - create: function(context) { + create: function (context) { // -------------------------------------------------------------------------- // Public // -------------------------------------------------------------------------- return { - CallExpression: function(node) { + CallExpression: function (node) { const callee = node.callee; const isfindDOMNode = diff --git a/lib/rules/no-is-mounted.js b/lib/rules/no-is-mounted.js index 23a9084d23..e5b4d7bedd 100644 --- a/lib/rules/no-is-mounted.js +++ b/lib/rules/no-is-mounted.js @@ -21,14 +21,14 @@ module.exports = { schema: [] }, - create: function(context) { + create: function (context) { // -------------------------------------------------------------------------- // Public // -------------------------------------------------------------------------- return { - CallExpression: function(node) { + CallExpression: function (node) { const callee = node.callee; if (callee.type !== 'MemberExpression') { return; diff --git a/lib/rules/no-multi-comp.js b/lib/rules/no-multi-comp.js index 9675bfec55..68beb34655 100644 --- a/lib/rules/no-multi-comp.js +++ b/lib/rules/no-multi-comp.js @@ -57,7 +57,7 @@ module.exports = { // -------------------------------------------------------------------------- return { - 'Program:exit': function() { + 'Program:exit': function () { if (components.length() <= 1) { return; } diff --git a/lib/rules/no-render-return-value.js b/lib/rules/no-render-return-value.js index 6303c35224..c5c3731d6c 100644 --- a/lib/rules/no-render-return-value.js +++ b/lib/rules/no-render-return-value.js @@ -22,7 +22,7 @@ module.exports = { schema: [] }, - create: function(context) { + create: function (context) { // -------------------------------------------------------------------------- // Public // -------------------------------------------------------------------------- @@ -38,7 +38,7 @@ module.exports = { return { - CallExpression: function(node) { + CallExpression: function (node) { const callee = node.callee; const parent = node.parent; if (callee.type !== 'MemberExpression') { diff --git a/lib/rules/no-set-state.js b/lib/rules/no-set-state.js index f5dc97f699..46470f5ea7 100644 --- a/lib/rules/no-set-state.js +++ b/lib/rules/no-set-state.js @@ -53,7 +53,7 @@ module.exports = { return { - CallExpression: function(node) { + CallExpression: function (node) { const callee = node.callee; if ( callee.type !== 'MemberExpression' || @@ -71,7 +71,7 @@ module.exports = { }); }, - 'Program:exit': function() { + 'Program:exit': function () { const list = components.list(); Object.keys(list).filter(component => !isValid(list[component])).forEach(component => { reportSetStateUsages(list[component]); diff --git a/lib/rules/no-string-refs.js b/lib/rules/no-string-refs.js index 7af866f6b4..22726a3b9f 100644 --- a/lib/rules/no-string-refs.js +++ b/lib/rules/no-string-refs.js @@ -90,7 +90,7 @@ module.exports = { } return { - MemberExpression: function(node) { + MemberExpression: function (node) { if (isRefsUsage(node)) { context.report({ node: node, @@ -98,7 +98,7 @@ module.exports = { }); } }, - JSXAttribute: function(node) { + JSXAttribute: function (node) { if ( isRefAttribute(node) && (containsStringLiteral(node) || containsStringExpressionContainer(node)) diff --git a/lib/rules/no-typos.js b/lib/rules/no-typos.js index 47e2b7fdf1..add89b8731 100644 --- a/lib/rules/no-typos.js +++ b/lib/rules/no-typos.js @@ -118,7 +118,7 @@ module.exports = { /* eslint-enable no-use-before-define */ - function checkValidPropObject (node) { + function checkValidPropObject(node) { if (node && node.type === 'ObjectExpression') { node.properties.forEach(prop => checkValidProp(prop.value)); } @@ -153,7 +153,7 @@ module.exports = { } return { - ImportDeclaration: function(node) { + ImportDeclaration: function (node) { if (node.source && node.source.value === 'prop-types') { // import PropType from "prop-types" propTypesPackageName = node.specifiers[0].local.name; } else if (node.source && node.source.value === 'react') { // import { PropTypes } from "react" @@ -171,7 +171,7 @@ module.exports = { } }, - ClassProperty: function(node) { + ClassProperty: function (node) { if (!node.static || !utils.isES6Component(node.parent.parent)) { return; } @@ -181,7 +181,7 @@ module.exports = { reportErrorIfPropertyCasingTypo(node.value, propertyName, true); }, - MemberExpression: function(node) { + MemberExpression: function (node) { const propertyName = node.property.name; if ( @@ -202,7 +202,7 @@ module.exports = { } }, - MethodDefinition: function(node) { + MethodDefinition: function (node) { if (!utils.isES6Component(node.parent.parent)) { return; } @@ -210,7 +210,7 @@ module.exports = { reportErrorIfLifecycleMethodCasingTypo(node); }, - ObjectExpression: function(node) { + ObjectExpression: function (node) { const component = utils.isES5Component(node) && components.get(node); if (!component) { diff --git a/lib/rules/no-unescaped-entities.js b/lib/rules/no-unescaped-entities.js index 3a2f263c2d..23d1390756 100644 --- a/lib/rules/no-unescaped-entities.js +++ b/lib/rules/no-unescaped-entities.js @@ -66,7 +66,7 @@ module.exports = { }] }, - create: function(context) { + create: function (context) { function reportInvalidEntity(node) { const configuration = context.options[0] || {}; const entities = configuration.forbid || DEFAULTS; @@ -108,7 +108,7 @@ module.exports = { } return { - 'Literal, JSXText': function(node) { + 'Literal, JSXText': function (node) { if (jsxUtil.isJSX(node.parent)) { reportInvalidEntity(node); } diff --git a/lib/rules/no-unknown-property.js b/lib/rules/no-unknown-property.js index 25508df044..4a83a7b3de 100644 --- a/lib/rules/no-unknown-property.js +++ b/lib/rules/no-unknown-property.js @@ -229,7 +229,7 @@ module.exports = { }] }, - create: function(context) { + create: function (context) { function getIgnoreConfig() { return context.options[0] && context.options[0].ignore || DEFAULTS.ignore; } @@ -238,7 +238,7 @@ module.exports = { return { - JSXAttribute: function(node) { + JSXAttribute: function (node) { const ignoreNames = getIgnoreConfig(); const name = sourceCode.getText(node.name); if (ignoreNames.indexOf(name) >= 0) { @@ -275,7 +275,7 @@ module.exports = { name: name, standardName: standardName }, - fix: function(fixer) { + fix: function (fixer) { return fixer.replaceText(node.name, standardName); } }); diff --git a/lib/rules/no-unused-prop-types.js b/lib/rules/no-unused-prop-types.js index 79488f16c0..47508e86a5 100644 --- a/lib/rules/no-unused-prop-types.js +++ b/lib/rules/no-unused-prop-types.js @@ -84,7 +84,7 @@ module.exports = { * @param {Object} component The component to process * @param {ASTNode[]|true} props List of props to validate */ - function reportUnusedPropType (component, props) { + function reportUnusedPropType(component, props) { // Skip props that check instances if (props === true) { return; @@ -129,7 +129,7 @@ module.exports = { // -------------------------------------------------------------------------- return { - 'Program:exit': function() { + 'Program:exit': function () { const list = components.list(); // Report undeclared proptypes for all classes Object.keys(list).filter(component => mustBeValidated(list[component])).forEach(component => { diff --git a/lib/rules/prefer-es6-class.js b/lib/rules/prefer-es6-class.js index c5e510a27e..5f52bf4a10 100644 --- a/lib/rules/prefer-es6-class.js +++ b/lib/rules/prefer-es6-class.js @@ -29,7 +29,7 @@ module.exports = { const configuration = context.options[0] || 'always'; return { - ObjectExpression: function(node) { + ObjectExpression: function (node) { if (utils.isES5Component(node) && configuration === 'always') { context.report({ node: node, @@ -37,7 +37,7 @@ module.exports = { }); } }, - ClassDeclaration: function(node) { + ClassDeclaration: function (node) { if (utils.isES6Component(node) && configuration === 'never') { context.report({ node: node, diff --git a/lib/rules/prefer-stateless-function.js b/lib/rules/prefer-stateless-function.js index 0b848db87a..38d821dbbb 100644 --- a/lib/rules/prefer-stateless-function.js +++ b/lib/rules/prefer-stateless-function.js @@ -280,7 +280,7 @@ module.exports = { ClassExpression: visitClass, // Mark `this` destructuring as a usage of `this` - VariableDeclarator: function(node) { + VariableDeclarator: function (node) { // Ignore destructuring on other than `this` if (!node.id || node.id.type !== 'ObjectPattern' || !node.init || node.init.type !== 'ThisExpression') { return; @@ -298,7 +298,7 @@ module.exports = { }, // Mark `this` usage - MemberExpression: function(node) { + MemberExpression: function (node) { if (node.object.type !== 'ThisExpression') { if (node.property && node.property.name === 'childContextTypes') { const component = utils.getRelatedComponent(node); @@ -321,7 +321,7 @@ module.exports = { }, // Mark `ref` usage - JSXAttribute: function(node) { + JSXAttribute: function (node) { const name = sourceCode.getText(node.name); if (name !== 'ref') { return; @@ -330,7 +330,7 @@ module.exports = { }, // Mark `render` that do not return some JSX - ReturnStatement: function(node) { + ReturnStatement: function (node) { let blockNode; let scope = context.getScope(); while (scope) { @@ -354,7 +354,7 @@ module.exports = { markReturnAsInvalid(node); }, - 'Program:exit': function() { + 'Program:exit': function () { const list = components.list(); Object.keys(list).forEach(component => { if ( diff --git a/lib/rules/prop-types.js b/lib/rules/prop-types.js index 089536d12b..3978dcffc6 100644 --- a/lib/rules/prop-types.js +++ b/lib/rules/prop-types.js @@ -187,7 +187,7 @@ module.exports = { // -------------------------------------------------------------------------- return { - 'Program:exit': function() { + 'Program:exit': function () { const list = components.list(); // Report undeclared proptypes for all classes Object.keys(list).filter(component => mustBeValidated(list[component])).forEach(component => { diff --git a/lib/rules/react-in-jsx-scope.js b/lib/rules/react-in-jsx-scope.js index c9a39f92a1..6e7b78f3c6 100644 --- a/lib/rules/react-in-jsx-scope.js +++ b/lib/rules/react-in-jsx-scope.js @@ -23,7 +23,7 @@ module.exports = { schema: [] }, - create: function(context) { + create: function (context) { const pragma = pragmaUtil.getFromContext(context); const NOT_DEFINED_MESSAGE = '\'{{name}}\' must be in scope when using JSX'; diff --git a/lib/rules/require-default-props.js b/lib/rules/require-default-props.js index 72b67272ba..77441f8b8d 100644 --- a/lib/rules/require-default-props.js +++ b/lib/rules/require-default-props.js @@ -79,7 +79,7 @@ module.exports = { // -------------------------------------------------------------------------- return { - 'Program:exit': function() { + 'Program:exit': function () { const list = components.list(); Object.keys(list).filter(component => list[component].declaredPropTypes).forEach(component => { diff --git a/lib/rules/require-render-return.js b/lib/rules/require-render-return.js index 6e56ec9848..04b642a540 100644 --- a/lib/rules/require-render-return.js +++ b/lib/rules/require-render-return.js @@ -47,7 +47,7 @@ module.exports = { } return { - ReturnStatement: function(node) { + ReturnStatement: function (node) { const ancestors = context.getAncestors(node).reverse(); let depth = 0; for (let i = 0, j = ancestors.length; i < j; i++) { @@ -65,14 +65,14 @@ module.exports = { } }, - ArrowFunctionExpression: function(node) { + ArrowFunctionExpression: function (node) { if (node.expression === false || astUtil.getPropertyName(node.parent) !== 'render') { return; } markReturnStatementPresent(node); }, - 'Program:exit': function() { + 'Program:exit': function () { const list = components.list(); Object.keys(list).forEach(component => { if ( diff --git a/lib/rules/self-closing-comp.js b/lib/rules/self-closing-comp.js index 5a46c5bd0b..a3c94388f4 100644 --- a/lib/rules/self-closing-comp.js +++ b/lib/rules/self-closing-comp.js @@ -39,7 +39,7 @@ module.exports = { }] }, - create: function(context) { + create: function (context) { function isComponent(node) { return node.name && node.name.type === 'JSXIdentifier' && !jsxUtil.isDOMComponent(node); } @@ -73,14 +73,14 @@ module.exports = { return { - JSXOpeningElement: function(node) { + JSXOpeningElement: function (node) { if (!isShouldBeSelfClosed(node)) { return; } context.report({ node: node, message: 'Empty components are self-closing', - fix: function(fixer) { + fix: function (fixer) { // Represents the last character of the JSXOpeningElement, the '>' character const openingElementEnding = node.range[1] - 1; // Represents the last character of the JSXClosingElement, the '>' character diff --git a/lib/rules/sort-comp.js b/lib/rules/sort-comp.js index cdb8704156..f73226bdb2 100644 --- a/lib/rules/sort-comp.js +++ b/lib/rules/sort-comp.js @@ -440,7 +440,7 @@ module.exports = { } return { - 'Program:exit': function() { + 'Program:exit': function () { const list = components.list(); Object.keys(list).forEach(component => { const properties = astUtil.getComponentProperties(list[component].node); diff --git a/lib/rules/sort-prop-types.js b/lib/rules/sort-prop-types.js index 71cff4a88b..36ae7accee 100644 --- a/lib/rules/sort-prop-types.js +++ b/lib/rules/sort-prop-types.js @@ -47,7 +47,7 @@ module.exports = { }] }, - create: function(context) { + create: function (context) { const sourceCode = context.getSourceCode(); const configuration = context.options[0] || {}; const requiredFirst = configuration.requiredFirst || false; @@ -81,7 +81,7 @@ module.exports = { ); } - function getShapeProperties (node) { + function getShapeProperties(node) { return node.arguments && node.arguments[0] && node.arguments[0].properties; } @@ -264,21 +264,21 @@ module.exports = { } return { - CallExpression: function(node) { + CallExpression: function (node) { if (!sortShapeProp || !isShapeProp(node) || !(node.arguments && node.arguments[0])) { return; } checkSorted(node.arguments[0].properties); }, - ClassProperty: function(node) { + ClassProperty: function (node) { if (!propsUtil.isPropTypesDeclaration(node)) { return; } checkNode(node.value); }, - MemberExpression: function(node) { + MemberExpression: function (node) { if (!propsUtil.isPropTypesDeclaration(node)) { return; } @@ -286,7 +286,7 @@ module.exports = { checkNode(node.parent.right); }, - ObjectExpression: function(node) { + ObjectExpression: function (node) { node.properties.forEach(property => { if (!property.key) { return; diff --git a/lib/rules/style-prop-object.js b/lib/rules/style-prop-object.js index 4b9f750be5..69a4a3a3d4 100644 --- a/lib/rules/style-prop-object.js +++ b/lib/rules/style-prop-object.js @@ -22,7 +22,7 @@ module.exports = { schema: [] }, - create: function(context) { + create: function (context) { /** * @param {ASTNode} expression An Identifier node */ @@ -46,7 +46,7 @@ module.exports = { } return { - CallExpression: function(node) { + CallExpression: function (node) { if ( node.callee && node.callee.type === 'MemberExpression' @@ -66,7 +66,7 @@ module.exports = { } }, - JSXAttribute: function(node) { + JSXAttribute: function (node) { if (!node.value || node.name.name !== 'style') { return; } diff --git a/lib/rules/void-dom-elements-no-children.js b/lib/rules/void-dom-elements-no-children.js index 758ba4b04f..6faf963ba6 100644 --- a/lib/rules/void-dom-elements-no-children.js +++ b/lib/rules/void-dom-elements-no-children.js @@ -59,7 +59,7 @@ module.exports = { }, create: Components.detect((context, components, utils) => ({ - JSXElement: function(node) { + JSXElement: function (node) { const elementName = node.openingElement.name.name; if (!isVoidDOMElement(elementName)) { @@ -94,7 +94,7 @@ module.exports = { } }, - CallExpression: function(node) { + CallExpression: function (node) { if (node.callee.type !== 'MemberExpression' && node.callee.type !== 'Identifier') { return; } diff --git a/lib/util/Components.js b/lib/util/Components.js index a2dd6f72e7..af69232bc2 100644 --- a/lib/util/Components.js +++ b/lib/util/Components.js @@ -186,7 +186,7 @@ function componentRule(rule, context) { * @param {ASTNode} node The AST node being checked. * @returns {Boolean} True if the node is a React ES5 component, false if not */ - isES5Component: function(node) { + isES5Component: function (node) { if (!node.parent) { return false; } @@ -199,7 +199,7 @@ function componentRule(rule, context) { * @param {ASTNode} node The AST node being checked. * @returns {Boolean} True if the node is a React ES6 component, false if not */ - isES6Component: function(node) { + isES6Component: function (node) { if (utils.isExplicitComponent(node)) { return true; } @@ -216,7 +216,7 @@ function componentRule(rule, context) { * @param {ASTNode} node The AST node being checked (can be a ReturnStatement or an ArrowFunctionExpression). * @returns {Boolean} True if the node is explicitly declared as a descendant of a React Component, false if not */ - isExplicitComponent: function(node) { + isExplicitComponent: function (node) { let comment; // Sometimes the passed node may not have been parsed yet by eslint, and this function call crashes. // Can be removed when eslint sets "parent" property for all nodes on initial AST traversal: https://github.com/eslint/eslint-scope/issues/27 @@ -261,7 +261,7 @@ function componentRule(rule, context) { * @param {string} variable The variable name to check * @returns {Boolean} True if createElement is destructured from the pragma */ - isDestructuredFromPragmaImport: function(variable) { + isDestructuredFromPragmaImport: function (variable) { const variables = variableUtil.variablesInScope(context); const variableInScope = variableUtil.getVariable(variables, variable); if (variableInScope) { @@ -277,7 +277,7 @@ function componentRule(rule, context) { * @param {ASTNode} node The AST node being checked. * @returns {Boolean} True if createElement called from pragma */ - isCreateElement: function(node) { + isCreateElement: function (node) { const calledOnPragma = ( node && node.callee && @@ -303,7 +303,7 @@ function componentRule(rule, context) { * Check if we are in a class constructor * @return {boolean} true if we are in a class constructor, false if not */ - inConstructor: function() { + inConstructor: function () { let scope = context.getScope(); while (scope) { if (scope.block && scope.block.parent && scope.block.parent.kind === 'constructor') { @@ -319,7 +319,7 @@ function componentRule(rule, context) { * @param {Object} node The node to process * @returns {Boolean} */ - isStateMemberExpression: function(node) { + isStateMemberExpression: function (node) { return node.type === 'MemberExpression' && node.object.type === 'ThisExpression' && node.property.name === 'state'; }, @@ -354,7 +354,7 @@ function componentRule(rule, context) { * @param {Boolean} [strict] If true, in a ternary condition the node must return JSX in both cases * @returns {Boolean} True if the node is returning JSX, false if not */ - isReturningJSX: function(ASTnode, strict) { + isReturningJSX: function (ASTnode, strict) { const nodeAndProperty = utils.getReturnPropertyAndNode(ASTnode); const node = nodeAndProperty.node; const property = nodeAndProperty.property; @@ -444,7 +444,7 @@ function componentRule(rule, context) { * * @returns {ASTNode} component node, null if we are not in a component */ - getParentComponent: function() { + getParentComponent: function () { return ( utils.getParentES6Component() || utils.getParentES5Component() || @@ -457,7 +457,7 @@ function componentRule(rule, context) { * * @returns {ASTNode} component node, null if we are not in a component */ - getParentES5Component: function() { + getParentES5Component: function () { let scope = context.getScope(); while (scope) { const node = scope.block && scope.block.parent && scope.block.parent.parent; @@ -474,7 +474,7 @@ function componentRule(rule, context) { * * @returns {ASTNode} component node, null if we are not in a component */ - getParentES6Component: function() { + getParentES6Component: function () { let scope = context.getScope(); while (scope && scope.type !== 'class') { scope = scope.upper; @@ -491,7 +491,7 @@ function componentRule(rule, context) { * * @returns {ASTNode} component node, null if we are not in a component */ - getParentStatelessComponent: function() { + getParentStatelessComponent: function () { let scope = context.getScope(); while (scope) { const node = scope.block; @@ -542,7 +542,7 @@ function componentRule(rule, context) { * @param {ASTNode} node The AST node being checked (must be a MemberExpression). * @returns {ASTNode} component node, null if we cannot find the component */ - getRelatedComponent: function(node) { + getRelatedComponent: function (node) { let i; let j; let k; @@ -646,7 +646,7 @@ function componentRule(rule, context) { // Component detection instructions const detectionInstructions = { - CallExpression: function(node) { + CallExpression: function (node) { if (!utils.isPragmaComponentWrapper(node)) { return; } @@ -655,21 +655,21 @@ function componentRule(rule, context) { } }, - ClassExpression: function(node) { + ClassExpression: function (node) { if (!utils.isES6Component(node)) { return; } components.add(node, 2); }, - ClassDeclaration: function(node) { + ClassDeclaration: function (node) { if (!utils.isES6Component(node)) { return; } components.add(node, 2); }, - ClassProperty: function(node) { + ClassProperty: function (node) { node = utils.getParentComponent(); if (!node) { return; @@ -677,14 +677,14 @@ function componentRule(rule, context) { components.add(node, 2); }, - ObjectExpression: function(node) { + ObjectExpression: function (node) { if (!utils.isES5Component(node)) { return; } components.add(node, 2); }, - FunctionExpression: function(node) { + FunctionExpression: function (node) { if (node.async) { components.add(node, 0); return; @@ -701,7 +701,7 @@ function componentRule(rule, context) { components.add(component, 1); }, - FunctionDeclaration: function(node) { + FunctionDeclaration: function (node) { if (node.async) { components.add(node, 0); return; @@ -713,7 +713,7 @@ function componentRule(rule, context) { components.add(node, 1); }, - ArrowFunctionExpression: function(node) { + ArrowFunctionExpression: function (node) { if (node.async) { components.add(node, 0); return; @@ -734,7 +734,7 @@ function componentRule(rule, context) { } }, - ThisExpression: function(node) { + ThisExpression: function (node) { const component = utils.getParentComponent(); if (!component || !/Function/.test(component.type) || !node.parent.property) { return; @@ -743,7 +743,7 @@ function componentRule(rule, context) { components.add(node, 0); }, - ReturnStatement: function(node) { + ReturnStatement: function (node) { if (!utils.isReturningJSX(node)) { return; } @@ -770,7 +770,7 @@ function componentRule(rule, context) { )); allKeys.forEach(instruction => { - updatedRuleInstructions[instruction] = function(node) { + updatedRuleInstructions[instruction] = function (node) { if (instruction in detectionInstructions) { detectionInstructions[instruction](node); } diff --git a/lib/util/defaultProps.js b/lib/util/defaultProps.js index b7287e4b90..05a6f462da 100644 --- a/lib/util/defaultProps.js +++ b/lib/util/defaultProps.js @@ -98,7 +98,7 @@ module.exports = function defaultPropsInstructions(context, components, utils) { } return { - MemberExpression: function(node) { + MemberExpression: function (node) { const isDefaultProp = propsUtil.isDefaultPropsDeclaration(node); if (!isDefaultProp) { @@ -160,7 +160,7 @@ module.exports = function defaultPropsInstructions(context, components, utils) { // return
Hello {this.props.name}
; // } // } - MethodDefinition: function(node) { + MethodDefinition: function (node) { if (!node.static || node.kind !== 'get') { return; } @@ -200,7 +200,7 @@ module.exports = function defaultPropsInstructions(context, components, utils) { // bar: 'baz' // }; // } - ClassProperty: function(node) { + ClassProperty: function (node) { if (!(node.static && node.value)) { return; } @@ -237,7 +237,7 @@ module.exports = function defaultPropsInstructions(context, components, utils) { // }; // } // }); - ObjectExpression: function(node) { + ObjectExpression: function (node) { // find component this propTypes/defaultProps belongs to const component = utils.isES5Component(node) && components.get(node); if (!component) { diff --git a/lib/util/makeNoMethodSetStateRule.js b/lib/util/makeNoMethodSetStateRule.js index 0b7e164312..5306d13351 100644 --- a/lib/util/makeNoMethodSetStateRule.js +++ b/lib/util/makeNoMethodSetStateRule.js @@ -38,7 +38,7 @@ function makeNoMethodSetStateRule(methodName, shouldCheckUnsafeCb) { }] }, - create: function(context) { + create: function (context) { const mode = context.options[0] || 'allow-in-func'; function nameMatches(name) { @@ -59,7 +59,7 @@ function makeNoMethodSetStateRule(methodName, shouldCheckUnsafeCb) { return { - CallExpression: function(node) { + CallExpression: function (node) { const callee = node.callee; if ( callee.type !== 'MemberExpression' || diff --git a/lib/util/propTypes.js b/lib/util/propTypes.js index 8485591822..ec26846642 100644 --- a/lib/util/propTypes.js +++ b/lib/util/propTypes.js @@ -138,14 +138,14 @@ module.exports = function propTypesInstructions(context, components, utils) { /* eslint-disable no-use-before-define */ /** @type {TypeDeclarationBuilders} */ const typeDeclarationBuilders = { - GenericTypeAnnotation: function(annotation, parentName, seen) { + GenericTypeAnnotation: function (annotation, parentName, seen) { if (getInTypeScope(annotation.id.name)) { return buildTypeAnnotationDeclarationTypes(getInTypeScope(annotation.id.name), parentName, seen); } return {}; }, - ObjectTypeAnnotation: function(annotation, parentName, seen) { + ObjectTypeAnnotation: function (annotation, parentName, seen) { let containsObjectTypeSpread = false; const shapeTypeDefinition = { type: 'shape', @@ -172,7 +172,7 @@ module.exports = function propTypesInstructions(context, components, utils) { return shapeTypeDefinition; }, - UnionTypeAnnotation: function(annotation, parentName, seen) { + UnionTypeAnnotation: function (annotation, parentName, seen) { /** @type {UnionTypeDefinition} */ const unionTypeDefinition = { type: 'union', @@ -198,7 +198,7 @@ module.exports = function propTypesInstructions(context, components, utils) { return unionTypeDefinition; }, - ArrayTypeAnnotation: function(annotation, parentName, seen) { + ArrayTypeAnnotation: function (annotation, parentName, seen) { const fullName = [parentName, '*'].join('.'); const child = buildTypeAnnotationDeclarationTypes(annotation.elementType, fullName, seen); child.fullName = fullName; @@ -648,20 +648,20 @@ module.exports = function propTypesInstructions(context, components, utils) { } return { - ClassExpression: function(node) { + ClassExpression: function (node) { // TypeParameterDeclaration need to be added to typeScope in order to handle ClassExpressions. // This visitor is executed before TypeParameterDeclaration are scoped, therefore we postpone // processing class expressions until when the program exists. classExpressions.push(node); }, - ClassDeclaration: function(node) { + ClassDeclaration: function (node) { if (isSuperTypeParameterPropsDeclaration(node)) { markPropTypesAsDeclared(node, resolveSuperParameterPropsType(node)); } }, - ClassProperty: function(node) { + ClassProperty: function (node) { if (isAnnotatedClassPropsDeclaration(node)) { markPropTypesAsDeclared(node, resolveTypeAnnotation(node)); } else if (propsUtil.isPropTypesDeclaration(node)) { @@ -669,7 +669,7 @@ module.exports = function propTypesInstructions(context, components, utils) { } }, - ObjectExpression: function(node) { + ObjectExpression: function (node) { // Search for the proptypes declaration node.properties.forEach(property => { if (!propsUtil.isPropTypesDeclaration(property)) { @@ -679,7 +679,7 @@ module.exports = function propTypesInstructions(context, components, utils) { }); }, - FunctionExpression: function(node) { + FunctionExpression: function (node) { if (node.parent.type !== 'MethodDefinition') { markAnnotatedFunctionArgumentsAsDeclared(node); } @@ -689,7 +689,7 @@ module.exports = function propTypesInstructions(context, components, utils) { ArrowFunctionExpression: markAnnotatedFunctionArgumentsAsDeclared, - MemberExpression: function(node) { + MemberExpression: function (node) { if (propsUtil.isPropTypesDeclaration(node)) { const component = utils.getRelatedComponent(node); if (!component) { @@ -699,7 +699,7 @@ module.exports = function propTypesInstructions(context, components, utils) { } }, - MethodDefinition: function(node) { + MethodDefinition: function (node) { if (!node.static || node.kind !== 'get' || !propsUtil.isPropTypesDeclaration(node)) { return; } @@ -716,11 +716,11 @@ module.exports = function propTypesInstructions(context, components, utils) { } }, - TypeAlias: function(node) { + TypeAlias: function (node) { setInTypeScope(node.id.name, node.right); }, - TypeParameterDeclaration: function(node) { + TypeParameterDeclaration: function (node) { const identifier = node.params[0]; if (identifier.typeAnnotation) { @@ -728,7 +728,7 @@ module.exports = function propTypesInstructions(context, components, utils) { } }, - Program: function() { + Program: function () { stack = [{}]; }, @@ -740,7 +740,7 @@ module.exports = function propTypesInstructions(context, components, utils) { stack.pop(); }, - 'Program:exit': function() { + 'Program:exit': function () { classExpressions.forEach(node => { if (isSuperTypeParameterPropsDeclaration(node)) { markPropTypesAsDeclared(node, resolveSuperParameterPropsType(node)); diff --git a/lib/util/usedPropTypes.js b/lib/util/usedPropTypes.js index f57d2e636b..9e89da13a8 100755 --- a/lib/util/usedPropTypes.js +++ b/lib/util/usedPropTypes.js @@ -21,7 +21,7 @@ const ASYNC_SAFE_LIFE_CYCLE_METHODS = ['getDerivedStateFromProps', 'getSnapshotB * @param {ASTNode} node The AST node being checked. * @returns {Boolean} True if the prop name matches */ -function isPropAttributeName (node) { +function isPropAttributeName(node) { return ( node.init.name === 'props' || node.init.name === 'nextProps' || @@ -468,7 +468,7 @@ module.exports = function usedPropTypesInstructions(context, components, utils) } return { - VariableDeclarator: function(node) { + VariableDeclarator: function (node) { const destructuring = node.init && node.id && node.id.type === 'ObjectPattern'; // let {props: {firstname}} = this const thisDestructuring = destructuring && node.init.type === 'ThisExpression'; @@ -490,20 +490,20 @@ module.exports = function usedPropTypesInstructions(context, components, utils) FunctionExpression: handleFunctionLikeExpressions, - JSXSpreadAttribute: function(node) { + JSXSpreadAttribute: function (node) { const component = components.get(utils.getParentComponent()); components.set(component ? component.node : node, { ignoreUnusedPropTypesValidation: true }); }, - MemberExpression: function(node) { + MemberExpression: function (node) { if (isPropTypesUsage(node)) { markPropTypesAsUsed(node); } }, - ObjectPattern: function(node) { + ObjectPattern: function (node) { // If the object pattern is a destructured props object in a lifecycle // method -- mark it for used props. if (isNodeALifeCycleMethod(node.parent.parent) && node.properties.length > 0) { @@ -511,7 +511,7 @@ module.exports = function usedPropTypesInstructions(context, components, utils) } }, - 'Program:exit': function() { + 'Program:exit': function () { const list = components.list(); Object.keys(list).filter(component => mustBeValidated(list[component])).forEach(component => { diff --git a/tests/lib/rules/jsx-closing-bracket-location.js b/tests/lib/rules/jsx-closing-bracket-location.js index 7d9f64cafb..ea250d77d9 100644 --- a/tests/lib/rules/jsx-closing-bracket-location.js +++ b/tests/lib/rules/jsx-closing-bracket-location.js @@ -24,7 +24,7 @@ const MESSAGE_PROPS_ALIGNED = 'The closing bracket must be aligned with the last const MESSAGE_TAG_ALIGNED = 'The closing bracket must be aligned with the opening tag'; const MESSAGE_LINE_ALIGNED = 'The closing bracket must be aligned with the line containing the opening tag'; -const messageWithDetails = function(message, expectedColumn, expectedNextLine) { +const messageWithDetails = function (message, expectedColumn, expectedNextLine) { const details = ` (expected column ${expectedColumn}${expectedNextLine ? ' on the next line)' : ')'}`; return message + details; }; From 08e57f8d5b77deb0bddd6c4badb239f7493a523a Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 18 May 2019 21:55:33 -0700 Subject: [PATCH 03/28] [eslint] enable and autofix `semi-style` --- .eslintrc | 1 - lib/rules/no-find-dom-node.js | 4 +--- lib/rules/prefer-stateless-function.js | 3 +-- lib/rules/prop-types.js | 3 +-- lib/util/Components.js | 9 +++------ 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/.eslintrc b/.eslintrc index 54464a0834..b6fee0fe3b 100644 --- a/.eslintrc +++ b/.eslintrc @@ -41,7 +41,6 @@ "no-case-declarations": 1, "no-underscore-dangle": 1, "no-mixed-operators": 1, - "semi-style": 1, "no-void": 1, "no-continue": 1, "no-tabs": 1, diff --git a/lib/rules/no-find-dom-node.js b/lib/rules/no-find-dom-node.js index 7db149b299..3992fb1b70 100644 --- a/lib/rules/no-find-dom-node.js +++ b/lib/rules/no-find-dom-node.js @@ -33,9 +33,7 @@ module.exports = { const isfindDOMNode = (callee.name === 'findDOMNode') || - (callee.property && callee.property.name === 'findDOMNode') - ; - + (callee.property && callee.property.name === 'findDOMNode'); if (!isfindDOMNode) { return; } diff --git a/lib/rules/prefer-stateless-function.js b/lib/rules/prefer-stateless-function.js index 38d821dbbb..fbf54632e8 100644 --- a/lib/rules/prefer-stateless-function.js +++ b/lib/rules/prefer-stateless-function.js @@ -188,8 +188,7 @@ module.exports = { const defaultProps = name === 'defaultProps'; const isUselessConstructor = property.kind === 'constructor' && - isRedundantSuperCall(property.value.body.body, property.value.params) - ; + isRedundantSuperCall(property.value.body.body, property.value.params); const isRender = name === 'render'; return !isDisplayName && !isPropTypes && !contextTypes && !defaultProps && !isUselessConstructor && !isRender; }); diff --git a/lib/rules/prop-types.js b/lib/rules/prop-types.js index 3978dcffc6..7dc20a394c 100644 --- a/lib/rules/prop-types.js +++ b/lib/rules/prop-types.js @@ -148,8 +148,7 @@ module.exports = { const isDeclared = component && component.confidence === 2 && - _isDeclaredInComponent(component.declaredPropTypes || {}, names) - ; + _isDeclaredInComponent(component.declaredPropTypes || {}, names); if (isDeclared) { return true; } diff --git a/lib/util/Components.js b/lib/util/Components.js index af69232bc2..53ac415e08 100644 --- a/lib/util/Components.js +++ b/lib/util/Components.js @@ -366,13 +366,11 @@ function componentRule(rule, context) { const returnsConditionalJSXConsequent = node[property] && node[property].type === 'ConditionalExpression' && - jsxUtil.isJSX(node[property].consequent) - ; + jsxUtil.isJSX(node[property].consequent); const returnsConditionalJSXAlternate = node[property] && node[property].type === 'ConditionalExpression' && - jsxUtil.isJSX(node[property].alternate) - ; + jsxUtil.isJSX(node[property].alternate); const returnsConditionalJSX = strict ? (returnsConditionalJSXConsequent && returnsConditionalJSXAlternate) : @@ -380,8 +378,7 @@ function componentRule(rule, context) { const returnsJSX = node[property] && - jsxUtil.isJSX(node[property]) - ; + jsxUtil.isJSX(node[property]); const returnsPragmaCreateElement = this.isCreateElement(node[property]); return Boolean( From b700f7d0f582abb7849347c5c6983c2d1958e748 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 18 May 2019 21:57:50 -0700 Subject: [PATCH 04/28] [eslint] enable and autofix `lines-around-directive` --- .eslintrc | 1 - lib/rules/boolean-prop-naming.js | 1 + lib/rules/button-has-type.js | 1 + lib/rules/default-props-match-prop-types.js | 1 + lib/rules/destructuring-assignment.js | 1 + lib/rules/display-name.js | 1 + lib/rules/forbid-component-props.js | 1 + lib/rules/forbid-dom-props.js | 1 + lib/rules/forbid-elements.js | 1 + lib/rules/forbid-foreign-prop-types.js | 1 + lib/rules/forbid-prop-types.js | 1 + lib/rules/jsx-boolean-value.js | 1 + lib/rules/jsx-closing-bracket-location.js | 1 + lib/rules/jsx-closing-tag-location.js | 1 + lib/rules/jsx-curly-brace-presence.js | 1 + lib/rules/jsx-curly-spacing.js | 1 + lib/rules/jsx-equals-spacing.js | 1 + lib/rules/jsx-filename-extension.js | 1 + lib/rules/jsx-first-prop-new-line.js | 1 + lib/rules/jsx-fragments.js | 1 + lib/rules/jsx-handler-names.js | 1 + lib/rules/jsx-indent-props.js | 1 + lib/rules/jsx-indent.js | 1 + lib/rules/jsx-key.js | 1 + lib/rules/jsx-max-depth.js | 1 + lib/rules/jsx-no-bind.js | 1 + lib/rules/jsx-no-comment-textnodes.js | 1 + lib/rules/jsx-no-literals.js | 1 + lib/rules/jsx-no-target-blank.js | 1 + lib/rules/jsx-props-no-spreading.js | 1 + lib/rules/jsx-sort-default-props.js | 1 + lib/rules/jsx-sort-props.js | 1 + lib/rules/jsx-space-before-closing.js | 1 + lib/rules/jsx-tag-spacing.js | 1 + lib/rules/jsx-uses-react.js | 1 + lib/rules/jsx-uses-vars.js | 1 + lib/rules/jsx-wrap-multilines.js | 1 + lib/rules/no-array-index-key.js | 1 + lib/rules/no-children-prop.js | 1 + lib/rules/no-danger-with-children.js | 1 + lib/rules/no-danger.js | 1 + lib/rules/no-deprecated.js | 1 + lib/rules/no-did-mount-set-state.js | 1 + lib/rules/no-did-update-set-state.js | 1 + lib/rules/no-direct-mutation-state.js | 1 + lib/rules/no-find-dom-node.js | 1 + lib/rules/no-is-mounted.js | 1 + lib/rules/no-multi-comp.js | 1 + lib/rules/no-redundant-should-component-update.js | 1 + lib/rules/no-render-return-value.js | 1 + lib/rules/no-set-state.js | 1 + lib/rules/no-string-refs.js | 1 + lib/rules/no-this-in-sfc.js | 1 + lib/rules/no-typos.js | 1 + lib/rules/no-unescaped-entities.js | 1 + lib/rules/no-unknown-property.js | 1 + lib/rules/no-unused-prop-types.js | 1 + lib/rules/no-will-update-set-state.js | 1 + lib/rules/prefer-es6-class.js | 1 + lib/rules/prefer-read-only-props.js | 1 + lib/rules/prefer-stateless-function.js | 1 + lib/rules/prop-types.js | 1 + lib/rules/react-in-jsx-scope.js | 1 + lib/rules/require-default-props.js | 1 + lib/rules/require-optimization.js | 1 + lib/rules/require-render-return.js | 1 + lib/rules/self-closing-comp.js | 1 + lib/rules/sort-comp.js | 1 + lib/rules/sort-prop-types.js | 1 + lib/rules/state-in-constructor.js | 1 + lib/rules/static-property-placement.js | 1 + lib/rules/style-prop-object.js | 1 + lib/rules/void-dom-elements-no-children.js | 1 + lib/util/Components.js | 1 + lib/util/annotations.js | 1 + lib/util/ast.js | 1 + lib/util/defaultProps.js | 1 + lib/util/jsx.js | 1 + lib/util/linkComponents.js | 1 + lib/util/makeNoMethodSetStateRule.js | 1 + lib/util/pragma.js | 1 + lib/util/propTypes.js | 1 + lib/util/propWrapper.js | 1 + lib/util/props.js | 1 + lib/util/usedPropTypes.js | 1 + lib/util/variable.js | 1 + lib/util/version.js | 1 + tests/index.js | 1 + tests/lib/rules/boolean-prop-naming.js | 1 + tests/lib/rules/button-has-type.js | 1 + tests/lib/rules/default-props-match-prop-types.js | 1 + tests/lib/rules/destructuring-assignment.js | 1 + tests/lib/rules/display-name.js | 1 + tests/lib/rules/forbid-component-props.js | 1 + tests/lib/rules/forbid-dom-props.js | 1 + tests/lib/rules/forbid-elements.js | 1 + tests/lib/rules/forbid-foreign-prop-types.js | 1 + tests/lib/rules/forbid-prop-types.js | 1 + tests/lib/rules/jsx-boolean-value.js | 1 + tests/lib/rules/jsx-closing-bracket-location.js | 1 + tests/lib/rules/jsx-closing-tag-location.js | 1 + tests/lib/rules/jsx-curly-brace-presence.js | 1 + tests/lib/rules/jsx-curly-spacing.js | 1 + tests/lib/rules/jsx-equals-spacing.js | 1 + tests/lib/rules/jsx-filename-extension.js | 1 + tests/lib/rules/jsx-first-prop-new-line.js | 1 + tests/lib/rules/jsx-fragments.js | 1 + tests/lib/rules/jsx-handler-names.js | 1 + tests/lib/rules/jsx-indent-props.js | 1 + tests/lib/rules/jsx-indent.js | 1 + tests/lib/rules/jsx-key.js | 1 + tests/lib/rules/jsx-max-depth.js | 1 + tests/lib/rules/jsx-max-props-per-line.js | 1 + tests/lib/rules/jsx-no-bind.js | 1 + tests/lib/rules/jsx-no-comment-textnodes.js | 1 + tests/lib/rules/jsx-no-literals.js | 1 + tests/lib/rules/jsx-no-target-blank.js | 1 + tests/lib/rules/jsx-pascal-case.js | 1 + tests/lib/rules/jsx-props-no-multi-spaces.js | 1 + tests/lib/rules/jsx-props-no-spreading.js | 1 + tests/lib/rules/jsx-sort-default-props.js | 1 + tests/lib/rules/jsx-space-before-closing.js | 1 + tests/lib/rules/jsx-wrap-multilines.js | 1 + tests/lib/rules/no-access-state-in-setstate.js | 1 + tests/lib/rules/no-danger-with-children.js | 1 + tests/lib/rules/no-deprecated.js | 1 + tests/lib/rules/no-did-mount-set-state.js | 1 + tests/lib/rules/no-did-update-set-state.js | 1 + tests/lib/rules/no-direct-mutation-state.js | 1 + tests/lib/rules/no-find-dom-node.js | 1 + tests/lib/rules/no-is-mounted.js | 1 + tests/lib/rules/no-multi-comp.js | 1 + tests/lib/rules/no-render-return-value.js | 1 + tests/lib/rules/no-set-state.js | 1 + tests/lib/rules/no-string-refs.js | 1 + tests/lib/rules/no-this-in-sfc.js | 1 + tests/lib/rules/no-typos.js | 1 + tests/lib/rules/no-unescaped-entities.js | 1 + tests/lib/rules/no-unsafe.js | 1 + tests/lib/rules/no-unused-prop-types.js | 1 + tests/lib/rules/no-will-update-set-state.js | 1 + tests/lib/rules/prefer-es6-class.js | 1 + tests/lib/rules/prefer-read-only-props.js | 1 + tests/lib/rules/prefer-stateless-function.js | 1 + tests/lib/rules/prop-types.js | 1 + tests/lib/rules/require-default-props.js | 1 + tests/lib/rules/require-optimization.js | 1 + tests/lib/rules/require-render-return.js | 1 + tests/lib/rules/self-closing-comp.js | 1 + tests/lib/rules/sort-comp.js | 1 + tests/lib/rules/sort-prop-types.js | 1 + tests/lib/rules/state-in-constructor.js | 1 + tests/lib/rules/static-property-placement.js | 1 + tests/lib/rules/style-prop-object.js | 1 + 154 files changed, 153 insertions(+), 1 deletion(-) diff --git a/.eslintrc b/.eslintrc index b6fee0fe3b..8cd144b606 100644 --- a/.eslintrc +++ b/.eslintrc @@ -26,7 +26,6 @@ "object-shorthand": 1, "import/order": 1, - "lines-around-directive": 1, "no-useless-escape": 1, "arrow-parens": 1, "import/newline-after-import": 1, diff --git a/lib/rules/boolean-prop-naming.js b/lib/rules/boolean-prop-naming.js index 5666e1878c..089fad2ae4 100644 --- a/lib/rules/boolean-prop-naming.js +++ b/lib/rules/boolean-prop-naming.js @@ -2,6 +2,7 @@ * @fileoverview Enforces consistent naming for boolean props * @author Ev Haus */ + 'use strict'; const Components = require('../util/Components'); diff --git a/lib/rules/button-has-type.js b/lib/rules/button-has-type.js index a0d999e07b..055ed1c64f 100644 --- a/lib/rules/button-has-type.js +++ b/lib/rules/button-has-type.js @@ -2,6 +2,7 @@ * @fileoverview Forbid "button" element without an explicit "type" attribute * @author Filipp Riabchun */ + 'use strict'; const getProp = require('jsx-ast-utils/getProp'); diff --git a/lib/rules/default-props-match-prop-types.js b/lib/rules/default-props-match-prop-types.js index 0578226d99..3b4d77efeb 100644 --- a/lib/rules/default-props-match-prop-types.js +++ b/lib/rules/default-props-match-prop-types.js @@ -3,6 +3,7 @@ * @author Vitor Balocco * @author Roy Sutton */ + 'use strict'; const Components = require('../util/Components'); diff --git a/lib/rules/destructuring-assignment.js b/lib/rules/destructuring-assignment.js index 18616124ba..8d2ef30165 100644 --- a/lib/rules/destructuring-assignment.js +++ b/lib/rules/destructuring-assignment.js @@ -1,6 +1,7 @@ /** * @fileoverview Enforce consistent usage of destructuring assignment of props, state, and context. **/ + 'use strict'; const Components = require('../util/Components'); diff --git a/lib/rules/display-name.js b/lib/rules/display-name.js index bf8a6d41a3..d9476483fb 100644 --- a/lib/rules/display-name.js +++ b/lib/rules/display-name.js @@ -2,6 +2,7 @@ * @fileoverview Prevent missing displayName in a React component definition * @author Yannick Croissant */ + 'use strict'; const Components = require('../util/Components'); diff --git a/lib/rules/forbid-component-props.js b/lib/rules/forbid-component-props.js index 33a312ca56..04db1084a1 100644 --- a/lib/rules/forbid-component-props.js +++ b/lib/rules/forbid-component-props.js @@ -2,6 +2,7 @@ * @fileoverview Forbid certain props on components * @author Joe Lencioni */ + 'use strict'; const docsUrl = require('../util/docsUrl'); diff --git a/lib/rules/forbid-dom-props.js b/lib/rules/forbid-dom-props.js index feda69c2af..8b491c0e59 100644 --- a/lib/rules/forbid-dom-props.js +++ b/lib/rules/forbid-dom-props.js @@ -2,6 +2,7 @@ * @fileoverview Forbid certain props on DOM Nodes * @author David Vázquez */ + 'use strict'; const docsUrl = require('../util/docsUrl'); diff --git a/lib/rules/forbid-elements.js b/lib/rules/forbid-elements.js index fac71c7efa..ebd3cbd834 100644 --- a/lib/rules/forbid-elements.js +++ b/lib/rules/forbid-elements.js @@ -2,6 +2,7 @@ * @fileoverview Forbid certain elements * @author Kenneth Chung */ + 'use strict'; const has = require('has'); diff --git a/lib/rules/forbid-foreign-prop-types.js b/lib/rules/forbid-foreign-prop-types.js index 3022517da2..fb77a5f820 100644 --- a/lib/rules/forbid-foreign-prop-types.js +++ b/lib/rules/forbid-foreign-prop-types.js @@ -2,6 +2,7 @@ * @fileoverview Forbid using another component's propTypes * @author Ian Christian Myers */ + 'use strict'; const docsUrl = require('../util/docsUrl'); diff --git a/lib/rules/forbid-prop-types.js b/lib/rules/forbid-prop-types.js index 9dd2bc268e..b5fb4ecf51 100644 --- a/lib/rules/forbid-prop-types.js +++ b/lib/rules/forbid-prop-types.js @@ -1,6 +1,7 @@ /** * @fileoverview Forbid certain propTypes */ + 'use strict'; const variableUtil = require('../util/variable'); diff --git a/lib/rules/jsx-boolean-value.js b/lib/rules/jsx-boolean-value.js index e56cac289f..9316f8102f 100644 --- a/lib/rules/jsx-boolean-value.js +++ b/lib/rules/jsx-boolean-value.js @@ -2,6 +2,7 @@ * @fileoverview Enforce boolean attributes notation in JSX * @author Yannick Croissant */ + 'use strict'; const docsUrl = require('../util/docsUrl'); diff --git a/lib/rules/jsx-closing-bracket-location.js b/lib/rules/jsx-closing-bracket-location.js index ebefada7b1..9db986a2f0 100644 --- a/lib/rules/jsx-closing-bracket-location.js +++ b/lib/rules/jsx-closing-bracket-location.js @@ -2,6 +2,7 @@ * @fileoverview Validate closing bracket location in JSX * @author Yannick Croissant */ + 'use strict'; const has = require('has'); diff --git a/lib/rules/jsx-closing-tag-location.js b/lib/rules/jsx-closing-tag-location.js index ea3cde7091..9cc73727c0 100644 --- a/lib/rules/jsx-closing-tag-location.js +++ b/lib/rules/jsx-closing-tag-location.js @@ -2,6 +2,7 @@ * @fileoverview Validate closing tag location in JSX * @author Ross Solomon */ + 'use strict'; const astUtil = require('../util/ast'); diff --git a/lib/rules/jsx-curly-brace-presence.js b/lib/rules/jsx-curly-brace-presence.js index 8c98e966ab..b2f8aaf291 100755 --- a/lib/rules/jsx-curly-brace-presence.js +++ b/lib/rules/jsx-curly-brace-presence.js @@ -3,6 +3,7 @@ * @author Jacky Ho * @author Simon Lydell */ + 'use strict'; const docsUrl = require('../util/docsUrl'); diff --git a/lib/rules/jsx-curly-spacing.js b/lib/rules/jsx-curly-spacing.js index 2a3a86daa2..1c69bbd144 100644 --- a/lib/rules/jsx-curly-spacing.js +++ b/lib/rules/jsx-curly-spacing.js @@ -8,6 +8,7 @@ * @author Yannick Croissant * @author Erik Wendel */ + 'use strict'; const has = require('has'); diff --git a/lib/rules/jsx-equals-spacing.js b/lib/rules/jsx-equals-spacing.js index 6ed2b57889..f5383b3b9e 100644 --- a/lib/rules/jsx-equals-spacing.js +++ b/lib/rules/jsx-equals-spacing.js @@ -2,6 +2,7 @@ * @fileoverview Disallow or enforce spaces around equal signs in JSX attributes. * @author ryym */ + 'use strict'; const docsUrl = require('../util/docsUrl'); diff --git a/lib/rules/jsx-filename-extension.js b/lib/rules/jsx-filename-extension.js index 2686960564..1494bf0413 100644 --- a/lib/rules/jsx-filename-extension.js +++ b/lib/rules/jsx-filename-extension.js @@ -2,6 +2,7 @@ * @fileoverview Restrict file extensions that may contain JSX * @author Joe Lencioni */ + 'use strict'; const path = require('path'); diff --git a/lib/rules/jsx-first-prop-new-line.js b/lib/rules/jsx-first-prop-new-line.js index 1dd1aa62f2..1d967d25c5 100644 --- a/lib/rules/jsx-first-prop-new-line.js +++ b/lib/rules/jsx-first-prop-new-line.js @@ -2,6 +2,7 @@ * @fileoverview Ensure proper position of the first property in JSX * @author Joachim Seminck */ + 'use strict'; const docsUrl = require('../util/docsUrl'); diff --git a/lib/rules/jsx-fragments.js b/lib/rules/jsx-fragments.js index eab38a4f7a..460d24b8a6 100644 --- a/lib/rules/jsx-fragments.js +++ b/lib/rules/jsx-fragments.js @@ -2,6 +2,7 @@ * @fileoverview Enforce shorthand or standard form for React fragments. * @author Alex Zherdev */ + 'use strict'; const elementType = require('jsx-ast-utils/elementType'); diff --git a/lib/rules/jsx-handler-names.js b/lib/rules/jsx-handler-names.js index cc683ac706..2d9893d257 100644 --- a/lib/rules/jsx-handler-names.js +++ b/lib/rules/jsx-handler-names.js @@ -2,6 +2,7 @@ * @fileoverview Enforce event handler naming conventions in JSX * @author Jake Marsh */ + 'use strict'; const docsUrl = require('../util/docsUrl'); diff --git a/lib/rules/jsx-indent-props.js b/lib/rules/jsx-indent-props.js index fe30534e83..048eb2daf5 100644 --- a/lib/rules/jsx-indent-props.js +++ b/lib/rules/jsx-indent-props.js @@ -27,6 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + 'use strict'; const astUtil = require('../util/ast'); diff --git a/lib/rules/jsx-indent.js b/lib/rules/jsx-indent.js index 9e97ccd8c8..e900824973 100644 --- a/lib/rules/jsx-indent.js +++ b/lib/rules/jsx-indent.js @@ -27,6 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + 'use strict'; const astUtil = require('../util/ast'); diff --git a/lib/rules/jsx-key.js b/lib/rules/jsx-key.js index b468d19215..13afbc8b72 100644 --- a/lib/rules/jsx-key.js +++ b/lib/rules/jsx-key.js @@ -2,6 +2,7 @@ * @fileoverview Report missing `key` props in iterators/collection literals. * @author Ben Mosher */ + 'use strict'; const hasProp = require('jsx-ast-utils/hasProp'); diff --git a/lib/rules/jsx-max-depth.js b/lib/rules/jsx-max-depth.js index 04a32ae213..6b0ecddce3 100644 --- a/lib/rules/jsx-max-depth.js +++ b/lib/rules/jsx-max-depth.js @@ -2,6 +2,7 @@ * @fileoverview Validate JSX maximum depth * @author Chris */ + 'use strict'; const has = require('has'); diff --git a/lib/rules/jsx-no-bind.js b/lib/rules/jsx-no-bind.js index f6e87b22b7..10b9b10c09 100644 --- a/lib/rules/jsx-no-bind.js +++ b/lib/rules/jsx-no-bind.js @@ -4,6 +4,7 @@ * @author Daniel Lo Nigro * @author Jacky Ho */ + 'use strict'; const propName = require('jsx-ast-utils/propName'); diff --git a/lib/rules/jsx-no-comment-textnodes.js b/lib/rules/jsx-no-comment-textnodes.js index 3ea2f9e395..3ea9c7f9c7 100644 --- a/lib/rules/jsx-no-comment-textnodes.js +++ b/lib/rules/jsx-no-comment-textnodes.js @@ -2,6 +2,7 @@ * @fileoverview Comments inside children section of tag should be placed inside braces. * @author Ben Vinegar */ + 'use strict'; const docsUrl = require('../util/docsUrl'); diff --git a/lib/rules/jsx-no-literals.js b/lib/rules/jsx-no-literals.js index 2d645e7108..7d4d766caa 100644 --- a/lib/rules/jsx-no-literals.js +++ b/lib/rules/jsx-no-literals.js @@ -3,6 +3,7 @@ * @author Caleb Morris * @author David Buchan-Swanson */ + 'use strict'; const docsUrl = require('../util/docsUrl'); diff --git a/lib/rules/jsx-no-target-blank.js b/lib/rules/jsx-no-target-blank.js index ef5428603b..4f6276770c 100644 --- a/lib/rules/jsx-no-target-blank.js +++ b/lib/rules/jsx-no-target-blank.js @@ -2,6 +2,7 @@ * @fileoverview Forbid target='_blank' attribute * @author Kevin Miller */ + 'use strict'; const docsUrl = require('../util/docsUrl'); diff --git a/lib/rules/jsx-props-no-spreading.js b/lib/rules/jsx-props-no-spreading.js index f8915d8337..0be323193c 100644 --- a/lib/rules/jsx-props-no-spreading.js +++ b/lib/rules/jsx-props-no-spreading.js @@ -2,6 +2,7 @@ * @fileoverview Prevent JSX prop spreading * @author Ashish Gambhir */ + 'use strict'; const docsUrl = require('../util/docsUrl'); diff --git a/lib/rules/jsx-sort-default-props.js b/lib/rules/jsx-sort-default-props.js index 1138b15cc5..112ef1d56b 100644 --- a/lib/rules/jsx-sort-default-props.js +++ b/lib/rules/jsx-sort-default-props.js @@ -2,6 +2,7 @@ * @fileoverview Enforce default props alphabetical sorting * @author Vladimir Kattsov */ + 'use strict'; const variableUtil = require('../util/variable'); diff --git a/lib/rules/jsx-sort-props.js b/lib/rules/jsx-sort-props.js index d3a0df8225..54ad7772c8 100644 --- a/lib/rules/jsx-sort-props.js +++ b/lib/rules/jsx-sort-props.js @@ -2,6 +2,7 @@ * @fileoverview Enforce props alphabetical sorting * @author Ilya Volodin, Yannick Croissant */ + 'use strict'; const propName = require('jsx-ast-utils/propName'); diff --git a/lib/rules/jsx-space-before-closing.js b/lib/rules/jsx-space-before-closing.js index 2122b68177..84924a39b9 100644 --- a/lib/rules/jsx-space-before-closing.js +++ b/lib/rules/jsx-space-before-closing.js @@ -3,6 +3,7 @@ * @author ryym * @deprecated */ + 'use strict'; const getTokenBeforeClosingBracket = require('../util/getTokenBeforeClosingBracket'); diff --git a/lib/rules/jsx-tag-spacing.js b/lib/rules/jsx-tag-spacing.js index 872ebd6ca4..0619c7506e 100644 --- a/lib/rules/jsx-tag-spacing.js +++ b/lib/rules/jsx-tag-spacing.js @@ -2,6 +2,7 @@ * @fileoverview Validates whitespace in and around the JSX opening and closing brackets * @author Diogo Franco (Kovensky) */ + 'use strict'; const getTokenBeforeClosingBracket = require('../util/getTokenBeforeClosingBracket'); diff --git a/lib/rules/jsx-uses-react.js b/lib/rules/jsx-uses-react.js index 3d3dfbef50..10003172af 100644 --- a/lib/rules/jsx-uses-react.js +++ b/lib/rules/jsx-uses-react.js @@ -2,6 +2,7 @@ * @fileoverview Prevent React to be marked as unused * @author Glen Mailer */ + 'use strict'; const pragmaUtil = require('../util/pragma'); diff --git a/lib/rules/jsx-uses-vars.js b/lib/rules/jsx-uses-vars.js index 184e7e1f75..4c1267ed8d 100644 --- a/lib/rules/jsx-uses-vars.js +++ b/lib/rules/jsx-uses-vars.js @@ -2,6 +2,7 @@ * @fileoverview Prevent variables used in JSX to be marked as unused * @author Yannick Croissant */ + 'use strict'; const docsUrl = require('../util/docsUrl'); diff --git a/lib/rules/jsx-wrap-multilines.js b/lib/rules/jsx-wrap-multilines.js index 584a1d12f9..570c61f9be 100644 --- a/lib/rules/jsx-wrap-multilines.js +++ b/lib/rules/jsx-wrap-multilines.js @@ -2,6 +2,7 @@ * @fileoverview Prevent missing parentheses around multilines JSX * @author Yannick Croissant */ + 'use strict'; const has = require('has'); diff --git a/lib/rules/no-array-index-key.js b/lib/rules/no-array-index-key.js index cb8a9d8ee9..c479fb0981 100644 --- a/lib/rules/no-array-index-key.js +++ b/lib/rules/no-array-index-key.js @@ -2,6 +2,7 @@ * @fileoverview Prevent usage of Array index in keys * @author Joe Lencioni */ + 'use strict'; const has = require('has'); diff --git a/lib/rules/no-children-prop.js b/lib/rules/no-children-prop.js index b3b426acba..73f3199e1c 100644 --- a/lib/rules/no-children-prop.js +++ b/lib/rules/no-children-prop.js @@ -2,6 +2,7 @@ * @fileoverview Prevent passing of children as props * @author Benjamin Stepp */ + 'use strict'; const docsUrl = require('../util/docsUrl'); diff --git a/lib/rules/no-danger-with-children.js b/lib/rules/no-danger-with-children.js index 3645955387..b123c936c4 100644 --- a/lib/rules/no-danger-with-children.js +++ b/lib/rules/no-danger-with-children.js @@ -2,6 +2,7 @@ * @fileoverview Report when a DOM element is using both children and dangerouslySetInnerHTML * @author David Petersen */ + 'use strict'; const variableUtil = require('../util/variable'); diff --git a/lib/rules/no-danger.js b/lib/rules/no-danger.js index f671771ef0..faae545e30 100644 --- a/lib/rules/no-danger.js +++ b/lib/rules/no-danger.js @@ -2,6 +2,7 @@ * @fileoverview Prevent usage of dangerous JSX props * @author Scott Andrews */ + 'use strict'; const docsUrl = require('../util/docsUrl'); diff --git a/lib/rules/no-deprecated.js b/lib/rules/no-deprecated.js index c46891ae97..660acc5ac3 100644 --- a/lib/rules/no-deprecated.js +++ b/lib/rules/no-deprecated.js @@ -4,6 +4,7 @@ * @author Scott Feeney * @author Sergei Startsev */ + 'use strict'; const has = require('has'); diff --git a/lib/rules/no-did-mount-set-state.js b/lib/rules/no-did-mount-set-state.js index a3d378b2f3..a5705ef2df 100644 --- a/lib/rules/no-did-mount-set-state.js +++ b/lib/rules/no-did-mount-set-state.js @@ -2,6 +2,7 @@ * @fileoverview Prevent usage of setState in componentDidMount * @author Yannick Croissant */ + 'use strict'; const makeNoMethodSetStateRule = require('../util/makeNoMethodSetStateRule'); diff --git a/lib/rules/no-did-update-set-state.js b/lib/rules/no-did-update-set-state.js index eb14688187..5c76a1ff5b 100644 --- a/lib/rules/no-did-update-set-state.js +++ b/lib/rules/no-did-update-set-state.js @@ -2,6 +2,7 @@ * @fileoverview Prevent usage of setState in componentDidUpdate * @author Yannick Croissant */ + 'use strict'; const makeNoMethodSetStateRule = require('../util/makeNoMethodSetStateRule'); diff --git a/lib/rules/no-direct-mutation-state.js b/lib/rules/no-direct-mutation-state.js index 9b51cf32b5..26cd84b944 100644 --- a/lib/rules/no-direct-mutation-state.js +++ b/lib/rules/no-direct-mutation-state.js @@ -3,6 +3,7 @@ * @author David Petersen * @author Nicolas Fernandez <@burabure> */ + 'use strict'; const Components = require('../util/Components'); diff --git a/lib/rules/no-find-dom-node.js b/lib/rules/no-find-dom-node.js index 3992fb1b70..32762e1865 100644 --- a/lib/rules/no-find-dom-node.js +++ b/lib/rules/no-find-dom-node.js @@ -2,6 +2,7 @@ * @fileoverview Prevent usage of findDOMNode * @author Yannick Croissant */ + 'use strict'; const docsUrl = require('../util/docsUrl'); diff --git a/lib/rules/no-is-mounted.js b/lib/rules/no-is-mounted.js index e5b4d7bedd..5b45bf2347 100644 --- a/lib/rules/no-is-mounted.js +++ b/lib/rules/no-is-mounted.js @@ -2,6 +2,7 @@ * @fileoverview Prevent usage of isMounted * @author Joe Lencioni */ + 'use strict'; const docsUrl = require('../util/docsUrl'); diff --git a/lib/rules/no-multi-comp.js b/lib/rules/no-multi-comp.js index 68beb34655..a86662be58 100644 --- a/lib/rules/no-multi-comp.js +++ b/lib/rules/no-multi-comp.js @@ -2,6 +2,7 @@ * @fileoverview Prevent multiple component definition per file * @author Yannick Croissant */ + 'use strict'; const Components = require('../util/Components'); diff --git a/lib/rules/no-redundant-should-component-update.js b/lib/rules/no-redundant-should-component-update.js index de0b6e7fad..9107d0748a 100644 --- a/lib/rules/no-redundant-should-component-update.js +++ b/lib/rules/no-redundant-should-component-update.js @@ -1,6 +1,7 @@ /** * @fileoverview Flag shouldComponentUpdate when extending PureComponent */ + 'use strict'; const Components = require('../util/Components'); diff --git a/lib/rules/no-render-return-value.js b/lib/rules/no-render-return-value.js index c5c3731d6c..d53cd0664e 100644 --- a/lib/rules/no-render-return-value.js +++ b/lib/rules/no-render-return-value.js @@ -2,6 +2,7 @@ * @fileoverview Prevent usage of the return value of React.render * @author Dustan Kasten */ + 'use strict'; const versionUtil = require('../util/version'); diff --git a/lib/rules/no-set-state.js b/lib/rules/no-set-state.js index 46470f5ea7..bdea98bcc4 100644 --- a/lib/rules/no-set-state.js +++ b/lib/rules/no-set-state.js @@ -2,6 +2,7 @@ * @fileoverview Prevent usage of setState * @author Mark Dalgleish */ + 'use strict'; const Components = require('../util/Components'); diff --git a/lib/rules/no-string-refs.js b/lib/rules/no-string-refs.js index 22726a3b9f..b44e8423b8 100644 --- a/lib/rules/no-string-refs.js +++ b/lib/rules/no-string-refs.js @@ -2,6 +2,7 @@ * @fileoverview Prevent string definitions for references and prevent referencing this.refs * @author Tom Hastjarjanto */ + 'use strict'; const Components = require('../util/Components'); diff --git a/lib/rules/no-this-in-sfc.js b/lib/rules/no-this-in-sfc.js index 5d3749d71f..7dc0f6ca34 100644 --- a/lib/rules/no-this-in-sfc.js +++ b/lib/rules/no-this-in-sfc.js @@ -1,6 +1,7 @@ /** * @fileoverview Report "this" being used in stateless functional components. */ + 'use strict'; const Components = require('../util/Components'); diff --git a/lib/rules/no-typos.js b/lib/rules/no-typos.js index add89b8731..c341f11b21 100644 --- a/lib/rules/no-typos.js +++ b/lib/rules/no-typos.js @@ -1,6 +1,7 @@ /** * @fileoverview Prevent common casing typos */ + 'use strict'; const Components = require('../util/Components'); diff --git a/lib/rules/no-unescaped-entities.js b/lib/rules/no-unescaped-entities.js index 23d1390756..8e072ffe56 100644 --- a/lib/rules/no-unescaped-entities.js +++ b/lib/rules/no-unescaped-entities.js @@ -2,6 +2,7 @@ * @fileoverview HTML special characters should be escaped. * @author Patrick Hayes */ + 'use strict'; const docsUrl = require('../util/docsUrl'); diff --git a/lib/rules/no-unknown-property.js b/lib/rules/no-unknown-property.js index 4a83a7b3de..67d4082c0c 100644 --- a/lib/rules/no-unknown-property.js +++ b/lib/rules/no-unknown-property.js @@ -2,6 +2,7 @@ * @fileoverview Prevent usage of unknown DOM property * @author Yannick Croissant */ + 'use strict'; const docsUrl = require('../util/docsUrl'); diff --git a/lib/rules/no-unused-prop-types.js b/lib/rules/no-unused-prop-types.js index 47508e86a5..4ab1d5e4ef 100644 --- a/lib/rules/no-unused-prop-types.js +++ b/lib/rules/no-unused-prop-types.js @@ -2,6 +2,7 @@ * @fileoverview Prevent definitions of unused prop types * @author Evgueni Naverniouk */ + 'use strict'; // As for exceptions for props.children or props.className (and alike) look at diff --git a/lib/rules/no-will-update-set-state.js b/lib/rules/no-will-update-set-state.js index 22bb633114..0267227a73 100644 --- a/lib/rules/no-will-update-set-state.js +++ b/lib/rules/no-will-update-set-state.js @@ -2,6 +2,7 @@ * @fileoverview Prevent usage of setState in componentWillUpdate * @author Yannick Croissant */ + 'use strict'; const makeNoMethodSetStateRule = require('../util/makeNoMethodSetStateRule'); diff --git a/lib/rules/prefer-es6-class.js b/lib/rules/prefer-es6-class.js index 5f52bf4a10..55cd9f97b9 100644 --- a/lib/rules/prefer-es6-class.js +++ b/lib/rules/prefer-es6-class.js @@ -2,6 +2,7 @@ * @fileoverview Enforce ES5 or ES6 class for React Components * @author Dan Hamilton */ + 'use strict'; const Components = require('../util/Components'); diff --git a/lib/rules/prefer-read-only-props.js b/lib/rules/prefer-read-only-props.js index 31d9993b78..19d1a23458 100644 --- a/lib/rules/prefer-read-only-props.js +++ b/lib/rules/prefer-read-only-props.js @@ -2,6 +2,7 @@ * @fileoverview Require component props to be typed as read-only. * @author Luke Zapart */ + 'use strict'; const Components = require('../util/Components'); diff --git a/lib/rules/prefer-stateless-function.js b/lib/rules/prefer-stateless-function.js index fbf54632e8..f72c711623 100644 --- a/lib/rules/prefer-stateless-function.js +++ b/lib/rules/prefer-stateless-function.js @@ -4,6 +4,7 @@ * @author Alberto Rodríguez * @copyright 2015 Alberto Rodríguez. All rights reserved. */ + 'use strict'; const Components = require('../util/Components'); diff --git a/lib/rules/prop-types.js b/lib/rules/prop-types.js index 7dc20a394c..cb235d1422 100644 --- a/lib/rules/prop-types.js +++ b/lib/rules/prop-types.js @@ -2,6 +2,7 @@ * @fileoverview Prevent missing props validation in a React component definition * @author Yannick Croissant */ + 'use strict'; // As for exceptions for props.children or props.className (and alike) look at diff --git a/lib/rules/react-in-jsx-scope.js b/lib/rules/react-in-jsx-scope.js index 6e7b78f3c6..5279cdaba6 100644 --- a/lib/rules/react-in-jsx-scope.js +++ b/lib/rules/react-in-jsx-scope.js @@ -2,6 +2,7 @@ * @fileoverview Prevent missing React when using JSX * @author Glen Mailer */ + 'use strict'; const variableUtil = require('../util/variable'); diff --git a/lib/rules/require-default-props.js b/lib/rules/require-default-props.js index 77441f8b8d..77e588ac68 100644 --- a/lib/rules/require-default-props.js +++ b/lib/rules/require-default-props.js @@ -2,6 +2,7 @@ * @fileOverview Enforce a defaultProps definition for every prop that is not a required prop. * @author Vitor Balocco */ + 'use strict'; const Components = require('../util/Components'); diff --git a/lib/rules/require-optimization.js b/lib/rules/require-optimization.js index e447bdcc5a..4bce9c148b 100644 --- a/lib/rules/require-optimization.js +++ b/lib/rules/require-optimization.js @@ -2,6 +2,7 @@ * @fileoverview Enforce React components to have a shouldComponentUpdate method * @author Evgueni Naverniouk */ + 'use strict'; const Components = require('../util/Components'); diff --git a/lib/rules/require-render-return.js b/lib/rules/require-render-return.js index 04b642a540..c170e7c193 100644 --- a/lib/rules/require-render-return.js +++ b/lib/rules/require-render-return.js @@ -2,6 +2,7 @@ * @fileoverview Enforce ES5 or ES6 class for returning value in render function. * @author Mark Orel */ + 'use strict'; const Components = require('../util/Components'); diff --git a/lib/rules/self-closing-comp.js b/lib/rules/self-closing-comp.js index a3c94388f4..6178ae9d65 100644 --- a/lib/rules/self-closing-comp.js +++ b/lib/rules/self-closing-comp.js @@ -2,6 +2,7 @@ * @fileoverview Prevent extra closing tags for components without children * @author Yannick Croissant */ + 'use strict'; const docsUrl = require('../util/docsUrl'); diff --git a/lib/rules/sort-comp.js b/lib/rules/sort-comp.js index f73226bdb2..84312fa07a 100644 --- a/lib/rules/sort-comp.js +++ b/lib/rules/sort-comp.js @@ -2,6 +2,7 @@ * @fileoverview Enforce component methods order * @author Yannick Croissant */ + 'use strict'; const has = require('has'); diff --git a/lib/rules/sort-prop-types.js b/lib/rules/sort-prop-types.js index 36ae7accee..dd1698b753 100644 --- a/lib/rules/sort-prop-types.js +++ b/lib/rules/sort-prop-types.js @@ -1,6 +1,7 @@ /** * @fileoverview Enforce propTypes declarations alphabetical sorting */ + 'use strict'; const variableUtil = require('../util/variable'); diff --git a/lib/rules/state-in-constructor.js b/lib/rules/state-in-constructor.js index ebfeb65605..04acf78e6e 100644 --- a/lib/rules/state-in-constructor.js +++ b/lib/rules/state-in-constructor.js @@ -2,6 +2,7 @@ * @fileoverview Enforce the state initialization style to be either in a constructor or with a class property * @author Kanitkorn Sujautra */ + 'use strict'; const Components = require('../util/Components'); diff --git a/lib/rules/static-property-placement.js b/lib/rules/static-property-placement.js index ddeebefc7a..e1c3abc652 100644 --- a/lib/rules/static-property-placement.js +++ b/lib/rules/static-property-placement.js @@ -2,6 +2,7 @@ * @fileoverview Defines where React component static properties should be positioned. * @author Daniel Mason */ + 'use strict'; const Components = require('../util/Components'); diff --git a/lib/rules/style-prop-object.js b/lib/rules/style-prop-object.js index 69a4a3a3d4..8f8f0e35ad 100644 --- a/lib/rules/style-prop-object.js +++ b/lib/rules/style-prop-object.js @@ -2,6 +2,7 @@ * @fileoverview Enforce style prop value is an object * @author David Petersen */ + 'use strict'; const variableUtil = require('../util/variable'); diff --git a/lib/rules/void-dom-elements-no-children.js b/lib/rules/void-dom-elements-no-children.js index 6faf963ba6..6d2bde2309 100644 --- a/lib/rules/void-dom-elements-no-children.js +++ b/lib/rules/void-dom-elements-no-children.js @@ -3,6 +3,7 @@ * children * @author Joe Lencioni */ + 'use strict'; const has = require('has'); diff --git a/lib/util/Components.js b/lib/util/Components.js index 53ac415e08..0892561078 100644 --- a/lib/util/Components.js +++ b/lib/util/Components.js @@ -2,6 +2,7 @@ * @fileoverview Utility class and functions for React components detection * @author Yannick Croissant */ + 'use strict'; const doctrine = require('doctrine'); diff --git a/lib/util/annotations.js b/lib/util/annotations.js index 9586cec8c9..3b63c9d6e7 100644 --- a/lib/util/annotations.js +++ b/lib/util/annotations.js @@ -3,6 +3,7 @@ * @author Yannick Croissant * @author Vitor Balocco */ + 'use strict'; /** diff --git a/lib/util/ast.js b/lib/util/ast.js index 746bdb9ade..b1c463272c 100644 --- a/lib/util/ast.js +++ b/lib/util/ast.js @@ -1,6 +1,7 @@ /** * @fileoverview Utility functions for AST */ + 'use strict'; /** diff --git a/lib/util/defaultProps.js b/lib/util/defaultProps.js index 05a6f462da..8cfa15f0f9 100644 --- a/lib/util/defaultProps.js +++ b/lib/util/defaultProps.js @@ -1,6 +1,7 @@ /** * @fileoverview Common defaultProps detection functionality. */ + 'use strict'; const fromEntries = require('object.fromentries'); diff --git a/lib/util/jsx.js b/lib/util/jsx.js index 69849df733..adb30a9971 100644 --- a/lib/util/jsx.js +++ b/lib/util/jsx.js @@ -1,6 +1,7 @@ /** * @fileoverview Utility functions for JSX */ + 'use strict'; const elementType = require('jsx-ast-utils/elementType'); diff --git a/lib/util/linkComponents.js b/lib/util/linkComponents.js index cb9847d1f0..aa2d8da189 100644 --- a/lib/util/linkComponents.js +++ b/lib/util/linkComponents.js @@ -1,6 +1,7 @@ /** * @fileoverview Utility functions for propWrapperFunctions setting */ + 'use strict'; /** TODO: type {(string | { name: string, linkAttribute: string })[]} */ diff --git a/lib/util/makeNoMethodSetStateRule.js b/lib/util/makeNoMethodSetStateRule.js index 5306d13351..b5635a55db 100644 --- a/lib/util/makeNoMethodSetStateRule.js +++ b/lib/util/makeNoMethodSetStateRule.js @@ -2,6 +2,7 @@ * @fileoverview Prevent usage of setState in lifecycle methods * @author Yannick Croissant */ + 'use strict'; const docsUrl = require('./docsUrl'); diff --git a/lib/util/pragma.js b/lib/util/pragma.js index 27e3ed7fa7..be60f09bb8 100644 --- a/lib/util/pragma.js +++ b/lib/util/pragma.js @@ -2,6 +2,7 @@ * @fileoverview Utility functions for React pragma configuration * @author Yannick Croissant */ + 'use strict'; const JSX_ANNOTATION_REGEX = /^\*\s*@jsx\s+([^\s]+)/; diff --git a/lib/util/propTypes.js b/lib/util/propTypes.js index ec26846642..8fe2574bef 100644 --- a/lib/util/propTypes.js +++ b/lib/util/propTypes.js @@ -1,6 +1,7 @@ /** * @fileoverview Common propTypes detection functionality. */ + 'use strict'; const annotations = require('./annotations'); diff --git a/lib/util/propWrapper.js b/lib/util/propWrapper.js index 24092c43aa..aa9b9524d6 100644 --- a/lib/util/propWrapper.js +++ b/lib/util/propWrapper.js @@ -1,6 +1,7 @@ /** * @fileoverview Utility functions for propWrapperFunctions setting */ + 'use strict'; function getPropWrapperFunctions(context) { diff --git a/lib/util/props.js b/lib/util/props.js index f8b7171b30..a548afb68c 100644 --- a/lib/util/props.js +++ b/lib/util/props.js @@ -1,6 +1,7 @@ /** * @fileoverview Utility functions for props */ + 'use strict'; const astUtil = require('./ast'); diff --git a/lib/util/usedPropTypes.js b/lib/util/usedPropTypes.js index 9e89da13a8..8af655cd86 100755 --- a/lib/util/usedPropTypes.js +++ b/lib/util/usedPropTypes.js @@ -1,6 +1,7 @@ /** * @fileoverview Common used propTypes detection functionality. */ + 'use strict'; const astUtil = require('./ast'); diff --git a/lib/util/variable.js b/lib/util/variable.js index 73b761c164..92d09e4dad 100644 --- a/lib/util/variable.js +++ b/lib/util/variable.js @@ -2,6 +2,7 @@ * @fileoverview Utility functions for React components detection * @author Yannick Croissant */ + 'use strict'; /** diff --git a/lib/util/version.js b/lib/util/version.js index 5836b86549..637a5ecffd 100644 --- a/lib/util/version.js +++ b/lib/util/version.js @@ -2,6 +2,7 @@ * @fileoverview Utility functions for React and Flow version configuration * @author Yannick Croissant */ + 'use strict'; const resolve = require('resolve'); diff --git a/tests/index.js b/tests/index.js index 4c55676f51..937ede2354 100644 --- a/tests/index.js +++ b/tests/index.js @@ -1,4 +1,5 @@ /* eslint-env mocha */ + 'use strict'; const plugin = require('..'); diff --git a/tests/lib/rules/boolean-prop-naming.js b/tests/lib/rules/boolean-prop-naming.js index 0850ef682e..d6156108f4 100644 --- a/tests/lib/rules/boolean-prop-naming.js +++ b/tests/lib/rules/boolean-prop-naming.js @@ -2,6 +2,7 @@ * @fileoverview Enforces consistent naming for boolean props * @author Ev Haus */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/button-has-type.js b/tests/lib/rules/button-has-type.js index 44989a6c1c..e74b81d31d 100644 --- a/tests/lib/rules/button-has-type.js +++ b/tests/lib/rules/button-has-type.js @@ -2,6 +2,7 @@ * @fileoverview Forbid "button" element without an explicit "type" attribute * @author Filipp Riabchun */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/default-props-match-prop-types.js b/tests/lib/rules/default-props-match-prop-types.js index 8c1f3643dc..6b1e5cf7e0 100644 --- a/tests/lib/rules/default-props-match-prop-types.js +++ b/tests/lib/rules/default-props-match-prop-types.js @@ -3,6 +3,7 @@ * @author Vitor Balocco * @author Roy Sutton */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/destructuring-assignment.js b/tests/lib/rules/destructuring-assignment.js index c2bf3accc9..dfbcf88872 100644 --- a/tests/lib/rules/destructuring-assignment.js +++ b/tests/lib/rules/destructuring-assignment.js @@ -2,6 +2,7 @@ /** * @fileoverview Rule to forbid or enforce destructuring assignment consistency. **/ + 'use strict'; const rule = require('../../../lib/rules/destructuring-assignment'); diff --git a/tests/lib/rules/display-name.js b/tests/lib/rules/display-name.js index 70e25e4538..90741754fa 100644 --- a/tests/lib/rules/display-name.js +++ b/tests/lib/rules/display-name.js @@ -2,6 +2,7 @@ * @fileoverview Prevent missing displayName in a React component definition * @author Yannick Croissant */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/forbid-component-props.js b/tests/lib/rules/forbid-component-props.js index 29d625390e..e23f029c8c 100644 --- a/tests/lib/rules/forbid-component-props.js +++ b/tests/lib/rules/forbid-component-props.js @@ -1,6 +1,7 @@ /** * @fileoverview Tests for forbid-component-props */ + 'use strict'; // ----------------------------------------------------------------------------- diff --git a/tests/lib/rules/forbid-dom-props.js b/tests/lib/rules/forbid-dom-props.js index ba0f1366c3..6d4a84e7e5 100644 --- a/tests/lib/rules/forbid-dom-props.js +++ b/tests/lib/rules/forbid-dom-props.js @@ -1,6 +1,7 @@ /** * @fileoverview Tests for forbid-dom-props */ + 'use strict'; // ----------------------------------------------------------------------------- diff --git a/tests/lib/rules/forbid-elements.js b/tests/lib/rules/forbid-elements.js index dfd155c94e..45a2a86198 100644 --- a/tests/lib/rules/forbid-elements.js +++ b/tests/lib/rules/forbid-elements.js @@ -1,6 +1,7 @@ /** * @fileoverview Tests for forbid-elements */ + 'use strict'; // ----------------------------------------------------------------------------- diff --git a/tests/lib/rules/forbid-foreign-prop-types.js b/tests/lib/rules/forbid-foreign-prop-types.js index cc2c6eb4fe..47367bd378 100644 --- a/tests/lib/rules/forbid-foreign-prop-types.js +++ b/tests/lib/rules/forbid-foreign-prop-types.js @@ -1,6 +1,7 @@ /** * @fileoverview Tests for forbid-foreign-prop-types */ + 'use strict'; // ----------------------------------------------------------------------------- diff --git a/tests/lib/rules/forbid-prop-types.js b/tests/lib/rules/forbid-prop-types.js index 3e85955295..e229b8fdec 100644 --- a/tests/lib/rules/forbid-prop-types.js +++ b/tests/lib/rules/forbid-prop-types.js @@ -1,6 +1,7 @@ /** * @fileoverview Tests for forbid-prop-types */ + 'use strict'; // ----------------------------------------------------------------------------- diff --git a/tests/lib/rules/jsx-boolean-value.js b/tests/lib/rules/jsx-boolean-value.js index eb52994c02..a0b2111e6b 100644 --- a/tests/lib/rules/jsx-boolean-value.js +++ b/tests/lib/rules/jsx-boolean-value.js @@ -2,6 +2,7 @@ * @fileoverview Enforce boolean attributes notation in JSX * @author Yannick Croissant */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/jsx-closing-bracket-location.js b/tests/lib/rules/jsx-closing-bracket-location.js index ea250d77d9..be74fe4540 100644 --- a/tests/lib/rules/jsx-closing-bracket-location.js +++ b/tests/lib/rules/jsx-closing-bracket-location.js @@ -2,6 +2,7 @@ * @fileoverview Validate closing bracket location in JSX * @author Yannick Croissant */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/jsx-closing-tag-location.js b/tests/lib/rules/jsx-closing-tag-location.js index 7ac6412276..4d8c2ef97c 100644 --- a/tests/lib/rules/jsx-closing-tag-location.js +++ b/tests/lib/rules/jsx-closing-tag-location.js @@ -2,6 +2,7 @@ * @fileoverview Validate closing tag location in JSX * @author Ross Solomon */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/jsx-curly-brace-presence.js b/tests/lib/rules/jsx-curly-brace-presence.js index 0e0d202464..71fd443c2e 100755 --- a/tests/lib/rules/jsx-curly-brace-presence.js +++ b/tests/lib/rules/jsx-curly-brace-presence.js @@ -2,6 +2,7 @@ * @fileoverview Enforce curly braces or disallow unnecessary curly braces in JSX * @author Jacky Ho */ + 'use strict'; /* eslint-disable quotes */ // For better readability on tests involving quotes diff --git a/tests/lib/rules/jsx-curly-spacing.js b/tests/lib/rules/jsx-curly-spacing.js index 0a60a302a8..80f33a48aa 100644 --- a/tests/lib/rules/jsx-curly-spacing.js +++ b/tests/lib/rules/jsx-curly-spacing.js @@ -3,6 +3,7 @@ * @author Yannick Croissant * @author Erik Wendel */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/jsx-equals-spacing.js b/tests/lib/rules/jsx-equals-spacing.js index 9da8042580..df69da45c7 100644 --- a/tests/lib/rules/jsx-equals-spacing.js +++ b/tests/lib/rules/jsx-equals-spacing.js @@ -2,6 +2,7 @@ * @fileoverview Disallow or enforce spaces around equal signs in JSX attributes. * @author ryym */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/jsx-filename-extension.js b/tests/lib/rules/jsx-filename-extension.js index 61c2848fc9..101d795e0b 100644 --- a/tests/lib/rules/jsx-filename-extension.js +++ b/tests/lib/rules/jsx-filename-extension.js @@ -2,6 +2,7 @@ * @fileoverview Restrict file extensions that may contain JSX * @author Joe Lencioni */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/jsx-first-prop-new-line.js b/tests/lib/rules/jsx-first-prop-new-line.js index 949ac356c1..fdebb663d4 100644 --- a/tests/lib/rules/jsx-first-prop-new-line.js +++ b/tests/lib/rules/jsx-first-prop-new-line.js @@ -2,6 +2,7 @@ * @fileoverview Ensure proper position of the first property in JSX * @author Joachim Seminck */ + 'use strict'; // ----------------------------------------------------------------------------- diff --git a/tests/lib/rules/jsx-fragments.js b/tests/lib/rules/jsx-fragments.js index 50fd4685ec..578c10558f 100644 --- a/tests/lib/rules/jsx-fragments.js +++ b/tests/lib/rules/jsx-fragments.js @@ -2,6 +2,7 @@ * @fileoverview Tests for jsx-fragments * @author Alex Zherdev */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/jsx-handler-names.js b/tests/lib/rules/jsx-handler-names.js index 8f95d0f1f9..e4698cf374 100644 --- a/tests/lib/rules/jsx-handler-names.js +++ b/tests/lib/rules/jsx-handler-names.js @@ -2,6 +2,7 @@ * @fileoverview Tests for jsx-handler-names * @author Jake Marsh */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/jsx-indent-props.js b/tests/lib/rules/jsx-indent-props.js index dd85753ec4..db02130eff 100644 --- a/tests/lib/rules/jsx-indent-props.js +++ b/tests/lib/rules/jsx-indent-props.js @@ -2,6 +2,7 @@ * @fileoverview Validate props indentation in JSX * @author Yannick Croissant */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/jsx-indent.js b/tests/lib/rules/jsx-indent.js index b1c9715d11..04d73ba2e2 100644 --- a/tests/lib/rules/jsx-indent.js +++ b/tests/lib/rules/jsx-indent.js @@ -2,6 +2,7 @@ * @fileoverview Validate JSX indentation * @author Yannick Croissant */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/jsx-key.js b/tests/lib/rules/jsx-key.js index c0c3d9c628..d713d12445 100644 --- a/tests/lib/rules/jsx-key.js +++ b/tests/lib/rules/jsx-key.js @@ -2,6 +2,7 @@ * @fileoverview Report missing `key` props in iterators/collection literals. * @author Ben Mosher */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/jsx-max-depth.js b/tests/lib/rules/jsx-max-depth.js index 24dc9ab8ab..22d9eb5271 100644 --- a/tests/lib/rules/jsx-max-depth.js +++ b/tests/lib/rules/jsx-max-depth.js @@ -2,6 +2,7 @@ * @fileoverview Validate JSX maximum depth * @author Chris */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/jsx-max-props-per-line.js b/tests/lib/rules/jsx-max-props-per-line.js index 177ce9bbc7..7bb7487bf7 100644 --- a/tests/lib/rules/jsx-max-props-per-line.js +++ b/tests/lib/rules/jsx-max-props-per-line.js @@ -2,6 +2,7 @@ * @fileoverview Limit maximum of props on a single line in JSX * @author Yannick Croissant */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/jsx-no-bind.js b/tests/lib/rules/jsx-no-bind.js index 150e7055f4..93587c6d22 100644 --- a/tests/lib/rules/jsx-no-bind.js +++ b/tests/lib/rules/jsx-no-bind.js @@ -3,6 +3,7 @@ * in React component definition. * @author Daniel Lo Nigro */ + 'use strict'; // ----------------------------------------------------------------------------- diff --git a/tests/lib/rules/jsx-no-comment-textnodes.js b/tests/lib/rules/jsx-no-comment-textnodes.js index b8b91e0e7e..e2dcf535a0 100644 --- a/tests/lib/rules/jsx-no-comment-textnodes.js +++ b/tests/lib/rules/jsx-no-comment-textnodes.js @@ -2,6 +2,7 @@ * @fileoverview Tests for jsx-no-comment-textnodes * @author Ben Vinegar */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/jsx-no-literals.js b/tests/lib/rules/jsx-no-literals.js index 74a6e03a5f..9cb5e16df8 100644 --- a/tests/lib/rules/jsx-no-literals.js +++ b/tests/lib/rules/jsx-no-literals.js @@ -3,6 +3,7 @@ * @author Caleb morris * @author David Buchan-Swanson */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/jsx-no-target-blank.js b/tests/lib/rules/jsx-no-target-blank.js index 16ce255c55..66d0ae2669 100644 --- a/tests/lib/rules/jsx-no-target-blank.js +++ b/tests/lib/rules/jsx-no-target-blank.js @@ -2,6 +2,7 @@ * @fileoverview Forbid target='_blank' attribute * @author Kevin Miller */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/jsx-pascal-case.js b/tests/lib/rules/jsx-pascal-case.js index 2a21bf949c..a64118cca5 100644 --- a/tests/lib/rules/jsx-pascal-case.js +++ b/tests/lib/rules/jsx-pascal-case.js @@ -2,6 +2,7 @@ * @fileoverview Tests for jsx-pascal-case * @author Jake Marsh */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/jsx-props-no-multi-spaces.js b/tests/lib/rules/jsx-props-no-multi-spaces.js index ce1869d3eb..0169c0d694 100644 --- a/tests/lib/rules/jsx-props-no-multi-spaces.js +++ b/tests/lib/rules/jsx-props-no-multi-spaces.js @@ -2,6 +2,7 @@ * @fileoverview Disallow multiple spaces between inline JSX props * @author Adrian Moennich */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/jsx-props-no-spreading.js b/tests/lib/rules/jsx-props-no-spreading.js index ac4f28fffc..3efa5e37d3 100644 --- a/tests/lib/rules/jsx-props-no-spreading.js +++ b/tests/lib/rules/jsx-props-no-spreading.js @@ -1,6 +1,7 @@ /** * @fileoverview Tests for jsx-props-no-spreading */ + 'use strict'; // ----------------------------------------------------------------------------- diff --git a/tests/lib/rules/jsx-sort-default-props.js b/tests/lib/rules/jsx-sort-default-props.js index 15325f4281..b2ee89da8c 100644 --- a/tests/lib/rules/jsx-sort-default-props.js +++ b/tests/lib/rules/jsx-sort-default-props.js @@ -2,6 +2,7 @@ * @fileoverview Tests for jsx-sort-default-props * @author Vladimir Kattsov */ + 'use strict'; // ----------------------------------------------------------------------------- diff --git a/tests/lib/rules/jsx-space-before-closing.js b/tests/lib/rules/jsx-space-before-closing.js index 687b0df9ee..97d24466e1 100644 --- a/tests/lib/rules/jsx-space-before-closing.js +++ b/tests/lib/rules/jsx-space-before-closing.js @@ -2,6 +2,7 @@ * @fileoverview Validate spacing before closing bracket in JSX. * @author ryym */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/jsx-wrap-multilines.js b/tests/lib/rules/jsx-wrap-multilines.js index 9ad9891d05..39a14d32c4 100644 --- a/tests/lib/rules/jsx-wrap-multilines.js +++ b/tests/lib/rules/jsx-wrap-multilines.js @@ -2,6 +2,7 @@ * @fileoverview Prevent missing parentheses around multilines JSX * @author Yannick Croissant */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/no-access-state-in-setstate.js b/tests/lib/rules/no-access-state-in-setstate.js index 580a48d5ff..3880d6f07b 100644 --- a/tests/lib/rules/no-access-state-in-setstate.js +++ b/tests/lib/rules/no-access-state-in-setstate.js @@ -2,6 +2,7 @@ * @fileoverview Prevent usage of this.state within setState * @author Rolf Erik Lekang, Jørgen Aaberg */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/no-danger-with-children.js b/tests/lib/rules/no-danger-with-children.js index 73301db7dd..da1d36e62c 100644 --- a/tests/lib/rules/no-danger-with-children.js +++ b/tests/lib/rules/no-danger-with-children.js @@ -2,6 +2,7 @@ * @fileoverview Report when a DOM element is using both children and dangerouslySetInnerHTML * @author David Petersen */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/no-deprecated.js b/tests/lib/rules/no-deprecated.js index 0ac3e2b3f3..8c3cf11355 100644 --- a/tests/lib/rules/no-deprecated.js +++ b/tests/lib/rules/no-deprecated.js @@ -4,6 +4,7 @@ * @author Scott Feeney * @author Sergei Startsev */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/no-did-mount-set-state.js b/tests/lib/rules/no-did-mount-set-state.js index 4d660c80b3..c72e07c2dd 100644 --- a/tests/lib/rules/no-did-mount-set-state.js +++ b/tests/lib/rules/no-did-mount-set-state.js @@ -2,6 +2,7 @@ * @fileoverview Prevent usage of setState in componentDidMount * @author Yannick Croissant */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/no-did-update-set-state.js b/tests/lib/rules/no-did-update-set-state.js index e17d7300f3..aebb176c07 100644 --- a/tests/lib/rules/no-did-update-set-state.js +++ b/tests/lib/rules/no-did-update-set-state.js @@ -2,6 +2,7 @@ * @fileoverview Prevent usage of setState in componentDidUpdate * @author Yannick Croissant */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/no-direct-mutation-state.js b/tests/lib/rules/no-direct-mutation-state.js index b84bf3c071..46bd3f6e5c 100644 --- a/tests/lib/rules/no-direct-mutation-state.js +++ b/tests/lib/rules/no-direct-mutation-state.js @@ -2,6 +2,7 @@ * @fileoverview Prevent direct mutation of this.state * @author David Petersen */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/no-find-dom-node.js b/tests/lib/rules/no-find-dom-node.js index eff8dee27e..ad7ec87517 100644 --- a/tests/lib/rules/no-find-dom-node.js +++ b/tests/lib/rules/no-find-dom-node.js @@ -2,6 +2,7 @@ * @fileoverview Prevent usage of findDOMNode * @author Yannick Croissant */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/no-is-mounted.js b/tests/lib/rules/no-is-mounted.js index 1c5180b28f..443d6e256e 100644 --- a/tests/lib/rules/no-is-mounted.js +++ b/tests/lib/rules/no-is-mounted.js @@ -2,6 +2,7 @@ * @fileoverview Prevent usage of isMounted * @author Joe Lencioni */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/no-multi-comp.js b/tests/lib/rules/no-multi-comp.js index 2e8ad3cffd..37bfc1991f 100644 --- a/tests/lib/rules/no-multi-comp.js +++ b/tests/lib/rules/no-multi-comp.js @@ -2,6 +2,7 @@ * @fileoverview Prevent multiple component definition per file * @author Yannick Croissant */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/no-render-return-value.js b/tests/lib/rules/no-render-return-value.js index 4b8a45825a..1a8cdbe922 100644 --- a/tests/lib/rules/no-render-return-value.js +++ b/tests/lib/rules/no-render-return-value.js @@ -2,6 +2,7 @@ * @fileoverview Prevent usage of setState * @author Mark Dalgleish */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/no-set-state.js b/tests/lib/rules/no-set-state.js index 1e163ec0c3..a807fb0798 100644 --- a/tests/lib/rules/no-set-state.js +++ b/tests/lib/rules/no-set-state.js @@ -2,6 +2,7 @@ * @fileoverview Prevent usage of setState * @author Mark Dalgleish */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/no-string-refs.js b/tests/lib/rules/no-string-refs.js index 0d21e4e6de..9af136b488 100644 --- a/tests/lib/rules/no-string-refs.js +++ b/tests/lib/rules/no-string-refs.js @@ -2,6 +2,7 @@ * @fileoverview Prevent string definitions for references and prevent referencing this.refs * @author Tom Hastjarjanto */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/no-this-in-sfc.js b/tests/lib/rules/no-this-in-sfc.js index 318d650ae0..e9a86b5e64 100644 --- a/tests/lib/rules/no-this-in-sfc.js +++ b/tests/lib/rules/no-this-in-sfc.js @@ -1,6 +1,7 @@ /** * @fileoverview Report "this" being used in stateless functional components. */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/no-typos.js b/tests/lib/rules/no-typos.js index ef1a90b280..190dd01c15 100644 --- a/tests/lib/rules/no-typos.js +++ b/tests/lib/rules/no-typos.js @@ -1,6 +1,7 @@ /** * @fileoverview Tests for no-typos */ + 'use strict'; // ----------------------------------------------------------------------------- diff --git a/tests/lib/rules/no-unescaped-entities.js b/tests/lib/rules/no-unescaped-entities.js index b92fc3d315..5fe828e17b 100644 --- a/tests/lib/rules/no-unescaped-entities.js +++ b/tests/lib/rules/no-unescaped-entities.js @@ -2,6 +2,7 @@ * @fileoverview Tests for no-unescaped-entities * @author Patrick Hayes */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/no-unsafe.js b/tests/lib/rules/no-unsafe.js index b3184ba0e4..301bdf44e5 100644 --- a/tests/lib/rules/no-unsafe.js +++ b/tests/lib/rules/no-unsafe.js @@ -2,6 +2,7 @@ * @fileoverview Prevent usage of unsafe lifecycle methods * @author Sergei Startsev */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/no-unused-prop-types.js b/tests/lib/rules/no-unused-prop-types.js index 3a7e45a9b1..7b22d2ab1d 100644 --- a/tests/lib/rules/no-unused-prop-types.js +++ b/tests/lib/rules/no-unused-prop-types.js @@ -2,6 +2,7 @@ * @fileoverview Warn about unused PropType definitions in React components * @author Evgueni Naverniouk */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/no-will-update-set-state.js b/tests/lib/rules/no-will-update-set-state.js index b33ac8b209..8cffadf4ba 100644 --- a/tests/lib/rules/no-will-update-set-state.js +++ b/tests/lib/rules/no-will-update-set-state.js @@ -2,6 +2,7 @@ * @fileoverview Prevent usage of setState in componentWillUpdate * @author Yannick Croissant */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/prefer-es6-class.js b/tests/lib/rules/prefer-es6-class.js index d047817ce7..af823b2dd3 100644 --- a/tests/lib/rules/prefer-es6-class.js +++ b/tests/lib/rules/prefer-es6-class.js @@ -2,6 +2,7 @@ * @fileoverview Prefer es6 class instead of createClass for React Component * @author Dan Hamilton */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/prefer-read-only-props.js b/tests/lib/rules/prefer-read-only-props.js index d1cb79ff65..7430e57b03 100644 --- a/tests/lib/rules/prefer-read-only-props.js +++ b/tests/lib/rules/prefer-read-only-props.js @@ -2,6 +2,7 @@ * @fileoverview Require component props to be typed as read-only. * @author Luke Zapart */ + 'use strict'; // ----------------------------------------------------------------------------- diff --git a/tests/lib/rules/prefer-stateless-function.js b/tests/lib/rules/prefer-stateless-function.js index 8e2efd6045..9cdd42f321 100644 --- a/tests/lib/rules/prefer-stateless-function.js +++ b/tests/lib/rules/prefer-stateless-function.js @@ -2,6 +2,7 @@ * @fileoverview Enforce stateless components to be written as a pure function * @author Yannick Croissant */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/prop-types.js b/tests/lib/rules/prop-types.js index 7ff969ec19..552a6c05e1 100755 --- a/tests/lib/rules/prop-types.js +++ b/tests/lib/rules/prop-types.js @@ -2,6 +2,7 @@ * @fileoverview Prevent missing props validation in a React component definition * @author Yannick Croissant */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/require-default-props.js b/tests/lib/rules/require-default-props.js index ea606c0178..f8e7682f21 100644 --- a/tests/lib/rules/require-default-props.js +++ b/tests/lib/rules/require-default-props.js @@ -2,6 +2,7 @@ * @fileoverview Enforce a defaultProps definition for every prop that is not a required prop. * @author Vitor Balocco */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/require-optimization.js b/tests/lib/rules/require-optimization.js index e7c5a5afb5..3a723ac5aa 100644 --- a/tests/lib/rules/require-optimization.js +++ b/tests/lib/rules/require-optimization.js @@ -2,6 +2,7 @@ * @fileoverview Enforce React components to have a shouldComponentUpdate method * @author Evgueni Naverniouk */ + 'use strict'; const rule = require('../../../lib/rules/require-optimization'); diff --git a/tests/lib/rules/require-render-return.js b/tests/lib/rules/require-render-return.js index 59b5ef4b6d..cae7432737 100644 --- a/tests/lib/rules/require-render-return.js +++ b/tests/lib/rules/require-render-return.js @@ -2,6 +2,7 @@ * @fileoverview Enforce ES5 or ES6 class for returning value in render function. * @author Mark Orel */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/self-closing-comp.js b/tests/lib/rules/self-closing-comp.js index afe2538182..6d3fc113b7 100644 --- a/tests/lib/rules/self-closing-comp.js +++ b/tests/lib/rules/self-closing-comp.js @@ -2,6 +2,7 @@ * @fileoverview Prevent extra closing tags for components without children * @author Yannick Croissant */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/sort-comp.js b/tests/lib/rules/sort-comp.js index d69e6d4ba3..76811f9841 100644 --- a/tests/lib/rules/sort-comp.js +++ b/tests/lib/rules/sort-comp.js @@ -2,6 +2,7 @@ * @fileoverview Enforce component methods order * @author Yannick Croissant */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/sort-prop-types.js b/tests/lib/rules/sort-prop-types.js index 41c1c426d0..d434558588 100644 --- a/tests/lib/rules/sort-prop-types.js +++ b/tests/lib/rules/sort-prop-types.js @@ -1,6 +1,7 @@ /** * @fileoverview Tests for sort-prop-types */ + 'use strict'; // ----------------------------------------------------------------------------- diff --git a/tests/lib/rules/state-in-constructor.js b/tests/lib/rules/state-in-constructor.js index 16ad63e80e..c8d81b25e0 100644 --- a/tests/lib/rules/state-in-constructor.js +++ b/tests/lib/rules/state-in-constructor.js @@ -2,6 +2,7 @@ * @fileoverview Enforce the state initialization style to be either in a constructor or with a class property * @author Kanitkorn Sujautra */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/static-property-placement.js b/tests/lib/rules/static-property-placement.js index 3b890b512a..8a6528bd49 100644 --- a/tests/lib/rules/static-property-placement.js +++ b/tests/lib/rules/static-property-placement.js @@ -2,6 +2,7 @@ * @fileoverview Defines where React component static properties should be positioned. * @author Daniel Mason */ + 'use strict'; // ------------------------------------------------------------------------------ diff --git a/tests/lib/rules/style-prop-object.js b/tests/lib/rules/style-prop-object.js index c2d8b3d765..09deffe162 100644 --- a/tests/lib/rules/style-prop-object.js +++ b/tests/lib/rules/style-prop-object.js @@ -2,6 +2,7 @@ * @fileoverview Enforce style prop value is an object * @author David Petersen */ + 'use strict'; // ------------------------------------------------------------------------------ From d685904017d2d088f38e5820e8bce4d8e8cb1147 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 18 May 2019 21:58:47 -0700 Subject: [PATCH 05/28] [eslint] enable and autofix `no-useless-return` --- .eslintrc | 1 - lib/rules/jsx-first-prop-new-line.js | 2 -- lib/rules/no-array-index-key.js | 2 -- 3 files changed, 5 deletions(-) diff --git a/.eslintrc b/.eslintrc index 8cd144b606..1d8c665d56 100644 --- a/.eslintrc +++ b/.eslintrc @@ -47,7 +47,6 @@ "array-callback-return": 1, "no-restricted-syntax": 1, "implicit-arrow-linebreak": 1, - "no-useless-return": 1, "valid-jsdoc": 1, }, "overrides": [ diff --git a/lib/rules/jsx-first-prop-new-line.js b/lib/rules/jsx-first-prop-new-line.js index 1d967d25c5..9766a5ae3c 100644 --- a/lib/rules/jsx-first-prop-new-line.js +++ b/lib/rules/jsx-first-prop-new-line.js @@ -62,10 +62,8 @@ module.exports = { return fixer.replaceTextRange([node.name.range[1], firstNode.range[0]], ' '); } }); - return; } } - return; } }; } diff --git a/lib/rules/no-array-index-key.js b/lib/rules/no-array-index-key.js index c479fb0981..2a26871d6f 100644 --- a/lib/rules/no-array-index-key.js +++ b/lib/rules/no-array-index-key.js @@ -150,8 +150,6 @@ module.exports = { identifiers.filter(isArrayIndex).forEach(() => { context.report({node: node, message: ERROR_MESSAGE}); }); - - return; } } From 0ed8e0dfebacf63ff215613a7d5fe070cd3a0ff2 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 18 May 2019 22:00:35 -0700 Subject: [PATCH 06/28] [eslint] enable and manually fix `no-tab` --- .eslintrc | 1 - lib/rules/boolean-prop-naming.js | 6 +++--- lib/rules/no-string-refs.js | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.eslintrc b/.eslintrc index 1d8c665d56..0b7b6c2fc1 100644 --- a/.eslintrc +++ b/.eslintrc @@ -42,7 +42,6 @@ "no-mixed-operators": 1, "no-void": 1, "no-continue": 1, - "no-tabs": 1, "global-require": 1, "array-callback-return": 1, "no-restricted-syntax": 1, diff --git a/lib/rules/boolean-prop-naming.js b/lib/rules/boolean-prop-naming.js index 089fad2ae4..f18d6ae49f 100644 --- a/lib/rules/boolean-prop-naming.js +++ b/lib/rules/boolean-prop-naming.js @@ -95,9 +95,9 @@ module.exports = { } /** - * Returns the name of the given node (prop) - * @param {Object} node The node we're getting the name of - */ + * Returns the name of the given node (prop) + * @param {Object} node The node we're getting the name of + */ function getPropName(node) { // Due to this bug https://github.com/babel/babel-eslint/issues/307 // we can't get the name of the Flow object key name. So we have diff --git a/lib/rules/no-string-refs.js b/lib/rules/no-string-refs.js index b44e8423b8..36bf2e6df9 100644 --- a/lib/rules/no-string-refs.js +++ b/lib/rules/no-string-refs.js @@ -85,8 +85,8 @@ module.exports = { node.value && node.value.type === 'JSXExpressionContainer' && node.value.expression && - ((node.value.expression.type === 'Literal' && typeof node.value.expression.value === 'string') || - (node.value.expression.type === 'TemplateLiteral' && detectTemplateLiterals)) + ((node.value.expression.type === 'Literal' && typeof node.value.expression.value === 'string') || + (node.value.expression.type === 'TemplateLiteral' && detectTemplateLiterals)) ); } From 0b49ae789ff13c3a3c9f2326c822aa538d5a7fa4 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 18 May 2019 22:07:31 -0700 Subject: [PATCH 07/28] [eslint] enable and auto + manually fix `no-else-return` --- .eslintrc | 1 - lib/rules/jsx-no-bind.js | 23 +++++++------------ lib/rules/jsx-sort-default-props.js | 6 +++-- lib/rules/jsx-sort-props.js | 12 ++++++---- lib/rules/no-danger-with-children.js | 3 ++- .../no-redundant-should-component-update.js | 3 ++- lib/rules/no-unused-state.js | 6 +++-- lib/rules/prefer-stateless-function.js | 4 ++-- lib/util/Components.js | 3 ++- lib/util/ast.js | 3 ++- lib/util/propTypes.js | 3 ++- 11 files changed, 36 insertions(+), 31 deletions(-) diff --git a/.eslintrc b/.eslintrc index 0b7b6c2fc1..7e7491e082 100644 --- a/.eslintrc +++ b/.eslintrc @@ -33,7 +33,6 @@ "function-paren-newline": 0, "no-plusplus": 1, "no-param-reassign": 1, - "no-else-return": 1, "object-curly-newline": 1, "object-property-newline": 1, "spaced-comment": 1, diff --git a/lib/rules/jsx-no-bind.js b/lib/rules/jsx-no-bind.js index 10b9b10c09..3145bdb91c 100644 --- a/lib/rules/jsx-no-bind.js +++ b/lib/rules/jsx-no-bind.js @@ -87,26 +87,19 @@ module.exports = { node.callee.property.name === 'bind' ) { return 'bindCall'; - } else if ( - nodeType === 'ConditionalExpression' - ) { + } + if (nodeType === 'ConditionalExpression') { return getNodeViolationType(node.test) || getNodeViolationType(node.consequent) || getNodeViolationType(node.alternate); - } else if ( - !configuration.allowArrowFunctions && - nodeType === 'ArrowFunctionExpression' - ) { + } + if (!configuration.allowArrowFunctions && nodeType === 'ArrowFunctionExpression') { return 'arrowFunc'; - } else if ( - !configuration.allowFunctions && - nodeType === 'FunctionExpression' - ) { + } + if (!configuration.allowFunctions && nodeType === 'FunctionExpression') { return 'func'; - } else if ( - !configuration.allowBind && - nodeType === 'BindExpression' - ) { + } + if (!configuration.allowBind && nodeType === 'BindExpression') { return 'bindExpression'; } diff --git a/lib/rules/jsx-sort-default-props.js b/lib/rules/jsx-sort-default-props.js index 112ef1d56b..c7c473a916 100644 --- a/lib/rules/jsx-sort-default-props.js +++ b/lib/rules/jsx-sort-default-props.js @@ -46,11 +46,13 @@ module.exports = { function getPropertyName(node) { if (node.key || ['MethodDefinition', 'Property'].indexOf(node.type) !== -1) { return node.key.name; - } else if (node.type === 'MemberExpression') { + } + if (node.type === 'MemberExpression') { return node.property.name; // Special case for class properties // (babel-eslint@5 does not expose property name so we have to rely on tokens) - } else if (node.type === 'ClassProperty') { + } + if (node.type === 'ClassProperty') { const tokens = context.getFirstTokens(node, 2); return tokens[1] && tokens[1].type === 'Identifier' ? tokens[1].value : tokens[0].value; } diff --git a/lib/rules/jsx-sort-props.js b/lib/rules/jsx-sort-props.js index 54ad7772c8..ce5dca1318 100644 --- a/lib/rules/jsx-sort-props.js +++ b/lib/rules/jsx-sort-props.js @@ -37,7 +37,8 @@ function contextCompare(a, b, options) { const bIsReserved = isReservedPropName(bProp, options.reservedList); if (aIsReserved && !bIsReserved) { return -1; - } else if (!aIsReserved && bIsReserved) { + } + if (!aIsReserved && bIsReserved) { return 1; } } @@ -47,7 +48,8 @@ function contextCompare(a, b, options) { const bIsCallback = isCallbackPropName(bProp); if (aIsCallback && !bIsCallback) { return 1; - } else if (!aIsCallback && bIsCallback) { + } + if (!aIsCallback && bIsCallback) { return -1; } } @@ -56,7 +58,8 @@ function contextCompare(a, b, options) { const shorthandSign = options.shorthandFirst ? -1 : 1; if (!a.value && b.value) { return shorthandSign; - } else if (a.value && !b.value) { + } + if (a.value && !b.value) { return -shorthandSign; } } @@ -178,7 +181,8 @@ function validateReservedFirstConfig(context, reservedFirst) { message: 'A customized reserved first list must not be empty' }); }; - } else if (nonReservedWords.length > 0) { + } + if (nonReservedWords.length > 0) { return function (decl) { context.report({ node: decl, diff --git a/lib/rules/no-danger-with-children.js b/lib/rules/no-danger-with-children.js index b123c936c4..011c3d9db6 100644 --- a/lib/rules/no-danger-with-children.js +++ b/lib/rules/no-danger-with-children.js @@ -38,7 +38,8 @@ module.exports = { return node.properties.find(prop => { if (prop.type === 'Property') { return prop.key.name === propName; - } else if (prop.type === 'ExperimentalSpreadProperty' || prop.type === 'SpreadElement') { + } + if (prop.type === 'ExperimentalSpreadProperty' || prop.type === 'SpreadElement') { const variable = findSpreadVariable(prop.argument.name); if (variable && variable.defs.length && variable.defs[0].node.init) { if (seenProps.indexOf(prop.argument.name) > -1) { diff --git a/lib/rules/no-redundant-should-component-update.js b/lib/rules/no-redundant-should-component-update.js index 9107d0748a..89897ebdec 100644 --- a/lib/rules/no-redundant-should-component-update.js +++ b/lib/rules/no-redundant-should-component-update.js @@ -49,7 +49,8 @@ module.exports = { function getNodeName(node) { if (node.id) { return node.id.name; - } else if (node.parent && node.parent.id) { + } + if (node.parent && node.parent.id) { return node.parent.id.name; } return ''; diff --git a/lib/rules/no-unused-state.js b/lib/rules/no-unused-state.js index 0e5e392a18..1bc70e2dfc 100644 --- a/lib/rules/no-unused-state.js +++ b/lib/rules/no-unused-state.js @@ -30,9 +30,11 @@ function getName(node) { if (type === 'Identifier') { return node.name; - } else if (type === 'Literal') { + } + if (type === 'Literal') { return String(node.value); - } else if (type === 'TemplateLiteral' && node.expressions.length === 0) { + } + if (type === 'TemplateLiteral' && node.expressions.length === 0) { return node.quasis[0].value.raw; } return null; diff --git a/lib/rules/prefer-stateless-function.js b/lib/rules/prefer-stateless-function.js index f72c711623..035a97786a 100644 --- a/lib/rules/prefer-stateless-function.js +++ b/lib/rules/prefer-stateless-function.js @@ -306,11 +306,11 @@ module.exports = { return; } markChildContextTypesAsDeclared(component.node); - return; } return; // Ignore calls to `this.props` and `this.context` - } else if ( + } + if ( (node.property.name || node.property.value) === 'props' || (node.property.name || node.property.value) === 'context' ) { diff --git a/lib/util/Components.js b/lib/util/Components.js index 0892561078..2904fd4dc1 100644 --- a/lib/util/Components.js +++ b/lib/util/Components.js @@ -24,7 +24,8 @@ function usedPropTypesAreEquivalent(propA, propB) { if (propA.name === propB.name) { if (!propA.allNames && !propB.allNames) { return true; - } else if (Array.isArray(propA.allNames) && Array.isArray(propB.allNames) && propA.allNames.join('') === propB.allNames.join('')) { + } + if (Array.isArray(propA.allNames) && Array.isArray(propB.allNames) && propA.allNames.join('') === propB.allNames.join('')) { return true; } return false; diff --git a/lib/util/ast.js b/lib/util/ast.js index b1c463272c..ac44adfb5e 100644 --- a/lib/util/ast.js +++ b/lib/util/ast.js @@ -44,7 +44,8 @@ function findReturnStatement(node) { function getPropertyNameNode(node) { if (node.key || ['MethodDefinition', 'Property'].indexOf(node.type) !== -1) { return node.key; - } else if (node.type === 'MemberExpression') { + } + if (node.type === 'MemberExpression') { return node.property; } return null; diff --git a/lib/util/propTypes.js b/lib/util/propTypes.js index 8fe2574bef..175f6c5bd6 100644 --- a/lib/util/propTypes.js +++ b/lib/util/propTypes.js @@ -320,7 +320,8 @@ module.exports = function propTypesInstructions(context, components, utils) { if (!typeNode) { return true; - } else if (typeNode.type === 'IntersectionTypeAnnotation') { + } + if (typeNode.type === 'IntersectionTypeAnnotation') { return declarePropTypesForIntersectionTypeAnnotation(typeNode, declaredPropTypes); } From 04d65bbb2da344ed9a20e6e5e0d4be09bd035344 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 18 May 2019 22:23:22 -0700 Subject: [PATCH 08/28] [eslint] enable and manually fix `no-case-declarations` --- .eslintrc | 1 - lib/rules/forbid-prop-types.js | 6 ++++-- lib/rules/jsx-closing-bracket-location.js | 3 ++- lib/rules/jsx-sort-default-props.js | 6 ++++-- lib/rules/sort-prop-types.js | 6 ++++-- lib/util/propTypes.js | 18 ++++++++++++------ lib/util/usedPropTypes.js | 6 ++++-- 7 files changed, 30 insertions(+), 16 deletions(-) diff --git a/.eslintrc b/.eslintrc index 7e7491e082..d5032c8fe8 100644 --- a/.eslintrc +++ b/.eslintrc @@ -36,7 +36,6 @@ "object-curly-newline": 1, "object-property-newline": 1, "spaced-comment": 1, - "no-case-declarations": 1, "no-underscore-dangle": 1, "no-mixed-operators": 1, "no-void": 1, diff --git a/lib/rules/forbid-prop-types.js b/lib/rules/forbid-prop-types.js index b5fb4ecf51..7a7943895f 100644 --- a/lib/rules/forbid-prop-types.js +++ b/lib/rules/forbid-prop-types.js @@ -118,18 +118,20 @@ module.exports = { case 'ObjectExpression': checkProperties(node.properties); break; - case 'Identifier': + case 'Identifier': { const propTypesObject = variableUtil.findVariableByName(context, node.name); if (propTypesObject && propTypesObject.properties) { checkProperties(propTypesObject.properties); } break; - case 'CallExpression': + } + case 'CallExpression': { const innerNode = node.arguments && node.arguments[0]; if (propWrapperUtil.isPropWrapperFunction(context, context.getSource(node.callee)) && innerNode) { checkNode(innerNode); } break; + } default: break; } diff --git a/lib/rules/jsx-closing-bracket-location.js b/lib/rules/jsx-closing-bracket-location.js index 9db986a2f0..8ade3e88c5 100644 --- a/lib/rules/jsx-closing-bracket-location.js +++ b/lib/rules/jsx-closing-bracket-location.js @@ -142,9 +142,10 @@ module.exports = { return tokens.lastProp.lastLine === tokens.closing.line; case 'props-aligned': case 'tag-aligned': - case 'line-aligned': + case 'line-aligned': { const correctColumn = getCorrectColumn(tokens, expectedLocation); return correctColumn === tokens.closing.column; + } default: return true; } diff --git a/lib/rules/jsx-sort-default-props.js b/lib/rules/jsx-sort-default-props.js index c7c473a916..72a0208dcf 100644 --- a/lib/rules/jsx-sort-default-props.js +++ b/lib/rules/jsx-sort-default-props.js @@ -129,18 +129,20 @@ module.exports = { case 'ObjectExpression': checkSorted(node.properties); break; - case 'Identifier': + case 'Identifier': { const propTypesObject = findVariableByName(node.name); if (propTypesObject && propTypesObject.properties) { checkSorted(propTypesObject.properties); } break; - case 'CallExpression': + } + case 'CallExpression': { const innerNode = node.arguments && node.arguments[0]; if (propWrapperUtil.isPropWrapperFunction(context, node.callee.name) && innerNode) { checkNode(innerNode); } break; + } default: break; } diff --git a/lib/rules/sort-prop-types.js b/lib/rules/sort-prop-types.js index dd1698b753..a8f09ab13a 100644 --- a/lib/rules/sort-prop-types.js +++ b/lib/rules/sort-prop-types.js @@ -247,18 +247,20 @@ module.exports = { case 'ObjectExpression': checkSorted(node.properties); break; - case 'Identifier': + case 'Identifier': { const propTypesObject = variableUtil.findVariableByName(context, node.name); if (propTypesObject && propTypesObject.properties) { checkSorted(propTypesObject.properties); } break; - case 'CallExpression': + } + case 'CallExpression': { const innerNode = node.arguments && node.arguments[0]; if (propWrapperUtil.isPropWrapperFunction(context, node.callee.name) && innerNode) { checkNode(innerNode); } break; + } default: break; } diff --git a/lib/util/propTypes.js b/lib/util/propTypes.js index 175f6c5bd6..bb74b6e64d 100644 --- a/lib/util/propTypes.js +++ b/lib/util/propTypes.js @@ -370,7 +370,7 @@ module.exports = function propTypesInstructions(context, components, utils) { const callName = value.callee.property.name; const argument = value.arguments[0]; switch (callName) { - case 'shape': + case 'shape': { if (argument.type !== 'ObjectExpression') { // Invalid proptype or cannot analyse statically return {}; @@ -390,8 +390,9 @@ module.exports = function propTypesInstructions(context, components, utils) { } }); return shapeTypeDefinition; + } case 'arrayOf': - case 'objectOf': + case 'objectOf': { const fullName = [parentName, '*'].join('.'); const child = buildReactDeclarationTypes(argument, fullName); child.fullName = fullName; @@ -403,7 +404,8 @@ module.exports = function propTypesInstructions(context, components, utils) { __ANY_KEY__: child } }; - case 'oneOfType': + } + case 'oneOfType': { if ( !argument.elements || !argument.elements.length @@ -435,6 +437,7 @@ module.exports = function propTypesInstructions(context, components, utils) { return {}; } return unionTypeDefinition; + } case 'instanceOf': return { type: 'instance', @@ -482,7 +485,7 @@ module.exports = function propTypesInstructions(context, components, utils) { declaredPropTypes[key] = types; }); break; - case 'MemberExpression': + case 'MemberExpression': { let curDeclaredPropTypes = declaredPropTypes; // Walk the list of properties, until we reach the assignment // ie: ClassX.propTypes.a.b.c = ... @@ -537,7 +540,8 @@ module.exports = function propTypesInstructions(context, components, utils) { } } break; - case 'Identifier': + } + case 'Identifier': { const variablesInScope = variableUtil.variablesInScope(context); for (let i = 0, j = variablesInScope.length; i < j; i++) { if (variablesInScope[i].name !== propTypes.name) { @@ -549,7 +553,8 @@ module.exports = function propTypesInstructions(context, components, utils) { } ignorePropsValidation = true; break; - case 'CallExpression': + } + case 'CallExpression': { if ( propWrapperUtil.isPropWrapperFunction(context, sourceCode.getText(propTypes.callee)) && propTypes.arguments && propTypes.arguments[0] @@ -558,6 +563,7 @@ module.exports = function propTypesInstructions(context, components, utils) { return; } break; + } case 'IntersectionTypeAnnotation': ignorePropsValidation = declarePropTypesForIntersectionTypeAnnotation(propTypes, declaredPropTypes); break; diff --git a/lib/util/usedPropTypes.js b/lib/util/usedPropTypes.js index 8af655cd86..3a64883d21 100755 --- a/lib/util/usedPropTypes.js +++ b/lib/util/usedPropTypes.js @@ -364,7 +364,7 @@ module.exports = function usedPropTypesInstructions(context, components, utils) let ignoreUnusedPropTypesValidation = component && component.ignoreUnusedPropTypesValidation || false; switch (type) { - case 'direct': + case 'direct': { // Ignore Object methods if (name in Object.prototype) { break; @@ -385,7 +385,8 @@ module.exports = function usedPropTypesInstructions(context, components, utils) node: reportedNode }); break; - case 'destructuring': + } + case 'destructuring': { for (let k = 0, l = (properties || []).length; k < l; k++) { if (hasSpreadOperator(properties[k]) || properties[k].computed) { ignoreUnusedPropTypesValidation = true; @@ -409,6 +410,7 @@ module.exports = function usedPropTypesInstructions(context, components, utils) } } break; + } default: break; } From e14f2b839fcdd252fa65135daa8ad5a3af5eee70 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 18 May 2019 22:26:59 -0700 Subject: [PATCH 09/28] [eslint] enable and autofix `arrow-parens` --- .eslintrc | 1 - lib/rules/boolean-prop-naming.js | 10 +++++----- lib/rules/default-props-match-prop-types.js | 4 ++-- lib/rules/display-name.js | 4 ++-- lib/rules/forbid-component-props.js | 2 +- lib/rules/forbid-elements.js | 2 +- lib/rules/forbid-prop-types.js | 4 ++-- lib/rules/jsx-child-element-spacing.js | 4 ++-- lib/rules/jsx-curly-brace-presence.js | 4 ++-- lib/rules/jsx-equals-spacing.js | 2 +- lib/rules/jsx-first-prop-new-line.js | 2 +- lib/rules/jsx-fragments.js | 4 ++-- lib/rules/jsx-indent-props.js | 2 +- lib/rules/jsx-max-depth.js | 2 +- lib/rules/jsx-max-props-per-line.js | 2 +- lib/rules/jsx-no-bind.js | 4 ++-- lib/rules/jsx-no-duplicate-props.js | 2 +- lib/rules/jsx-no-target-blank.js | 2 +- lib/rules/jsx-one-expression-per-line.js | 6 +++--- lib/rules/jsx-sort-props.js | 4 ++-- lib/rules/jsx-wrap-multilines.js | 2 +- lib/rules/no-access-state-in-setstate.js | 6 +++--- lib/rules/no-array-index-key.js | 2 +- lib/rules/no-danger-with-children.js | 4 ++-- lib/rules/no-deprecated.js | 4 ++-- lib/rules/no-direct-mutation-state.js | 2 +- lib/rules/no-redundant-should-component-update.js | 2 +- lib/rules/no-set-state.js | 2 +- lib/rules/no-typos.js | 8 ++++---- lib/rules/no-unused-prop-types.js | 4 ++-- lib/rules/prefer-read-only-props.js | 6 +++--- lib/rules/prefer-stateless-function.js | 6 +++--- lib/rules/prop-types.js | 2 +- lib/rules/require-default-props.js | 4 ++-- lib/rules/require-optimization.js | 2 +- lib/rules/require-render-return.js | 2 +- lib/rules/sort-comp.js | 2 +- lib/rules/sort-prop-types.js | 4 ++-- lib/rules/static-property-placement.js | 6 +++--- lib/rules/void-dom-elements-no-children.js | 4 ++-- lib/util/Components.js | 8 ++++---- lib/util/defaultProps.js | 2 +- lib/util/linkComponents.js | 2 +- lib/util/propTypes.js | 8 ++++---- lib/util/propWrapper.js | 2 +- lib/util/usedPropTypes.js | 4 ++-- tests/index.js | 12 ++++++------ 47 files changed, 89 insertions(+), 90 deletions(-) diff --git a/.eslintrc b/.eslintrc index d5032c8fe8..6147ec8615 100644 --- a/.eslintrc +++ b/.eslintrc @@ -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, diff --git a/lib/rules/boolean-prop-naming.js b/lib/rules/boolean-prop-naming.js index f18d6ae49f..c5d87f72b9 100644 --- a/lib/rules/boolean-prop-naming.js +++ b/lib/rules/boolean-prop-naming.js @@ -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; @@ -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); }); @@ -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, @@ -253,7 +253,7 @@ module.exports = { } // Search for the proptypes declaration - node.properties.forEach(property => { + node.properties.forEach((property) => { if (!propsUtil.isPropTypesDeclaration(property)) { return; } @@ -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' && diff --git a/lib/rules/default-props-match-prop-types.js b/lib/rules/default-props-match-prop-types.js index 3b4d77efeb..fca3c0fae6 100644 --- a/lib/rules/default-props-match-prop-types.js +++ b/lib/rules/default-props-match-prop-types.js @@ -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]; @@ -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 d9476483fb..bb50138c4c 100644 --- a/lib/rules/display-name.js +++ b/lib/rules/display-name.js @@ -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; } @@ -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]); }); } diff --git a/lib/rules/forbid-component-props.js b/lib/rules/forbid-component-props.js index 04db1084a1..70dc3dba5f 100644 --- a/lib/rules/forbid-component-props.js +++ b/lib/rules/forbid-component-props.js @@ -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]; diff --git a/lib/rules/forbid-elements.js b/lib/rules/forbid-elements.js index ebd3cbd834..91b037d1e7 100644 --- a/lib/rules/forbid-elements.js +++ b/lib/rules/forbid-elements.js @@ -53,7 +53,7 @@ module.exports = { const indexedForbidConfigs = {}; - forbidConfiguration.forEach(item => { + forbidConfiguration.forEach((item) => { if (typeof item === 'string') { indexedForbidConfigs[item] = {element: item}; } else { diff --git a/lib/rules/forbid-prop-types.js b/lib/rules/forbid-prop-types.js index 7a7943895f..12cabb5af0 100644 --- a/lib/rules/forbid-prop-types.js +++ b/lib/rules/forbid-prop-types.js @@ -79,7 +79,7 @@ module.exports = { * @returns {void} */ function checkProperties(declarations) { - declarations.forEach(declaration => { + declarations.forEach((declaration) => { if (declaration.type !== 'Property') { return; } @@ -178,7 +178,7 @@ module.exports = { }, ObjectExpression: function (node) { - node.properties.forEach(property => { + node.properties.forEach((property) => { if (!property.key) { return; } diff --git a/lib/rules/jsx-child-element-spacing.js b/lib/rules/jsx-child-element-spacing.js index 271423d970..5c8fbc3b70 100644 --- a/lib/rules/jsx-child-element-spacing.js +++ b/lib/rules/jsx-child-element-spacing.js @@ -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)) && diff --git a/lib/rules/jsx-curly-brace-presence.js b/lib/rules/jsx-curly-brace-presence.js index b2f8aaf291..fccd2ba1c6 100755 --- a/lib/rules/jsx-curly-brace-presence.js +++ b/lib/rules/jsx-curly-brace-presence.js @@ -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); } diff --git a/lib/rules/jsx-equals-spacing.js b/lib/rules/jsx-equals-spacing.js index f5383b3b9e..db372272ae 100644 --- a/lib/rules/jsx-equals-spacing.js +++ b/lib/rules/jsx-equals-spacing.js @@ -45,7 +45,7 @@ module.exports = { return { JSXOpeningElement: function (node) { - node.attributes.forEach(attrNode => { + node.attributes.forEach((attrNode) => { if (!hasEqual(attrNode)) { return; } diff --git a/lib/rules/jsx-first-prop-new-line.js b/lib/rules/jsx-first-prop-new-line.js index 9766a5ae3c..6e0b08ebf0 100644 --- a/lib/rules/jsx-first-prop-new-line.js +++ b/lib/rules/jsx-first-prop-new-line.js @@ -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, diff --git a/lib/rules/jsx-fragments.js b/lib/rules/jsx-fragments.js index 460d24b8a6..88da620f17 100644 --- a/lib/rules/jsx-fragments.js +++ b/lib/rules/jsx-fragments.js @@ -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); @@ -164,7 +164,7 @@ module.exports = { }, 'Program:exit'() { - jsxElements.forEach(node => { + jsxElements.forEach((node) => { const openingEl = node.openingElement; const elName = elementType(openingEl); diff --git a/lib/rules/jsx-indent-props.js b/lib/rules/jsx-indent-props.js index 048eb2daf5..68d1b9b5c8 100644 --- a/lib/rules/jsx-indent-props.js +++ b/lib/rules/jsx-indent-props.js @@ -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' && diff --git a/lib/rules/jsx-max-depth.js b/lib/rules/jsx-max-depth.js index 6b0ecddce3..d29548b00d 100644 --- a/lib/rules/jsx-max-depth.js +++ b/lib/rules/jsx-max-depth.js @@ -104,7 +104,7 @@ module.exports = { function checkDescendant(baseDepth, children) { baseDepth++; - (children || []).forEach(node => { + (children || []).forEach((node) => { if (!hasJSX(node)) { return; } diff --git a/lib/rules/jsx-max-props-per-line.js b/lib/rules/jsx-max-props-per-line.js index 96d900a5e1..dc592ca358 100644 --- a/lib/rules/jsx-max-props-per-line.js +++ b/lib/rules/jsx-max-props-per-line.js @@ -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({ diff --git a/lib/rules/jsx-no-bind.js b/lib/rules/jsx-no-bind.js index 3145bdb91c..d8f8a41510 100644 --- a/lib/rules/jsx-no-bind.js +++ b/lib/rules/jsx-no-bind.js @@ -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, @@ -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; diff --git a/lib/rules/jsx-no-duplicate-props.js b/lib/rules/jsx-no-duplicate-props.js index 7fc2c51db7..782e5a9d2e 100644 --- a/lib/rules/jsx-no-duplicate-props.js +++ b/lib/rules/jsx-no-duplicate-props.js @@ -40,7 +40,7 @@ module.exports = { JSXOpeningElement: function (node) { const props = {}; - node.attributes.forEach(decl => { + node.attributes.forEach((decl) => { if (decl.type === 'JSXSpreadAttribute') { return; } diff --git a/lib/rules/jsx-no-target-blank.js b/lib/rules/jsx-no-target-blank.js index 4f6276770c..097be191cf 100644 --- a/lib/rules/jsx-no-target-blank.js +++ b/lib/rules/jsx-no-target-blank.js @@ -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); diff --git a/lib/rules/jsx-one-expression-per-line.js b/lib/rules/jsx-one-expression-per-line.js index b250cc4825..60ccc2eb1a 100644 --- a/lib/rules/jsx-one-expression-per-line.js +++ b/lib/rules/jsx-one-expression-per-line.js @@ -85,7 +85,7 @@ module.exports = { const childrenGroupedByLine = {}; const fixDetailsByNode = {}; - children.forEach(child => { + children.forEach((child) => { let countNewLinesBeforeContent = 0; let countNewLinesAfterContent = 0; @@ -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; @@ -191,7 +191,7 @@ module.exports = { }); }); - Object.keys(fixDetailsByNode).forEach(key => { + Object.keys(fixDetailsByNode).forEach((key) => { const details = fixDetailsByNode[key]; const nodeToReport = details.node; diff --git a/lib/rules/jsx-sort-props.js b/lib/rules/jsx-sort-props.js index ce5dca1318..8a8543ae32 100644 --- a/lib/rules/jsx-sort-props.js +++ b/lib/rules/jsx-sort-props.js @@ -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])}`; }); @@ -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; } diff --git a/lib/rules/jsx-wrap-multilines.js b/lib/rules/jsx-wrap-multilines.js index 570c61f9be..730294ca87 100644 --- a/lib/rules/jsx-wrap-multilines.js +++ b/lib/rules/jsx-wrap-multilines.js @@ -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) { diff --git a/lib/rules/no-access-state-in-setstate.js b/lib/rules/no-access-state-in-setstate.js index 027a4c4355..2efe90ad6e 100644 --- a/lib/rules/no-access-state-in-setstate.js +++ b/lib/rules/no-access-state-in-setstate.js @@ -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') { @@ -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, @@ -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, diff --git a/lib/rules/no-array-index-key.js b/lib/rules/no-array-index-key.js index 2a26871d6f..d12e9ad46a 100644 --- a/lib/rules/no-array-index-key.js +++ b/lib/rules/no-array-index-key.js @@ -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 } diff --git a/lib/rules/no-danger-with-children.js b/lib/rules/no-danger-with-children.js index 011c3d9db6..caa0b7e93d 100644 --- a/lib/rules/no-danger-with-children.js +++ b/lib/rules/no-danger-with-children.js @@ -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; } @@ -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) { diff --git a/lib/rules/no-deprecated.js b/lib/rules/no-deprecated.js index 660acc5ac3..dd6906685c 100644 --- a/lib/rules/no-deprecated.js +++ b/lib/rules/no-deprecated.js @@ -189,7 +189,7 @@ module.exports = { if (!isReactImport) { return; } - node.specifiers.forEach(specifier => { + node.specifiers.forEach((specifier) => { if (!specifier.imported) { return; } @@ -212,7 +212,7 @@ module.exports = { ) { return; } - node.id.properties.forEach(property => { + node.id.properties.forEach((property) => { checkDeprecation(node, `${reactModuleName || pragma}.${property.key.name}`); }); }, diff --git a/lib/rules/no-direct-mutation-state.js b/lib/rules/no-direct-mutation-state.js index 26cd84b944..226d981e50 100644 --- a/lib/rules/no-direct-mutation-state.js +++ b/lib/rules/no-direct-mutation-state.js @@ -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]); } diff --git a/lib/rules/no-redundant-should-component-update.js b/lib/rules/no-redundant-should-component-update.js index 89897ebdec..791ec676ab 100644 --- a/lib/rules/no-redundant-should-component-update.js +++ b/lib/rules/no-redundant-should-component-update.js @@ -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'; }); diff --git a/lib/rules/no-set-state.js b/lib/rules/no-set-state.js index bdea98bcc4..0f065ae194 100644 --- a/lib/rules/no-set-state.js +++ b/lib/rules/no-set-state.js @@ -74,7 +74,7 @@ module.exports = { 'Program:exit': function () { 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 c341f11b21..fabd703303 100644 --- a/lib/rules/no-typos.js +++ b/lib/rules/no-typos.js @@ -84,7 +84,7 @@ module.exports = { } else if (callee.type === 'MemberExpression' && callee.property.name === 'oneOfType') { const args = node.arguments[0]; if (args && args.type === 'ArrayExpression') { - args.elements.forEach(el => { + args.elements.forEach((el) => { checkValidProp(el); }); } @@ -129,7 +129,7 @@ module.exports = { if (propertyName === 'propTypes' || propertyName === 'contextTypes' || propertyName === 'childContextTypes') { checkValidPropObject(node); } - STATIC_CLASS_PROPERTIES.forEach(CLASS_PROP => { + STATIC_CLASS_PROPERTIES.forEach((CLASS_PROP) => { if (propertyName && CLASS_PROP.toLowerCase() === propertyName.toLowerCase() && CLASS_PROP !== propertyName) { const message = isClassProperty ? 'Typo in static class property declaration' @@ -143,7 +143,7 @@ module.exports = { } function reportErrorIfLifecycleMethodCasingTypo(node) { - LIFECYCLE_METHODS.forEach(method => { + LIFECYCLE_METHODS.forEach((method) => { if (method.toLowerCase() === node.key.name.toLowerCase() && method !== node.key.name) { context.report({ node: node, @@ -218,7 +218,7 @@ module.exports = { return; } - node.properties.forEach(property => { + node.properties.forEach((property) => { reportErrorIfPropertyCasingTypo(property.value, property.key.name, false); reportErrorIfLifecycleMethodCasingTypo(property); }); diff --git a/lib/rules/no-unused-prop-types.js b/lib/rules/no-unused-prop-types.js index 4ab1d5e4ef..1f095a1cc7 100644 --- a/lib/rules/no-unused-prop-types.js +++ b/lib/rules/no-unused-prop-types.js @@ -91,7 +91,7 @@ module.exports = { return; } - Object.keys(props || {}).forEach(key => { + Object.keys(props || {}).forEach((key) => { const prop = props[key]; // Skip props that check instances if (prop === true) { @@ -133,7 +133,7 @@ module.exports = { 'Program:exit': function () { 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/prefer-read-only-props.js b/lib/rules/prefer-read-only-props.js index 19d1a23458..225dac0b27 100644 --- a/lib/rules/prefer-read-only-props.js +++ b/lib/rules/prefer-read-only-props.js @@ -36,14 +36,14 @@ module.exports = { 'Program:exit': function () { const list = components.list(); - Object.keys(list).forEach(key => { + Object.keys(list).forEach((key) => { const component = list[key]; if (!component.declaredPropTypes) { return; } - Object.keys(component.declaredPropTypes).forEach(propName => { + Object.keys(component.declaredPropTypes).forEach((propName) => { const prop = component.declaredPropTypes[propName]; if (!isFlowPropertyType(prop.node)) { @@ -57,7 +57,7 @@ module.exports = { data: { propName }, - fix: fixer => { + fix: (fixer) => { if (!prop.node.variance) { // Insert covariance return fixer.insertTextBefore(prop.node, '+'); diff --git a/lib/rules/prefer-stateless-function.js b/lib/rules/prefer-stateless-function.js index 035a97786a..c843564259 100644 --- a/lib/rules/prefer-stateless-function.js +++ b/lib/rules/prefer-stateless-function.js @@ -181,7 +181,7 @@ module.exports = { */ function hasOtherProperties(node) { const properties = astUtil.getComponentProperties(node); - return properties.some(property => { + return properties.some((property) => { const name = astUtil.getPropertyName(property); const isDisplayName = name === 'displayName'; const isPropTypes = name === 'propTypes' || name === 'props' && property.typeAnnotation; @@ -286,7 +286,7 @@ module.exports = { return; } // Ignore `props` and `context` - const useThis = node.id.properties.some(property => { + const useThis = node.id.properties.some((property) => { const name = astUtil.getPropertyName(property); return name !== 'props' && name !== 'context'; }); @@ -356,7 +356,7 @@ module.exports = { 'Program:exit': function () { const list = components.list(); - Object.keys(list).forEach(component => { + Object.keys(list).forEach((component) => { if ( hasOtherProperties(list[component].node) || list[component].useThis || diff --git a/lib/rules/prop-types.js b/lib/rules/prop-types.js index cb235d1422..89828bf15d 100644 --- a/lib/rules/prop-types.js +++ b/lib/rules/prop-types.js @@ -190,7 +190,7 @@ module.exports = { 'Program:exit': function () { 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-default-props.js b/lib/rules/require-default-props.js index 77e588ac68..f128090822 100644 --- a/lib/rules/require-default-props.js +++ b/lib/rules/require-default-props.js @@ -50,7 +50,7 @@ module.exports = { return; } - Object.keys(propTypes).forEach(propName => { + Object.keys(propTypes).forEach((propName) => { const prop = propTypes[propName]; if (prop.isRequired) { if (forbidDefaultForRequired && defaultProps[propName]) { @@ -83,7 +83,7 @@ module.exports = { 'Program:exit': function () { const list = components.list(); - Object.keys(list).filter(component => list[component].declaredPropTypes).forEach(component => { + Object.keys(list).filter(component => list[component].declaredPropTypes).forEach((component) => { reportPropTypesWithoutDefault( list[component].declaredPropTypes, list[component].defaultProps || {} diff --git a/lib/rules/require-optimization.js b/lib/rules/require-optimization.js index 4bce9c148b..fb19200aba 100644 --- a/lib/rules/require-optimization.js +++ b/lib/rules/require-optimization.js @@ -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 c170e7c193..8d753bf37a 100644 --- a/lib/rules/require-render-return.js +++ b/lib/rules/require-render-return.js @@ -75,7 +75,7 @@ module.exports = { 'Program:exit': function () { const list = components.list(); - Object.keys(list).forEach(component => { + Object.keys(list).forEach((component) => { if ( !findRenderMethod(list[component].node) || list[component].hasReturnStatement || diff --git a/lib/rules/sort-comp.js b/lib/rules/sort-comp.js index 84312fa07a..40a3f72f30 100644 --- a/lib/rules/sort-comp.js +++ b/lib/rules/sort-comp.js @@ -443,7 +443,7 @@ module.exports = { return { 'Program:exit': function () { const list = components.list(); - Object.keys(list).forEach(component => { + Object.keys(list).forEach((component) => { const properties = astUtil.getComponentProperties(list[component].node); checkPropsOrder(properties); }); diff --git a/lib/rules/sort-prop-types.js b/lib/rules/sort-prop-types.js index a8f09ab13a..56f08cb164 100644 --- a/lib/rules/sort-prop-types.js +++ b/lib/rules/sort-prop-types.js @@ -150,7 +150,7 @@ module.exports = { return acc; }, [[]]); - nodeGroups.forEach(nodes => { + nodeGroups.forEach((nodes) => { const sortedAttributes = nodes.slice().sort(sorter); for (let i = nodes.length - 1; i >= 0; i--) { @@ -290,7 +290,7 @@ module.exports = { }, ObjectExpression: function (node) { - node.properties.forEach(property => { + node.properties.forEach((property) => { if (!property.key) { return; } diff --git a/lib/rules/static-property-placement.js b/lib/rules/static-property-placement.js index e1c3abc652..3c96c08973 100644 --- a/lib/rules/static-property-placement.js +++ b/lib/rules/static-property-placement.js @@ -108,7 +108,7 @@ module.exports = { */ function reportNodeIncorrectlyPositioned(node, expectedRule) { // Detect if this node is an expected property declaration adn return the property name - const name = classProperties.find(propertyName => { + const name = classProperties.find((propertyName) => { if (propertiesToCheck[propertyName](node)) { return !!propertyName; } @@ -129,7 +129,7 @@ module.exports = { return { ClassProperty: node => reportNodeIncorrectlyPositioned(node, STATIC_PUBLIC_FIELD), - MemberExpression: node => { + MemberExpression: (node) => { // If definition type is undefined then it must not be a defining expression or if the definition is inside a // class body then skip this node. const right = node.parent.right; @@ -149,7 +149,7 @@ module.exports = { reportNodeIncorrectlyPositioned(node, PROPERTY_ASSIGNMENT); }, - MethodDefinition: node => { + MethodDefinition: (node) => { // If the function is inside a class and is static getter then check if correctly positioned if (isContextInClass() && node.static && node.kind === 'get') { // Report error if needed diff --git a/lib/rules/void-dom-elements-no-children.js b/lib/rules/void-dom-elements-no-children.js index 6d2bde2309..74b7e66584 100644 --- a/lib/rules/void-dom-elements-no-children.js +++ b/lib/rules/void-dom-elements-no-children.js @@ -78,7 +78,7 @@ module.exports = { const attributes = node.openingElement.attributes; - const hasChildrenAttributeOrDanger = attributes.some(attribute => { + const hasChildrenAttributeOrDanger = attributes.some((attribute) => { if (!attribute.name) { return false; } @@ -133,7 +133,7 @@ module.exports = { const props = args[1].properties; - const hasChildrenPropOrDanger = props.some(prop => { + const hasChildrenPropOrDanger = props.some((prop) => { if (!prop.key) { return false; } diff --git a/lib/util/Components.js b/lib/util/Components.js index 2904fd4dc1..c35e586bb6 100644 --- a/lib/util/Components.js +++ b/lib/util/Components.js @@ -35,7 +35,7 @@ function usedPropTypesAreEquivalent(propA, propB) { function mergeUsedPropTypes(propsList, newPropsList) { const propsToAdd = []; - newPropsList.forEach(newProp => { + newPropsList.forEach((newProp) => { const newPropisAlreadyInTheList = propsList.some(prop => usedPropTypesAreEquivalent(prop, newProp)); if (!newPropisAlreadyInTheList) { propsToAdd.push(newProp); @@ -130,7 +130,7 @@ class Components { const usedPropTypes = {}; // Find props used in components for which we are not confident - Object.keys(this._list).filter(i => this._list[i].confidence < 2).forEach(i => { + Object.keys(this._list).filter(i => this._list[i].confidence < 2).forEach((i) => { let component = null; let node = null; node = this._list[i].node; @@ -152,7 +152,7 @@ class Components { }); // Assign used props in not confident components to the parent component - Object.keys(this._list).filter(j => this._list[j].confidence >= 2).forEach(j => { + Object.keys(this._list).filter(j => this._list[j].confidence >= 2).forEach((j) => { const id = getId(this._list[j].node); list[j] = this._list[j]; if (usedPropTypes[id]) { @@ -768,7 +768,7 @@ function componentRule(rule, context) { Object.keys(defaultPropsInstructions) )); - allKeys.forEach(instruction => { + allKeys.forEach((instruction) => { updatedRuleInstructions[instruction] = function (node) { if (instruction in detectionInstructions) { detectionInstructions[instruction](node); diff --git a/lib/util/defaultProps.js b/lib/util/defaultProps.js index 8cfa15f0f9..8525791fb2 100644 --- a/lib/util/defaultProps.js +++ b/lib/util/defaultProps.js @@ -246,7 +246,7 @@ module.exports = function defaultPropsInstructions(context, components, utils) { } // Search for the proptypes declaration - node.properties.forEach(property => { + node.properties.forEach((property) => { if (property.type === 'ExperimentalSpreadProperty' || property.type === 'SpreadElement') { return; } diff --git a/lib/util/linkComponents.js b/lib/util/linkComponents.js index aa2d8da189..f4260cd1c5 100644 --- a/lib/util/linkComponents.js +++ b/lib/util/linkComponents.js @@ -14,7 +14,7 @@ function getLinkComponents(context) { const linkComponents = /** @type {typeof DEFAULT_LINK_COMPONENTS} */ ( DEFAULT_LINK_COMPONENTS.concat(settings.linkComponents || []) ); - return new Map(linkComponents.map(value => { + return new Map(linkComponents.map((value) => { if (typeof value === 'string') { return [value, DEFAULT_LINK_ATTRIBUTE]; } diff --git a/lib/util/propTypes.js b/lib/util/propTypes.js index bb74b6e64d..2799cbc3ce 100644 --- a/lib/util/propTypes.js +++ b/lib/util/propTypes.js @@ -302,7 +302,7 @@ module.exports = function propTypesInstructions(context, components, utils) { * @returns {Boolean} True if propTypes should be ignored (e.g. when a type can't be resolved, when it is imported) */ function declarePropTypesForIntersectionTypeAnnotation(propTypes, declaredPropTypes) { - return propTypes.types.some(annotation => { + return propTypes.types.some((annotation) => { if (annotation.type === 'ObjectTypeAnnotation') { return declarePropTypesForObjectTypeAnnotation(annotation, declaredPropTypes); } @@ -595,7 +595,7 @@ module.exports = function propTypesInstructions(context, components, utils) { const param = node.params[0]; if (param.typeAnnotation && param.typeAnnotation.typeAnnotation && param.typeAnnotation.typeAnnotation.type === 'UnionTypeAnnotation') { - param.typeAnnotation.typeAnnotation.types.forEach(annotation => { + param.typeAnnotation.typeAnnotation.types.forEach((annotation) => { if (annotation.type === 'GenericTypeAnnotation') { markPropTypesAsDeclared(node, resolveTypeAnnotation(annotation)); } else { @@ -679,7 +679,7 @@ module.exports = function propTypesInstructions(context, components, utils) { ObjectExpression: function (node) { // Search for the proptypes declaration - node.properties.forEach(property => { + node.properties.forEach((property) => { if (!propsUtil.isPropTypesDeclaration(property)) { return; } @@ -749,7 +749,7 @@ module.exports = function propTypesInstructions(context, components, utils) { }, 'Program:exit': function () { - classExpressions.forEach(node => { + classExpressions.forEach((node) => { if (isSuperTypeParameterPropsDeclaration(node)) { markPropTypesAsDeclared(node, resolveSuperParameterPropsType(node)); } diff --git a/lib/util/propWrapper.js b/lib/util/propWrapper.js index aa9b9524d6..b38a3f926b 100644 --- a/lib/util/propWrapper.js +++ b/lib/util/propWrapper.js @@ -14,7 +14,7 @@ function isPropWrapperFunction(context, name) { } const propWrapperFunctions = getPropWrapperFunctions(context); const splitName = name.split('.'); - return Array.from(propWrapperFunctions).some(func => { + return Array.from(propWrapperFunctions).some((func) => { if (splitName.length === 2 && func.object === splitName[0] && func.property === splitName[1]) { return true; } diff --git a/lib/util/usedPropTypes.js b/lib/util/usedPropTypes.js index 3a64883d21..d837c6e484 100755 --- a/lib/util/usedPropTypes.js +++ b/lib/util/usedPropTypes.js @@ -461,7 +461,7 @@ module.exports = function usedPropTypesInstructions(context, components, utils) return; } - Object.keys(propTypes).forEach(key => { + Object.keys(propTypes).forEach((key) => { const node = propTypes[key].node; if (node.value && astUtil.isFunctionLikeExpression(node.value)) { @@ -517,7 +517,7 @@ module.exports = function usedPropTypesInstructions(context, components, utils) 'Program:exit': function () { 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/tests/index.js b/tests/index.js index 937ede2354..2a05f350f6 100644 --- a/tests/index.js +++ b/tests/index.js @@ -12,7 +12,7 @@ const ruleFiles = fs.readdirSync(path.resolve(__dirname, '../lib/rules/')) .map(f => path.basename(f, '.js')); describe('all rule files should be exported by the plugin', () => { - ruleFiles.forEach(ruleName => { + ruleFiles.forEach((ruleName) => { it(`should export ${ruleName}`, () => { assert.equal( plugin.rules[ruleName], @@ -24,7 +24,7 @@ describe('all rule files should be exported by the plugin', () => { describe('deprecated rules', () => { it('marks all deprecated rules as deprecated', () => { - ruleFiles.forEach(ruleName => { + ruleFiles.forEach((ruleName) => { const inDeprecatedRules = Boolean(plugin.deprecatedRules[ruleName]); const isDeprecated = plugin.rules[ruleName].meta.deprecated; if (inDeprecatedRules) { @@ -39,13 +39,13 @@ describe('deprecated rules', () => { describe('configurations', () => { it('should export a ‘recommended’ configuration', () => { assert(plugin.configs.recommended); - Object.keys(plugin.configs.recommended.rules).forEach(configName => { + Object.keys(plugin.configs.recommended.rules).forEach((configName) => { assert.equal(configName.indexOf('react/'), 0); const ruleName = configName.slice('react/'.length); assert(plugin.rules[ruleName]); }); - ruleFiles.forEach(ruleName => { + ruleFiles.forEach((ruleName) => { const inRecommendedConfig = !!plugin.configs.recommended.rules[`react/${ruleName}`]; const isRecommended = plugin.rules[ruleName].meta.docs.recommended; if (inRecommendedConfig) { @@ -59,12 +59,12 @@ describe('configurations', () => { it('should export an ‘all’ configuration', () => { assert(plugin.configs.all); - Object.keys(plugin.configs.all.rules).forEach(configName => { + Object.keys(plugin.configs.all.rules).forEach((configName) => { assert.equal(configName.indexOf('react/'), 0); assert.equal(plugin.configs.all.rules[configName], 2); }); - ruleFiles.forEach(ruleName => { + ruleFiles.forEach((ruleName) => { const inDeprecatedRules = Boolean(plugin.deprecatedRules[ruleName]); const inAllConfig = Boolean(plugin.configs.all.rules[`react/${ruleName}`]); assert(inDeprecatedRules ^ inAllConfig); // eslint-disable-line no-bitwise From 28914aab300f9912b65051991e94b05b4e5fe062 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 19 May 2019 09:46:30 -0700 Subject: [PATCH 10/28] [eslint] enable and autofix `object-shorthand` --- .eslintrc | 1 - index.js | 2 +- lib/rules/boolean-prop-naming.js | 12 +- lib/rules/button-has-type.js | 12 +- lib/rules/destructuring-assignment.js | 16 +- lib/rules/display-name.js | 18 +- lib/rules/forbid-component-props.js | 6 +- lib/rules/forbid-dom-props.js | 6 +- lib/rules/forbid-elements.js | 8 +- lib/rules/forbid-foreign-prop-types.js | 6 +- lib/rules/forbid-prop-types.js | 10 +- lib/rules/jsx-boolean-value.js | 10 +- lib/rules/jsx-child-element-spacing.js | 2 +- lib/rules/jsx-closing-bracket-location.js | 22 +- lib/rules/jsx-closing-tag-location.js | 6 +- lib/rules/jsx-curly-brace-presence.js | 6 +- lib/rules/jsx-curly-spacing.js | 26 +-- lib/rules/jsx-equals-spacing.js | 12 +- lib/rules/jsx-filename-extension.js | 2 +- lib/rules/jsx-first-prop-new-line.js | 8 +- lib/rules/jsx-fragments.js | 4 +- lib/rules/jsx-handler-names.js | 8 +- lib/rules/jsx-indent-props.js | 12 +- lib/rules/jsx-indent.js | 14 +- lib/rules/jsx-key.js | 10 +- lib/rules/jsx-max-depth.js | 6 +- lib/rules/jsx-max-props-per-line.js | 4 +- lib/rules/jsx-no-bind.js | 6 +- lib/rules/jsx-no-comment-textnodes.js | 4 +- lib/rules/jsx-no-duplicate-props.js | 4 +- lib/rules/jsx-no-literals.js | 10 +- lib/rules/jsx-no-target-blank.js | 4 +- lib/rules/jsx-no-undef.js | 6 +- lib/rules/jsx-one-expression-per-line.js | 6 +- lib/rules/jsx-pascal-case.js | 6 +- lib/rules/jsx-props-no-multi-spaces.js | 8 +- lib/rules/jsx-props-no-spreading.js | 6 +- lib/rules/jsx-sort-default-props.js | 6 +- lib/rules/jsx-sort-props.js | 4 +- lib/rules/jsx-space-before-closing.js | 10 +- lib/rules/jsx-tag-spacing.js | 46 ++-- lib/rules/jsx-uses-react.js | 2 +- lib/rules/jsx-uses-vars.js | 4 +- lib/rules/jsx-wrap-multilines.js | 14 +- lib/rules/no-access-state-in-setstate.js | 8 +- lib/rules/no-array-index-key.js | 12 +- lib/rules/no-children-prop.js | 10 +- lib/rules/no-danger-with-children.js | 6 +- lib/rules/no-danger.js | 6 +- lib/rules/no-deprecated.js | 6 +- lib/rules/no-direct-mutation-state.js | 2 +- lib/rules/no-find-dom-node.js | 4 +- lib/rules/no-is-mounted.js | 4 +- .../no-redundant-should-component-update.js | 2 +- lib/rules/no-render-return-value.js | 4 +- lib/rules/no-set-state.js | 4 +- lib/rules/no-string-refs.js | 8 +- lib/rules/no-this-in-sfc.js | 2 +- lib/rules/no-typos.js | 20 +- lib/rules/no-unescaped-entities.js | 6 +- lib/rules/no-unknown-property.js | 18 +- lib/rules/no-unsafe.js | 2 +- lib/rules/no-unused-state.js | 10 +- lib/rules/prefer-es6-class.js | 8 +- lib/rules/prefer-stateless-function.js | 8 +- lib/rules/react-in-jsx-scope.js | 4 +- lib/rules/require-optimization.js | 12 +- lib/rules/require-render-return.js | 4 +- lib/rules/self-closing-comp.js | 8 +- lib/rules/sort-prop-types.js | 10 +- lib/rules/state-in-constructor.js | 2 +- lib/rules/style-prop-object.js | 6 +- lib/rules/void-dom-elements-no-children.js | 12 +- lib/util/Components.js | 56 ++--- lib/util/annotations.js | 2 +- lib/util/ast.js | 20 +- lib/util/defaultProps.js | 8 +- lib/util/jsx.js | 4 +- lib/util/linkComponents.js | 2 +- lib/util/makeNoMethodSetStateRule.js | 4 +- lib/util/pragma.js | 6 +- lib/util/propTypes.js | 34 +-- lib/util/propWrapper.js | 4 +- lib/util/props.js | 14 +- lib/util/usedPropTypes.js | 18 +- lib/util/variable.js | 8 +- tests/lib/rules/jsx-max-props-per-line.js | 20 +- .../lib/rules/jsx-one-expression-per-line.js | 100 ++++---- tests/lib/rules/jsx-uses-react.js | 6 +- .../lib/rules/no-access-state-in-setstate.js | 30 +-- .../no-redundant-should-component-update.js | 20 +- tests/lib/rules/no-typos.js | 218 +++++++++--------- tests/lib/rules/no-unused-prop-types.js | 2 +- tests/lib/rules/prefer-stateless-function.js | 2 +- tests/lib/rules/prop-types.js | 2 +- tests/lib/rules/react-in-jsx-scope.js | 4 +- tests/lib/rules/sort-comp.js | 6 +- tests/util/linkComponents.js | 2 +- tests/util/propWrapper.js | 2 +- 99 files changed, 598 insertions(+), 599 deletions(-) diff --git a/.eslintrc b/.eslintrc index 6147ec8615..e45dc69077 100644 --- a/.eslintrc +++ b/.eslintrc @@ -24,7 +24,6 @@ "prefer-destructuring": [2, { "array": false, "object": false }, { "enforceForRenamedProperties": false }], - "object-shorthand": 1, "import/order": 1, "no-useless-escape": 1, "import/newline-after-import": 1, diff --git a/index.js b/index.js index b2d4ccdb90..d39472d70c 100644 --- a/index.js +++ b/index.js @@ -114,7 +114,7 @@ const activeRulesConfig = configureAsError(activeRules); const deprecatedRules = filterRules(allRules, rule => rule.meta.deprecated); module.exports = { - deprecatedRules: deprecatedRules, + deprecatedRules, rules: allRules, configs: { recommended: { diff --git a/lib/rules/boolean-prop-naming.js b/lib/rules/boolean-prop-naming.js index c5d87f72b9..03711d7b1d 100644 --- a/lib/rules/boolean-prop-naming.js +++ b/lib/rules/boolean-prop-naming.js @@ -181,7 +181,7 @@ module.exports = { }); components.set(node, { - invalidProps: invalidProps + invalidProps }); } @@ -197,7 +197,7 @@ module.exports = { message: config.message || 'Prop name ({{ propName }}) doesn\'t match rule ({{ pattern }})', data: { component: propName, - propName: propName, + propName, pattern: config.rule } }); @@ -216,7 +216,7 @@ module.exports = { // -------------------------------------------------------------------------- return { - ClassProperty: function (node) { + ClassProperty(node) { if (!rule || !propsUtil.isPropTypesDeclaration(node)) { return; } @@ -231,7 +231,7 @@ module.exports = { } }, - MemberExpression: function (node) { + MemberExpression(node) { if (!rule || !propsUtil.isPropTypesDeclaration(node)) { return; } @@ -247,7 +247,7 @@ module.exports = { validatePropNaming(component.node, node.parent.right.properties); }, - ObjectExpression: function (node) { + ObjectExpression(node) { if (!rule) { return; } @@ -261,7 +261,7 @@ module.exports = { }); }, - TypeAlias: function (node) { + TypeAlias(node) { // Cache all ObjectType annotations, we will check them at the end if (node.right.type === 'ObjectTypeAnnotation') { objectTypeAnnotations.set(node.id.name, node.right); diff --git a/lib/rules/button-has-type.js b/lib/rules/button-has-type.js index 055ed1c64f..120dbb6220 100644 --- a/lib/rules/button-has-type.js +++ b/lib/rules/button-has-type.js @@ -62,12 +62,12 @@ module.exports = { }] }, - create: function (context) { + create(context) { const configuration = Object.assign({}, optionDefaults, context.options[0]); function reportMissing(node) { context.report({ - node: node, + node, message: 'Missing an explicit type attribute for button' }); } @@ -76,19 +76,19 @@ module.exports = { const q = quoteFn || (x => `"${x}"`); if (!(value in configuration)) { context.report({ - node: node, + node, message: `${q(value)} is an invalid value for button type attribute` }); } else if (!configuration[value]) { context.report({ - node: node, + node, message: `${q(value)} is a forbidden value for button type attribute` }); } } return { - JSXElement: function (node) { + JSXElement(node) { if (node.openingElement.name.name !== 'button') { return; } @@ -107,7 +107,7 @@ module.exports = { checkValue(node, propValue); } }, - CallExpression: function (node) { + CallExpression(node) { if (!isCreateElement(node, context)) { return; } diff --git a/lib/rules/destructuring-assignment.js b/lib/rules/destructuring-assignment.js index 8d2ef30165..10adcde7e7 100644 --- a/lib/rules/destructuring-assignment.js +++ b/lib/rules/destructuring-assignment.js @@ -61,12 +61,12 @@ module.exports = { if (destructuringProps && components.get(node) && configuration === 'never') { context.report({ - node: node, + node, message: 'Must never use destructuring props assignment in SFC argument' }); } else if (destructuringContext && components.get(node) && configuration === 'never') { context.report({ - node: node, + node, message: 'Must never use destructuring context assignment in SFC argument' }); } @@ -77,7 +77,7 @@ module.exports = { const isPropUsed = (node.object.name === 'props' || node.object.name === 'context') && !isAssignmentToProp(node); if (isPropUsed && configuration === 'always') { context.report({ - node: node, + node, message: `Must use destructuring ${node.object.name} assignment` }); } @@ -107,7 +107,7 @@ module.exports = { !(ignoreClassFields && isInClassProperty(node)) ) { context.report({ - node: node, + node, message: `Must use destructuring ${node.object.property.name} assignment` }); } @@ -121,7 +121,7 @@ module.exports = { FunctionExpression: handleStatelessComponent, - MemberExpression: function (node) { + MemberExpression(node) { const SFCComponent = components.get(context.getScope(node).block); const classComponent = utils.getParentComponent(node); if (SFCComponent) { @@ -132,7 +132,7 @@ module.exports = { } }, - VariableDeclarator: function (node) { + VariableDeclarator(node) { const classComponent = utils.getParentComponent(node); const SFCComponent = components.get(context.getScope(node).block); @@ -146,7 +146,7 @@ module.exports = { if (SFCComponent && destructuringSFC && configuration === 'never') { context.report({ - node: node, + node, message: `Must never use destructuring ${node.init.name} assignment` }); } @@ -156,7 +156,7 @@ module.exports = { !(ignoreClassFields && node.parent.type === 'ClassProperty') ) { context.report({ - node: node, + node, message: `Must never use destructuring ${node.init.property.name} assignment` }); } diff --git a/lib/rules/display-name.js b/lib/rules/display-name.js index bb50138c4c..ecfeaa7b4f 100644 --- a/lib/rules/display-name.js +++ b/lib/rules/display-name.js @@ -122,14 +122,14 @@ module.exports = { return { - ClassProperty: function (node) { + ClassProperty(node) { if (!propsUtil.isDisplayNameDeclaration(node)) { return; } markDisplayNameAsDeclared(node); }, - MemberExpression: function (node) { + MemberExpression(node) { if (!propsUtil.isDisplayNameDeclaration(node.property)) { return; } @@ -140,7 +140,7 @@ module.exports = { markDisplayNameAsDeclared(component.node); }, - FunctionExpression: function (node) { + FunctionExpression(node) { if (ignoreTranspilerName || !hasTranspilerName(node)) { return; } @@ -149,7 +149,7 @@ module.exports = { } }, - FunctionDeclaration: function (node) { + FunctionDeclaration(node) { if (ignoreTranspilerName || !hasTranspilerName(node)) { return; } @@ -158,7 +158,7 @@ module.exports = { } }, - ArrowFunctionExpression: function (node) { + ArrowFunctionExpression(node) { if (ignoreTranspilerName || !hasTranspilerName(node)) { return; } @@ -167,28 +167,28 @@ module.exports = { } }, - MethodDefinition: function (node) { + MethodDefinition(node) { if (!propsUtil.isDisplayNameDeclaration(node.key)) { return; } markDisplayNameAsDeclared(node); }, - ClassExpression: function (node) { + ClassExpression(node) { if (ignoreTranspilerName || !hasTranspilerName(node)) { return; } markDisplayNameAsDeclared(node); }, - ClassDeclaration: function (node) { + ClassDeclaration(node) { if (ignoreTranspilerName || !hasTranspilerName(node)) { return; } markDisplayNameAsDeclared(node); }, - ObjectExpression: function (node) { + ObjectExpression(node) { if (ignoreTranspilerName || !hasTranspilerName(node)) { // Search for the displayName declaration node.properties.forEach((property) => { diff --git a/lib/rules/forbid-component-props.js b/lib/rules/forbid-component-props.js index 70dc3dba5f..6c11687315 100644 --- a/lib/rules/forbid-component-props.js +++ b/lib/rules/forbid-component-props.js @@ -55,7 +55,7 @@ module.exports = { }] }, - create: function (context) { + create(context) { const configuration = context.options[0] || {}; const forbid = new Map((configuration.forbid || DEFAULTS).map((value) => { const propName = typeof value === 'string' ? value : value.propName; @@ -70,7 +70,7 @@ module.exports = { } return { - JSXAttribute: function (node) { + JSXAttribute(node) { const tag = node.parent.name.name; if (tag && tag[0] !== tag[0].toUpperCase()) { // This is a DOM node, not a Component, so exit. @@ -84,7 +84,7 @@ module.exports = { } context.report({ - node: node, + node, message: `Prop \`${prop}\` is forbidden on Components` }); } diff --git a/lib/rules/forbid-dom-props.js b/lib/rules/forbid-dom-props.js index 8b491c0e59..08853a412d 100644 --- a/lib/rules/forbid-dom-props.js +++ b/lib/rules/forbid-dom-props.js @@ -42,7 +42,7 @@ module.exports = { }] }, - create: function (context) { + create(context) { function isForbidden(prop) { const configuration = context.options[0] || {}; @@ -51,7 +51,7 @@ module.exports = { } return { - JSXAttribute: function (node) { + JSXAttribute(node) { const tag = node.parent.name.name; if (!(tag && tag[0] !== tag[0].toUpperCase())) { // This is a Component, not a DOM node, so exit. @@ -65,7 +65,7 @@ module.exports = { } context.report({ - node: node, + node, message: `Prop \`${prop}\` is forbidden on DOM Nodes` }); } diff --git a/lib/rules/forbid-elements.js b/lib/rules/forbid-elements.js index 91b037d1e7..e39bea2933 100644 --- a/lib/rules/forbid-elements.js +++ b/lib/rules/forbid-elements.js @@ -46,7 +46,7 @@ module.exports = { }] }, - create: function (context) { + create(context) { const sourceCode = context.getSourceCode(); const configuration = context.options[0] || {}; const forbidConfiguration = configuration.forbid || []; @@ -83,18 +83,18 @@ module.exports = { function reportIfForbidden(element, node) { if (has(indexedForbidConfigs, element)) { context.report({ - node: node, + node, message: errorMessageForElement(element) }); } } return { - JSXOpeningElement: function (node) { + JSXOpeningElement(node) { reportIfForbidden(sourceCode.getText(node.name), node.name); }, - CallExpression: function (node) { + CallExpression(node) { if (!isValidCreateElement(node)) { return; } diff --git a/lib/rules/forbid-foreign-prop-types.js b/lib/rules/forbid-foreign-prop-types.js index fb77a5f820..42d7a9e075 100644 --- a/lib/rules/forbid-foreign-prop-types.js +++ b/lib/rules/forbid-foreign-prop-types.js @@ -29,7 +29,7 @@ module.exports = { ] }, - create: function (context) { + create(context) { const config = context.options[0] || {}; const allowInPropTypes = config.allowInPropTypes || false; @@ -94,7 +94,7 @@ module.exports = { } return { - MemberExpression: function (node) { + MemberExpression(node) { if ( node.property && ( @@ -117,7 +117,7 @@ module.exports = { } }, - ObjectPattern: function (node) { + ObjectPattern(node) { const propTypesNode = node.properties.find(property => property.type === 'Property' && property.key.name === 'propTypes'); if (propTypesNode) { diff --git a/lib/rules/forbid-prop-types.js b/lib/rules/forbid-prop-types.js index 12cabb5af0..04b61bf734 100644 --- a/lib/rules/forbid-prop-types.js +++ b/lib/rules/forbid-prop-types.js @@ -49,7 +49,7 @@ module.exports = { }] }, - create: function (context) { + create(context) { const configuration = context.options[0] || {}; const checkContextTypes = configuration.checkContextTypes || false; const checkChildContextTypes = configuration.checkChildContextTypes || false; @@ -138,7 +138,7 @@ module.exports = { } return { - ClassProperty: function (node) { + ClassProperty(node) { if ( !propsUtil.isPropTypesDeclaration(node) && !shouldCheckContextTypes(node) && @@ -149,7 +149,7 @@ module.exports = { checkNode(node.value); }, - MemberExpression: function (node) { + MemberExpression(node) { if ( !propsUtil.isPropTypesDeclaration(node) && !shouldCheckContextTypes(node) && @@ -161,7 +161,7 @@ module.exports = { checkNode(node.parent.right); }, - MethodDefinition: function (node) { + MethodDefinition(node) { if ( !propsUtil.isPropTypesDeclaration(node) && !shouldCheckContextTypes(node) && @@ -177,7 +177,7 @@ module.exports = { } }, - ObjectExpression: function (node) { + ObjectExpression(node) { node.properties.forEach((property) => { if (!property.key) { return; diff --git a/lib/rules/jsx-boolean-value.js b/lib/rules/jsx-boolean-value.js index 9316f8102f..50768b5875 100644 --- a/lib/rules/jsx-boolean-value.js +++ b/lib/rules/jsx-boolean-value.js @@ -25,7 +25,7 @@ function getErrorData(exceptions) { if (!errorData.has(exceptions)) { const exceptionProps = Array.from(exceptions, name => `\`${name}\``).join(', '); const exceptionsMessage = exceptions.size > 0 ? ` for the following props: ${exceptionProps}` : ''; - errorData.set(exceptions, {exceptionsMessage: exceptionsMessage}); + errorData.set(exceptions, {exceptionsMessage}); } return errorData.get(exceptions); } @@ -105,9 +105,9 @@ module.exports = { if (isAlways(configuration, exceptions, propName) && value === null) { const data = getErrorData(exceptions); context.report({ - node: node, + node, message: ALWAYS_MESSAGE, - data: data, + data, fix(fixer) { return fixer.insertTextAfter(node, '={true}'); } @@ -116,9 +116,9 @@ module.exports = { if (isNever(configuration, exceptions, propName) && value && value.type === 'JSXExpressionContainer' && value.expression.value === true) { const data = getErrorData(exceptions); context.report({ - node: node, + node, message: NEVER_MESSAGE, - data: data, + data, fix(fixer) { return fixer.removeRange([node.name.range[1], value.range[1]]); } diff --git a/lib/rules/jsx-child-element-spacing.js b/lib/rules/jsx-child-element-spacing.js index 5c8fbc3b70..0d0756fef0 100644 --- a/lib/rules/jsx-child-element-spacing.js +++ b/lib/rules/jsx-child-element-spacing.js @@ -55,7 +55,7 @@ module.exports = { } ] }, - create: function (context) { + create(context) { const TEXT_FOLLOWING_ELEMENT_PATTERN = /^\s*\n\s*\S/; const TEXT_PRECEDING_ELEMENT_PATTERN = /\S\s*\n\s*$/; diff --git a/lib/rules/jsx-closing-bracket-location.js b/lib/rules/jsx-closing-bracket-location.js index 8ade3e88c5..0170658ac3 100644 --- a/lib/rules/jsx-closing-bracket-location.js +++ b/lib/rules/jsx-closing-bracket-location.js @@ -50,7 +50,7 @@ module.exports = { }] }, - create: function (context) { + create(context) { const MESSAGE = 'The closing bracket must be {{location}}{{details}}'; const MESSAGE_LOCATION = { 'after-props': 'placed after the last prop', @@ -206,12 +206,12 @@ module.exports = { line: opening.line }; return { - tag: tag, - opening: opening, - closing: closing, - lastProp: lastProp, + tag, + opening, + closing, + lastProp, selfClosing: node.selfClosing, - openingStartOfLine: openingStartOfLine + openingStartOfLine }; } @@ -228,11 +228,11 @@ module.exports = { const lastAttributeNode = {}; return { - JSXAttribute: function (node) { + JSXAttribute(node) { lastAttributeNode[getOpeningElementId(node.parent)] = node; }, - JSXSpreadAttribute: function (node) { + JSXSpreadAttribute(node) { lastAttributeNode[getOpeningElementId(node.parent)] = node; }, @@ -257,11 +257,11 @@ module.exports = { } context.report({ - node: node, + node, loc: tokens.closing, message: MESSAGE, - data: data, - fix: function (fixer) { + data, + fix(fixer) { const closingTag = tokens.selfClosing ? '/>' : '>'; switch (expectedLocation) { case 'after-tag': diff --git a/lib/rules/jsx-closing-tag-location.js b/lib/rules/jsx-closing-tag-location.js index 9cc73727c0..d4bf10e1a7 100644 --- a/lib/rules/jsx-closing-tag-location.js +++ b/lib/rules/jsx-closing-tag-location.js @@ -22,7 +22,7 @@ module.exports = { fixable: 'whitespace' }, - create: function (context) { + create(context) { function handleClosingElement(node) { if (!node.parent) { return; @@ -45,10 +45,10 @@ module.exports = { } context.report({ - node: node, + node, loc: node.loc, message, - fix: function (fixer) { + fix(fixer) { const indent = Array(opening.loc.start.column + 1).join(' '); if (astUtil.isNodeFirstInLine(context, node)) { return fixer.replaceTextRange( diff --git a/lib/rules/jsx-curly-brace-presence.js b/lib/rules/jsx-curly-brace-presence.js index fccd2ba1c6..ddaba8f2eb 100755 --- a/lib/rules/jsx-curly-brace-presence.js +++ b/lib/rules/jsx-curly-brace-presence.js @@ -59,7 +59,7 @@ module.exports = { ] }, - create: function (context) { + create(context) { const ruleOptions = context.options[0]; const userConfig = typeof ruleOptions === 'string' ? {props: ruleOptions, children: ruleOptions} : @@ -117,7 +117,7 @@ module.exports = { context.report({ node: JSXExpressionNode, message: 'Curly braces are unnecessary here.', - fix: function (fixer) { + fix(fixer) { const expression = JSXExpressionNode.expression; const expressionType = expression.type; const parentType = JSXExpressionNode.parent.type; @@ -142,7 +142,7 @@ module.exports = { context.report({ node: literalNode, message: 'Need to wrap this literal in a JSX expression.', - fix: function (fixer) { + fix(fixer) { // If a HTML entity name is found, bail out because it can be fixed // by either using the real character or the unicode equivalent. // If it contains any line terminator character, bail out as well. diff --git a/lib/rules/jsx-curly-spacing.js b/lib/rules/jsx-curly-spacing.js index 1c69bbd144..34310b907e 100644 --- a/lib/rules/jsx-curly-spacing.js +++ b/lib/rules/jsx-curly-spacing.js @@ -102,7 +102,7 @@ module.exports = { } }, - create: function (context) { + create(context) { function normalizeConfig(configOrTrue, defaults, lastPass) { const config = configOrTrue === true ? {} : configOrTrue; const when = config.when || defaults.when; @@ -189,10 +189,10 @@ module.exports = { */ function reportNoBeginningNewline(node, token, spacing) { context.report({ - node: node, + node, loc: token.loc.start, message: `There should be no newline after '${token.value}'`, - fix: function (fixer) { + fix(fixer) { const nextToken = sourceCode.getTokenAfter(token); return fixByTrimmingWhitespace(fixer, token.range[1], nextToken.range[0], 'start', spacing); } @@ -208,10 +208,10 @@ module.exports = { */ function reportNoEndingNewline(node, token, spacing) { context.report({ - node: node, + node, loc: token.loc.start, message: `There should be no newline before '${token.value}'`, - fix: function (fixer) { + fix(fixer) { const previousToken = sourceCode.getTokenBefore(token); return fixByTrimmingWhitespace(fixer, previousToken.range[1], token.range[0], 'end', spacing); } @@ -226,10 +226,10 @@ module.exports = { */ function reportNoBeginningSpace(node, token) { context.report({ - node: node, + node, loc: token.loc.start, message: `There should be no space after '${token.value}'`, - fix: function (fixer) { + fix(fixer) { const nextToken = sourceCode.getTokenAfter(token); let nextComment; @@ -260,10 +260,10 @@ module.exports = { */ function reportNoEndingSpace(node, token) { context.report({ - node: node, + node, loc: token.loc.start, message: `There should be no space before '${token.value}'`, - fix: function (fixer) { + fix(fixer) { const previousToken = sourceCode.getTokenBefore(token); let previousComment; @@ -294,10 +294,10 @@ module.exports = { */ function reportRequiredBeginningSpace(node, token) { context.report({ - node: node, + node, loc: token.loc.start, message: `A space is required after '${token.value}'`, - fix: function (fixer) { + fix(fixer) { return fixer.insertTextAfter(token, ' '); } }); @@ -311,10 +311,10 @@ module.exports = { */ function reportRequiredEndingSpace(node, token) { context.report({ - node: node, + node, loc: token.loc.start, message: `A space is required before '${token.value}'`, - fix: function (fixer) { + fix(fixer) { return fixer.insertTextBefore(token, ' '); } }); diff --git a/lib/rules/jsx-equals-spacing.js b/lib/rules/jsx-equals-spacing.js index db372272ae..03e76f41fd 100644 --- a/lib/rules/jsx-equals-spacing.js +++ b/lib/rules/jsx-equals-spacing.js @@ -26,7 +26,7 @@ module.exports = { }] }, - create: function (context) { + create(context) { const config = context.options[0]; const sourceCode = context.getSourceCode(); @@ -44,7 +44,7 @@ module.exports = { // -------------------------------------------------------------------------- return { - JSXOpeningElement: function (node) { + JSXOpeningElement(node) { node.attributes.forEach((attrNode) => { if (!hasEqual(attrNode)) { return; @@ -62,7 +62,7 @@ module.exports = { node: attrNode, loc: equalToken.loc.start, message: 'There should be no space before \'=\'', - fix: function (fixer) { + fix(fixer) { return fixer.removeRange([attrNode.name.range[1], equalToken.range[0]]); } }); @@ -72,7 +72,7 @@ module.exports = { node: attrNode, loc: equalToken.loc.start, message: 'There should be no space after \'=\'', - fix: function (fixer) { + fix(fixer) { return fixer.removeRange([equalToken.range[1], attrNode.value.range[0]]); } }); @@ -84,7 +84,7 @@ module.exports = { node: attrNode, loc: equalToken.loc.start, message: 'A space is required before \'=\'', - fix: function (fixer) { + fix(fixer) { return fixer.insertTextBefore(equalToken, ' '); } }); @@ -94,7 +94,7 @@ module.exports = { node: attrNode, loc: equalToken.loc.start, message: 'A space is required after \'=\'', - fix: function (fixer) { + fix(fixer) { return fixer.insertTextAfter(equalToken, ' '); } }); diff --git a/lib/rules/jsx-filename-extension.js b/lib/rules/jsx-filename-extension.js index 1494bf0413..d636b068ae 100644 --- a/lib/rules/jsx-filename-extension.js +++ b/lib/rules/jsx-filename-extension.js @@ -43,7 +43,7 @@ module.exports = { }] }, - create: function (context) { + create(context) { let invalidExtension; let invalidNode; diff --git a/lib/rules/jsx-first-prop-new-line.js b/lib/rules/jsx-first-prop-new-line.js index 6e0b08ebf0..30b4a574be 100644 --- a/lib/rules/jsx-first-prop-new-line.js +++ b/lib/rules/jsx-first-prop-new-line.js @@ -26,7 +26,7 @@ module.exports = { }] }, - create: function (context) { + create(context) { const configuration = context.options[0] || 'multiline-multiprop'; function isMultilineJSX(jsxNode) { @@ -34,7 +34,7 @@ module.exports = { } return { - JSXOpeningElement: function (node) { + JSXOpeningElement(node) { if ( (configuration === 'multiline' && isMultilineJSX(node)) || (configuration === 'multiline-multiprop' && isMultilineJSX(node) && node.attributes.length > 1) || @@ -45,7 +45,7 @@ module.exports = { context.report({ node: decl, message: 'Property should be placed on a new line', - fix: function (fixer) { + fix(fixer) { return fixer.replaceTextRange([node.name.range[1], decl.range[0]], '\n'); } }); @@ -58,7 +58,7 @@ module.exports = { context.report({ node: firstNode, message: 'Property should be placed on the same line as the component declaration', - fix: function (fixer) { + fix(fixer) { return fixer.replaceTextRange([node.name.range[1], firstNode.range[0]], ' '); } }); diff --git a/lib/rules/jsx-fragments.js b/lib/rules/jsx-fragments.js index 88da620f17..d39498d49b 100644 --- a/lib/rules/jsx-fragments.js +++ b/lib/rules/jsx-fragments.js @@ -34,7 +34,7 @@ module.exports = { }] }, - create: function (context) { + create(context) { const configuration = context.options[0] || 'syntax'; const sourceCode = context.getSourceCode(); const reactPragma = pragmaUtil.getFromContext(context); @@ -163,7 +163,7 @@ module.exports = { } }, - 'Program:exit'() { + 'Program:exit': function () { jsxElements.forEach((node) => { const openingEl = node.openingElement; const elName = elementType(openingEl); diff --git a/lib/rules/jsx-handler-names.js b/lib/rules/jsx-handler-names.js index 2d9893d257..89f67ec193 100644 --- a/lib/rules/jsx-handler-names.js +++ b/lib/rules/jsx-handler-names.js @@ -34,7 +34,7 @@ module.exports = { }] }, - create: function (context) { + create(context) { const sourceCode = context.getSourceCode(); const configuration = context.options[0] || {}; const eventHandlerPrefix = configuration.eventHandlerPrefix || 'handle'; @@ -44,7 +44,7 @@ module.exports = { const PROP_EVENT_HANDLER_REGEX = new RegExp(`^(${eventHandlerPropPrefix}[A-Z].*|ref)$`); return { - JSXAttribute: function (node) { + JSXAttribute(node) { if (!node.value || !node.value.expression || !node.value.expression.object) { return; } @@ -61,12 +61,12 @@ module.exports = { if (propIsEventHandler && !propFnIsNamedCorrectly) { context.report({ - node: node, + node, message: `Handler function for ${propKey} prop key must begin with '${eventHandlerPrefix}'` }); } else if (propFnIsNamedCorrectly && !propIsEventHandler) { context.report({ - node: node, + node, message: `Prop key for ${propValue} must begin with '${eventHandlerPropPrefix}'` }); } diff --git a/lib/rules/jsx-indent-props.js b/lib/rules/jsx-indent-props.js index 68d1b9b5c8..1febadfd09 100644 --- a/lib/rules/jsx-indent-props.js +++ b/lib/rules/jsx-indent-props.js @@ -55,7 +55,7 @@ module.exports = { }] }, - create: function (context) { + create(context) { const MESSAGE = 'Expected indentation of {{needed}} {{type}} {{characters}} but found {{gotten}}.'; const extraColumnStart = 0; @@ -86,17 +86,17 @@ module.exports = { */ function report(node, needed, gotten) { const msgContext = { - needed: needed, + needed, type: indentType, characters: needed === 1 ? 'character' : 'characters', - gotten: gotten + gotten }; context.report({ - node: node, + node, message: MESSAGE, data: msgContext, - fix: function (fixer) { + fix(fixer) { return fixer.replaceTextRange([node.range[0] - node.loc.start.column, node.range[0]], Array(needed + 1).join(indentType === 'space' ? ' ' : '\t')); } @@ -142,7 +142,7 @@ module.exports = { } return { - JSXOpeningElement: function (node) { + JSXOpeningElement(node) { if (!node.attributes.length) { return; } diff --git a/lib/rules/jsx-indent.js b/lib/rules/jsx-indent.js index e900824973..d620cdc515 100644 --- a/lib/rules/jsx-indent.js +++ b/lib/rules/jsx-indent.js @@ -65,7 +65,7 @@ module.exports = { }] }, - create: function (context) { + create(context) { const MESSAGE = 'Expected indentation of {{needed}} {{type}} {{characters}} but found {{gotten}}.'; const extraColumnStart = 0; @@ -115,23 +115,23 @@ module.exports = { */ function report(node, needed, gotten, loc) { const msgContext = { - needed: needed, + needed, type: indentType, characters: needed === 1 ? 'character' : 'characters', - gotten: gotten + gotten }; if (loc) { context.report({ - node: node, - loc: loc, + node, + loc, message: MESSAGE, data: msgContext, fix: getFixerFunction(node, needed) }); } else { context.report({ - node: node, + node, message: MESSAGE, data: msgContext, fix: getFixerFunction(node, needed) @@ -275,7 +275,7 @@ module.exports = { JSXClosingElement: handleClosingElement, JSXClosingFragment: handleClosingElement, JSXAttribute: handleAttribute, - JSXExpressionContainer: function (node) { + JSXExpressionContainer(node) { if (!node.parent) { return; } diff --git a/lib/rules/jsx-key.js b/lib/rules/jsx-key.js index 13afbc8b72..83e7873cfd 100644 --- a/lib/rules/jsx-key.js +++ b/lib/rules/jsx-key.js @@ -24,11 +24,11 @@ module.exports = { schema: [] }, - create: function (context) { + create(context) { function checkIteratorElement(node) { if (node.type === 'JSXElement' && !hasProp(node.openingElement.attributes, 'key')) { context.report({ - node: node, + node, message: 'Missing "key" prop for element in iterator' }); } @@ -39,21 +39,21 @@ module.exports = { } return { - JSXElement: function (node) { + JSXElement(node) { if (hasProp(node.openingElement.attributes, 'key')) { return; } if (node.parent.type === 'ArrayExpression') { context.report({ - node: node, + node, message: 'Missing "key" prop for element in array' }); } }, // Array.prototype.map - CallExpression: function (node) { + CallExpression(node) { if (node.callee && node.callee.type !== 'MemberExpression') { return; } diff --git a/lib/rules/jsx-max-depth.js b/lib/rules/jsx-max-depth.js index d29548b00d..50aa4780c5 100644 --- a/lib/rules/jsx-max-depth.js +++ b/lib/rules/jsx-max-depth.js @@ -34,7 +34,7 @@ module.exports = { } ] }, - create: function (context) { + create(context) { const MESSAGE = 'Expected the depth of nested jsx elements to be <= {{needed}}, but found {{found}}.'; const DEFAULT_DEPTH = 2; @@ -71,7 +71,7 @@ module.exports = { function report(node, depth) { context.report({ - node: node, + node, message: MESSAGE, data: { found: depth, @@ -132,7 +132,7 @@ module.exports = { JSXElement: handleJSX, JSXFragment: handleJSX, - JSXExpressionContainer: function (node) { + JSXExpressionContainer(node) { if (node.expression.type !== 'Identifier') { return; } diff --git a/lib/rules/jsx-max-props-per-line.js b/lib/rules/jsx-max-props-per-line.js index dc592ca358..69025c1e70 100644 --- a/lib/rules/jsx-max-props-per-line.js +++ b/lib/rules/jsx-max-props-per-line.js @@ -35,7 +35,7 @@ module.exports = { }] }, - create: function (context) { + create(context) { const sourceCode = context.getSourceCode(); const configuration = context.options[0] || {}; const maximum = configuration.maximum || 1; @@ -68,7 +68,7 @@ module.exports = { } return { - JSXOpeningElement: function (node) { + JSXOpeningElement(node) { if (!node.attributes.length) { return; } diff --git a/lib/rules/jsx-no-bind.js b/lib/rules/jsx-no-bind.js index d8f8a41510..612f492cea 100644 --- a/lib/rules/jsx-no-bind.js +++ b/lib/rules/jsx-no-bind.js @@ -122,7 +122,7 @@ module.exports = { return violationTypes.find((type) => { if (blockSets[type].has(name)) { - context.report({node: node, message: violationMessageStore[type]}); + context.report({node, message: violationMessageStore[type]}); return true; } @@ -159,7 +159,7 @@ module.exports = { } }, - JSXAttribute: function (node) { + JSXAttribute(node) { const isRef = configuration.ignoreRefs && propName(node) === 'ref'; if (isRef || !node.value || !node.value.expression) { return; @@ -176,7 +176,7 @@ module.exports = { findVariableViolation(node, valueNode.name); } else if (nodeViolationType) { context.report({ - node: node, message: violationMessageStore[nodeViolationType] + node, message: violationMessageStore[nodeViolationType] }); } } diff --git a/lib/rules/jsx-no-comment-textnodes.js b/lib/rules/jsx-no-comment-textnodes.js index 3ea9c7f9c7..6385f5c567 100644 --- a/lib/rules/jsx-no-comment-textnodes.js +++ b/lib/rules/jsx-no-comment-textnodes.js @@ -27,7 +27,7 @@ module.exports = { }] }, - create: function (context) { + create(context) { function reportLiteralNode(node) { context.report(node, 'Comments inside children section of tag should be placed inside braces'); } @@ -37,7 +37,7 @@ module.exports = { // -------------------------------------------------------------------------- return { - Literal: function (node) { + Literal(node) { const sourceCode = context.getSourceCode(); // since babel-eslint has the wrong node.raw, we'll get the source text const rawValue = sourceCode.getText(node); diff --git a/lib/rules/jsx-no-duplicate-props.js b/lib/rules/jsx-no-duplicate-props.js index 782e5a9d2e..7d9e00689e 100644 --- a/lib/rules/jsx-no-duplicate-props.js +++ b/lib/rules/jsx-no-duplicate-props.js @@ -32,12 +32,12 @@ module.exports = { }] }, - create: function (context) { + create(context) { const configuration = context.options[0] || {}; const ignoreCase = configuration.ignoreCase || false; return { - JSXOpeningElement: function (node) { + JSXOpeningElement(node) { const props = {}; node.attributes.forEach((decl) => { diff --git a/lib/rules/jsx-no-literals.js b/lib/rules/jsx-no-literals.js index 7d4d766caa..e34f2ba8d1 100644 --- a/lib/rules/jsx-no-literals.js +++ b/lib/rules/jsx-no-literals.js @@ -32,7 +32,7 @@ module.exports = { }] }, - create: function (context) { + create(context) { const isNoStrings = context.options[0] ? context.options[0].noStrings : false; const sourceCode = context.getSourceCode(); @@ -42,7 +42,7 @@ module.exports = { function reportLiteralNode(node) { context.report({ - node: node, + node, message: `${message}: “${sourceCode.getText(node).trim()}”` }); } @@ -73,19 +73,19 @@ module.exports = { return { - Literal: function (node) { + Literal(node) { if (getValidation(node)) { reportLiteralNode(node); } }, - JSXText: function (node) { + JSXText(node) { if (getValidation(node)) { reportLiteralNode(node); } }, - TemplateLiteral: function (node) { + TemplateLiteral(node) { const parent = getParentIgnoringBinaryExpressions(node); if (isNoStrings && parent.type === 'JSXExpressionContainer') { reportLiteralNode(node); diff --git a/lib/rules/jsx-no-target-blank.js b/lib/rules/jsx-no-target-blank.js index 097be191cf..46c266ab85 100644 --- a/lib/rules/jsx-no-target-blank.js +++ b/lib/rules/jsx-no-target-blank.js @@ -62,13 +62,13 @@ module.exports = { }] }, - create: function (context) { + create(context) { const configuration = context.options[0] || {}; const enforceDynamicLinks = configuration.enforceDynamicLinks || 'always'; const components = linkComponentsUtil.getLinkComponents(context); return { - JSXAttribute: function (node) { + JSXAttribute(node) { if (!components.has(node.parent.name.name) || !isTargetBlank(node) || hasSecureRel(node.parent)) { return; } diff --git a/lib/rules/jsx-no-undef.js b/lib/rules/jsx-no-undef.js index 76209fad93..a887e48bb1 100644 --- a/lib/rules/jsx-no-undef.js +++ b/lib/rules/jsx-no-undef.js @@ -31,7 +31,7 @@ module.exports = { }] }, - create: function (context) { + create(context) { const config = context.options[0] || {}; const allowGlobals = config.allowGlobals || false; @@ -77,13 +77,13 @@ module.exports = { } context.report({ - node: node, + node, message: `'${node.name}' is not defined.` }); } return { - JSXOpeningElement: function (node) { + JSXOpeningElement(node) { switch (node.name.type) { case 'JSXIdentifier': if (jsxUtil.isDOMComponent(node)) { diff --git a/lib/rules/jsx-one-expression-per-line.js b/lib/rules/jsx-one-expression-per-line.js index 60ccc2eb1a..55c424ede6 100644 --- a/lib/rules/jsx-one-expression-per-line.js +++ b/lib/rules/jsx-one-expression-per-line.js @@ -38,7 +38,7 @@ module.exports = { ] }, - create: function (context) { + create(context) { const options = Object.assign({}, optionDefaults, context.options[0]); const sourceCode = context.getSourceCode(); @@ -171,7 +171,7 @@ module.exports = { if (!fixDetailsByNode[key]) { fixDetailsByNode[key] = { node: child, - source: source, + source, descriptor: nodeDescriptor(child) }; } @@ -208,7 +208,7 @@ module.exports = { context.report({ node: nodeToReport, message: `\`${descriptor}\` must be placed on a new line`, - fix: function (fixer) { + fix(fixer) { return fixer.replaceText(nodeToReport, replaceText); } }); diff --git a/lib/rules/jsx-pascal-case.js b/lib/rules/jsx-pascal-case.js index 9e6e83abe8..34de9ae67b 100644 --- a/lib/rules/jsx-pascal-case.js +++ b/lib/rules/jsx-pascal-case.js @@ -43,13 +43,13 @@ module.exports = { }] }, - create: function (context) { + create(context) { const configuration = context.options[0] || {}; const allowAllCaps = configuration.allowAllCaps || false; const ignore = configuration.ignore || []; return { - JSXOpeningElement: function (node) { + JSXOpeningElement(node) { let name = elementType(node); // Get namespace if the type is JSXNamespacedName or JSXMemberExpression @@ -66,7 +66,7 @@ module.exports = { if (!isPascalCase && !isCompatTag && !isAllowedAllCaps && !isIgnored) { context.report({ - node: node, + node, message: `Imported JSX component ${name} must be in PascalCase` }); } diff --git a/lib/rules/jsx-props-no-multi-spaces.js b/lib/rules/jsx-props-no-multi-spaces.js index efa4584abb..94b3f7d3f2 100644 --- a/lib/rules/jsx-props-no-multi-spaces.js +++ b/lib/rules/jsx-props-no-multi-spaces.js @@ -23,7 +23,7 @@ module.exports = { schema: [] }, - create: function (context) { + create(context) { const sourceCode = context.getSourceCode(); function getPropName(propNode) { @@ -46,9 +46,9 @@ module.exports = { const between = sourceCode.text.slice(prev.range[1], node.range[0]); if (between !== ' ') { context.report({ - node: node, + node, message: `Expected only one space between "${getPropName(prev)}" and "${getPropName(node)}"`, - fix: function (fixer) { + fix(fixer) { return fixer.replaceTextRange([prev.range[1], node.range[0]], ' '); } }); @@ -81,7 +81,7 @@ module.exports = { } return { - JSXOpeningElement: function (node) { + JSXOpeningElement(node) { node.attributes.reduce((prev, prop) => { checkSpacing(prev, prop); return prop; diff --git a/lib/rules/jsx-props-no-spreading.js b/lib/rules/jsx-props-no-spreading.js index 0be323193c..f5ad8087f5 100644 --- a/lib/rules/jsx-props-no-spreading.js +++ b/lib/rules/jsx-props-no-spreading.js @@ -66,14 +66,14 @@ module.exports = { }] }, - create: function (context) { + create(context) { const configuration = context.options[0] || {}; const ignoreHtmlTags = (configuration.html || DEFAULTS.html) === OPTIONS.ignore; const ignoreCustomTags = (configuration.custom || DEFAULTS.custom) === OPTIONS.ignore; const exceptions = configuration.exceptions || DEFAULTS.exceptions; const isException = (tag, allExceptions) => allExceptions.indexOf(tag) !== -1; return { - JSXSpreadAttribute: function (node) { + JSXSpreadAttribute(node) { const tagName = node.parent.name.name; const isHTMLTag = tagName && tagName[0] !== tagName[0].toUpperCase(); const isCustomTag = tagName && tagName[0] === tagName[0].toUpperCase(); @@ -88,7 +88,7 @@ module.exports = { return; } context.report({ - node: node, + node, message: 'Prop spreading is forbidden' }); } diff --git a/lib/rules/jsx-sort-default-props.js b/lib/rules/jsx-sort-default-props.js index 72a0208dcf..af7df43984 100644 --- a/lib/rules/jsx-sort-default-props.js +++ b/lib/rules/jsx-sort-default-props.js @@ -33,7 +33,7 @@ module.exports = { }] }, - create: function (context) { + create(context) { const sourceCode = context.getSourceCode(); const configuration = context.options[0] || {}; const ignoreCase = configuration.ignoreCase || false; @@ -153,7 +153,7 @@ module.exports = { // -------------------------------------------------------------------------- return { - ClassProperty: function (node) { + ClassProperty(node) { if (!isDefaultPropsDeclaration(node)) { return; } @@ -161,7 +161,7 @@ module.exports = { checkNode(node.value); }, - MemberExpression: function (node) { + MemberExpression(node) { if (!isDefaultPropsDeclaration(node)) { return; } diff --git a/lib/rules/jsx-sort-props.js b/lib/rules/jsx-sort-props.js index 8a8543ae32..04f0eb97ac 100644 --- a/lib/rules/jsx-sort-props.js +++ b/lib/rules/jsx-sort-props.js @@ -238,7 +238,7 @@ module.exports = { }] }, - create: function (context) { + create(context) { const configuration = context.options[0] || {}; const ignoreCase = configuration.ignoreCase || false; const callbacksLast = configuration.callbacksLast || false; @@ -250,7 +250,7 @@ module.exports = { let reservedList = Array.isArray(reservedFirst) ? reservedFirst : RESERVED_PROPS_LIST; return { - JSXOpeningElement: function (node) { + JSXOpeningElement(node) { // `dangerouslySetInnerHTML` is only "reserved" on DOM components if (reservedFirst && !jsxUtil.isDOMComponent(node)) { reservedList = reservedList.filter(prop => prop !== 'dangerouslySetInnerHTML'); diff --git a/lib/rules/jsx-space-before-closing.js b/lib/rules/jsx-space-before-closing.js index 84924a39b9..ae69710cd2 100644 --- a/lib/rules/jsx-space-before-closing.js +++ b/lib/rules/jsx-space-before-closing.js @@ -32,7 +32,7 @@ module.exports = { }] }, - create: function (context) { + create(context) { const configuration = context.options[0] || 'always'; const sourceCode = context.getSourceCode(); @@ -44,7 +44,7 @@ module.exports = { // -------------------------------------------------------------------------- return { - JSXOpeningElement: function (node) { + JSXOpeningElement(node) { if (!node.selfClosing) { return; } @@ -60,7 +60,7 @@ module.exports = { context.report({ loc: closingSlash.loc.start, message: ALWAYS_MESSAGE, - fix: function (fixer) { + fix(fixer) { return fixer.insertTextBefore(closingSlash, ' '); } }); @@ -68,7 +68,7 @@ module.exports = { context.report({ loc: closingSlash.loc.start, message: NEVER_MESSAGE, - fix: function (fixer) { + fix(fixer) { const previousToken = sourceCode.getTokenBefore(closingSlash); return fixer.removeRange([previousToken.range[1], closingSlash.range[0]]); } @@ -76,7 +76,7 @@ module.exports = { } }, - Program: function () { + Program() { if (isWarnedForDeprecation) { return; } diff --git a/lib/rules/jsx-tag-spacing.js b/lib/rules/jsx-tag-spacing.js index 0619c7506e..9568672ac6 100644 --- a/lib/rules/jsx-tag-spacing.js +++ b/lib/rules/jsx-tag-spacing.js @@ -30,26 +30,26 @@ function validateClosingSlash(context, node, option) { if (option === 'never') { if (!adjacent) { context.report({ - node: node, + node, loc: { start: lastTokens[0].loc.start, end: lastTokens[1].loc.end }, message: SELF_CLOSING_NEVER_MESSAGE, - fix: function (fixer) { + fix(fixer) { return fixer.removeRange([lastTokens[0].range[1], lastTokens[1].range[0]]); } }); } } else if (option === 'always' && adjacent) { context.report({ - node: node, + node, loc: { start: lastTokens[0].loc.start, end: lastTokens[1].loc.end }, message: SELF_CLOSING_ALWAYS_MESSAGE, - fix: function (fixer) { + fix(fixer) { return fixer.insertTextBefore(lastTokens[1], ' '); } }); @@ -62,26 +62,26 @@ function validateClosingSlash(context, node, option) { if (option === 'never') { if (!adjacent) { context.report({ - node: node, + node, loc: { start: firstTokens[0].loc.start, end: firstTokens[1].loc.end }, message: NEVER_MESSAGE, - fix: function (fixer) { + fix(fixer) { return fixer.removeRange([firstTokens[0].range[1], firstTokens[1].range[0]]); } }); } } else if (option === 'always' && adjacent) { context.report({ - node: node, + node, loc: { start: firstTokens[0].loc.start, end: firstTokens[1].loc.end }, message: ALWAYS_MESSAGE, - fix: function (fixer) { + fix(fixer) { return fixer.insertTextBefore(firstTokens[1], ' '); } }); @@ -104,19 +104,19 @@ function validateBeforeSelfClosing(context, node, option) { if (option === 'always' && !sourceCode.isSpaceBetweenTokens(leftToken, closingSlash)) { context.report({ - node: node, + node, loc: closingSlash.loc.start, message: ALWAYS_MESSAGE, - fix: function (fixer) { + fix(fixer) { return fixer.insertTextBefore(closingSlash, ' '); } }); } else if (option === 'never' && sourceCode.isSpaceBetweenTokens(leftToken, closingSlash)) { context.report({ - node: node, + node, loc: closingSlash.loc.start, message: NEVER_MESSAGE, - fix: function (fixer) { + fix(fixer) { const previousToken = sourceCode.getTokenBefore(closingSlash); return fixer.removeRange([previousToken.range[1], closingSlash.range[0]]); } @@ -143,26 +143,26 @@ function validateAfterOpening(context, node, option) { if (option === 'never' || option === 'allow-multiline') { if (!adjacent) { context.report({ - node: node, + node, loc: { start: openingToken.loc.start, end: node.name.loc.start }, message: NEVER_MESSAGE, - fix: function (fixer) { + fix(fixer) { return fixer.removeRange([openingToken.range[1], node.name.range[0]]); } }); } } else if (option === 'always' && adjacent) { context.report({ - node: node, + node, loc: { start: openingToken.loc.start, end: node.name.loc.start }, message: ALWAYS_MESSAGE, - fix: function (fixer) { + fix(fixer) { return fixer.insertTextBefore(node.name, ' '); } }); @@ -189,25 +189,25 @@ function validateBeforeClosing(context, node, option) { if (option === 'never' && !adjacent) { context.report({ - node: node, + node, loc: { start: leftToken.loc.end, end: closingToken.loc.start }, message: NEVER_MESSAGE, - fix: function (fixer) { + fix(fixer) { return fixer.removeRange([leftToken.range[1], closingToken.range[0]]); } }); } else if (option === 'always' && adjacent) { context.report({ - node: node, + node, loc: { start: leftToken.loc.end, end: closingToken.loc.start }, message: ALWAYS_MESSAGE, - fix: function (fixer) { + fix(fixer) { return fixer.insertTextBefore(closingToken, ' '); } }); @@ -257,11 +257,11 @@ module.exports = { } ] }, - create: function (context) { + create(context) { const options = Object.assign({}, optionDefaults, context.options[0]); return { - JSXOpeningElement: function (node) { + JSXOpeningElement(node) { if (options.closingSlash !== 'allow' && node.selfClosing) { validateClosingSlash(context, node, options.closingSlash); } @@ -275,7 +275,7 @@ module.exports = { validateBeforeClosing(context, node, options.beforeClosing); } }, - JSXClosingElement: function (node) { + JSXClosingElement(node) { if (options.afterOpening !== 'allow') { validateAfterOpening(context, node, options.afterOpening); } diff --git a/lib/rules/jsx-uses-react.js b/lib/rules/jsx-uses-react.js index 10003172af..bebcdf3cfa 100644 --- a/lib/rules/jsx-uses-react.js +++ b/lib/rules/jsx-uses-react.js @@ -23,7 +23,7 @@ module.exports = { schema: [] }, - create: function (context) { + create(context) { const pragma = pragmaUtil.getFromContext(context); function handleOpeningElement() { diff --git a/lib/rules/jsx-uses-vars.js b/lib/rules/jsx-uses-vars.js index 4c1267ed8d..86a32f1f46 100644 --- a/lib/rules/jsx-uses-vars.js +++ b/lib/rules/jsx-uses-vars.js @@ -22,9 +22,9 @@ module.exports = { schema: [] }, - create: function (context) { + create(context) { return { - JSXOpeningElement: function (node) { + JSXOpeningElement(node) { let name; if (node.name.namespace && node.name.namespace.name) { // diff --git a/lib/rules/jsx-wrap-multilines.js b/lib/rules/jsx-wrap-multilines.js index 730294ca87..197200bdbc 100644 --- a/lib/rules/jsx-wrap-multilines.js +++ b/lib/rules/jsx-wrap-multilines.js @@ -70,7 +70,7 @@ module.exports = { }] }, - create: function (context) { + create(context) { const sourceCode = context.getSourceCode(); function getOption(type) { @@ -196,7 +196,7 @@ module.exports = { return { - VariableDeclarator: function (node) { + VariableDeclarator(node) { const type = 'declaration'; if (!isEnabled(type)) { return; @@ -209,7 +209,7 @@ module.exports = { check(node.init, type); }, - AssignmentExpression: function (node) { + AssignmentExpression(node) { const type = 'assignment'; if (!isEnabled(type)) { return; @@ -222,7 +222,7 @@ module.exports = { check(node.right, type); }, - ReturnStatement: function (node) { + ReturnStatement(node) { const type = 'return'; if (isEnabled(type)) { check(node.argument, type); @@ -238,7 +238,7 @@ module.exports = { } }, - ConditionalExpression: function (node) { + ConditionalExpression(node) { const type = 'condition'; if (isEnabled(type)) { check(node.consequent, type); @@ -246,14 +246,14 @@ module.exports = { } }, - LogicalExpression: function (node) { + LogicalExpression(node) { const type = 'logical'; if (isEnabled(type)) { check(node.right, type); } }, - JSXAttribute: function (node) { + JSXAttribute(node) { const type = 'prop'; if (isEnabled(type) && node.value && node.value.type === 'JSXExpressionContainer') { check(node.value.expression, type); diff --git a/lib/rules/no-access-state-in-setstate.js b/lib/rules/no-access-state-in-setstate.js index 2efe90ad6e..01699839a1 100644 --- a/lib/rules/no-access-state-in-setstate.js +++ b/lib/rules/no-access-state-in-setstate.js @@ -21,7 +21,7 @@ module.exports = { } }, - create: function (context) { + create(context) { function isSetStateCall(node) { return node.type === 'CallExpression' && node.callee.property && @@ -105,13 +105,13 @@ module.exports = { if (current.type === 'MethodDefinition') { methods.push({ methodName: current.key.name, - node: node + node }); break; } else if (current.type === 'FunctionExpression' && current.parent.key) { methods.push({ methodName: current.parent.key.name, - node: node + node }); break; } @@ -119,7 +119,7 @@ module.exports = { // Storing all variables containg this.state if (current.type === 'VariableDeclarator') { vars.push({ - node: node, + node, scope: context.getScope(), variableName: current.id.name }); diff --git a/lib/rules/no-array-index-key.js b/lib/rules/no-array-index-key.js index d12e9ad46a..291c8cda1b 100644 --- a/lib/rules/no-array-index-key.js +++ b/lib/rules/no-array-index-key.js @@ -26,7 +26,7 @@ module.exports = { schema: [] }, - create: function (context) { + create(context) { // -------------------------------------------------------------------------- // Public // -------------------------------------------------------------------------- @@ -128,7 +128,7 @@ module.exports = { if (isArrayIndex(node)) { // key={bar} context.report({ - node: node, + node, message: ERROR_MESSAGE }); return; @@ -137,7 +137,7 @@ module.exports = { if (node.type === 'TemplateLiteral') { // key={`foo-${bar}`} node.expressions.filter(isArrayIndex).forEach(() => { - context.report({node: node, message: ERROR_MESSAGE}); + context.report({node, message: ERROR_MESSAGE}); }); return; @@ -148,13 +148,13 @@ module.exports = { const identifiers = getIdentifiersFromBinaryExpression(node); identifiers.filter(isArrayIndex).forEach(() => { - context.report({node: node, message: ERROR_MESSAGE}); + context.report({node, message: ERROR_MESSAGE}); }); } } return { - CallExpression: function (node) { + CallExpression(node) { if ( node.callee && node.callee.type === 'MemberExpression' @@ -193,7 +193,7 @@ module.exports = { indexParamNames.push(mapIndexParamName); }, - JSXAttribute: function (node) { + JSXAttribute(node) { if (node.name.name !== 'key') { // foo={bar} return; diff --git a/lib/rules/no-children-prop.js b/lib/rules/no-children-prop.js index 73f3199e1c..67161fc9fa 100644 --- a/lib/rules/no-children-prop.js +++ b/lib/rules/no-children-prop.js @@ -39,19 +39,19 @@ module.exports = { }, schema: [] }, - create: function (context) { + create(context) { return { - JSXAttribute: function (node) { + JSXAttribute(node) { if (node.name.name !== 'children') { return; } context.report({ - node: node, + node, message: 'Do not pass children as props. Instead, nest children between the opening and closing tags.' }); }, - CallExpression: function (node) { + CallExpression(node) { if (!isCreateElementWithProps(node)) { return; } @@ -61,7 +61,7 @@ module.exports = { if (childrenProp) { context.report({ - node: node, + node, message: 'Do not pass children as props. Instead, pass them as additional arguments to React.createElement.' }); } diff --git a/lib/rules/no-danger-with-children.js b/lib/rules/no-danger-with-children.js index caa0b7e93d..0c664f5d43 100644 --- a/lib/rules/no-danger-with-children.js +++ b/lib/rules/no-danger-with-children.js @@ -21,7 +21,7 @@ module.exports = { }, schema: [] // no options }, - create: function (context) { + create(context) { function findSpreadVariable(name) { return variableUtil.variablesInScope(context).find(item => item.name === name); } @@ -85,7 +85,7 @@ module.exports = { } return { - JSXElement: function (node) { + JSXElement(node) { let hasChildren = false; if (node.children.length && !isLineBreak(node.children[0])) { @@ -102,7 +102,7 @@ module.exports = { context.report(node, 'Only set one of `children` or `props.dangerouslySetInnerHTML`'); } }, - CallExpression: function (node) { + CallExpression(node) { if ( node.callee && node.callee.type === 'MemberExpression' diff --git a/lib/rules/no-danger.js b/lib/rules/no-danger.js index faae545e30..9322c090fe 100644 --- a/lib/rules/no-danger.js +++ b/lib/rules/no-danger.js @@ -51,13 +51,13 @@ module.exports = { schema: [] }, - create: function (context) { + create(context) { return { - JSXAttribute: function (node) { + JSXAttribute(node) { if (jsxUtil.isDOMComponent(node.parent) && isDangerous(node.name.name)) { context.report({ - node: node, + node, message: DANGEROUS_MESSAGE, data: { name: node.name.name diff --git a/lib/rules/no-deprecated.js b/lib/rules/no-deprecated.js index dd6906685c..f7d57f4f31 100644 --- a/lib/rules/no-deprecated.js +++ b/lib/rules/no-deprecated.js @@ -180,11 +180,11 @@ module.exports = { return { - MemberExpression: function (node) { + MemberExpression(node) { checkDeprecation(node, sourceCode.getText(node)); }, - ImportDeclaration: function (node) { + ImportDeclaration(node) { const isReactImport = typeof MODULES[node.source.value] !== 'undefined'; if (!isReactImport) { return; @@ -197,7 +197,7 @@ module.exports = { }); }, - VariableDeclarator: function (node) { + VariableDeclarator(node) { const reactModuleName = getReactModuleName(node); const isRequire = node.init && node.init.callee && node.init.callee.name === 'require'; const isReactRequire = node.init diff --git a/lib/rules/no-direct-mutation-state.js b/lib/rules/no-direct-mutation-state.js index 226d981e50..30a88cfbff 100644 --- a/lib/rules/no-direct-mutation-state.js +++ b/lib/rules/no-direct-mutation-state.js @@ -81,7 +81,7 @@ module.exports = { } }, - CallExpression: function (node) { + CallExpression(node) { components.set(node, { inCallExpression: true }); diff --git a/lib/rules/no-find-dom-node.js b/lib/rules/no-find-dom-node.js index 32762e1865..d7f2ef16da 100644 --- a/lib/rules/no-find-dom-node.js +++ b/lib/rules/no-find-dom-node.js @@ -22,14 +22,14 @@ module.exports = { schema: [] }, - create: function (context) { + create(context) { // -------------------------------------------------------------------------- // Public // -------------------------------------------------------------------------- return { - CallExpression: function (node) { + CallExpression(node) { const callee = node.callee; const isfindDOMNode = diff --git a/lib/rules/no-is-mounted.js b/lib/rules/no-is-mounted.js index 5b45bf2347..3132079831 100644 --- a/lib/rules/no-is-mounted.js +++ b/lib/rules/no-is-mounted.js @@ -22,14 +22,14 @@ module.exports = { schema: [] }, - create: function (context) { + create(context) { // -------------------------------------------------------------------------- // Public // -------------------------------------------------------------------------- return { - CallExpression: function (node) { + CallExpression(node) { const callee = node.callee; if (callee.type !== 'MemberExpression') { return; diff --git a/lib/rules/no-redundant-should-component-update.js b/lib/rules/no-redundant-should-component-update.js index 791ec676ab..3321dffe6f 100644 --- a/lib/rules/no-redundant-should-component-update.js +++ b/lib/rules/no-redundant-should-component-update.js @@ -66,7 +66,7 @@ module.exports = { if (hasScu) { const className = getNodeName(node); context.report({ - node: node, + node, message: errorMessage(className) }); } diff --git a/lib/rules/no-render-return-value.js b/lib/rules/no-render-return-value.js index d53cd0664e..d0349f3e01 100644 --- a/lib/rules/no-render-return-value.js +++ b/lib/rules/no-render-return-value.js @@ -23,7 +23,7 @@ module.exports = { schema: [] }, - create: function (context) { + create(context) { // -------------------------------------------------------------------------- // Public // -------------------------------------------------------------------------- @@ -39,7 +39,7 @@ module.exports = { return { - CallExpression: function (node) { + CallExpression(node) { const callee = node.callee; const parent = node.parent; if (callee.type !== 'MemberExpression') { diff --git a/lib/rules/no-set-state.js b/lib/rules/no-set-state.js index 0f065ae194..7af70116f8 100644 --- a/lib/rules/no-set-state.js +++ b/lib/rules/no-set-state.js @@ -54,7 +54,7 @@ module.exports = { return { - CallExpression: function (node) { + CallExpression(node) { const callee = node.callee; if ( callee.type !== 'MemberExpression' || @@ -68,7 +68,7 @@ module.exports = { setStateUsages.push(callee); components.set(node, { useSetState: true, - setStateUsages: setStateUsages + setStateUsages }); }, diff --git a/lib/rules/no-string-refs.js b/lib/rules/no-string-refs.js index 36bf2e6df9..96ebc2e48c 100644 --- a/lib/rules/no-string-refs.js +++ b/lib/rules/no-string-refs.js @@ -91,21 +91,21 @@ module.exports = { } return { - MemberExpression: function (node) { + MemberExpression(node) { if (isRefsUsage(node)) { context.report({ - node: node, + node, message: 'Using this.refs is deprecated.' }); } }, - JSXAttribute: function (node) { + JSXAttribute(node) { if ( isRefAttribute(node) && (containsStringLiteral(node) || containsStringExpressionContainer(node)) ) { context.report({ - node: node, + node, message: 'Using string literals in ref attributes is deprecated.' }); } diff --git a/lib/rules/no-this-in-sfc.js b/lib/rules/no-this-in-sfc.js index 7dc0f6ca34..df86ba55ca 100644 --- a/lib/rules/no-this-in-sfc.js +++ b/lib/rules/no-this-in-sfc.js @@ -36,7 +36,7 @@ module.exports = { return; } context.report({ - node: node, + node, message: ERROR_MESSAGE }); } diff --git a/lib/rules/no-typos.js b/lib/rules/no-typos.js index fabd703303..5ac103b204 100644 --- a/lib/rules/no-typos.js +++ b/lib/rules/no-typos.js @@ -49,7 +49,7 @@ module.exports = { function checkValidPropTypeQualifier(node) { if (node.name !== 'isRequired') { context.report({ - node: node, + node, message: `Typo in prop type chain qualifier: ${node.name}` }); } @@ -58,7 +58,7 @@ module.exports = { function checkValidPropType(node) { if (node.name && !PROP_TYPES.some(propTypeName => propTypeName === node.name)) { context.report({ - node: node, + node, message: `Typo in declared prop type: ${node.name}` }); } @@ -135,8 +135,8 @@ module.exports = { ? 'Typo in static class property declaration' : 'Typo in property declaration'; context.report({ - node: node, - message: message + node, + message }); } }); @@ -146,7 +146,7 @@ module.exports = { LIFECYCLE_METHODS.forEach((method) => { if (method.toLowerCase() === node.key.name.toLowerCase() && method !== node.key.name) { context.report({ - node: node, + node, message: 'Typo in component lifecycle method declaration' }); } @@ -154,7 +154,7 @@ module.exports = { } return { - ImportDeclaration: function (node) { + ImportDeclaration(node) { if (node.source && node.source.value === 'prop-types') { // import PropType from "prop-types" propTypesPackageName = node.specifiers[0].local.name; } else if (node.source && node.source.value === 'react') { // import { PropTypes } from "react" @@ -172,7 +172,7 @@ module.exports = { } }, - ClassProperty: function (node) { + ClassProperty(node) { if (!node.static || !utils.isES6Component(node.parent.parent)) { return; } @@ -182,7 +182,7 @@ module.exports = { reportErrorIfPropertyCasingTypo(node.value, propertyName, true); }, - MemberExpression: function (node) { + MemberExpression(node) { const propertyName = node.property.name; if ( @@ -203,7 +203,7 @@ module.exports = { } }, - MethodDefinition: function (node) { + MethodDefinition(node) { if (!utils.isES6Component(node.parent.parent)) { return; } @@ -211,7 +211,7 @@ module.exports = { reportErrorIfLifecycleMethodCasingTypo(node); }, - ObjectExpression: function (node) { + ObjectExpression(node) { const component = utils.isES5Component(node) && components.get(node); if (!component) { diff --git a/lib/rules/no-unescaped-entities.js b/lib/rules/no-unescaped-entities.js index 8e072ffe56..b8f5e76e38 100644 --- a/lib/rules/no-unescaped-entities.js +++ b/lib/rules/no-unescaped-entities.js @@ -67,7 +67,7 @@ module.exports = { }] }, - create: function (context) { + create(context) { function reportInvalidEntity(node) { const configuration = context.options[0] || {}; const entities = configuration.forbid || DEFAULTS; @@ -93,14 +93,14 @@ module.exports = { context.report({ loc: {line: i, column: start + index}, message: `HTML entity, \`${entities[j]}\` , must be escaped.`, - node: node + node }); } } 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(', ')}.`, - node: node + node }); } } diff --git a/lib/rules/no-unknown-property.js b/lib/rules/no-unknown-property.js index 67d4082c0c..477e788bc5 100644 --- a/lib/rules/no-unknown-property.js +++ b/lib/rules/no-unknown-property.js @@ -230,7 +230,7 @@ module.exports = { }] }, - create: function (context) { + create(context) { function getIgnoreConfig() { return context.options[0] && context.options[0].ignore || DEFAULTS.ignore; } @@ -239,7 +239,7 @@ module.exports = { return { - JSXAttribute: function (node) { + JSXAttribute(node) { const ignoreNames = getIgnoreConfig(); const name = sourceCode.getText(node.name); if (ignoreNames.indexOf(name) >= 0) { @@ -255,11 +255,11 @@ module.exports = { const allowedTags = ATTRIBUTE_TAGS_MAP[name]; if (tagName && allowedTags && /[^A-Z]/.test(tagName.charAt(0)) && allowedTags.indexOf(tagName) === -1) { context.report({ - node: node, + node, message: WRONG_TAG_MESSAGE, data: { - name: name, - tagName: tagName, + name, + tagName, allowedTags: allowedTags.join(', ') } }); @@ -270,13 +270,13 @@ module.exports = { return; } context.report({ - node: node, + node, message: UNKNOWN_MESSAGE, data: { - name: name, - standardName: standardName + name, + standardName }, - fix: function (fixer) { + fix(fixer) { return fixer.replaceText(node.name, standardName); } }); diff --git a/lib/rules/no-unsafe.js b/lib/rules/no-unsafe.js index 704e004a65..59b691b461 100644 --- a/lib/rules/no-unsafe.js +++ b/lib/rules/no-unsafe.js @@ -101,7 +101,7 @@ module.exports = { const details = meta.details; context.report({ - node: node, + node, message: `${method} is unsafe for use in async rendering. Update the component to use ${newMethod} instead. ${details}` }); } diff --git a/lib/rules/no-unused-state.js b/lib/rules/no-unused-state.js index 1bc70e2dfc..4b1628950c 100644 --- a/lib/rules/no-unused-state.js +++ b/lib/rules/no-unused-state.js @@ -230,7 +230,7 @@ module.exports = { } }, - 'ObjectExpression:exit'(node) { + 'ObjectExpression:exit': function (node) { if (!classInfo) { return; } @@ -241,7 +241,7 @@ module.exports = { } }, - 'ClassDeclaration:exit'() { + 'ClassDeclaration:exit': function () { if (!classInfo) { return; } @@ -305,7 +305,7 @@ module.exports = { } }, - 'ClassProperty:exit'(node) { + 'ClassProperty:exit': function (node) { if ( classInfo && !node.static && @@ -325,7 +325,7 @@ module.exports = { classInfo.aliases = new Set(); }, - 'MethodDefinition:exit'() { + 'MethodDefinition:exit': function () { if (!classInfo) { return; } @@ -421,7 +421,7 @@ module.exports = { } }, - 'ExperimentalSpreadProperty, SpreadElement'(node) { + 'ExperimentalSpreadProperty, SpreadElement': function (node) { if (classInfo && isStateReference(node.argument)) { classInfo = null; } diff --git a/lib/rules/prefer-es6-class.js b/lib/rules/prefer-es6-class.js index 55cd9f97b9..b35a85b969 100644 --- a/lib/rules/prefer-es6-class.js +++ b/lib/rules/prefer-es6-class.js @@ -30,18 +30,18 @@ module.exports = { const configuration = context.options[0] || 'always'; return { - ObjectExpression: function (node) { + ObjectExpression(node) { if (utils.isES5Component(node) && configuration === 'always') { context.report({ - node: node, + node, message: 'Component should use es6 class instead of createClass' }); } }, - ClassDeclaration: function (node) { + ClassDeclaration(node) { if (utils.isES6Component(node) && configuration === 'never') { context.report({ - node: node, + node, message: 'Component should use createClass instead of es6 class' }); } diff --git a/lib/rules/prefer-stateless-function.js b/lib/rules/prefer-stateless-function.js index c843564259..521a66d0a8 100644 --- a/lib/rules/prefer-stateless-function.js +++ b/lib/rules/prefer-stateless-function.js @@ -280,7 +280,7 @@ module.exports = { ClassExpression: visitClass, // Mark `this` destructuring as a usage of `this` - VariableDeclarator: function (node) { + VariableDeclarator(node) { // Ignore destructuring on other than `this` if (!node.id || node.id.type !== 'ObjectPattern' || !node.init || node.init.type !== 'ThisExpression') { return; @@ -298,7 +298,7 @@ module.exports = { }, // Mark `this` usage - MemberExpression: function (node) { + MemberExpression(node) { if (node.object.type !== 'ThisExpression') { if (node.property && node.property.name === 'childContextTypes') { const component = utils.getRelatedComponent(node); @@ -321,7 +321,7 @@ module.exports = { }, // Mark `ref` usage - JSXAttribute: function (node) { + JSXAttribute(node) { const name = sourceCode.getText(node.name); if (name !== 'ref') { return; @@ -330,7 +330,7 @@ module.exports = { }, // Mark `render` that do not return some JSX - ReturnStatement: function (node) { + ReturnStatement(node) { let blockNode; let scope = context.getScope(); while (scope) { diff --git a/lib/rules/react-in-jsx-scope.js b/lib/rules/react-in-jsx-scope.js index 5279cdaba6..9df35dab76 100644 --- a/lib/rules/react-in-jsx-scope.js +++ b/lib/rules/react-in-jsx-scope.js @@ -24,7 +24,7 @@ module.exports = { schema: [] }, - create: function (context) { + create(context) { const pragma = pragmaUtil.getFromContext(context); const NOT_DEFINED_MESSAGE = '\'{{name}}\' must be in scope when using JSX'; @@ -34,7 +34,7 @@ module.exports = { return; } context.report({ - node: node, + node, message: NOT_DEFINED_MESSAGE, data: { name: pragma diff --git a/lib/rules/require-optimization.js b/lib/rules/require-optimization.js index fb19200aba..43600bf435 100644 --- a/lib/rules/require-optimization.js +++ b/lib/rules/require-optimization.js @@ -165,19 +165,19 @@ module.exports = { }; return { - ArrowFunctionExpression: function (node) { + ArrowFunctionExpression(node) { // Stateless Functional Components cannot be optimized (yet) markSCUAsDeclared(node); }, - ClassDeclaration: function (node) { + ClassDeclaration(node) { if (!(hasPureRenderDecorator(node) || hasCustomDecorator(node) || utils.isPureComponent(node))) { return; } markSCUAsDeclared(node); }, - FunctionDeclaration: function (node) { + FunctionDeclaration(node) { // Skip if the function is declared in the class if (isFunctionInClass()) { return; @@ -186,7 +186,7 @@ module.exports = { markSCUAsDeclared(node); }, - FunctionExpression: function (node) { + FunctionExpression(node) { // Skip if the function is declared in the class if (isFunctionInClass()) { return; @@ -195,14 +195,14 @@ module.exports = { markSCUAsDeclared(node); }, - MethodDefinition: function (node) { + MethodDefinition(node) { if (!isSCUDeclarеd(node.key)) { return; } markSCUAsDeclared(node); }, - ObjectExpression: function (node) { + ObjectExpression(node) { // Search for the shouldComponentUpdate declaration for (let i = 0, l = node.properties.length; i < l; i++) { if ( diff --git a/lib/rules/require-render-return.js b/lib/rules/require-render-return.js index 8d753bf37a..b02126ccca 100644 --- a/lib/rules/require-render-return.js +++ b/lib/rules/require-render-return.js @@ -48,7 +48,7 @@ module.exports = { } return { - ReturnStatement: function (node) { + ReturnStatement(node) { const ancestors = context.getAncestors(node).reverse(); let depth = 0; for (let i = 0, j = ancestors.length; i < j; i++) { @@ -66,7 +66,7 @@ module.exports = { } }, - ArrowFunctionExpression: function (node) { + ArrowFunctionExpression(node) { if (node.expression === false || astUtil.getPropertyName(node.parent) !== 'render') { return; } diff --git a/lib/rules/self-closing-comp.js b/lib/rules/self-closing-comp.js index 6178ae9d65..94ca78a374 100644 --- a/lib/rules/self-closing-comp.js +++ b/lib/rules/self-closing-comp.js @@ -40,7 +40,7 @@ module.exports = { }] }, - create: function (context) { + create(context) { function isComponent(node) { return node.name && node.name.type === 'JSXIdentifier' && !jsxUtil.isDOMComponent(node); } @@ -74,14 +74,14 @@ module.exports = { return { - JSXOpeningElement: function (node) { + JSXOpeningElement(node) { if (!isShouldBeSelfClosed(node)) { return; } context.report({ - node: node, + node, message: 'Empty components are self-closing', - fix: function (fixer) { + fix(fixer) { // Represents the last character of the JSXOpeningElement, the '>' character const openingElementEnding = node.range[1] - 1; // Represents the last character of the JSXClosingElement, the '>' character diff --git a/lib/rules/sort-prop-types.js b/lib/rules/sort-prop-types.js index 56f08cb164..90a7f8f075 100644 --- a/lib/rules/sort-prop-types.js +++ b/lib/rules/sort-prop-types.js @@ -48,7 +48,7 @@ module.exports = { }] }, - create: function (context) { + create(context) { const sourceCode = context.getSourceCode(); const configuration = context.options[0] || {}; const requiredFirst = configuration.requiredFirst || false; @@ -267,21 +267,21 @@ module.exports = { } return { - CallExpression: function (node) { + CallExpression(node) { if (!sortShapeProp || !isShapeProp(node) || !(node.arguments && node.arguments[0])) { return; } checkSorted(node.arguments[0].properties); }, - ClassProperty: function (node) { + ClassProperty(node) { if (!propsUtil.isPropTypesDeclaration(node)) { return; } checkNode(node.value); }, - MemberExpression: function (node) { + MemberExpression(node) { if (!propsUtil.isPropTypesDeclaration(node)) { return; } @@ -289,7 +289,7 @@ module.exports = { checkNode(node.parent.right); }, - ObjectExpression: function (node) { + ObjectExpression(node) { node.properties.forEach((property) => { if (!property.key) { return; diff --git a/lib/rules/state-in-constructor.js b/lib/rules/state-in-constructor.js index 04acf78e6e..91a5d5d9db 100644 --- a/lib/rules/state-in-constructor.js +++ b/lib/rules/state-in-constructor.js @@ -28,7 +28,7 @@ module.exports = { create: Components.detect((context, components, utils) => { const option = context.options[0] || 'always'; return { - ClassProperty: function (node) { + ClassProperty(node) { if ( option === 'always' && !node.static && diff --git a/lib/rules/style-prop-object.js b/lib/rules/style-prop-object.js index 8f8f0e35ad..71d9a6807f 100644 --- a/lib/rules/style-prop-object.js +++ b/lib/rules/style-prop-object.js @@ -23,7 +23,7 @@ module.exports = { schema: [] }, - create: function (context) { + create(context) { /** * @param {ASTNode} expression An Identifier node */ @@ -47,7 +47,7 @@ module.exports = { } return { - CallExpression: function (node) { + CallExpression(node) { if ( node.callee && node.callee.type === 'MemberExpression' @@ -67,7 +67,7 @@ module.exports = { } }, - JSXAttribute: function (node) { + JSXAttribute(node) { if (!node.value || node.name.name !== 'style') { return; } diff --git a/lib/rules/void-dom-elements-no-children.js b/lib/rules/void-dom-elements-no-children.js index 74b7e66584..e4e1ce6643 100644 --- a/lib/rules/void-dom-elements-no-children.js +++ b/lib/rules/void-dom-elements-no-children.js @@ -60,7 +60,7 @@ module.exports = { }, create: Components.detect((context, components, utils) => ({ - JSXElement: function (node) { + JSXElement(node) { const elementName = node.openingElement.name.name; if (!isVoidDOMElement(elementName)) { @@ -71,7 +71,7 @@ module.exports = { if (node.children.length > 0) { // e.g.
Foo
context.report({ - node: node, + node, message: errorMessage(elementName) }); } @@ -89,13 +89,13 @@ module.exports = { if (hasChildrenAttributeOrDanger) { // e.g.
context.report({ - node: node, + node, message: errorMessage(elementName) }); } }, - CallExpression: function (node) { + CallExpression(node) { if (node.callee.type !== 'MemberExpression' && node.callee.type !== 'Identifier') { return; } @@ -126,7 +126,7 @@ module.exports = { if (firstChild) { // e.g. React.createElement('br', undefined, 'Foo') context.report({ - node: node, + node, message: errorMessage(elementName) }); } @@ -144,7 +144,7 @@ module.exports = { if (hasChildrenPropOrDanger) { // e.g. React.createElement('br', { children: 'Foo' }) context.report({ - node: node, + node, message: errorMessage(elementName) }); } diff --git a/lib/util/Components.js b/lib/util/Components.js index c35e586bb6..8819dc4582 100644 --- a/lib/util/Components.js +++ b/lib/util/Components.js @@ -71,8 +71,8 @@ class Components { return this._list[id]; } this._list[id] = { - node: node, - confidence: confidence + node, + confidence }; return this._list[id]; } @@ -188,7 +188,7 @@ function componentRule(rule, context) { * @param {ASTNode} node The AST node being checked. * @returns {Boolean} True if the node is a React ES5 component, false if not */ - isES5Component: function (node) { + isES5Component(node) { if (!node.parent) { return false; } @@ -201,7 +201,7 @@ function componentRule(rule, context) { * @param {ASTNode} node The AST node being checked. * @returns {Boolean} True if the node is a React ES6 component, false if not */ - isES6Component: function (node) { + isES6Component(node) { if (utils.isExplicitComponent(node)) { return true; } @@ -218,7 +218,7 @@ function componentRule(rule, context) { * @param {ASTNode} node The AST node being checked (can be a ReturnStatement or an ArrowFunctionExpression). * @returns {Boolean} True if the node is explicitly declared as a descendant of a React Component, false if not */ - isExplicitComponent: function (node) { + isExplicitComponent(node) { let comment; // Sometimes the passed node may not have been parsed yet by eslint, and this function call crashes. // Can be removed when eslint sets "parent" property for all nodes on initial AST traversal: https://github.com/eslint/eslint-scope/issues/27 @@ -250,7 +250,7 @@ function componentRule(rule, context) { * @param {ASTNode} node The AST node being checked. * @returns {Boolean} True if node extends React.PureComponent, false if not */ - isPureComponent: function (node) { + isPureComponent(node) { if (node.superClass) { return new RegExp(`^(${pragma}\\.)?PureComponent$`).test(sourceCode.getText(node.superClass)); } @@ -263,7 +263,7 @@ function componentRule(rule, context) { * @param {string} variable The variable name to check * @returns {Boolean} True if createElement is destructured from the pragma */ - isDestructuredFromPragmaImport: function (variable) { + isDestructuredFromPragmaImport(variable) { const variables = variableUtil.variablesInScope(context); const variableInScope = variableUtil.getVariable(variables, variable); if (variableInScope) { @@ -279,7 +279,7 @@ function componentRule(rule, context) { * @param {ASTNode} node The AST node being checked. * @returns {Boolean} True if createElement called from pragma */ - isCreateElement: function (node) { + isCreateElement(node) { const calledOnPragma = ( node && node.callee && @@ -305,7 +305,7 @@ function componentRule(rule, context) { * Check if we are in a class constructor * @return {boolean} true if we are in a class constructor, false if not */ - inConstructor: function () { + inConstructor() { let scope = context.getScope(); while (scope) { if (scope.block && scope.block.parent && scope.block.parent.kind === 'constructor') { @@ -321,7 +321,7 @@ function componentRule(rule, context) { * @param {Object} node The node to process * @returns {Boolean} */ - isStateMemberExpression: function (node) { + isStateMemberExpression(node) { return node.type === 'MemberExpression' && node.object.type === 'ThisExpression' && node.property.name === 'state'; }, @@ -344,8 +344,8 @@ function componentRule(rule, context) { property = 'argument'; } return { - node: node, - property: property + node, + property }; }, @@ -356,7 +356,7 @@ function componentRule(rule, context) { * @param {Boolean} [strict] If true, in a ternary condition the node must return JSX in both cases * @returns {Boolean} True if the node is returning JSX, false if not */ - isReturningJSX: function (ASTnode, strict) { + isReturningJSX(ASTnode, strict) { const nodeAndProperty = utils.getReturnPropertyAndNode(ASTnode); const node = nodeAndProperty.node; const property = nodeAndProperty.property; @@ -443,7 +443,7 @@ function componentRule(rule, context) { * * @returns {ASTNode} component node, null if we are not in a component */ - getParentComponent: function () { + getParentComponent() { return ( utils.getParentES6Component() || utils.getParentES5Component() || @@ -456,7 +456,7 @@ function componentRule(rule, context) { * * @returns {ASTNode} component node, null if we are not in a component */ - getParentES5Component: function () { + getParentES5Component() { let scope = context.getScope(); while (scope) { const node = scope.block && scope.block.parent && scope.block.parent.parent; @@ -473,7 +473,7 @@ function componentRule(rule, context) { * * @returns {ASTNode} component node, null if we are not in a component */ - getParentES6Component: function () { + getParentES6Component() { let scope = context.getScope(); while (scope && scope.type !== 'class') { scope = scope.upper; @@ -490,7 +490,7 @@ function componentRule(rule, context) { * * @returns {ASTNode} component node, null if we are not in a component */ - getParentStatelessComponent: function () { + getParentStatelessComponent() { let scope = context.getScope(); while (scope) { const node = scope.block; @@ -541,7 +541,7 @@ function componentRule(rule, context) { * @param {ASTNode} node The AST node being checked (must be a MemberExpression). * @returns {ASTNode} component node, null if we cannot find the component */ - getRelatedComponent: function (node) { + getRelatedComponent(node) { let i; let j; let k; @@ -645,7 +645,7 @@ function componentRule(rule, context) { // Component detection instructions const detectionInstructions = { - CallExpression: function (node) { + CallExpression(node) { if (!utils.isPragmaComponentWrapper(node)) { return; } @@ -654,21 +654,21 @@ function componentRule(rule, context) { } }, - ClassExpression: function (node) { + ClassExpression(node) { if (!utils.isES6Component(node)) { return; } components.add(node, 2); }, - ClassDeclaration: function (node) { + ClassDeclaration(node) { if (!utils.isES6Component(node)) { return; } components.add(node, 2); }, - ClassProperty: function (node) { + ClassProperty(node) { node = utils.getParentComponent(); if (!node) { return; @@ -676,14 +676,14 @@ function componentRule(rule, context) { components.add(node, 2); }, - ObjectExpression: function (node) { + ObjectExpression(node) { if (!utils.isES5Component(node)) { return; } components.add(node, 2); }, - FunctionExpression: function (node) { + FunctionExpression(node) { if (node.async) { components.add(node, 0); return; @@ -700,7 +700,7 @@ function componentRule(rule, context) { components.add(component, 1); }, - FunctionDeclaration: function (node) { + FunctionDeclaration(node) { if (node.async) { components.add(node, 0); return; @@ -712,7 +712,7 @@ function componentRule(rule, context) { components.add(node, 1); }, - ArrowFunctionExpression: function (node) { + ArrowFunctionExpression(node) { if (node.async) { components.add(node, 0); return; @@ -733,7 +733,7 @@ function componentRule(rule, context) { } }, - ThisExpression: function (node) { + ThisExpression(node) { const component = utils.getParentComponent(); if (!component || !/Function/.test(component.type) || !node.parent.property) { return; @@ -742,7 +742,7 @@ function componentRule(rule, context) { components.add(node, 0); }, - ReturnStatement: function (node) { + ReturnStatement(node) { if (!utils.isReturningJSX(node)) { return; } diff --git a/lib/util/annotations.js b/lib/util/annotations.js index 3b63c9d6e7..3161381b5b 100644 --- a/lib/util/annotations.js +++ b/lib/util/annotations.js @@ -26,5 +26,5 @@ function isAnnotatedFunctionPropsDeclaration(node, context) { } module.exports = { - isAnnotatedFunctionPropsDeclaration: isAnnotatedFunctionPropsDeclaration + isAnnotatedFunctionPropsDeclaration }; diff --git a/lib/util/ast.js b/lib/util/ast.js index ac44adfb5e..260b139003 100644 --- a/lib/util/ast.js +++ b/lib/util/ast.js @@ -151,14 +151,14 @@ function isClass(node) { } module.exports = { - findReturnStatement: findReturnStatement, - getFirstNodeInLine: getFirstNodeInLine, - getPropertyName: getPropertyName, - getPropertyNameNode: getPropertyNameNode, - getComponentProperties: getComponentProperties, - isArrowFunction: isArrowFunction, - isClass: isClass, - isFunction: isFunction, - isFunctionLikeExpression: isFunctionLikeExpression, - isNodeFirstInLine: isNodeFirstInLine + findReturnStatement, + getFirstNodeInLine, + getPropertyName, + getPropertyNameNode, + getComponentProperties, + isArrowFunction, + isClass, + isFunction, + isFunctionLikeExpression, + isNodeFirstInLine }; diff --git a/lib/util/defaultProps.js b/lib/util/defaultProps.js index 8525791fb2..cf8ab46d14 100644 --- a/lib/util/defaultProps.js +++ b/lib/util/defaultProps.js @@ -99,7 +99,7 @@ module.exports = function defaultPropsInstructions(context, components, utils) { } return { - MemberExpression: function (node) { + MemberExpression(node) { const isDefaultProp = propsUtil.isDefaultPropsDeclaration(node); if (!isDefaultProp) { @@ -161,7 +161,7 @@ module.exports = function defaultPropsInstructions(context, components, utils) { // return
Hello {this.props.name}
; // } // } - MethodDefinition: function (node) { + MethodDefinition(node) { if (!node.static || node.kind !== 'get') { return; } @@ -201,7 +201,7 @@ module.exports = function defaultPropsInstructions(context, components, utils) { // bar: 'baz' // }; // } - ClassProperty: function (node) { + ClassProperty(node) { if (!(node.static && node.value)) { return; } @@ -238,7 +238,7 @@ module.exports = function defaultPropsInstructions(context, components, utils) { // }; // } // }); - ObjectExpression: function (node) { + ObjectExpression(node) { // find component this propTypes/defaultProps belongs to const component = utils.isES5Component(node) && components.get(node); if (!component) { diff --git a/lib/util/jsx.js b/lib/util/jsx.js index adb30a9971..d287297dee 100644 --- a/lib/util/jsx.js +++ b/lib/util/jsx.js @@ -36,6 +36,6 @@ function isJSX(node) { } module.exports = { - isDOMComponent: isDOMComponent, - isJSX: isJSX + isDOMComponent, + isJSX }; diff --git a/lib/util/linkComponents.js b/lib/util/linkComponents.js index f4260cd1c5..066b2ea249 100644 --- a/lib/util/linkComponents.js +++ b/lib/util/linkComponents.js @@ -23,5 +23,5 @@ function getLinkComponents(context) { } module.exports = { - getLinkComponents: getLinkComponents + getLinkComponents }; diff --git a/lib/util/makeNoMethodSetStateRule.js b/lib/util/makeNoMethodSetStateRule.js index b5635a55db..2e86d9403c 100644 --- a/lib/util/makeNoMethodSetStateRule.js +++ b/lib/util/makeNoMethodSetStateRule.js @@ -39,7 +39,7 @@ function makeNoMethodSetStateRule(methodName, shouldCheckUnsafeCb) { }] }, - create: function (context) { + create(context) { const mode = context.options[0] || 'allow-in-func'; function nameMatches(name) { @@ -60,7 +60,7 @@ function makeNoMethodSetStateRule(methodName, shouldCheckUnsafeCb) { return { - CallExpression: function (node) { + CallExpression(node) { const callee = node.callee; if ( callee.type !== 'MemberExpression' || diff --git a/lib/util/pragma.js b/lib/util/pragma.js index be60f09bb8..47682847d5 100644 --- a/lib/util/pragma.js +++ b/lib/util/pragma.js @@ -55,7 +55,7 @@ function getFromContext(context) { } module.exports = { - getCreateClassFromContext: getCreateClassFromContext, - getFragmentFromContext: getFragmentFromContext, - getFromContext: getFromContext + getCreateClassFromContext, + getFragmentFromContext, + getFromContext }; diff --git a/lib/util/propTypes.js b/lib/util/propTypes.js index 2799cbc3ce..6f53b382a1 100644 --- a/lib/util/propTypes.js +++ b/lib/util/propTypes.js @@ -139,14 +139,14 @@ module.exports = function propTypesInstructions(context, components, utils) { /* eslint-disable no-use-before-define */ /** @type {TypeDeclarationBuilders} */ const typeDeclarationBuilders = { - GenericTypeAnnotation: function (annotation, parentName, seen) { + GenericTypeAnnotation(annotation, parentName, seen) { if (getInTypeScope(annotation.id.name)) { return buildTypeAnnotationDeclarationTypes(getInTypeScope(annotation.id.name), parentName, seen); } return {}; }, - ObjectTypeAnnotation: function (annotation, parentName, seen) { + ObjectTypeAnnotation(annotation, parentName, seen) { let containsObjectTypeSpread = false; const shapeTypeDefinition = { type: 'shape', @@ -173,7 +173,7 @@ module.exports = function propTypesInstructions(context, components, utils) { return shapeTypeDefinition; }, - UnionTypeAnnotation: function (annotation, parentName, seen) { + UnionTypeAnnotation(annotation, parentName, seen) { /** @type {UnionTypeDefinition} */ const unionTypeDefinition = { type: 'union', @@ -199,7 +199,7 @@ module.exports = function propTypesInstructions(context, components, utils) { return unionTypeDefinition; }, - ArrayTypeAnnotation: function (annotation, parentName, seen) { + ArrayTypeAnnotation(annotation, parentName, seen) { const fullName = [parentName, '*'].join('.'); const child = buildTypeAnnotationDeclarationTypes(annotation.elementType, fullName, seen); child.fullName = fullName; @@ -575,8 +575,8 @@ module.exports = function propTypesInstructions(context, components, utils) { } components.set(node, { - declaredPropTypes: declaredPropTypes, - ignorePropsValidation: ignorePropsValidation + declaredPropTypes, + ignorePropsValidation }); } @@ -656,20 +656,20 @@ module.exports = function propTypesInstructions(context, components, utils) { } return { - ClassExpression: function (node) { + ClassExpression(node) { // TypeParameterDeclaration need to be added to typeScope in order to handle ClassExpressions. // This visitor is executed before TypeParameterDeclaration are scoped, therefore we postpone // processing class expressions until when the program exists. classExpressions.push(node); }, - ClassDeclaration: function (node) { + ClassDeclaration(node) { if (isSuperTypeParameterPropsDeclaration(node)) { markPropTypesAsDeclared(node, resolveSuperParameterPropsType(node)); } }, - ClassProperty: function (node) { + ClassProperty(node) { if (isAnnotatedClassPropsDeclaration(node)) { markPropTypesAsDeclared(node, resolveTypeAnnotation(node)); } else if (propsUtil.isPropTypesDeclaration(node)) { @@ -677,7 +677,7 @@ module.exports = function propTypesInstructions(context, components, utils) { } }, - ObjectExpression: function (node) { + ObjectExpression(node) { // Search for the proptypes declaration node.properties.forEach((property) => { if (!propsUtil.isPropTypesDeclaration(property)) { @@ -687,7 +687,7 @@ module.exports = function propTypesInstructions(context, components, utils) { }); }, - FunctionExpression: function (node) { + FunctionExpression(node) { if (node.parent.type !== 'MethodDefinition') { markAnnotatedFunctionArgumentsAsDeclared(node); } @@ -697,7 +697,7 @@ module.exports = function propTypesInstructions(context, components, utils) { ArrowFunctionExpression: markAnnotatedFunctionArgumentsAsDeclared, - MemberExpression: function (node) { + MemberExpression(node) { if (propsUtil.isPropTypesDeclaration(node)) { const component = utils.getRelatedComponent(node); if (!component) { @@ -707,7 +707,7 @@ module.exports = function propTypesInstructions(context, components, utils) { } }, - MethodDefinition: function (node) { + MethodDefinition(node) { if (!node.static || node.kind !== 'get' || !propsUtil.isPropTypesDeclaration(node)) { return; } @@ -724,11 +724,11 @@ module.exports = function propTypesInstructions(context, components, utils) { } }, - TypeAlias: function (node) { + TypeAlias(node) { setInTypeScope(node.id.name, node.right); }, - TypeParameterDeclaration: function (node) { + TypeParameterDeclaration(node) { const identifier = node.params[0]; if (identifier.typeAnnotation) { @@ -736,11 +736,11 @@ module.exports = function propTypesInstructions(context, components, utils) { } }, - Program: function () { + Program() { stack = [{}]; }, - BlockStatement: function () { + BlockStatement() { stack.push(Object.create(typeScope())); }, diff --git a/lib/util/propWrapper.js b/lib/util/propWrapper.js index b38a3f926b..7202b13a16 100644 --- a/lib/util/propWrapper.js +++ b/lib/util/propWrapper.js @@ -23,6 +23,6 @@ function isPropWrapperFunction(context, name) { } module.exports = { - getPropWrapperFunctions: getPropWrapperFunctions, - isPropWrapperFunction: isPropWrapperFunction + getPropWrapperFunctions, + isPropWrapperFunction }; diff --git a/lib/util/props.js b/lib/util/props.js index a548afb68c..1177200972 100644 --- a/lib/util/props.js +++ b/lib/util/props.js @@ -92,11 +92,11 @@ function isRequiredPropType(propTypeExpression) { } module.exports = { - isPropTypesDeclaration: isPropTypesDeclaration, - isContextTypesDeclaration: isContextTypesDeclaration, - isContextTypeDeclaration: isContextTypeDeclaration, - isChildContextTypesDeclaration: isChildContextTypesDeclaration, - isDefaultPropsDeclaration: isDefaultPropsDeclaration, - isDisplayNameDeclaration: isDisplayNameDeclaration, - isRequiredPropType: isRequiredPropType + isPropTypesDeclaration, + isContextTypesDeclaration, + isContextTypeDeclaration, + isChildContextTypesDeclaration, + isDefaultPropsDeclaration, + isDisplayNameDeclaration, + isRequiredPropType }; diff --git a/lib/util/usedPropTypes.js b/lib/util/usedPropTypes.js index d837c6e484..f63003334f 100755 --- a/lib/util/usedPropTypes.js +++ b/lib/util/usedPropTypes.js @@ -380,8 +380,8 @@ module.exports = function usedPropTypesInstructions(context, components, utils) node.property ); usedPropTypes.push({ - name: name, - allNames: allNames, + name, + allNames, node: reportedNode }); break; @@ -403,7 +403,7 @@ module.exports = function usedPropTypesInstructions(context, components, utils) allNames.push(propName); if (propName) { usedPropTypes.push({ - allNames: allNames, + allNames, name: propName, node: properties[k] }); @@ -416,8 +416,8 @@ module.exports = function usedPropTypesInstructions(context, components, utils) } components.set(component ? component.node : node, { - usedPropTypes: usedPropTypes, - ignoreUnusedPropTypesValidation: ignoreUnusedPropTypesValidation + usedPropTypes, + ignoreUnusedPropTypesValidation }); } @@ -471,7 +471,7 @@ module.exports = function usedPropTypesInstructions(context, components, utils) } return { - VariableDeclarator: function (node) { + VariableDeclarator(node) { const destructuring = node.init && node.id && node.id.type === 'ObjectPattern'; // let {props: {firstname}} = this const thisDestructuring = destructuring && node.init.type === 'ThisExpression'; @@ -493,20 +493,20 @@ module.exports = function usedPropTypesInstructions(context, components, utils) FunctionExpression: handleFunctionLikeExpressions, - JSXSpreadAttribute: function (node) { + JSXSpreadAttribute(node) { const component = components.get(utils.getParentComponent()); components.set(component ? component.node : node, { ignoreUnusedPropTypesValidation: true }); }, - MemberExpression: function (node) { + MemberExpression(node) { if (isPropTypesUsage(node)) { markPropTypesAsUsed(node); } }, - ObjectPattern: function (node) { + ObjectPattern(node) { // If the object pattern is a destructured props object in a lifecycle // method -- mark it for used props. if (isNodeALifeCycleMethod(node.parent.parent) && node.properties.length > 0) { diff --git a/lib/util/variable.js b/lib/util/variable.js index 92d09e4dad..cbc30f4ad0 100644 --- a/lib/util/variable.js +++ b/lib/util/variable.js @@ -73,8 +73,8 @@ function findVariableByName(context, name) { } module.exports = { - findVariable: findVariable, - findVariableByName: findVariableByName, - getVariable: getVariable, - variablesInScope: variablesInScope + findVariable, + findVariableByName, + getVariable, + variablesInScope }; diff --git a/tests/lib/rules/jsx-max-props-per-line.js b/tests/lib/rules/jsx-max-props-per-line.js index 7bb7487bf7..a94745bf76 100644 --- a/tests/lib/rules/jsx-max-props-per-line.js +++ b/tests/lib/rules/jsx-max-props-per-line.js @@ -70,7 +70,7 @@ ruleTester.run('jsx-max-props-per-line', rule, { 'baz />;' ].join('\n'), errors: [{message: 'Prop `bar` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: ';', output: [ @@ -86,7 +86,7 @@ ruleTester.run('jsx-max-props-per-line', rule, { 'bar />;' ].join('\n'), errors: [{message: 'Prop `bar` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: ';', output: [ @@ -94,7 +94,7 @@ ruleTester.run('jsx-max-props-per-line', rule, { '{...this.props} />;' ].join('\n'), errors: [{message: 'Prop `this.props` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '' ].join('\n'), errors: [{message: 'Prop `bar` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '' ].join('\n'), errors: [{message: 'Prop `this.props` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '' ].join('\n'), errors: [{message: 'Prop `bar` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '' ].join('\n'), errors: [{message: 'Prop `bar` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '' ].join('\n'), errors: [{message: 'Prop `rest` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '' ].join('\n'), errors: [{message: 'Prop `bar` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '' ].join('\n'), errors: [{message: 'Prop `rest` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '' ].join('\n'), errors: [{message: '`{"foo"}` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: 'foo', output: [ @@ -177,7 +177,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { '' ].join('\n'), errors: [{message: '`foo` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '
', @@ -194,7 +194,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { errors: [ {message: '`{"bar"}` must be placed on a new line'} ], - parserOptions: parserOptions + parserOptions }, { code: [ '
', @@ -211,7 +211,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { errors: [ {message: '` bar` must be placed on a new line'} ], - parserOptions: parserOptions + parserOptions }, { code: [ '', @@ -225,7 +225,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { '' ].join('\n'), errors: [{message: '`Bar` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '
', @@ -239,7 +239,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { '
' ].join('\n'), errors: [{message: '`foo` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '
', @@ -253,7 +253,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { '
' ].join('\n'), errors: [{message: '`{"foo"}` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '
', @@ -270,7 +270,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { errors: [ {message: '`{ I18n.t(\'baz\') }` must be placed on a new line'} ], - parserOptions: parserOptions + parserOptions }, { code: [ '{ bar } { I18n.t(\'baz\') }' @@ -289,7 +289,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { {message: '`Text` must be placed on a new line'}, {message: '`{ I18n.t(\'baz\') }` must be placed on a new line'} ], - parserOptions: parserOptions + parserOptions }, { code: [ @@ -307,7 +307,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { {message: '`Bar` must be placed on a new line'}, {message: '`Baz` must be placed on a new line'} ], - parserOptions: parserOptions + parserOptions }, { code: [ ' ' @@ -331,7 +331,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { {message: '`Bunk` must be placed on a new line'}, {message: '`Bruno` must be placed on a new line'} ], - parserOptions: parserOptions + parserOptions }, { code: [ ' ' @@ -345,7 +345,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { errors: [ {message: '`Bar` must be placed on a new line'} ], - parserOptions: parserOptions + parserOptions }, { code: [ ' ', @@ -360,7 +360,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { errors: [ {message: '`Bar` must be placed on a new line'} ], - parserOptions: parserOptions + parserOptions }, { code: [ '', @@ -377,7 +377,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { errors: [ {message: '`Baz` must be placed on a new line'} ], - parserOptions: parserOptions + parserOptions }, { code: [ '', @@ -394,7 +394,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { errors: [ {message: '`{ I18n.t(\'baz\') }` must be placed on a new line'} ], - parserOptions: parserOptions + parserOptions }, { code: [ '
', @@ -410,7 +410,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { errors: [ {message: '`input` must be placed on a new line'} ], - parserOptions: parserOptions + parserOptions }, { code: [ '
', @@ -424,7 +424,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { '
' ].join('\n'), errors: [{message: '`span` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '
', @@ -439,7 +439,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { '
' ].join('\n'), errors: [{message: '`input` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '
', @@ -454,7 +454,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { '
' ].join('\n'), errors: [{message: '` foo` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '
', @@ -471,7 +471,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { errors: [ {message: '`input` must be placed on a new line'} ], - parserOptions: parserOptions + parserOptions }, { code: [ '
', @@ -489,7 +489,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { errors: [ {message: '`input` must be placed on a new line'} ], - parserOptions: parserOptions + parserOptions }, { code: [ '
', @@ -506,7 +506,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { errors: [ {message: '`input` must be placed on a new line'} ], - parserOptions: parserOptions + parserOptions }, { code: [ '
', @@ -521,7 +521,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { '
' ].join('\n'), errors: [{message: '` bar` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '
', @@ -538,7 +538,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { errors: [ {message: '`{"bar"}` must be placed on a new line'} ], - parserOptions: parserOptions + parserOptions }, { code: [ '
', @@ -555,7 +555,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { errors: [ {message: '`{"foo"}` must be placed on a new line'} ], - parserOptions: parserOptions + parserOptions }, { code: [ '', @@ -569,7 +569,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { '' ].join('\n'), errors: [{message: '`Bar` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '', @@ -581,7 +581,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { '' ].join('\n'), errors: [{message: '`Foo` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '', @@ -593,7 +593,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { '' ].join('\n'), errors: [{message: '`Foo` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '', @@ -605,7 +605,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { '' ].join('\n'), errors: [{message: '`Foo` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '' ].join('\n'), errors: [{message: '`Foo` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '' ].join('\n'), errors: [{message: '`Foo` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '' ].join('\n'), errors: [{message: '`Foo` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '' ].join('\n'), errors: [{message: '`Foo` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '', @@ -677,7 +677,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { '' ].join('\n'), errors: [{message: '`Foo` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '', @@ -691,7 +691,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { '' ].join('\n'), errors: [{message: '`Foo` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '', @@ -705,7 +705,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { '' ].join('\n'), errors: [{message: '`Foo` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '', @@ -721,7 +721,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { '' ].join('\n'), errors: [{message: '`Bar` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '', @@ -737,7 +737,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { '' ].join('\n'), errors: [{message: '`Bar` must be placed on a new line'}], - parserOptions: parserOptions + parserOptions }, { code: [ '', @@ -760,7 +760,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { errors: [ {message: '` baz ` must be placed on a new line'} ], - parserOptions: parserOptions + parserOptions }, { // Would be nice to handle in one pass, but multipass works fine. code: [ @@ -779,7 +779,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { {message: '`{"bar"}` must be placed on a new line'}, {message: '` baz` must be placed on a new line'} ], - parserOptions: parserOptions + parserOptions }, { // Would be nice to handle in one pass, but multipass works fine. code: [ @@ -797,7 +797,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { errors: [ {message: '`{"bar"}` must be placed on a new line'} ], - parserOptions: parserOptions + parserOptions }, { // Would be nice to handle in one pass, but multipass works fine. code: [ @@ -819,7 +819,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { errors: [ {message: '` baz` must be placed on a new line'} ], - parserOptions: parserOptions + parserOptions }, { // Would be nice to handle in one pass, but multipass works fine. code: [ @@ -842,7 +842,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { {message: '`{"bar"}` must be placed on a new line'}, {message: '` baz` must be placed on a new line'} ], - parserOptions: parserOptions + parserOptions }, { // Would be nice to handle in one pass, but multipass works fine. code: [ @@ -868,7 +868,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { errors: [ {message: '` baz` must be placed on a new line'} ], - parserOptions: parserOptions + parserOptions }, { code: [ '{', @@ -885,7 +885,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { errors: [ {message: '`{ foo}` must be placed on a new line'} ], - parserOptions: parserOptions + parserOptions }, { code: [ ' {', @@ -904,7 +904,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { errors: [ {message: '`{ foo}` must be placed on a new line'} ], - parserOptions: parserOptions + parserOptions }, { code: [ ' ', @@ -925,7 +925,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { errors: [ {message: '`{ foo}` must be placed on a new line'} ], - parserOptions: parserOptions + parserOptions }, { code: '', options: [{allow: 'none'}], @@ -1014,7 +1014,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { ].join('\n'), errors: [{message: '`{"foo"}` must be placed on a new line'}], parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: [ '', @@ -1029,7 +1029,7 @@ ruleTester.run('jsx-one-expression-per-line', rule, { ].join('\n'), errors: [{message: '`<>` must be placed on a new line'}], parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: [ '<', @@ -1044,6 +1044,6 @@ ruleTester.run('jsx-one-expression-per-line', rule, { ].join('\n'), errors: [{message: '`Foo` must be placed on a new line'}], parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }] }); diff --git a/tests/lib/rules/jsx-uses-react.js b/tests/lib/rules/jsx-uses-react.js index 5c08605483..0deb834acd 100644 --- a/tests/lib/rules/jsx-uses-react.js +++ b/tests/lib/rules/jsx-uses-react.js @@ -41,7 +41,7 @@ ruleTester.run('no-unused-vars', rule, { {code: '/*eslint jsx-uses-react:1*/ var React;
;'}, {code: '/*eslint jsx-uses-react:1*/ var React; (function () {
})();'}, {code: '/*eslint jsx-uses-react:1*/ /** @jsx Foo */ var Foo;
;'}, - {code: '/*eslint jsx-uses-react:1*/ var Foo;
;', settings: settings}, + {code: '/*eslint jsx-uses-react:1*/ var Foo;
;', settings}, {code: '/*eslint jsx-uses-react:1*/ var React; <>;', parser: parsers.BABEL_ESLINT} ], invalid: [{ @@ -53,11 +53,11 @@ ruleTester.run('no-unused-vars', rule, { }, { code: '/*eslint jsx-uses-react:1*/ var React;
;', errors: [{message: '\'React\' is defined but never used.'}], - settings: settings + settings }, { code: '/*eslint jsx-uses-react:1*/ var React; <>;', parser: parsers.BABEL_ESLINT, errors: [{message: '\'React\' is defined but never used.'}], - settings: settings + settings }] }); diff --git a/tests/lib/rules/no-access-state-in-setstate.js b/tests/lib/rules/no-access-state-in-setstate.js index 3880d6f07b..49bf0f08ee 100644 --- a/tests/lib/rules/no-access-state-in-setstate.js +++ b/tests/lib/rules/no-access-state-in-setstate.js @@ -33,7 +33,7 @@ ruleTester.run('no-access-state-in-setstate', rule, { ' }', '});' ].join('\n'), - parserOptions: parserOptions + parserOptions }, { code: [ 'var Hello = React.createClass({', @@ -46,7 +46,7 @@ ruleTester.run('no-access-state-in-setstate', rule, { ' }', '});' ].join('\n'), - parserOptions: parserOptions + parserOptions }, { // issue 1559: don't crash code: ` @@ -64,7 +64,7 @@ ruleTester.run('no-access-state-in-setstate', rule, { } }); `, - parserOptions: parserOptions + parserOptions }, { // issue 1604: allow this.state in callback code: ` @@ -74,7 +74,7 @@ ruleTester.run('no-access-state-in-setstate', rule, { } }); `, - parserOptions: parserOptions + parserOptions }, { code: ` var Hello = React.createClass({ @@ -83,7 +83,7 @@ ruleTester.run('no-access-state-in-setstate', rule, { } }); `, - parserOptions: parserOptions + parserOptions }, { code: [ 'var Hello = React.createClass({', @@ -94,14 +94,14 @@ ruleTester.run('no-access-state-in-setstate', rule, { ' }', '});' ].join('\n'), - parserOptions: parserOptions + parserOptions }, { // https://github.com/yannickcr/eslint-plugin-react/pull/1611 code: ` function testFunction({a, b}) { }; `, - parserOptions: parserOptions + parserOptions }], invalid: [{ @@ -112,7 +112,7 @@ ruleTester.run('no-access-state-in-setstate', rule, { ' }', '});' ].join('\n'), - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Use callback in setState when referencing the previous state.' }] @@ -124,7 +124,7 @@ ruleTester.run('no-access-state-in-setstate', rule, { ' }', '});' ].join('\n'), - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Use callback in setState when referencing the previous state.' }] @@ -137,7 +137,7 @@ ruleTester.run('no-access-state-in-setstate', rule, { ' }', '});' ].join('\n'), - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Use callback in setState when referencing the previous state.' }] @@ -150,7 +150,7 @@ ruleTester.run('no-access-state-in-setstate', rule, { ' }', '});' ].join('\n'), - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Use callback in setState when referencing the previous state.' }] @@ -165,7 +165,7 @@ ruleTester.run('no-access-state-in-setstate', rule, { ' }', '});' ].join('\n'), - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Use callback in setState when referencing the previous state.' }] @@ -177,7 +177,7 @@ ruleTester.run('no-access-state-in-setstate', rule, { } }); `, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Use callback in setState when referencing the previous state.' }] @@ -189,7 +189,7 @@ ruleTester.run('no-access-state-in-setstate', rule, { } }); `, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Use callback in setState when referencing the previous state.' }] @@ -204,7 +204,7 @@ ruleTester.run('no-access-state-in-setstate', rule, { ' }', '});' ].join('\n'), - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Use callback in setState when referencing the previous state.' }] diff --git a/tests/lib/rules/no-redundant-should-component-update.js b/tests/lib/rules/no-redundant-should-component-update.js index f31c6f0bee..63e15a8921 100644 --- a/tests/lib/rules/no-redundant-should-component-update.js +++ b/tests/lib/rules/no-redundant-should-component-update.js @@ -39,7 +39,7 @@ ruleTester.run('no-redundant-should-component-update', rule, { } } `, - parserOptions: parserOptions + parserOptions }, { code: ` @@ -50,7 +50,7 @@ ruleTester.run('no-redundant-should-component-update', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: ` @@ -60,7 +60,7 @@ ruleTester.run('no-redundant-should-component-update', rule, { } } `, - parserOptions: parserOptions + parserOptions }, { code: ` @@ -72,7 +72,7 @@ ruleTester.run('no-redundant-should-component-update', rule, { }; } `, - parserOptions: parserOptions + parserOptions } ], @@ -86,7 +86,7 @@ ruleTester.run('no-redundant-should-component-update', rule, { } `, errors: [{message: errorMessage('Foo')}], - parserOptions: parserOptions + parserOptions }, { code: ` @@ -97,7 +97,7 @@ ruleTester.run('no-redundant-should-component-update', rule, { } `, errors: [{message: errorMessage('Foo')}], - parserOptions: parserOptions + parserOptions }, { code: ` @@ -109,7 +109,7 @@ ruleTester.run('no-redundant-should-component-update', rule, { `, errors: [{message: errorMessage('Foo')}], parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: ` @@ -122,7 +122,7 @@ ruleTester.run('no-redundant-should-component-update', rule, { } `, errors: [{message: errorMessage('Bar')}], - parserOptions: parserOptions + parserOptions }, { code: ` @@ -135,7 +135,7 @@ ruleTester.run('no-redundant-should-component-update', rule, { } `, errors: [{message: errorMessage('Bar')}], - parserOptions: parserOptions + parserOptions }, { code: ` @@ -146,7 +146,7 @@ ruleTester.run('no-redundant-should-component-update', rule, { } `, errors: [{message: errorMessage('Foo')}], - parserOptions: parserOptions + parserOptions } ] }); diff --git a/tests/lib/rules/no-typos.js b/tests/lib/rules/no-typos.js index 190dd01c15..6fcaa6af7a 100644 --- a/tests/lib/rules/no-typos.js +++ b/tests/lib/rules/no-typos.js @@ -41,7 +41,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: ` class First {} @@ -50,7 +50,7 @@ ruleTester.run('no-typos', rule, { First.ChildContextTypes = {key: "myValue"}; First.DefaultProps = {key: "myValue"}; `, - parserOptions: parserOptions + parserOptions }, { code: ` class First extends React.Component { @@ -61,7 +61,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: ` class First extends React.Component {} @@ -70,7 +70,7 @@ ruleTester.run('no-typos', rule, { First.childContextTypes = {key: "myValue"}; First.defaultProps = {key: "myValue"}; `, - parserOptions: parserOptions + parserOptions }, { code: ` class MyClass { @@ -81,7 +81,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: ` class MyClass { @@ -92,7 +92,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: ` class MyClass { @@ -103,7 +103,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: ` class MyClass { @@ -114,7 +114,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: ` class MyClass { @@ -125,7 +125,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: ` class MyClass {} @@ -134,7 +134,7 @@ ruleTester.run('no-typos', rule, { MyClass.prototype.ChildContextTypes = function() {}; MyClass.prototype.DefaultProps = function() {}; `, - parserOptions: parserOptions + parserOptions }, { code: ` class MyClass {} @@ -143,7 +143,7 @@ ruleTester.run('no-typos', rule, { MyClass.ChildContextTypes = function() {}; MyClass.DefaultProps = function() {}; `, - parserOptions: parserOptions + parserOptions }, { code: ` function MyRandomFunction() {} @@ -152,7 +152,7 @@ ruleTester.run('no-typos', rule, { MyRandomFunction.ChildContextTypes = {}; MyRandomFunction.DefaultProps = {}; `, - parserOptions: parserOptions + parserOptions }, { // This case is currently not supported code: ` @@ -162,7 +162,7 @@ ruleTester.run('no-typos', rule, { First["childContext" + "Types"] = {}; First["default" + "Props"] = {}; `, - parserOptions: parserOptions + parserOptions }, { // This case is currently not supported code: ` @@ -172,7 +172,7 @@ ruleTester.run('no-typos', rule, { First["CHILDCONTEXT" + "TYPES"] = {}; First["DEFAULT" + "PROPS"] = {}; `, - parserOptions: parserOptions + parserOptions }, { code: ` const propTypes = "PROPTYPES" @@ -186,7 +186,7 @@ ruleTester.run('no-typos', rule, { First[childContextTypes] = {}; First[defautProps] = {}; `, - parserOptions: parserOptions + parserOptions }, { code: ` class Hello extends React.Component { @@ -202,7 +202,7 @@ ruleTester.run('no-typos', rule, { } } `, - parserOptions: parserOptions + parserOptions }, { code: ` class MyClass { @@ -216,7 +216,7 @@ ruleTester.run('no-typos', rule, { render() { } } `, - parserOptions: parserOptions + parserOptions }, { code: ` class MyClass { @@ -230,7 +230,7 @@ ruleTester.run('no-typos', rule, { render() { } } `, - parserOptions: parserOptions + parserOptions }, { code: ` class MyClass { @@ -244,7 +244,7 @@ ruleTester.run('no-typos', rule, { Render() { } } `, - parserOptions: parserOptions + parserOptions }, { // https://github.com/yannickcr/eslint-plugin-react/issues/1353 code: ` @@ -254,7 +254,7 @@ ruleTester.run('no-typos', rule, { function a() {} `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: ` import PropTypes from "prop-types"; @@ -264,7 +264,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: ` import PropTypes from "prop-types"; @@ -276,7 +276,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: ` import PropTypes from "prop-types"; @@ -291,7 +291,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: ` import PropTypes from "prop-types"; @@ -304,7 +304,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: ` import PropTypes from "prop-types"; @@ -317,7 +317,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: ` import PropTypes from "prop-types"; @@ -332,7 +332,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: ` import PropTypes from "prop-types"; @@ -345,7 +345,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: ` import PropTypes from "prop-types"; @@ -359,7 +359,7 @@ ruleTester.run('no-typos', rule, { }).isRequired } `, - parserOptions: parserOptions + parserOptions }, { code: ` import PropTypes from "prop-types"; @@ -373,7 +373,7 @@ ruleTester.run('no-typos', rule, { }).isRequired } `, - parserOptions: parserOptions + parserOptions }, { code: ` import PropTypes from 'prop-types' @@ -385,7 +385,7 @@ ruleTester.run('no-typos', rule, { c: MyPropTypes.MYSTRING.isRequired, } `, - parserOptions: parserOptions + parserOptions }, { code: ` import PropTypes from "prop-types" @@ -396,7 +396,7 @@ ruleTester.run('no-typos', rule, { a: MyPropTypes.MYSTRING, } `, - parserOptions: parserOptions + parserOptions }, { code: ` import CustomReact from "react" @@ -405,7 +405,7 @@ ruleTester.run('no-typos', rule, { b: CustomReact.PropTypes.string, } `, - parserOptions: parserOptions + parserOptions }, { code: ` import PropTypes from "prop-types"; @@ -420,7 +420,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: ` import PropTypes from "prop-types"; @@ -435,7 +435,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: ` import PropTypes from 'prop-types' @@ -448,7 +448,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: ` import PropTypes from "prop-types" @@ -460,7 +460,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: ` import CustomReact from "react" @@ -470,7 +470,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { // ensure that an absent arg to PropTypes.shape does not crash code: `class Component extends React.Component {}; @@ -481,7 +481,7 @@ ruleTester.run('no-typos', rule, { a: PropTypes.shape(), }; `, - parserOptions: parserOptions + parserOptions }, { // ensure that an absent arg to PropTypes.shape does not crash code: `class Component extends React.Component {}; @@ -493,7 +493,7 @@ ruleTester.run('no-typos', rule, { }; `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: ` const fn = (err, res) => { @@ -511,7 +511,7 @@ ruleTester.run('no-typos', rule, { }).isRequired } `, - parserOptions: parserOptions + parserOptions }, { code: `class Component extends React.Component {}; Component.propTypes = { @@ -522,7 +522,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: ` import React from 'react'; @@ -536,7 +536,7 @@ ruleTester.run('no-typos', rule, { } }); `, - parserOptions: parserOptions + parserOptions }, { code: ` import React from 'react'; @@ -551,7 +551,7 @@ ruleTester.run('no-typos', rule, { }); `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: ` import React from 'react'; @@ -565,7 +565,7 @@ ruleTester.run('no-typos', rule, { } }); `, - parserOptions: parserOptions + parserOptions }, { code: ` import React from 'react'; @@ -580,7 +580,7 @@ ruleTester.run('no-typos', rule, { }); `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: ` import React from 'react'; @@ -600,7 +600,7 @@ ruleTester.run('no-typos', rule, { } }); `, - parserOptions: parserOptions + parserOptions }, { code: ` import React from 'react'; @@ -621,7 +621,7 @@ ruleTester.run('no-typos', rule, { }); `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: ` import { string, element } from "prop-types"; @@ -635,7 +635,7 @@ ruleTester.run('no-typos', rule, { body: element.isRequired }; `, - parserOptions: parserOptions + parserOptions }], invalid: [{ @@ -645,21 +645,21 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions, + parserOptions, errors: [{message: ERROR_MESSAGE}] }, { code: ` class Component extends React.Component {} Component.PropTypes = {} `, - parserOptions: parserOptions, + parserOptions, errors: [{message: ERROR_MESSAGE}] }, { code: ` function MyComponent() { return (
{this.props.myProp}
) } MyComponent.PropTypes = {} `, - parserOptions: parserOptions, + parserOptions, errors: [{message: ERROR_MESSAGE}] }, { code: ` @@ -668,21 +668,21 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions, + parserOptions, errors: [{message: ERROR_MESSAGE}] }, { code: ` class Component extends React.Component {} Component.proptypes = {} `, - parserOptions: parserOptions, + parserOptions, errors: [{message: ERROR_MESSAGE}] }, { code: ` function MyComponent() { return (
{this.props.myProp}
) } MyComponent.proptypes = {} `, - parserOptions: parserOptions, + parserOptions, errors: [{message: ERROR_MESSAGE}] }, { code: ` @@ -691,21 +691,21 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions, + parserOptions, errors: [{message: ERROR_MESSAGE}] }, { code: ` class Component extends React.Component {} Component.ContextTypes = {} `, - parserOptions: parserOptions, + parserOptions, errors: [{message: ERROR_MESSAGE}] }, { code: ` function MyComponent() { return (
{this.props.myProp}
) } MyComponent.ContextTypes = {} `, - parserOptions: parserOptions, + parserOptions, errors: [{message: ERROR_MESSAGE}] }, { code: ` @@ -714,21 +714,21 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions, + parserOptions, errors: [{message: ERROR_MESSAGE}] }, { code: ` class Component extends React.Component {} Component.contexttypes = {} `, - parserOptions: parserOptions, + parserOptions, errors: [{message: ERROR_MESSAGE}] }, { code: ` function MyComponent() { return (
{this.props.myProp}
) } MyComponent.contexttypes = {} `, - parserOptions: parserOptions, + parserOptions, errors: [{message: ERROR_MESSAGE}] }, { code: ` @@ -737,21 +737,21 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions, + parserOptions, errors: [{message: ERROR_MESSAGE}] }, { code: ` class Component extends React.Component {} Component.ChildContextTypes = {} `, - parserOptions: parserOptions, + parserOptions, errors: [{message: ERROR_MESSAGE}] }, { code: ` function MyComponent() { return (
{this.props.myProp}
) } MyComponent.ChildContextTypes = {} `, - parserOptions: parserOptions, + parserOptions, errors: [{message: ERROR_MESSAGE}] }, { code: ` @@ -760,21 +760,21 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions, + parserOptions, errors: [{message: ERROR_MESSAGE}] }, { code: ` class Component extends React.Component {} Component.childcontexttypes = {} `, - parserOptions: parserOptions, + parserOptions, errors: [{message: ERROR_MESSAGE}] }, { code: ` function MyComponent() { return (
{this.props.myProp}
) } MyComponent.childcontexttypes = {} `, - parserOptions: parserOptions, + parserOptions, errors: [{message: ERROR_MESSAGE}] }, { code: ` @@ -783,21 +783,21 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions, + parserOptions, errors: [{message: ERROR_MESSAGE}] }, { code: ` class Component extends React.Component {} Component.DefaultProps = {} `, - parserOptions: parserOptions, + parserOptions, errors: [{message: ERROR_MESSAGE}] }, { code: ` function MyComponent() { return (
{this.props.myProp}
) } MyComponent.DefaultProps = {} `, - parserOptions: parserOptions, + parserOptions, errors: [{message: ERROR_MESSAGE}] }, { code: ` @@ -806,28 +806,28 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions, + parserOptions, errors: [{message: ERROR_MESSAGE}] }, { code: ` class Component extends React.Component {} Component.defaultprops = {} `, - parserOptions: parserOptions, + parserOptions, errors: [{message: ERROR_MESSAGE}] }, { code: ` function MyComponent() { return (
{this.props.myProp}
) } MyComponent.defaultprops = {} `, - parserOptions: parserOptions, + parserOptions, errors: [{message: ERROR_MESSAGE}] }, { code: ` Component.defaultprops = {} class Component extends React.Component {} `, - parserOptions: parserOptions, + parserOptions, errors: [{message: ERROR_MESSAGE}] }, { code: ` @@ -835,7 +835,7 @@ ruleTester.run('no-typos', rule, { class MyComponent extends BaseComponent {} MyComponent.PROPTYPES = {} `, - parserOptions: parserOptions, + parserOptions, errors: [{message: ERROR_MESSAGE}] }, { code: ` @@ -858,7 +858,7 @@ ruleTester.run('no-typos', rule, { } } `, - parserOptions: parserOptions, + parserOptions, errors: [{ message: ERROR_MESSAGE_LIFECYCLE_METHOD, type: 'MethodDefinition' @@ -920,7 +920,7 @@ ruleTester.run('no-typos', rule, { } } `, - parserOptions: parserOptions, + parserOptions, errors: [{ message: ERROR_MESSAGE_LIFECYCLE_METHOD, type: 'MethodDefinition' @@ -985,7 +985,7 @@ ruleTester.run('no-typos', rule, { } } `, - parserOptions: parserOptions, + parserOptions, errors: [{ message: ERROR_MESSAGE_LIFECYCLE_METHOD, type: 'MethodDefinition' @@ -1034,7 +1034,7 @@ ruleTester.run('no-typos', rule, { a: PropTypes.Number.isRequired } `, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in declared prop type: Number' }] @@ -1046,7 +1046,7 @@ ruleTester.run('no-typos', rule, { a: PropTypes.number.isrequired } `, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in prop type chain qualifier: isrequired' }] @@ -1060,7 +1060,7 @@ ruleTester.run('no-typos', rule, { }; `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in prop type chain qualifier: isrequired' }] @@ -1074,7 +1074,7 @@ ruleTester.run('no-typos', rule, { }; `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in declared prop type: Number' }] @@ -1087,7 +1087,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in declared prop type: Number' }] @@ -1103,7 +1103,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in declared prop type: String' }] @@ -1119,7 +1119,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in declared prop type: bools' }] @@ -1135,7 +1135,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in declared prop type: bools' }, { @@ -1157,7 +1157,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in declared prop type: bools' }, { @@ -1179,7 +1179,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in declared prop type: bools' }, { @@ -1200,7 +1200,7 @@ ruleTester.run('no-typos', rule, { }).isrequired } `, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in prop type chain qualifier: isrequired' }, { @@ -1218,7 +1218,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in prop type chain qualifier: isrequired' }, { @@ -1236,7 +1236,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in declared prop type: bools' }, { @@ -1258,7 +1258,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in prop type chain qualifier: isrequired' }, { @@ -1276,7 +1276,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in declared prop type: bools' }, { @@ -1298,7 +1298,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in prop type chain qualifier: isrequired' }, { @@ -1310,7 +1310,7 @@ ruleTester.run('no-typos', rule, { class Component extends React.Component {}; `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions, + parserOptions, errors: [] }, { code: ` @@ -1324,7 +1324,7 @@ ruleTester.run('no-typos', rule, { } `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in declared prop type: bools' }, { @@ -1345,7 +1345,7 @@ ruleTester.run('no-typos', rule, { d: PropTypes.objectof, } `, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in declared prop type: bools' }, { @@ -1366,7 +1366,7 @@ ruleTester.run('no-typos', rule, { }).isrequired } `, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in prop type chain qualifier: isrequired' }, { @@ -1383,7 +1383,7 @@ ruleTester.run('no-typos', rule, { }).isrequired } `, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in prop type chain qualifier: isrequired' }, { @@ -1400,7 +1400,7 @@ ruleTester.run('no-typos', rule, { d: RealPropTypes.objectof, } `, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in declared prop type: bools' }, { @@ -1421,7 +1421,7 @@ ruleTester.run('no-typos', rule, { }).isrequired } `, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in prop type chain qualifier: isrequired' }, { @@ -1438,7 +1438,7 @@ ruleTester.run('no-typos', rule, { d: React.PropTypes.objectof, } `, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in declared prop type: bools' }, { @@ -1459,7 +1459,7 @@ ruleTester.run('no-typos', rule, { }).isrequired } `, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in prop type chain qualifier: isrequired' }, { @@ -1476,7 +1476,7 @@ ruleTester.run('no-typos', rule, { d: PropTypes.objectof, } `, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in declared prop type: bools' }, { @@ -1500,7 +1500,7 @@ ruleTester.run('no-typos', rule, { }); `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in prop type chain qualifier: isrequired' }, { @@ -1520,7 +1520,7 @@ ruleTester.run('no-typos', rule, { }); `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in declared prop type: bools' }, { @@ -1543,7 +1543,7 @@ ruleTester.run('no-typos', rule, { } }); `, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in prop type chain qualifier: isrequired' }, { @@ -1562,7 +1562,7 @@ ruleTester.run('no-typos', rule, { } }); `, - parserOptions: parserOptions, + parserOptions, errors: [{ message: 'Typo in declared prop type: bools' }, { @@ -1591,7 +1591,7 @@ ruleTester.run('no-typos', rule, { } }); `, - parserOptions: parserOptions, + parserOptions, errors: [{ message: ERROR_MESSAGE_ES5, type: 'ObjectExpression' @@ -1643,7 +1643,7 @@ ruleTester.run('no-typos', rule, { }); `, parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions, + parserOptions, errors: [{ message: ERROR_MESSAGE_ES5, type: 'ObjectExpression' diff --git a/tests/lib/rules/no-unused-prop-types.js b/tests/lib/rules/no-unused-prop-types.js index 7b22d2ab1d..4c52df3f27 100644 --- a/tests/lib/rules/no-unused-prop-types.js +++ b/tests/lib/rules/no-unused-prop-types.js @@ -3506,7 +3506,7 @@ ruleTester.run('no-unused-prop-types', rule, { '};' ].join('\n'), parser: parsers.BABEL_ESLINT, - settings: settings, + settings, errors: [ {message: '\'unused\' PropType is defined but prop is never used'} ] diff --git a/tests/lib/rules/prefer-stateless-function.js b/tests/lib/rules/prefer-stateless-function.js index 9cdd42f321..406196b630 100644 --- a/tests/lib/rules/prefer-stateless-function.js +++ b/tests/lib/rules/prefer-stateless-function.js @@ -73,7 +73,7 @@ ruleTester.run('prefer-stateless-function', rule, { } }; `, - parserOptions: parserOptions, + parserOptions, options: [{ ignorePureComponents: true }] diff --git a/tests/lib/rules/prop-types.js b/tests/lib/rules/prop-types.js index 552a6c05e1..c6c2d3a6b9 100755 --- a/tests/lib/rules/prop-types.js +++ b/tests/lib/rules/prop-types.js @@ -3048,7 +3048,7 @@ ruleTester.run('prop-types', rule, { '};' ].join('\n'), parser: parsers.BABEL_ESLINT, - settings: settings, + settings, errors: [ {message: '\'lastname\' is missing in props validation'} ] diff --git a/tests/lib/rules/react-in-jsx-scope.js b/tests/lib/rules/react-in-jsx-scope.js index 477e9d1bbe..cead0edc65 100644 --- a/tests/lib/rules/react-in-jsx-scope.js +++ b/tests/lib/rules/react-in-jsx-scope.js @@ -55,7 +55,7 @@ ruleTester.run('react-in-jsx-scope', rule, { }); export default Button; `}, - {code: 'var Foo, App; ;', settings: settings} + {code: 'var Foo, App; ;', settings} ], invalid: [{ code: 'var App, a = ;', @@ -78,6 +78,6 @@ ruleTester.run('react-in-jsx-scope', rule, { errors: [{message: '\'Foo\' must be in scope when using JSX'}] }, { code: 'var React, a = ;', - errors: [{message: '\'Foo\' must be in scope when using JSX'}], settings: settings + errors: [{message: '\'Foo\' must be in scope when using JSX'}], settings }] }); diff --git a/tests/lib/rules/sort-comp.js b/tests/lib/rules/sort-comp.js index 76811f9841..3a8597d15b 100644 --- a/tests/lib/rules/sort-comp.js +++ b/tests/lib/rules/sort-comp.js @@ -324,7 +324,7 @@ ruleTester.run('sort-comp', rule, { '}' ].join('\n'), parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: [ '// Non-react classes should be ignored, even in expressions', @@ -338,7 +338,7 @@ ruleTester.run('sort-comp', rule, { '}' ].join('\n'), parser: parsers.BABEL_ESLINT, - parserOptions: parserOptions + parserOptions }, { code: [ '// Getters should be at the top', @@ -553,7 +553,7 @@ ruleTester.run('sort-comp', rule, { ' }', '};' ].join('\n'), - parserOptions: parserOptions, + parserOptions, errors: [{message: 'render should be placed after onClick'}] }, { code: [ diff --git a/tests/util/linkComponents.js b/tests/util/linkComponents.js index bbfe82e798..3b93b601e8 100644 --- a/tests/util/linkComponents.js +++ b/tests/util/linkComponents.js @@ -22,7 +22,7 @@ describe('linkComponentsFunctions', () => { ]; const context = { settings: { - linkComponents: linkComponents + linkComponents } }; assert.deepStrictEqual(linkComponentsUtil.getLinkComponents(context), new Map([ diff --git a/tests/util/propWrapper.js b/tests/util/propWrapper.js index 98fe3ea804..4472958816 100644 --- a/tests/util/propWrapper.js +++ b/tests/util/propWrapper.js @@ -11,7 +11,7 @@ describe('PropWrapperFunctions', () => { }]; const context = { settings: { - propWrapperFunctions: propWrapperFunctions + propWrapperFunctions } }; assert.deepStrictEqual(propWrapperUtil.getPropWrapperFunctions(context), new Set(propWrapperFunctions)); From 2508066b4b00485db1708547934128b8fc53210c Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 19 May 2019 09:48:52 -0700 Subject: [PATCH 11/28] [eslint] enable and manually fix `array-callback-return` --- .eslintrc | 1 - lib/rules/jsx-sort-props.js | 10 ++++------ lib/rules/no-access-state-in-setstate.js | 14 ++++++++------ 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.eslintrc b/.eslintrc index e45dc69077..2bfd90adc9 100644 --- a/.eslintrc +++ b/.eslintrc @@ -39,7 +39,6 @@ "no-void": 1, "no-continue": 1, "global-require": 1, - "array-callback-return": 1, "no-restricted-syntax": 1, "implicit-arrow-linebreak": 1, "valid-jsdoc": 1, diff --git a/lib/rules/jsx-sort-props.js b/lib/rules/jsx-sort-props.js index 04f0eb97ac..2658d740af 100644 --- a/lib/rules/jsx-sort-props.js +++ b/lib/rules/jsx-sort-props.js @@ -167,12 +167,10 @@ function validateReservedFirstConfig(context, reservedFirst) { if (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) => { - if (!isReservedPropName(word, RESERVED_PROPS_LIST)) { - return true; - } - }); + const nonReservedWords = reservedFirst.filter(word => !isReservedPropName( + word, + RESERVED_PROPS_LIST + )); if (reservedFirst.length === 0) { return function (decl) { diff --git a/lib/rules/no-access-state-in-setstate.js b/lib/rules/no-access-state-in-setstate.js index 01699839a1..068219c173 100644 --- a/lib/rules/no-access-state-in-setstate.js +++ b/lib/rules/no-access-state-in-setstate.js @@ -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.forEach((method) => { if (node.callee.name === method.methodName) { let current = node.parent; while (current.type !== 'Program') { @@ -70,7 +70,7 @@ module.exports = { while (current.type !== 'Program') { if (isFirstArgumentInSetStateCall(current, node)) { const methodName = node.callee.name; - methods.map((method) => { + methods.forEach((method) => { if (method.methodName === methodName) { context.report( method.node, @@ -145,10 +145,12 @@ module.exports = { if (isFirstArgumentInSetStateCall(current, node)) { vars .filter(v => v.scope === context.getScope() && v.variableName === node.name) - .map(v => context.report( - v.node, - 'Use callback in setState when referencing the previous state.' - )); + .forEach((v) => { + context.report( + v.node, + 'Use callback in setState when referencing the previous state.' + ); + }); } current = current.parent; } From 9841e978bc6a8aaf00e7ddcb29d691934ab0f0da Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 19 May 2019 09:50:08 -0700 Subject: [PATCH 12/28] [eslint] enable and autofix `import/newline-after-import` --- .eslintrc | 1 - tests/lib/rules/jsx-closing-bracket-location.js | 1 + tests/lib/rules/jsx-no-undef.js | 2 ++ tests/lib/rules/jsx-uses-react.js | 2 ++ tests/lib/rules/jsx-uses-vars.js | 2 ++ 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.eslintrc b/.eslintrc index 2bfd90adc9..83835f519c 100644 --- a/.eslintrc +++ b/.eslintrc @@ -26,7 +26,6 @@ "import/order": 1, "no-useless-escape": 1, - "import/newline-after-import": 1, "operator-linebreak": 1, "function-paren-newline": 0, "no-plusplus": 1, diff --git a/tests/lib/rules/jsx-closing-bracket-location.js b/tests/lib/rules/jsx-closing-bracket-location.js index be74fe4540..019c33a7bf 100644 --- a/tests/lib/rules/jsx-closing-bracket-location.js +++ b/tests/lib/rules/jsx-closing-bracket-location.js @@ -11,6 +11,7 @@ const rule = require('../../../lib/rules/jsx-closing-bracket-location'); const RuleTester = require('eslint').RuleTester; + const parserOptions = { ecmaVersion: 2018, sourceType: 'module', diff --git a/tests/lib/rules/jsx-no-undef.js b/tests/lib/rules/jsx-no-undef.js index dbb77a2a1d..36668edd99 100644 --- a/tests/lib/rules/jsx-no-undef.js +++ b/tests/lib/rules/jsx-no-undef.js @@ -11,6 +11,7 @@ const eslint = require('eslint'); const rule = require('../../../lib/rules/jsx-no-undef'); + const RuleTester = eslint.RuleTester; const parsers = require('../../helpers/parsers'); @@ -29,6 +30,7 @@ const parserOptions = { const ruleTester = new RuleTester({parserOptions}); const linter = ruleTester.linter || eslint.linter; linter.defineRule('no-undef', require('eslint/lib/rules/no-undef')); + ruleTester.run('jsx-no-undef', rule, { valid: [{ code: '/*eslint no-undef:1*/ var React, App; React.render();' diff --git a/tests/lib/rules/jsx-uses-react.js b/tests/lib/rules/jsx-uses-react.js index 0deb834acd..8ac2189b88 100644 --- a/tests/lib/rules/jsx-uses-react.js +++ b/tests/lib/rules/jsx-uses-react.js @@ -11,6 +11,7 @@ const eslint = require('eslint'); const rule = require('eslint/lib/rules/no-unused-vars'); + const RuleTester = eslint.RuleTester; const parsers = require('../../helpers/parsers'); @@ -36,6 +37,7 @@ const settings = { const ruleTester = new RuleTester({parserOptions}); const linter = ruleTester.linter || eslint.linter; linter.defineRule('jsx-uses-react', require('../../../lib/rules/jsx-uses-react')); + ruleTester.run('no-unused-vars', rule, { valid: [ {code: '/*eslint jsx-uses-react:1*/ var React;
;'}, diff --git a/tests/lib/rules/jsx-uses-vars.js b/tests/lib/rules/jsx-uses-vars.js index 7bb5200e9c..efac09331b 100644 --- a/tests/lib/rules/jsx-uses-vars.js +++ b/tests/lib/rules/jsx-uses-vars.js @@ -12,6 +12,7 @@ const eslint = require('eslint'); const ruleNoUnusedVars = require('eslint/lib/rules/no-unused-vars'); const rulePreferConst = require('eslint/lib/rules/prefer-const'); + const RuleTester = eslint.RuleTester; const parsers = require('../../helpers/parsers'); @@ -31,6 +32,7 @@ const parserOptions = { const ruleTester = new RuleTester({parserOptions}); const linter = ruleTester.linter || eslint.linter; linter.defineRule('jsx-uses-vars', require('../../../lib/rules/jsx-uses-vars')); + ruleTester.run('no-unused-vars', ruleNoUnusedVars, { valid: [ { From 2d251e64f37897e16820da975eaa74586f881fcf Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 19 May 2019 09:52:27 -0700 Subject: [PATCH 13/28] [eslint] enable and auto + manually fix `implicit-arrow-linebreak` --- .eslintrc | 1 - lib/rules/jsx-sort-props.js | 8 +++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.eslintrc b/.eslintrc index 83835f519c..3b3de5b6e4 100644 --- a/.eslintrc +++ b/.eslintrc @@ -39,7 +39,6 @@ "no-continue": 1, "global-require": 1, "no-restricted-syntax": 1, - "implicit-arrow-linebreak": 1, "valid-jsdoc": 1, }, "overrides": [ diff --git a/lib/rules/jsx-sort-props.js b/lib/rules/jsx-sort-props.js index 2658d740af..ca56a8d42f 100644 --- a/lib/rules/jsx-sort-props.js +++ b/lib/rules/jsx-sort-props.js @@ -121,11 +121,9 @@ const generateFixerFunction = (node, context, reservedList) => { const options = {ignoreCase, callbacksLast, shorthandFirst, shorthandLast, noSortAlphabetically, reservedFirst, reservedList}; const sortableAttributeGroups = getGroupsOfSortableAttributes(attributes); - const sortedAttributeGroups = sortableAttributeGroups.slice(0).map(group => - group.slice(0).sort((a, b) => - contextCompare(a, b, options) - ) - ); + const sortedAttributeGroups = sortableAttributeGroups + .slice(0) + .map(group => group.slice(0).sort((a, b) => contextCompare(a, b, options))); return function (fixer) { const fixers = []; From cf71c709353de76aa8357e9a295ec9a955b4f28c Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 19 May 2019 09:53:56 -0700 Subject: [PATCH 14/28] [eslint] enable and auto + manually fix `spaced-comment` --- .eslintrc | 1 - lib/rules/destructuring-assignment.js | 2 +- lib/util/usedPropTypes.js | 2 +- tests/lib/rules/destructuring-assignment.js | 2 +- tests/lib/rules/no-direct-mutation-state.js | 2 +- tests/lib/rules/no-unused-prop-types.js | 2 +- 6 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.eslintrc b/.eslintrc index 3b3de5b6e4..e2cad193e7 100644 --- a/.eslintrc +++ b/.eslintrc @@ -32,7 +32,6 @@ "no-param-reassign": 1, "object-curly-newline": 1, "object-property-newline": 1, - "spaced-comment": 1, "no-underscore-dangle": 1, "no-mixed-operators": 1, "no-void": 1, diff --git a/lib/rules/destructuring-assignment.js b/lib/rules/destructuring-assignment.js index 10adcde7e7..21ba911f00 100644 --- a/lib/rules/destructuring-assignment.js +++ b/lib/rules/destructuring-assignment.js @@ -1,6 +1,6 @@ /** * @fileoverview Enforce consistent usage of destructuring assignment of props, state, and context. - **/ + */ 'use strict'; diff --git a/lib/util/usedPropTypes.js b/lib/util/usedPropTypes.js index f63003334f..6b83f86557 100755 --- a/lib/util/usedPropTypes.js +++ b/lib/util/usedPropTypes.js @@ -66,7 +66,7 @@ module.exports = function usedPropTypesInstructions(context, components, utils) /** * Check if we are in a lifecycle method * @return {boolean} true if we are in a class constructor, false if not - **/ + */ function inLifeCycleMethod() { let scope = context.getScope(); while (scope) { diff --git a/tests/lib/rules/destructuring-assignment.js b/tests/lib/rules/destructuring-assignment.js index dfbcf88872..24cd069fbb 100644 --- a/tests/lib/rules/destructuring-assignment.js +++ b/tests/lib/rules/destructuring-assignment.js @@ -1,7 +1,7 @@ /** * @fileoverview Rule to forbid or enforce destructuring assignment consistency. - **/ + */ 'use strict'; diff --git a/tests/lib/rules/no-direct-mutation-state.js b/tests/lib/rules/no-direct-mutation-state.js index 46bd3f6e5c..1f85966cde 100644 --- a/tests/lib/rules/no-direct-mutation-state.js +++ b/tests/lib/rules/no-direct-mutation-state.js @@ -279,6 +279,6 @@ ruleTester.run('no-direct-mutation-state', rule, { errors: [{ message: 'Do not mutate state directly. Use setState().' }] - }*/ + } */ ] }); diff --git a/tests/lib/rules/no-unused-prop-types.js b/tests/lib/rules/no-unused-prop-types.js index 4c52df3f27..4279be371e 100644 --- a/tests/lib/rules/no-unused-prop-types.js +++ b/tests/lib/rules/no-unused-prop-types.js @@ -5021,6 +5021,6 @@ ruleTester.run('no-unused-prop-types', rule, { errors: [{ message: '\'foo\' PropType is defined but prop is never used' }] - }*/ + } */ ] }); From 52207e480505d69740f7db04d0fe8838861ee15b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 19 May 2019 09:57:28 -0700 Subject: [PATCH 15/28] [eslint] enable and autofix `object-curly-newline` and `object-property-newline` --- .eslintrc | 2 -- lib/rules/jsx-sort-props.js | 11 +++++-- tests/lib/rules/forbid-elements.js | 42 +++++++++++++++++---------- tests/lib/rules/jsx-boolean-value.js | 4 ++- tests/lib/rules/react-in-jsx-scope.js | 9 ++++-- 5 files changed, 44 insertions(+), 24 deletions(-) diff --git a/.eslintrc b/.eslintrc index e2cad193e7..b2964a2f3b 100644 --- a/.eslintrc +++ b/.eslintrc @@ -30,8 +30,6 @@ "function-paren-newline": 0, "no-plusplus": 1, "no-param-reassign": 1, - "object-curly-newline": 1, - "object-property-newline": 1, "no-underscore-dangle": 1, "no-mixed-operators": 1, "no-void": 1, diff --git a/lib/rules/jsx-sort-props.js b/lib/rules/jsx-sort-props.js index ca56a8d42f..a3ff43ab4e 100644 --- a/lib/rules/jsx-sort-props.js +++ b/lib/rules/jsx-sort-props.js @@ -118,8 +118,15 @@ const generateFixerFunction = (node, context, reservedList) => { // Sort props according to the context. Only supports ignoreCase. // Since we cannot safely move JSXSpreadAttribute (due to potential variable overrides), // we only consider groups of sortable attributes. - const options = {ignoreCase, callbacksLast, shorthandFirst, shorthandLast, - noSortAlphabetically, reservedFirst, reservedList}; + const options = { + ignoreCase, + callbacksLast, + shorthandFirst, + shorthandLast, + noSortAlphabetically, + reservedFirst, + reservedList + }; const sortableAttributeGroups = getGroupsOfSortableAttributes(attributes); const sortedAttributeGroups = sortableAttributeGroups .slice(0) diff --git a/tests/lib/rules/forbid-elements.js b/tests/lib/rules/forbid-elements.js index 45a2a86198..dd78399bb3 100644 --- a/tests/lib/rules/forbid-elements.js +++ b/tests/lib/rules/forbid-elements.js @@ -105,16 +105,20 @@ ruleTester.run('forbid-elements', rule, { }, { code: '', - options: [{forbid: [ - {element: 'dotted.Component', message: 'that ain\'t cool'} - ]}], + options: [{ + forbid: [ + {element: 'dotted.Component', message: 'that ain\'t cool'} + ] + }], errors: [{message: ' is forbidden, that ain\'t cool'}] }, { code: '