base.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. module.exports = {
  2. extends: ['eslint:recommended'],
  3. env: {
  4. browser: true,
  5. node: true,
  6. es6: true,
  7. },
  8. parserOptions: {
  9. ecmaVersion: 2022,
  10. sourceType: 'module',
  11. },
  12. rules: {
  13. // 错误级别规则
  14. 'no-console': ['warn', { allow: ['warn', 'error', 'info'] }],
  15. 'no-debugger': 'warn',
  16. 'no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
  17. // 代码风格规则
  18. 'arrow-body-style': ['error', 'as-needed'],
  19. 'prefer-const': 'error',
  20. 'no-var': 'error',
  21. 'eqeqeq': ['error', 'always', { null: 'ignore' }],
  22. 'no-multiple-empty-lines': ['error', { max: 1, maxEOF: 1 }],
  23. 'no-trailing-spaces': 'error',
  24. // 其他规则
  25. 'no-restricted-syntax': [
  26. 'error',
  27. {
  28. selector: 'ForInStatement',
  29. message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
  30. },
  31. ],
  32. },
  33. overrides: [
  34. {
  35. files: ['*.ts', '*.tsx'],
  36. parser: '@typescript-eslint/parser',
  37. extends: [
  38. 'plugin:@typescript-eslint/recommended',
  39. ],
  40. rules: {
  41. '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
  42. 'no-unused-vars': 'off',
  43. },
  44. },
  45. ],
  46. };