From 4803b38d344285e0b82af7bf7c06fdc1bf715b4e Mon Sep 17 00:00:00 2001 From: Nathan Vasse Date: Thu, 1 Dec 2022 12:02:09 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7(lint)=20setup=20ESLint=20package?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a shared package for ESLint configuration to avoid duplication accross repos. --- packages/eslint-config-custom/.eslintrc.json | 89 ++++++++++++++++++++ packages/eslint-config-custom/package.json | 26 ++++++ 2 files changed, 115 insertions(+) create mode 100644 packages/eslint-config-custom/.eslintrc.json create mode 100644 packages/eslint-config-custom/package.json diff --git a/packages/eslint-config-custom/.eslintrc.json b/packages/eslint-config-custom/.eslintrc.json new file mode 100644 index 0000000..89f0ca3 --- /dev/null +++ b/packages/eslint-config-custom/.eslintrc.json @@ -0,0 +1,89 @@ +{ + "env": { + "browser": true, + "jest": true, + "es6": true + }, + "extends": [ + "airbnb", + "airbnb-typescript", + "plugin:compat/recommended", + "plugin:prettier/recommended" + ], + "parser": "@typescript-eslint/parser", + "parserOptions": { + /* + To use eslint with VSCode and see lint error directly in file, + you have to install dbaeumer.vscode-eslint extension + and you may have to tweak your workspace settings with: + "eslint.workingDirectories": ["src/frontend"] + + As frontend is not at the root of the repository, + this setting allows ESLint extension to find the ./tsconfig.json file + */ + "project": "./tsconfig.json", + "ecmaFeatures": { + "jsx": true + } + }, + "plugins": ["formatjs", "@typescript-eslint"], + /* Disable some rules to be iso with tslint which was previously used */ + "rules": { + "@typescript-eslint/explicit-member-accessibility": ["error", { "accessibility": "no-public" }], + "@typescript-eslint/lines-between-class-members": "off", + "@typescript-eslint/no-use-before-define": "off", + "arrow-parens": "error", + "consistent-return": "off", + "default-case": "off", + "formatjs/no-multiple-whitespaces": "error", + "formatjs/enforce-description": "error", + "formatjs/enforce-default-message": "error", + "global-require": "off", + "import/extensions": "off", + "import/no-cycle": ["off"], + "import/no-dynamic-require": "off", + "import/order": [ + "error", + { + "groups": ["builtin", "external", "internal", "parent", "sibling", "index"], + "alphabetize": { "order": "ignore" } + } + ], + "import/prefer-default-export": "off", + "jsx-a11y/click-events-have-key-events": "off", + "jsx-a11y/label-has-associated-control": "warn", + "no-console": ["error", { "allow": ["warn"] }], + "no-else-return": "off", + "no-empty-function": "off", + "no-nested-ternary": "warn", + "no-param-reassign": "off", + "no-plusplus": "off", + "no-promise-executor-return": "off", + "no-prototype-builtins": "off", + "no-return-assign": "off", + "no-return-await": "off", + "no-undef": "off", + "no-underscore-dangle": "off", + "no-useless-escape": "off", + "prefer-template": "off", + "react/button-has-type": "off", + "react/destructuring-assignment": "off", + "react/function-component-definition": [ + "error", + { "namedComponents": "arrow-function", "unnamedComponents": "arrow-function" } + ], + "react/jsx-boolean-value": "off", + "react/jsx-fragments": "off", + "react/jsx-props-no-spreading": "off", + "react/jsx-uses-react": "off", + "react/no-array-index-key": "warn", + "react/prop-types": "off", + "react/react-in-jsx-scope": "off", + "react/require-default-props": "off", + "react/style-prop-object": ["error", { "allow": ["FormattedNumber"] }] + }, + "settings": { + "polyfills": ["fetch", "Promise"], + "import/resolver": "webpack" + } +} diff --git a/packages/eslint-config-custom/package.json b/packages/eslint-config-custom/package.json new file mode 100644 index 0000000..c7911cd --- /dev/null +++ b/packages/eslint-config-custom/package.json @@ -0,0 +1,26 @@ +{ + "name": "eslint-config-custom", + "version": "0.0.0", + "license": "MIT", + "main": ".eslintrc.json", + "dependencies": { + "@typescript-eslint/eslint-plugin": "5.42.0", + "@typescript-eslint/parser": "5.42.0", + "eslint": "8.27.0", + "eslint-config-next": "13.0.0", + "eslint-config-airbnb": "19.0.4", + "eslint-config-airbnb-typescript": "17.0.0", + "eslint-config-prettier": "8.5.0", + "eslint-import-resolver-webpack": "0.13.2", + "eslint-plugin-compat": "4.0.2", + "eslint-plugin-formatjs": "4.3.4", + "eslint-plugin-import": "2.26.0", + "eslint-plugin-jsx-a11y": "6.6.1", + "eslint-plugin-prettier": "4.2.1", + "eslint-plugin-react": "7.31.10", + "eslint-plugin-react-hooks": "4.6.0" + }, + "publishConfig": { + "access": "public" + } +}