eslint.config.js 3.7 KB

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