diff --git a/eslint.config.js b/eslint.config.js index a513873f..6726c09a 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,93 +1,114 @@ import react from 'eslint-plugin-react' import reactRefresh from 'react-refresh' import eslint from '@eslint/js'; +import jestPlugin from 'eslint-plugin-jest'; import tseslint from 'typescript-eslint' import globals from 'globals' -export default [ - ...tseslint.config( - eslint.configs.recommended, - ...tseslint.configs.recommended, - ); - { - languageOptions: { - parserOptions: { - tsconfigRootDir: "./", - } - }, - rules: { - "typescript-eslint/consistent-type-imports": [ - 2, - { - fixStyle: "separate-type-imports" - } +export default tseslint.config( + { + root: true, + ignores: [ + "**/node_modules/**", + "**/dist/**", + "**/build/**", + "**/scripts/**" + ], + } + // BASIC ESLINT AND TYPESCRIPT + eslint.configs.recommended, + ...tseslint.configs.recommended, + { + plugins: { + '@typescript-eslint': tseslint.plugin + }, + extends: [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "prettier" ], - "typescript-eslint/no-restricted-imports": [ - 2, + languageOptions: { + parser: tseslint.parser, + parserOptions: { + projectService: true, + tsconfigRootDir: "./", + } + }, + rules: { + "typescript-eslint/consistent-type-imports": [ + 2, + { + fixStyle: "separate-type-imports" + } + ], + "typescript-eslint/no-restricted-imports": [ + 2, + { + paths: [ + { + name: "react-redux", + importNames: [ + "useSelector", + "useStore", + "useDispatch" + ], + message: "Please use pre-typed versions from `src/app/hooks.ts` instead." + } + ] + } + ] + }, + }, + // TESTING + { + ..jestPlugin.configs['flat/recommended'], + plugins: { + jest: jestPlugin + }, + overrides: [ { - paths: [ - { - name: "react-redux", - importNames: [ - "useSelector", - "useStore", - "useDispatch" - ], - message: "Please use pre-typed versions from `src/app/hooks.ts` instead." - } - ] + files: ["*{test,spec}.{t,j}s?(x)"], + env: { + jest: true + } } ] + } + // JAVASCRIPT + { + files: ['**/*.js'], + ...tseslint.configs.disableTypeChecked, }, - }, - { - files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'], - ...reactPlugin.configs.flat.recommended, - }, - { - files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'], - globals: { - ...globals.browser, - ...globals.node, - ...globals.serviceworker - }, - extends: [ - "eslint:recommended", - "plugin:react/jsx-runtime", - "plugin:@typescript-eslint/recommended", - "plugin:react-hooks/recommended", - "prettier" - ], - root: true, - ignorePatterns: [ - "node_modules", - "dist", - "build", - "scripts" - ], - languageOptions: { - parserOptions: { - project: true, - ecmaVersion: "latest", - sourceType: "module", - ecmaFeatures: { - jsx: true + // REACT + { + files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'], + ...reactPlugin.configs.flat.recommended, + globals: { + ...globals.browser, + ...globals.node, + ...globals.serviceworker + }, + extends: [ + "plugin:react/jsx-runtime", + "plugin:react-hooks/recommended", + ], + languageOptions: { + parserOptions: { + ecmaVersion: "latest", + sourceType: "module", + ecmaFeatures: { + jsx: true + } } - } - }, - plugins: { - reactRefresh - }, - overrides: [ - { - files: ["*.{c,m,}{t,j}s", "*.{t,j}sx"] }, - { - files: ["*{test,spec}.{t,j}s?(x)"], - env: { - jest: true + plugins: { + reactRefresh + }, + overrides: [ + { + files: ["*.{c,m,}{t,j}s", "*.{t,j}sx"] } - } - ] - } + ] + } + ) ]