eslint.config.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import js from '@eslint/js';
  2. import prettierConfig from 'eslint-config-prettier/flat';
  3. import importX from 'eslint-plugin-import-x';
  4. import jsxA11y from 'eslint-plugin-jsx-a11y';
  5. import react from 'eslint-plugin-react';
  6. import reactHooks from 'eslint-plugin-react-hooks';
  7. import reactRefresh from 'eslint-plugin-react-refresh';
  8. import globals from 'globals';
  9. import tseslint from 'typescript-eslint';
  10. export default [
  11. { ignores: ['dist/**/*', 'node_modules/**/*', 'public/**/*', '*.config.js', '*.config.mjs', '.*.mjs'] },
  12. js.configs.recommended,
  13. ...tseslint.configs.recommended,
  14. {
  15. files: ['**/*.{ts,tsx}'],
  16. languageOptions: {
  17. ecmaVersion: 2020,
  18. globals: {
  19. ...globals.browser,
  20. ...globals.node,
  21. Recordable: 'readonly',
  22. ImportMetaEnv: 'readonly',
  23. BuildCompression: 'readonly',
  24. },
  25. parser: tseslint.parser,
  26. parserOptions: {
  27. ecmaFeatures: {
  28. jsx: true,
  29. },
  30. sourceType: 'module',
  31. project: ['./tsconfig.json'],
  32. tsconfigRootDir: import.meta.dirname,
  33. },
  34. },
  35. plugins: {
  36. 'react-hooks': reactHooks,
  37. 'react-refresh': reactRefresh,
  38. react: react,
  39. 'import-x': importX,
  40. 'jsx-a11y': jsxA11y,
  41. '@typescript-eslint': tseslint.plugin,
  42. },
  43. rules: {
  44. ...reactHooks.configs.recommended.rules,
  45. 'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
  46. 'react/react-in-jsx-scope': 'off',
  47. 'react/prop-types': 'off',
  48. '@typescript-eslint/explicit-module-boundary-types': 'off',
  49. '@typescript-eslint/no-explicit-any': 'off',
  50. '@typescript-eslint/no-unused-vars': [
  51. 'error',
  52. {
  53. argsIgnorePattern: '^_',
  54. varsIgnorePattern: '^_',
  55. ignoreRestSiblings: true,
  56. },
  57. ],
  58. 'import-x/order': [
  59. 'error',
  60. {
  61. groups: [
  62. 'builtin',
  63. 'external',
  64. 'internal',
  65. 'parent',
  66. 'sibling',
  67. 'index',
  68. 'object',
  69. 'type',
  70. ],
  71. pathGroups: [
  72. {
  73. pattern: 'react',
  74. group: 'external',
  75. position: 'before',
  76. },
  77. {
  78. pattern: '@/**',
  79. group: 'internal',
  80. position: 'before',
  81. },
  82. ],
  83. pathGroupsExcludedImportTypes: ['react'],
  84. 'newlines-between': 'always',
  85. alphabetize: {
  86. order: 'asc',
  87. caseInsensitive: true,
  88. },
  89. distinctGroup: true,
  90. },
  91. ],
  92. 'no-unused-vars': 'off',
  93. 'no-redeclare': 'off',
  94. 'prefer-const': 'error',
  95. },
  96. settings: {
  97. react: {
  98. version: 'detect',
  99. },
  100. 'import-x/resolver': {
  101. typescript: {
  102. project: ['./tsconfig.json'],
  103. },
  104. },
  105. },
  106. },
  107. prettierConfig,
  108. ];