From 8f9788c722c3cac7971de92d72d843af2ad821d9 Mon Sep 17 00:00:00 2001 From: "D. Ror" Date: Mon, 6 Nov 2023 11:58:15 -0500 Subject: [PATCH] Split off eslintConfig from package.json into .eslintrc.cjs (#2740) --- .dockerignore | 5 +-- .eslintrc.cjs | 69 +++++++++++++++++++++++++++++++++++ package.json | 83 ------------------------------------------- scripts/setupMongo.ts | 2 +- tsconfig.json | 24 ++++++------- 5 files changed, 85 insertions(+), 98 deletions(-) create mode 100644 .eslintrc.cjs diff --git a/.dockerignore b/.dockerignore index 74a21c55e0..709fd21975 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,15 +2,16 @@ ** # Except the following. +!docs/user_guide !nginx !public !src -!docs/user_guide !.env +!.eslintrc.cjs !dev-requirements.txt !package*.json -!tsconfig.json !tox.ini +!tsconfig.json # Ignore user guide build directory. docs/user_guide/site diff --git a/.eslintrc.cjs b/.eslintrc.cjs new file mode 100644 index 0000000000..fe11647d20 --- /dev/null +++ b/.eslintrc.cjs @@ -0,0 +1,69 @@ +module.exports = { + env: { + browser: true, + jest: true, + }, + extends: [ + "plugin:react/recommended", + "plugin:react/jsx-runtime", + "plugin:react-hooks/recommended", + "plugin:import/recommended", + ], + ignorePatterns: ["*.dic.js"], + parser: "@typescript-eslint/parser", + parserOptions: { + ecmaFeatures: { jsx: true }, + project: "./tsconfig.json", + }, + plugins: ["@typescript-eslint", "react", "unused-imports"], + root: true, + rules: { + "import/first": "warn", + "import/newline-after-import": "warn", + "import/no-duplicates": "warn", + "import/no-named-as-default": "off", + "import/no-named-as-default-member": "off", + "import/order": [ + "warn", + { + alphabetize: { order: "asc" }, + groups: [ + "builtin", + "external", + ["internal", "parent", "sibling", "index", "object", "type"], + ], + "newlines-between": "always", + }, + ], + "no-undef": "off", + "prefer-const": "warn", + "react/jsx-boolean-value": "warn", + "unused-imports/no-unused-imports": "warn", + }, + settings: { + react: { version: "detect" }, + "import/resolver": { + typescript: { alwaysTryTypes: true }, + }, + }, + overrides: [ + { + files: ["*.ts", "*.tsx"], + extends: [ + "plugin:@typescript-eslint/recommended", + "plugin:import/typescript", + ], + rules: { + "@typescript-eslint/explicit-function-return-type": [ + "warn", + { allowExpressions: true }, + ], + "@typescript-eslint/no-empty-interface": "warn", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-inferrable-types": "warn", + "@typescript-eslint/no-unused-vars": "warn", + "@typescript-eslint/switch-exhaustiveness-check": "warn", + }, + }, + ], +}; diff --git a/package.json b/package.json index 67e5a699bc..ff4b70113d 100644 --- a/package.json +++ b/package.json @@ -125,89 +125,6 @@ "source-map-explorer": "^2.5.3", "typescript": "4.9.5" }, - "eslintConfig": { - "extends": [ - "plugin:@typescript-eslint/recommended", - "plugin:react/recommended", - "plugin:react/jsx-runtime", - "plugin:react-hooks/recommended", - "plugin:import/recommended", - "plugin:import/typescript" - ], - "env": { - "browser": true, - "jest": true - }, - "ignorePatterns": [ - "*.dic.js" - ], - "rules": { - "@typescript-eslint/explicit-function-return-type": [ - "warn", - { - "allowExpressions": true - } - ], - "@typescript-eslint/no-empty-interface": "warn", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-inferrable-types": "warn", - "@typescript-eslint/no-unused-vars": "warn", - "@typescript-eslint/switch-exhaustiveness-check": "warn", - "import/first": "warn", - "import/newline-after-import": "warn", - "import/no-duplicates": "warn", - "import/no-named-as-default": "off", - "import/no-named-as-default-member": "off", - "import/order": [ - "warn", - { - "groups": [ - "builtin", - "external", - [ - "internal", - "parent", - "sibling", - "index", - "object", - "type" - ] - ], - "alphabetize": { - "order": "asc" - }, - "newlines-between": "always" - } - ], - "no-undef": "off", - "prefer-const": "warn", - "react/jsx-boolean-value": "warn", - "unused-imports/no-unused-imports": "warn" - }, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaFeatures": { - "jsx": true - }, - "project": "./tsconfig.json" - }, - "plugins": [ - "@typescript-eslint", - "react", - "unused-imports" - ], - "root": true, - "settings": { - "react": { - "version": "detect" - }, - "import/resolver": { - "typescript": { - "alwaysTryTypes": true - } - } - } - }, "jest": { "coverageReporters": [ "cobertura", diff --git a/scripts/setupMongo.ts b/scripts/setupMongo.ts index 862f00bf9d..7f8f85a906 100644 --- a/scripts/setupMongo.ts +++ b/scripts/setupMongo.ts @@ -2,7 +2,7 @@ import * as makeDir from "make-dir"; const directory = "./mongo_database"; -const makeMongoDirectory = async () => { +const makeMongoDirectory = async (): Promise => { await makeDir(directory); }; diff --git a/tsconfig.json b/tsconfig.json index f6222becae..9f9b6736f9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,23 +1,23 @@ { "compilerOptions": { - "target": "es5", - "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, - "skipLibCheck": true, - "esModuleInterop": true, "allowSyntheticDefaultImports": true, - "strict": true, + "baseUrl": "src", + "downlevelIteration": true, + "esModuleInterop": true, "forceConsistentCasingInFileNames": true, + "isolatedModules": true, + "jsx": "react-jsx", + "lib": ["dom", "dom.iterable", "esnext"], "module": "esnext", "moduleResolution": "node", - "resolveJsonModule": true, - "isolatedModules": true, "noEmit": true, - "jsx": "react-jsx", - "downlevelIteration": true, - "baseUrl": "src", - "noFallthroughCasesInSwitch": true + "noFallthroughCasesInSwitch": true, + "resolveJsonModule": true, + "skipLibCheck": true, + "strict": true, + "target": "es5" }, "exclude": ["*.dic.js"], - "include": ["src", "scripts"] + "include": [".eslintrc.cjs", "src", "scripts"] }