eslint.config.mjs (2045B)
1 import { globalIgnores } from 'eslint/config'; 2 import eslint from '@eslint/js'; 3 import { fixupConfigRules } from '@eslint/compat'; 4 import tseslint from 'typescript-eslint'; 5 import unusedImports from 'eslint-plugin-unused-imports'; 6 import eslintConfigPrettier from 'eslint-config-prettier/flat'; 7 import importPlugin from 'eslint-plugin-import'; 8 import globals from 'globals'; 9 import path from 'node:path'; 10 import { fileURLToPath } from 'node:url'; 11 import js from '@eslint/js'; 12 import { FlatCompat } from '@eslint/eslintrc'; 13 14 const __filename = fileURLToPath(import.meta.url); 15 const __dirname = path.dirname(__filename); 16 const compat = new FlatCompat({ 17 baseDirectory: __dirname, 18 recommendedConfig: js.configs.recommended, 19 allConfig: js.configs.all, 20 }); 21 22 export default tseslint.config( 23 globalIgnores([ 24 '**/node_modules/', 25 '**/.next/', 26 '**/.yarn/', 27 '**/*config.js', 28 ]), 29 eslint.configs.recommended, 30 tseslint.configs.recommended, 31 { 32 extends: fixupConfigRules( 33 compat.extends('next/core-web-vitals'), 34 importPlugin.flatConfigs.recommended, 35 importPlugin.flatConfigs.typescript, 36 eslintConfigPrettier, 37 ), 38 }, 39 { 40 languageOptions: { 41 globals: { 42 ...globals.node, 43 }, 44 45 ecmaVersion: 5, 46 sourceType: 'commonjs', 47 48 parser: tseslint.parser, 49 parserOptions: { 50 ecmaFeatures: { 51 jsx: true, 52 }, 53 project: './tsconfig.eslint.json', 54 tsconfigRootDir: import.meta.dirname, 55 }, 56 }, 57 58 rules: { 59 'import/order': [ 60 'error', 61 { 62 groups: [ 63 'builtin', 64 'external', 65 'internal', 66 'parent', 67 'sibling', 68 'index', 69 'object', 70 'type', 71 ], 72 73 alphabetize: { 74 order: 'asc', 75 }, 76 77 'newlines-between': 'always', 78 }, 79 ], 80 81 '@typescript-eslint/consistent-type-imports': 'error', 82 83 'react/jsx-key': [ 84 'error', 85 { 86 checkFragmentShorthand: true, 87 warnOnDuplicates: true, 88 }, 89 ], 90 }, 91 }, 92 { 93 plugins: { 94 'unused-imports': unusedImports, 95 }, 96 rules: { 97 'unused-imports/no-unused-imports': 'error', 98 }, 99 }, 100 );