.eslintrc.base.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /**
  2. * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
  3. * SPDX-License-Identifier: MIT
  4. */
  5. // This is a workaround for https://github.com/eslint/eslint/issues/3458
  6. require('@rushstack/eslint-config/patch/modern-module-resolution');
  7. module.exports = {
  8. parser: '@babel/eslint-parser',
  9. extends: ['plugin:prettier/recommended'],
  10. parserOptions: {
  11. requireConfigFile: false,
  12. babelOptions: {
  13. babelrc: false,
  14. configFile: false,
  15. cwd: __dirname,
  16. presets: ['@babel/preset-env', '@babel/preset-react'],
  17. },
  18. },
  19. plugins: ['babel'],
  20. ignorePatterns: [
  21. '**/*.d.ts',
  22. '**/__mocks__',
  23. '**/node_modules',
  24. '**/build',
  25. '**/dist',
  26. '**/es',
  27. '**/lib',
  28. '**/.codebase',
  29. '**/.changeset',
  30. '**/config',
  31. '**/common/scripts',
  32. '**/output',
  33. 'error-log-str.js',
  34. '*.bundle.js',
  35. '*.min.js',
  36. '*.js.map',
  37. '**/output',
  38. '**/*.log',
  39. '**/tsconfig.tsbuildinfo',
  40. '**/vitest.config.ts',
  41. 'package.json',
  42. '*.json',
  43. ],
  44. rules: {
  45. // eslint-disable-next-line global-require
  46. 'prettier/prettier': [
  47. 'warn',
  48. {
  49. semi: true,
  50. singleQuote: true,
  51. printWidth: 100,
  52. usePrettierrc: false,
  53. },
  54. ],
  55. },
  56. overrides: [
  57. {
  58. files: ['*.ts', '*.tsx'],
  59. parser: '@typescript-eslint/parser',
  60. settings: {
  61. 'import/resolver': {
  62. node: {
  63. moduleDirectory: ['node_modules', 'src'],
  64. extensions: ['.js', '.jsx', '.ts', '.tsx'],
  65. },
  66. },
  67. },
  68. extends: [
  69. 'plugin:prettier/recommended',
  70. 'plugin:react/recommended',
  71. 'plugin:react/jsx-runtime',
  72. ],
  73. plugins: ['@typescript-eslint', 'import'],
  74. parserOptions: {
  75. ecmaFeatures: {
  76. jsx: true,
  77. },
  78. ecmaVersion: 'latest',
  79. sourceType: 'module',
  80. },
  81. rules: {
  82. 'import/prefer-default-export': 'off',
  83. 'lines-between-class-members': 'warn',
  84. 'import/no-unresolved': 'warn',
  85. 'react/jsx-no-useless-fragment': 'off',
  86. 'no-unused-vars': 'off',
  87. 'no-redeclare': 'off',
  88. 'prefer-destructurin': 'off',
  89. 'no-underscore-dangle': 'off',
  90. 'no-empty-function': 'off',
  91. 'no-multi-assign': 'off',
  92. 'arrow-body-style': 'warn',
  93. 'no-useless-constructor': 'off',
  94. 'no-param-reassign': 'off',
  95. 'max-classes-per-file': 'off',
  96. 'grouped-accessor-pairs': 'off',
  97. 'no-plusplus': 'off',
  98. 'no-restricted-syntax': 'off',
  99. 'react/destructuring-assignment': 'off',
  100. 'import/extensions': 'off',
  101. 'consistent-return': 'off',
  102. 'jsx-a11y/no-static-element-interactions': 'off',
  103. 'react/jsx-filename-extension': [1, { extensions: ['.jsx', '.tsx'] }],
  104. 'no-use-before-define': 'off',
  105. 'no-bitwise': 'off',
  106. 'no-case-declarations': 'off',
  107. 'react/no-array-index-key': 'off',
  108. 'react/require-default-props': 'off',
  109. 'no-dupe-class-members': 'off',
  110. 'react/self-closing-comp': [
  111. 'error',
  112. {
  113. component: true,
  114. html: false,
  115. },
  116. ],
  117. 'react/jsx-props-no-spreading': 'off',
  118. 'no-console': ['error', { allow: ['warn', 'error'] }],
  119. 'no-shadow': 'off',
  120. 'class-methods-use-this': 'off',
  121. 'default-param-last': 'off',
  122. 'prettier/prettier': [
  123. 'warn',
  124. {
  125. semi: true,
  126. singleQuote: true,
  127. printWidth: 100,
  128. usePrettierrc: false,
  129. },
  130. ],
  131. 'import/no-cycle': 'error',
  132. 'import/no-extraneous-dependencies': [
  133. 'error',
  134. {
  135. devDependencies: true,
  136. },
  137. ],
  138. 'import/no-relative-packages': 'error',
  139. 'import/order': [
  140. 'warn',
  141. {
  142. groups: ['builtin', 'external', ['internal', 'parent', 'sibling', 'index'], 'unknown'],
  143. pathGroups: [
  144. {
  145. pattern: 'react*',
  146. group: 'builtin',
  147. position: 'before',
  148. },
  149. {
  150. pattern: '@/**',
  151. group: 'internal',
  152. position: 'before',
  153. },
  154. {
  155. pattern: './*.+(css|sass|less|scss|pcss|styl)',
  156. patternOptions: { dot: true, nocomment: true },
  157. group: 'unknown',
  158. position: 'after',
  159. },
  160. ],
  161. alphabetize: {
  162. order: 'desc' /* sort in ascending order. Options: ['ignore', 'asc', 'desc'] */,
  163. caseInsensitive: true /* ignore case. Options: [true, false] */,
  164. },
  165. pathGroupsExcludedImportTypes: ['builtin'],
  166. 'newlines-between': 'always',
  167. },
  168. ],
  169. },
  170. },
  171. ],
  172. };