From caad21ab4ce78fa2898d00e7b4a49980bb0f64a1 Mon Sep 17 00:00:00 2001 From: Otto G Date: Thu, 30 Jan 2020 10:00:42 -0500 Subject: [PATCH] style: improve lint config --- .eslintignore | 1 + .eslintrc.js | 96 +++++++++++++++++++++++++++------------------------ package.json | 14 ++++---- 3 files changed, 60 insertions(+), 51 deletions(-) diff --git a/.eslintignore b/.eslintignore index c5e2402..deaaa08 100644 --- a/.eslintignore +++ b/.eslintignore @@ -3,3 +3,4 @@ build .cache dist coverage +!.eslintrc.js \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js index 745ef03..9c17cf3 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,65 +1,71 @@ +const ignoreExports = [ + '.eslintrc.js', + 'app/script.js', + 'app/script.test.js', + 'commitlint.config.js', + 'test/About.test.js', + 'truffle-config.js', + // TODO: Fix index exports + '**/index.js', +] + module.exports = { env: { browser: true, + commonjs: true, es6: true, node: true, - commonjs: true, }, extends: [ + 'standard', 'standard-react', 'eslint:recommended', 'plugin:import/errors', - 'plugin:react/recommended', + 'plugin:react/recommended', // will import plugin and enable jsx in parser options 'plugin:jsx-a11y/recommended', ], parser: 'babel-eslint', parserOptions: { - ecmaFeatures: { - jsx: true - }, ecmaVersion: 2018, - sourceType: 'module' }, - plugins: ['react'], + plugins: [ 'react-hooks', 'sort-keys-fix' ], rules: { - 'arrow-parens': ["error", "as-needed"], - indent: ['error', 2], - 'linebreak-style': ['error', 'unix'], - quotes: ['error', 'single'], - 'react/no-typos': 1, - semi: ['error', 'never'], - 'array-bracket-spacing': [ - 'error', - 'always', - { - objectsInArrays: false, - arraysInArrays: false, - singleValue: false - } - ], - 'func-style': ["warn", "declaration", { "allowArrowFunctions": true }], - 'object-curly-spacing': ['error', 'always'], - // "import/no-unused-modules": [ - // "warn", - // { - // unusedExports: true, - // missingExports: true, - // ignoreExports: [], - // } - // ], - "no-undef": "error", - "no-unused-vars": ["warn", { "vars": "all", "args": "after-used", "ignoreRestSiblings": false }], - 'no-console': ['warn', { allow: ['warn', 'error'] }], - "react/jsx-uses-react": "warn", - "react/jsx-uses-vars": "warn", - "react/jsx-filename-extension": "off", - "react/no-unused-prop-types": "warn", - "react/self-closing-comp": ["error", {"component": true, "html": true}], - "sort-imports": ["warn", { "ignoreDeclarationSort": true }] + 'array-bracket-spacing': [ 'error', 'always', { singleValue: false } ], + 'arrow-parens': [ 'error', 'as-needed' ], + 'comma-dangle': [ 'error', 'always-multiline' ], + 'comma-spacing': ['error'], + 'func-style': [ 'warn', 'declaration', { 'allowArrowFunctions': true } ], + 'import/no-unresolved': ['error'], + 'import/no-unused-modules': [ 'error', { ignoreExports, missingExports: true, unusedExports: true } ], + 'indent': [ 'error', 2 ], + 'linebreak-style': [ 'error', 'unix' ], + 'no-console': [ 'warn', { allow: [ 'warn', 'error' ] } ], + 'no-multi-spaces': 'error', + 'no-trailing-spaces': ['error'], + 'no-undef': 'error', + 'no-unused-vars': [ 'warn', { 'args': 'after-used', 'ignoreRestSiblings': false, 'vars': 'all' } ], + 'object-curly-spacing': [ 'error', 'always' ], + 'quotes': [ 'error', 'single' ], + 'react-hooks/exhaustive-deps': 'error', + 'react-hooks/rules-of-hooks': 'error', + 'react/default-props-match-prop-types': ['error'], + 'react/destructuring-assignment': [ 'error', 'always' ], + 'react/forbid-prop-types': ['warn'], + 'react/function-component-definition': [ 'error', { 'namedComponents': 'arrow-function', 'unnamedComponents': 'function-expression' } ], + 'react/no-array-index-key': 'warn', + 'react/no-danger': 'error', + 'react/no-typos': 'error', + 'react/no-unused-prop-types': 'warn', + 'react/require-default-props': ['error'], + 'react/self-closing-comp': [ 'error', { 'component': true, 'html': true } ], + 'react/sort-comp': ['error'], + 'react/sort-prop-types': [ 'error', { 'ignoreCase': true, 'sortShapeProp': 'true' } ], + 'react/void-dom-elements-no-children': 'error', + 'semi': [ 'error', 'never' ], + 'sort-imports': [ 'error', { 'ignoreDeclarationSort': true } ], + 'sort-keys-fix/sort-keys-fix': 'error', }, settings: { - react: { - version: 'detect', - } - } + react: { version: 'detect' }, + }, } diff --git a/package.json b/package.json index 8df1e1e..f7670a7 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "@types/react": "^16.8.6", "acorn": "^6.1.1", "ava": "^1.4.1", - "babel-eslint": "^10.0.1", + "babel-eslint": "^10.0.3", "babel-plugin-styled-components": "^1.10.0", "copyfiles": "^2.1.1", "coveralls": "3.0.2", @@ -52,12 +52,14 @@ "eslint-config-prettier": "^6.0.0", "eslint-config-standard": "^12.0.0", "eslint-config-standard-react": "^7.0.2", - "eslint-plugin-import": "^2.17.3", + "eslint-plugin-import": "^2.20.0", "eslint-plugin-jsx-a11y": "^6.2.1", - "eslint-plugin-node": "^9.1.0", - "eslint-plugin-promise": "^4.1.1", - "eslint-plugin-react": "^7.13.0", - "eslint-plugin-standard": "^4.0.0", + "eslint-plugin-node": "^9.2.0", + "eslint-plugin-promise": "^4.2.1", + "eslint-plugin-react": "^7.18.0", + "eslint-plugin-react-hooks": "^2.3.0", + "eslint-plugin-sort-keys-fix": "^1.1.0", + "eslint-plugin-standard": "^4.0.1", "eth-gas-reporter": "0.1.12", "ethereumjs-abi": "0.6.5", "ganache-cli": "6.1.8",