diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..d811f404 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "./index.js" +} diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..9d5ce399 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,5 @@ +{ + "printWidth": 120, + "singleQuote": true, + "trailingComma": "es5" +} diff --git a/index.js b/index.js index 83c8dd4c..09dc3b13 100644 --- a/index.js +++ b/index.js @@ -1,68 +1,65 @@ module.exports = { extends: [ - "airbnb-base", - "eslint:recommended", - "plugin:eslint-comments/recommended", - "plugin:import/errors", - "plugin:import/warnings", - "plugin:sonarjs/recommended", - "prettier" + 'airbnb-base', + 'eslint:recommended', + 'plugin:eslint-comments/recommended', + 'plugin:import/errors', + 'plugin:import/warnings', + 'plugin:sonarjs/recommended', + 'prettier', ], - plugins: ["node", "prettier", "unicorn"], + plugins: ['node', 'prettier', 'unicorn'], rules: { - "arrow-body-style": "off", + 'arrow-body-style': 'off', - "eslint-comments/disable-enable-pair": ["error", { allowWholeFile: true }], - "eslint-comments/no-unused-disable": "error", + 'eslint-comments/disable-enable-pair': ['error', { allowWholeFile: true }], + 'eslint-comments/no-unused-disable': 'error', - "func-names": "off", + 'func-names': 'off', - "import/default": "off", - "import/named": "off", // @fixme Disabling this for now, but there are some weird callouts with it. - "import/order": "off", + 'import/default': 'off', + 'import/named': 'off', // @fixme Disabling this for now, but there are some weird callouts with it. + 'import/order': 'off', - "no-constructor-return": "error", - "no-dupe-else-if": "error", - "no-else-return": ["error", { allowElseIf: true }], + 'no-constructor-return': 'error', + 'no-dupe-else-if': 'error', + 'no-else-return': ['error', { allowElseIf: true }], // Disallow shadowing of any variable that isn't "err" as this is a common case that is acceptable. - "no-shadow": ["error", { allow: ["err"] }], + 'no-shadow': ['error', { allow: ['err'] }], - "node/no-deprecated-api": "error", - "node/no-exports-assign": "error", - "node/no-extraneous-require": "error", + 'node/no-deprecated-api': 'error', + 'node/no-exports-assign': 'error', + 'node/no-extraneous-require': 'error', - "prefer-destructuring": "off", + 'prefer-destructuring': 'off', - "prettier/prettier": "error", + 'prettier/prettier': 'error', - "sonarjs/cognitive-complexity": "off", - "sonarjs/no-collapsible-if": "off", - "sonarjs/no-duplicate-string": "off", - "sonarjs/no-duplicated-branches": "off", - "sonarjs/no-identical-functions": "off", // @todo We should fix these. - "sonarjs/prefer-immediate-return": "off", // @todo We should fix these. + 'sonarjs/cognitive-complexity': 'off', + 'sonarjs/no-collapsible-if': 'off', + 'sonarjs/no-duplicate-string': 'off', + 'sonarjs/no-duplicated-branches': 'off', + 'sonarjs/no-identical-functions': 'off', // @todo We should fix these. + 'sonarjs/prefer-immediate-return': 'off', // @todo We should fix these. - "unicorn/catch-error-name": [ - "error", - { caughtErrorsIgnorePattern: "^(error|err|e)$" } - ], + 'unicorn/catch-error-name': ['error', { caughtErrorsIgnorePattern: '^(error|err|e)$' }], // "unicorn/consistent-function-scoping": "error", // Maybe? - "unicorn/custom-error-definition": "error", - "unicorn/error-message": "error", - "unicorn/escape-case": "error", - "unicorn/new-for-builtins": "error", - "unicorn/no-array-instanceof": "error", + 'unicorn/custom-error-definition': 'error', + 'unicorn/error-message': 'error', + 'unicorn/escape-case': 'error', + 'unicorn/new-for-builtins': 'error', + 'unicorn/no-array-instanceof': 'error', // "unicorn/no-for-loop": "error", // Maybe? - "no-nested-ternary": "off", // Disabled in favor of `unicorn/no-nested-ternary` which has better nesting detection. - "unicorn/no-nested-ternary": "error", - "unicorn/no-unreadable-array-destructuring": "error", + 'no-nested-ternary': 'off', // Disabled in favor of `unicorn/no-nested-ternary` which has better nesting detection. + 'unicorn/no-nested-ternary': 'error', + 'unicorn/no-unreadable-array-destructuring': 'error', // "unicorn/no-unsafe-regex": "error", // @todo We should resolve these. - "unicorn/no-unused-properties": "error", + 'unicorn/no-unused-properties': 'error', // "unicorn/prefer-includes": "error", // Maybe? // "unicorn/prefer-query-selector": "error", // Maybe? - "unicorn/prefer-starts-ends-with": "off", // @todo We should resolve these. - "unicorn/prefer-type-error": "error", - "unicorn/throw-new-error": "error" - } + 'unicorn/prefer-starts-ends-with': 'off', // @todo We should resolve these. + 'unicorn/prefer-type-error': 'error', + 'unicorn/throw-new-error': 'error', + }, }; diff --git a/package.json b/package.json index 0b8e36ff..0306a53c 100644 --- a/package.json +++ b/package.json @@ -47,8 +47,5 @@ "extends": [ "@commitlint/config-conventional" ] - }, - "eslintConfig": { - "extends": "./index.js" } } diff --git a/react.js b/react.js index 478ce249..dbc92119 100644 --- a/react.js +++ b/react.js @@ -1,43 +1,40 @@ module.exports = { - extends: ["plugin:jsx-a11y/recommended", "plugin:react/recommended"], + extends: ['plugin:jsx-a11y/recommended', 'plugin:react/recommended'], env: { - browser: true + browser: true, }, settings: { - "import/resolver": { + 'import/resolver': { node: { - extensions: [".js", ".jsx"] - } + extensions: ['.js', '.jsx'], + }, }, react: { - version: "detect" - } + version: 'detect', + }, }, rules: { - "jsx-a11y/no-onchange": "off", // @todo We should fix these. + 'jsx-a11y/no-onchange': 'off', // @todo We should fix these. - "no-param-reassign": ["error", { props: false }], + 'no-param-reassign': ['error', { props: false }], - "react/destructuring-assignment": "off", - "react/jsx-props-no-spreading": [ - "error", + 'react/destructuring-assignment': 'off', + 'react/jsx-props-no-spreading': [ + 'error', { - html: "enforce", - custom: "ignore" - } + html: 'enforce', + custom: 'ignore', + }, ], - "react/jsx-sort-default-props": ["error", { ignoreCase: true }], - "react/jsx-sort-props": [ - "error", - { ignoreCase: true, reservedFirst: true } - ], - "react/sort-prop-types": [ - "error", + 'react/jsx-sort-default-props': ['error', { ignoreCase: true }], + 'react/jsx-sort-props': ['error', { ignoreCase: true, reservedFirst: true }], + 'react/sort-prop-types': [ + 'error', { ignoreCase: true, - sortShapeProp: true - } - ] - } + sortShapeProp: true, + }, + ], + }, }; diff --git a/testing.js b/testing.js index 182470cf..5a4c813e 100644 --- a/testing.js +++ b/testing.js @@ -1,24 +1,25 @@ module.exports = { - extends: ["plugin:jest/recommended", "plugin:jest/style"], - plugins: ["jest"], + extends: ['plugin:jest/recommended', 'plugin:jest/style'], + plugins: ['jest'], env: { - "jest/globals": true + 'jest/globals': true, }, rules: { - "jest/consistent-test-it": "warn", - "jest/expect-expect": "warn", - "jest/no-disabled-tests": "off", - "jest/no-duplicate-hooks": "warn", - "jest/no-expect-resolves": "warn", - "jest/no-if": "error", - "jest/prefer-hooks-on-top": "warn", - "jest/prefer-strict-equal": "error", - "jest/valid-describe": "error", - "jest/valid-title": "warn", + 'jest/consistent-test-it': 'warn', + 'jest/expect-expect': 'warn', + 'jest/no-disabled-tests': 'off', + 'jest/no-duplicate-hooks': 'warn', + 'jest/no-expect-resolves': 'warn', + 'jest/no-if': 'error', + 'jest/prefer-hooks-on-top': 'warn', + 'jest/prefer-strict-equal': 'error', + 'jest/require-tothrow-message': 'error', + 'jest/valid-describe': 'error', + 'jest/valid-title': 'warn', - "import/no-extraneous-dependencies": "off", - "node/no-extraneous-require": "off", + 'import/no-extraneous-dependencies': 'off', + 'node/no-extraneous-require': 'off', - "sonarjs/no-identical-functions": "off" - } + 'sonarjs/no-identical-functions': 'off', + }, };