From 095a31c8fb4575dd1b02d4c10a188368398e0749 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 18 Jun 2020 11:01:17 +0400 Subject: Added jsx-a11y plugin Signed-off-by: Valentin Popov --- src/react-javascript.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/react-javascript.ts (limited to 'src/react-javascript.ts') diff --git a/src/react-javascript.ts b/src/react-javascript.ts new file mode 100644 index 0000000..813e859 --- /dev/null +++ b/src/react-javascript.ts @@ -0,0 +1,15 @@ +import rJsxA11y from "./rules/jsx-a11y/default.json"; +import rDefault from "./rules/react/default.json"; + +module.exports = { + "extends": [ + "./javascript", + ], + "plugins": [ + "jsx-a11y", + ], + "rules": { + ...rDefault, + ...rJsxA11y, + }, +}; -- cgit v1.2.3 From e66c5dd2335131c0a96d66bbb401b541ff29672e Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 18 Jun 2020 11:11:34 +0400 Subject: Added react and react-hooks plugins Signed-off-by: Valentin Popov --- docs/roadmap/react-hooks.md | 4 + docs/roadmap/react.md | 89 ++++++++++++++++++++ package-lock.json | 161 +++++++++++++++++++++++++++++++++++++ package.json | 4 + src/react-javascript.ts | 12 +++ src/rules/react-hooks/default.json | 1 + 6 files changed, 271 insertions(+) create mode 100644 docs/roadmap/react-hooks.md create mode 100644 docs/roadmap/react.md create mode 100644 src/rules/react-hooks/default.json (limited to 'src/react-javascript.ts') diff --git a/docs/roadmap/react-hooks.md b/docs/roadmap/react-hooks.md new file mode 100644 index 0000000..2e651d4 --- /dev/null +++ b/docs/roadmap/react-hooks.md @@ -0,0 +1,4 @@ +# React Hooks + +- [ ] "exhaustive-deps" +- [ ] "rules-of-hooks" diff --git a/docs/roadmap/react.md b/docs/roadmap/react.md new file mode 100644 index 0000000..20a9b26 --- /dev/null +++ b/docs/roadmap/react.md @@ -0,0 +1,89 @@ +# React + +- [ ] "boolean-prop-naming" +- [ ] "button-has-type" +- [ ] "default-props-match-prop-types" +- [ ] "destructuring-assignment" +- [ ] "display-name" +- [ ] "forbid-component-props" +- [ ] "forbid-dom-props" +- [ ] "forbid-elements" +- [ ] "forbid-foreign-prop-types" +- [ ] "forbid-prop-types" +- [ ] "function-component-definition" +- [ ] "jsx-boolean-value" +- [ ] "jsx-child-element-spacing" +- [ ] "jsx-closing-bracket-location" +- [ ] "jsx-closing-tag-location" +- [ ] "jsx-curly-brace-presence" +- [ ] "jsx-curly-newline" +- [ ] "jsx-curly-spacing" +- [ ] "jsx-equals-spacing" +- [ ] "jsx-filename-extension" +- [ ] "jsx-first-prop-new-line" +- [ ] "jsx-fragments" +- [ ] "jsx-handler-names" +- [ ] "jsx-indent" +- [ ] "jsx-indent-props" +- [ ] "jsx-key" +- [ ] "jsx-max-depth" +- [ ] "jsx-max-props-per-line" +- [ ] "jsx-no-bind" +- [ ] "jsx-no-comment-textnodes" +- [ ] "jsx-no-duplicate-props" +- [ ] "jsx-no-literals" +- [ ] "jsx-no-script-url" +- [ ] "jsx-no-target-blank" +- [ ] "jsx-no-undef" +- [ ] "jsx-no-useless-fragment" +- [ ] "jsx-one-expression-per-line" +- [ ] "jsx-pascal-case" +- [ ] "jsx-props-no-multi-spaces" +- [ ] "jsx-props-no-spreading" +- [ ] "jsx-sort-default-props" +- [ ] "jsx-sort-props" +- [ ] "jsx-space-before-closing" +- [ ] "jsx-tag-spacing" +- [ ] "jsx-uses-react" +- [ ] "jsx-uses-vars" +- [ ] "jsx-wrap-multilines" +- [ ] "no-access-state-in-setstate" +- [ ] "no-adjacent-inline-elements" +- [ ] "no-array-index-key" +- [ ] "no-children-prop" +- [ ] "no-danger" +- [ ] "no-danger-with-children" +- [ ] "no-deprecated" +- [ ] "no-did-mount-set-state" +- [ ] "no-did-update-set-state" +- [ ] "no-direct-mutation-state" +- [ ] "no-find-dom-node" +- [ ] "no-is-mounted" +- [ ] "no-multi-comp" +- [ ] "no-redundant-should-component-update" +- [ ] "no-render-return-value" +- [ ] "no-set-state" +- [ ] "no-string-refs" +- [ ] "no-this-in-sfc" +- [ ] "no-typos" +- [ ] "no-unescaped-entities" +- [ ] "no-unknown-property" +- [ ] "no-unsafe" +- [ ] "no-unused-prop-types" +- [ ] "no-unused-state" +- [ ] "no-will-update-set-state" +- [ ] "prefer-es6-class" +- [ ] "prefer-read-only-props" +- [ ] "prefer-stateless-function" +- [ ] "prop-types" +- [ ] "react-in-jsx-scope" +- [ ] "require-default-props" +- [ ] "require-optimization" +- [ ] "require-render-return" +- [ ] "self-closing-comp" +- [ ] "sort-comp" +- [ ] "sort-prop-types" +- [ ] "state-in-constructor" +- [ ] "static-property-placement" +- [ ] "style-prop-object" +- [ ] "void-dom-elements-no-children" diff --git a/package-lock.json b/package-lock.json index d3edb9a..500c4d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39,6 +39,16 @@ "regenerator-runtime": "^0.13.4" } }, + "@babel/runtime-corejs3": { + "version": "7.10.2", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.10.2.tgz", + "integrity": "sha512-+a2M/u7r15o3dV1NEizr9bRi+KUVnrs/qYxF0Z06DAPx/4VCWaz1WA7EcbE+uqGgt39lp5akWGmHsTseIkHkHg==", + "dev": true, + "requires": { + "core-js-pure": "^3.0.0", + "regenerator-runtime": "^0.13.4" + } + }, "@rollup/plugin-json": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-4.1.0.tgz", @@ -385,6 +395,12 @@ "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=", "dev": true }, + "core-js-pure": { + "version": "3.6.5", + "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.6.5.tgz", + "integrity": "sha512-lacdXOimsiD0QyNf9BC/mxivNJ/ybBGJXQFKzRekp1WTHoVUWsUHEn+2T8GJAzzIhyOuXA+gOxCVN3l+5PLPUA==", + "dev": true + }, "cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -737,6 +753,42 @@ } } }, + "eslint-plugin-react": { + "version": "7.20.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.20.0.tgz", + "integrity": "sha512-rqe1abd0vxMjmbPngo4NaYxTcR3Y4Hrmc/jg4T+sYz63yqlmJRknpEQfmWY+eDWPuMmix6iUIK+mv0zExjeLgA==", + "dev": true, + "requires": { + "array-includes": "^3.1.1", + "doctrine": "^2.1.0", + "has": "^1.0.3", + "jsx-ast-utils": "^2.2.3", + "object.entries": "^1.1.1", + "object.fromentries": "^2.0.2", + "object.values": "^1.1.1", + "prop-types": "^15.7.2", + "resolve": "^1.15.1", + "string.prototype.matchall": "^4.0.2", + "xregexp": "^4.3.0" + }, + "dependencies": { + "doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "dev": true, + "requires": { + "esutils": "^2.0.2" + } + } + } + }, + "eslint-plugin-react-hooks": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.0.4.tgz", + "integrity": "sha512-equAdEIsUETLFNCmmCkiCGq6rkSK5MoJhXFPFYeUebcjKgBmWWcgVOqZyQC8Bv1BwVCnTq9tBxgJFgAJTWoJtA==", + "dev": true + }, "eslint-plugin-security": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/eslint-plugin-security/-/eslint-plugin-security-1.4.0.tgz", @@ -1274,6 +1326,17 @@ } } }, + "internal-slot": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.2.tgz", + "integrity": "sha512-2cQNfwhAfJIkU4KZPkDI+Gj5yNNnbqi40W9Gge6dfnk4TocEVm00B3bdiL+JINrbGJil2TeHvM4rETGzk/f/0g==", + "dev": true, + "requires": { + "es-abstract": "^1.17.0-next.1", + "has": "^1.0.3", + "side-channel": "^1.0.2" + } + }, "is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", @@ -1485,6 +1548,15 @@ "integrity": "sha1-7GZi5IlkCO1KtsVCo5kLcswIACA=", "dev": true }, + "loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, + "requires": { + "js-tokens": "^3.0.0 || ^4.0.0" + } + }, "merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", @@ -1565,6 +1637,12 @@ } } }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, "object-inspect": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", @@ -1589,6 +1667,29 @@ "object-keys": "^1.0.11" } }, + "object.entries": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.2.tgz", + "integrity": "sha512-BQdB9qKmb/HyNdMNWVr7O3+z5MUIx3aiegEIJqjMBbBf0YT9RRxTJSim4mzFqtyr7PDAHigq0N9dO0m0tRakQA==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.5", + "has": "^1.0.3" + } + }, + "object.fromentries": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.2.tgz", + "integrity": "sha512-r3ZiBH7MQppDJVLx6fhD618GKNG40CZYH9wgwdhKxBDDbQgjeWGGd4AtkZad84d291YxvWe7bJGuE65Anh0dxQ==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0-next.1", + "function-bind": "^1.1.1", + "has": "^1.0.3" + } + }, "object.values": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.1.tgz", @@ -1753,6 +1854,17 @@ "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", "dev": true }, + "prop-types": { + "version": "15.7.2", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz", + "integrity": "sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==", + "dev": true, + "requires": { + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.8.1" + } + }, "punycode": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", @@ -1768,6 +1880,12 @@ "safe-buffer": "^5.1.0" } }, + "react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", + "dev": true + }, "read-pkg": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", @@ -1801,6 +1919,16 @@ "integrity": "sha512-kUUXjX4AnqnR8KRTCrayAo9PzYMRKmVoGgaz2tBuz0MF3g1ZbGebmtW0yFHfFK9CmBjQKeYIgoL22pFLBJY7sw==", "dev": true }, + "regexp.prototype.flags": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.3.0.tgz", + "integrity": "sha512-2+Q0C5g951OlYlJz6yu5/M33IcsESLlLfsyIaLJaG4FA2r4yP8MvVMJUUP/fVBkSpbbbZlS5gynbEWLipiiXiQ==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0-next.1" + } + }, "regexpp": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz", @@ -1945,6 +2073,16 @@ "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true }, + "side-channel": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.2.tgz", + "integrity": "sha512-7rL9YlPHg7Ancea1S96Pa8/QWb4BtXL/TZvS6B8XFetGBeuhAsfmUspK6DokBeZ64+Kj9TCNRD/30pVz1BvQNA==", + "dev": true, + "requires": { + "es-abstract": "^1.17.0-next.1", + "object-inspect": "^1.7.0" + } + }, "signal-exit": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", @@ -2035,6 +2173,20 @@ "strip-ansi": "^6.0.0" } }, + "string.prototype.matchall": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.2.tgz", + "integrity": "sha512-N/jp6O5fMf9os0JU3E72Qhf590RSRZU/ungsL/qJUYVTNv7hTG0P/dbPjxINVN9jpscu3nzYwKESU3P3RY5tOg==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0", + "has-symbols": "^1.0.1", + "internal-slot": "^1.0.2", + "regexp.prototype.flags": "^1.3.0", + "side-channel": "^1.0.2" + } + }, "string.prototype.trimend": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz", @@ -2306,6 +2458,15 @@ "requires": { "mkdirp": "^0.5.1" } + }, + "xregexp": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-4.3.0.tgz", + "integrity": "sha512-7jXDIFXh5yJ/orPn4SXjuVrWWoi4Cr8jfV1eHv9CixKSbU+jY4mxfrBwAuDvupPNKpMUY+FeIqsVw/JLT9+B8g==", + "dev": true, + "requires": { + "@babel/runtime-corejs3": "^7.8.3" + } } } } diff --git a/package.json b/package.json index 75e09f9..c826c88 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,8 @@ "eslint-plugin-eslint-comments": "^3.2.0", "eslint-plugin-import": "^2.21.2", "eslint-plugin-jsx-a11y": "^6.2.3", + "eslint-plugin-react": "^7.20.0", + "eslint-plugin-react-hooks": "^4.0.4", "eslint-plugin-security": "^1.4.0", "eslint-plugin-sonarjs": "^0.5.0", "eslint-plugin-unicorn": "^20.1.0", @@ -36,6 +38,8 @@ "eslint-plugin-eslint-comments": "^3.2.0", "eslint-plugin-import": "^2.21.2", "eslint-plugin-jsx-a11y": "^6.2.3", + "eslint-plugin-react": "^7.20.0", + "eslint-plugin-react-hooks": "^4.0.4", "eslint-plugin-security": "^1.4.0", "eslint-plugin-sonarjs": "^0.5.0", "eslint-plugin-unicorn": "^20.1.0", diff --git a/src/react-javascript.ts b/src/react-javascript.ts index 813e859..e3bea86 100644 --- a/src/react-javascript.ts +++ b/src/react-javascript.ts @@ -1,15 +1,27 @@ import rJsxA11y from "./rules/jsx-a11y/default.json"; +import rReactHooks from "./rules/react-hooks/default.json"; import rDefault from "./rules/react/default.json"; module.exports = { "extends": [ "./javascript", + "plugin:jsx-a11y/recommended", + "plugin:react-hooks/recommended", + "plugin:react/recommended", ], + "parserOptions": { + ecmaFeatures: { + jsx: true, + }, + }, "plugins": [ "jsx-a11y", + "react", + "react-hooks", ], "rules": { ...rDefault, ...rJsxA11y, + ...rReactHooks, }, }; diff --git a/src/rules/react-hooks/default.json b/src/rules/react-hooks/default.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/src/rules/react-hooks/default.json @@ -0,0 +1 @@ +{} -- cgit v1.2.3