From 340eabb9609c8a46ff535ffe2e53eb28730d94c0 Mon Sep 17 00:00:00 2001 From: Danny Rorabaugh Date: Tue, 24 Oct 2023 16:25:49 -0400 Subject: [PATCH] Split off eslintConfig from package.json into .eslintrc.cjs --- .eslintrc.cjs | 69 +++++++++++++++++++++++++++++++++++ package.json | 83 ------------------------------------------- scripts/setupMongo.ts | 2 +- tsconfig.json | 24 ++++++------- 4 files changed, 82 insertions(+), 96 deletions(-) create mode 100644 .eslintrc.cjs 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 f4ad45bf59..0405cda72f 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": { "transformIgnorePatterns": [ "/node_modules/(!${axios})" 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"] }