diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 440f3276..00000000 --- a/.eslintrc.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "env": { - "node": true, - "es2021": true, - "jest/globals": true - }, - "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": 2021, - "sourceType": "module" - }, - "plugins": ["@typescript-eslint", "jest", "simple-import-sort"], - "overrides": [ - // override "simple-import-sort" config - { - "files": ["*.js", "*.jsx", "*.ts", "*.tsx"], - "rules": { - "simple-import-sort/imports": [ - "error", - { - "groups": [ - // Packages `react` related packages come first. - ["^react", "^@?\\w"], - // Internal packages. - ["^(@|components)(/.*|$)"], - // Side effect imports. - ["^\\u0000"], - // Parent imports. Put `..` last. - ["^\\.\\.(?!/?$)", "^\\.\\./?$"], - // Other relative imports. Put same-folder imports and `.` last. - ["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"], - // Style imports. - ["^.+\\.?(css)$"] - ] - } - ] - } - } - ] -} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000..7ba20864 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,71 @@ +import typescriptEslint from '@typescript-eslint/eslint-plugin' +import jest from 'eslint-plugin-jest' +import simpleImportSort from 'eslint-plugin-simple-import-sort' +import globals from 'globals' +import tsParser from '@typescript-eslint/parser' +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import js from '@eslint/js' +import { FlatCompat } from '@eslint/eslintrc' +import { includeIgnoreFile } from '@eslint/compat' + +const __filename = fileURLToPath(import.meta.url) +const __dirname = path.dirname(__filename) +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all +}) +const gitignorePath = path.resolve(__dirname, '.gitignore') + +export default [ + ...compat.extends('eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'), + includeIgnoreFile(gitignorePath), + { + ignores: ['dist/'] + }, + { + plugins: { + '@typescript-eslint': typescriptEslint, + jest, + 'simple-import-sort': simpleImportSort + }, + + languageOptions: { + globals: { + ...globals.node, + ...jest.environments.globals.globals + }, + + parser: tsParser, + ecmaVersion: 2021, + sourceType: 'module' + } + }, + { + files: ['**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx'], + + rules: { + 'simple-import-sort/imports': [ + 'error', + { + groups: [ + // Packages `react` related packages come first. + ['^react', '^@?\\w'], + // Internal packages. + ['^(@|components)(/.*|$)'], + // Side effect imports. + ['^\\u0000'], + // Parent imports. Put `..` last. + ['^\\.\\.(?!/?$)', '^\\.\\./?$'], + // Other relative imports. Put same-folder imports and `.` last. + ['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'], + // Style imports. + ['^.+\\.?(css)$'] + ] + } + ], + 'simple-import-sort/exports': 'error' + } + } +] diff --git a/package.json b/package.json index 3fe5d81e..8e6b2c3a 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,9 @@ "zod": "^3.20.6" }, "devDependencies": { + "@eslint/compat": "^1.1.1", + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "^9.8.0", "@jest/types": "29.6.3", "@redocly/cli": "1.19.0", "@types/html-to-text": "9.0.4", @@ -64,6 +67,7 @@ "eslint-config-prettier": "9.1.0", "eslint-plugin-jest": "28.6.0", "eslint-plugin-simple-import-sort": "12.1.1", + "globals": "^15.9.0", "jest": "29.7.0", "nodemon": "3.1.4", "prettier": "3.2.5",