From 6f71cfeff9bfffb479ea2dd8feb4f357e81a0676 Mon Sep 17 00:00:00 2001 From: Koala Yeung Date: Sun, 7 May 2017 03:26:54 +0800 Subject: [PATCH] Eslintrc fix (#2850) * eslintrc: adapt changes in eslint-plugin-jsx-a11y * Replace 'jsx-a11y/img-has-alt' with 'jsx-a11y/alt-text'. Reference: evcohen/eslint-plugin-jsx-a11y@24b6193 * Replace 'jsx-a11y/onclick-has-focus' with 'jsx-a11y/interactive-supports-focus' Reference: evcohen/eslint-plugin-jsx-a11y@cbdfeb8 * Replace 'jsx-a11y/onclick-has-role' with 'jsx-a11y/no-noninteractive-element-interactions' Reference: evcohen/eslint-plugin-jsx-a11y@18c9b71 * Update eslint-plugin-jsx-a11y to 5.0.0 Follow the change in Code Climate. Make sure the same eslintrc can be executed locally and in Code Climate. * Convert .eslintrc.json to equivlant .eslintrc.yml * Less quotes and commas, more readability, allow comment. --- .eslintrc.json | 79 ------------------------------------------------- .eslintrc.yml | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 4 +-- yarn.lock | 30 +++++++++++-------- 4 files changed, 100 insertions(+), 93 deletions(-) delete mode 100644 .eslintrc.json create mode 100644 .eslintrc.yml diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index a3640b2657..0000000000 --- a/.eslintrc.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "env": { - "browser": true, - "node": false, - "es6": true - }, - - "parser": "babel-eslint", - - "plugins": [ - "react", - "jsx-a11y" - ], - - "parserOptions": { - "sourceType": "module", - - "ecmaFeatures": { - "arrowFunctions": true, - "jsx": true, - "destructuring": true, - "modules": true, - "spread": true - } - }, - - "rules": { - "no-cond-assign": 2, - "no-console": 1, - "no-irregular-whitespace": 2, - "no-unreachable": 2, - "valid-typeof": 2, - "consistent-return": 2, - "dot-notation": 2, - "eqeqeq": 2, - "no-fallthrough": 2, - "no-unused-expressions": 2, - "strict": 0, - "no-catch-shadow": 2, - "indent": [1, 2], - "brace-style": 1, - "comma-spacing": [1, {"before": false, "after": true}], - "comma-style": [1, "last"], - "no-mixed-spaces-and-tabs": 1, - "no-nested-ternary": 1, - "no-trailing-spaces": 1, - - "react/jsx-wrap-multilines": 2, - "react/self-closing-comp": 2, - "react/prop-types": 2, - "react/no-multi-comp": 0, - - "jsx-a11y/accessible-emoji": 1, - "jsx-a11y/anchor-has-content": 1, - "jsx-a11y/aria-activedescendant-has-tabindex": 1, - "jsx-a11y/aria-props": 1, - "jsx-a11y/aria-proptypes": 1, - "jsx-a11y/aria-role": 1, - "jsx-a11y/aria-unsupported-elements": 1, - "jsx-a11y/heading-has-content": 1, - "jsx-a11y/href-no-hash": 1, - "jsx-a11y/html-has-lang": 1, - "jsx-a11y/iframe-has-title": 1, - "jsx-a11y/img-has-alt": 1, - "jsx-a11y/img-redundant-alt": 1, - "jsx-a11y/label-has-for": 1, - "jsx-a11y/mouse-events-have-key-events": 1, - "jsx-a11y/no-access-key": 1, - "jsx-a11y/no-distracting-elements": 1, - "jsx-a11y/no-onchange": 1, - "jsx-a11y/no-redundant-roles": 1, - "jsx-a11y/onclick-has-focus": 1, - "jsx-a11y/onclick-has-role": 1, - "jsx-a11y/role-has-required-aria-props": 1, - "jsx-a11y/role-supports-aria-props": 1, - "jsx-a11y/scope": 1, - "jsx-a11y/tabindex-no-positive": 1 - } -} diff --git a/.eslintrc.yml b/.eslintrc.yml new file mode 100644 index 0000000000..ac7c8a0c7f --- /dev/null +++ b/.eslintrc.yml @@ -0,0 +1,80 @@ +--- +env: + browser: true + node: false + es6: true + +parser: babel-eslint + +plugins: +- react +- jsx-a11y + +parserOptions: + sourceType: module + ecmaFeatures: + arrowFunctions: true + jsx: true + destructuring: true + modules: true + spread: true + +rules: + + no-cond-assign: error + no-console: warn + no-irregular-whitespace: error + no-unreachable: error + valid-typeof: error + consistent-return: error + dot-notation: error + eqeqeq: error + no-fallthrough: error + no-unused-expressions: error + strict: off + no-catch-shadow: error + indent: + - warn + - 2 + brace-style: warn + comma-spacing: + - warn + - before: false + after: true + comma-style: + - warn + - last + no-mixed-spaces-and-tabs: warn + no-nested-ternary: warn + no-trailing-spaces: warn + + react/jsx-wrap-multilines: error + react/self-closing-comp: error + react/prop-types: error + react/no-multi-comp: off + + jsx-a11y/accessible-emoji: warn + jsx-a11y/anchor-has-content: warn + jsx-a11y/alt-text: warn + jsx-a11y/aria-activedescendant-has-tabindex: warn + jsx-a11y/aria-props: warn + jsx-a11y/aria-proptypes: warn + jsx-a11y/aria-role: warn + jsx-a11y/aria-unsupported-elements: warn + jsx-a11y/heading-has-content: warn + jsx-a11y/href-no-hash: warn + jsx-a11y/html-has-lang: warn + jsx-a11y/iframe-has-title: warn + jsx-a11y/img-redundant-alt: warn + jsx-a11y/interactive-supports-focus: warn + jsx-a11y/label-has-for: warn + jsx-a11y/mouse-events-have-key-events: warn + jsx-a11y/no-access-key: warn + jsx-a11y/no-distracting-elements: warn + jsx-a11y/no-noninteractive-element-interactions: warn + jsx-a11y/no-onchange: warn + jsx-a11y/no-redundant-roles: warn + jsx-a11y/role-has-required-aria-props: warn + jsx-a11y/role-supports-aria-props: warn + jsx-a11y/scope: warn + jsx-a11y/tabindex-no-positive: warn diff --git a/package.json b/package.json index 6b88c7a1f1..136c92860a 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "start": "babel-node ./streaming/index.js --presets es2015,stage-2", "storybook": "start-storybook -p 9001 -c storybook", "test": "npm run test:lint && npm run test:mocha", - "test:lint": "eslint -c .eslintrc.json --ext=js --ext=jsx app/javascript/", + "test:lint": "eslint -c .eslintrc.yml --ext=js --ext=jsx app/javascript/", "test:mocha": "mocha --require ./spec/javascript/setup.js --compilers js:babel-register ./spec/javascript/components/*.test.jsx" }, "repository": { @@ -112,7 +112,7 @@ "chai-enzyme": "^0.6.1", "enzyme": "^2.8.2", "eslint": "^3.19.0", - "eslint-plugin-jsx-a11y": "^4.0.0", + "eslint-plugin-jsx-a11y": "^5.0.0", "eslint-plugin-react": "^6.10.3", "jsdom": "^9.11.0", "minimist": "^1.2.0", diff --git a/yarn.lock b/yarn.lock index 861a3818b7..84b20ef5d9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -232,9 +232,9 @@ argparse@^1.0.7: dependencies: sprintf-js "~1.0.2" -aria-query@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/aria-query/-/aria-query-0.3.0.tgz#cb8a9984e2862711c83c80ade5b8f5ca0de2b467" +aria-query@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/aria-query/-/aria-query-0.5.0.tgz#85e3152cd8cc5bab18dbed61cd9c4fce54fa79c3" dependencies: ast-types-flow "0.0.7" @@ -389,6 +389,12 @@ axios@^0.15.3: dependencies: follow-redirects "1.0.0" +axobject-query@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-0.1.0.tgz#62f59dbc59c9f9242759ca349960e7a2fe3c36c0" + dependencies: + ast-types-flow "0.0.7" + babel-cli@^6.23.0: version "6.23.0" resolved "https://registry.yarnpkg.com/babel-cli/-/babel-cli-6.23.0.tgz#52ff946a2b0f64645c35e7bd5eea267aa0948c0f" @@ -2514,16 +2520,16 @@ escope@^3.6.0: esrecurse "^4.1.0" estraverse "^4.1.1" -eslint-plugin-jsx-a11y@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-4.0.0.tgz#779bb0fe7b08da564a422624911de10061e048ee" +eslint-plugin-jsx-a11y@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-5.0.0.tgz#88c1d26b2d145ef077ab3d130be15243ac06a877" dependencies: - aria-query "^0.3.0" + aria-query "^0.5.0" ast-types-flow "0.0.7" + axobject-query "^0.1.0" damerau-levenshtein "^1.0.0" emoji-regex "^6.1.0" - jsx-ast-utils "^1.0.0" - object-assign "^4.0.1" + jsx-ast-utils "^1.4.0" eslint-plugin-react@^6.10.3: version "6.10.3" @@ -3751,7 +3757,7 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.3.6" -jsx-ast-utils@^1.0.0, jsx-ast-utils@^1.3.4: +jsx-ast-utils@^1.3.4, jsx-ast-utils@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-1.4.0.tgz#5afe38868f56bc8cc7aeaef0100ba8c75bd12591" dependencies: @@ -3990,11 +3996,11 @@ lodash.tail@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/lodash.tail/-/lodash.tail-4.1.1.tgz#d2333a36d9e7717c8ad2f7cacafec7c32b444664" -lodash@4.x.x, "lodash@>=3.5 <5", lodash@^4.0.0, lodash@^4.14.0, lodash@^4.17.2, lodash@^4.17.4, lodash@^4.2.1, lodash@^4.3.0: +lodash@4.x.x, "lodash@>=3.5 <5", lodash@^4.0.0, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.2, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0, lodash@^4.6.1: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" -lodash@^4.15.0, lodash@^4.2.0, lodash@^4.6.1, lodash@~4.16.4: +lodash@~4.16.4: version "4.16.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.16.4.tgz#01ce306b9bad1319f2a5528674f88297aeb70127"