.eslintrc.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. module.exports = {
  2. root: true,
  3. env: {
  4. browser: true,
  5. node: true,
  6. es6: true,
  7. },
  8. parser: 'vue-eslint-parser',
  9. parserOptions: {
  10. parser: '@typescript-eslint/parser',
  11. ecmaVersion: 2020,
  12. sourceType: 'module',
  13. jsxPragma: 'React',
  14. ecmaFeatures: {
  15. jsx: true,
  16. tsx: true,
  17. },
  18. },
  19. plugins: ['@typescript-eslint', 'prettier', 'import'],
  20. extends: [
  21. 'eslint:recommended',
  22. 'plugin:@typescript-eslint/recommended',
  23. 'plugin:vue/vue3-recommended',
  24. 'prettier',
  25. ],
  26. overrides: [
  27. {
  28. files: ['*.ts', '*.tsx', '*.vue'],
  29. rules: {
  30. 'no-undef': 'off',
  31. },
  32. },
  33. ],
  34. rules: {
  35. // js/ts
  36. // 'no-console': ['warn', { allow: ['error'] }],
  37. 'no-restricted-syntax': ['error', 'LabeledStatement', 'WithStatement'],
  38. camelcase: ['error', { properties: 'never' }],
  39. 'no-var': 'error',
  40. 'no-empty': ['error', { allowEmptyCatch: true }],
  41. 'no-void': 'error',
  42. 'prefer-const': ['warn', { destructuring: 'all', ignoreReadBeforeAssign: true }],
  43. 'prefer-template': 'error',
  44. 'object-shorthand': ['error', 'always', { ignoreConstructors: false, avoidQuotes: true }],
  45. 'block-scoped-var': 'error',
  46. 'no-constant-condition': ['error', { checkLoops: false }],
  47. 'no-redeclare': 'off',
  48. '@typescript-eslint/no-redeclare': 'error',
  49. '@typescript-eslint/ban-ts-comment': 'off',
  50. '@typescript-eslint/ban-types': 'off',
  51. '@typescript-eslint/explicit-module-boundary-types': 'off',
  52. '@typescript-eslint/no-empty-function': 'off',
  53. '@typescript-eslint/no-explicit-any': 'off',
  54. '@typescript-eslint/no-non-null-assertion': 'off',
  55. '@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
  56. // '@typescript-eslint/consistent-type-imports': ['error', { disallowTypeAnnotations: false }],
  57. '@typescript-eslint/no-var-requires': 'off',
  58. '@typescript-eslint/no-unused-vars': [
  59. 'error',
  60. {
  61. argsIgnorePattern: '^_',
  62. varsIgnorePattern: '^_',
  63. },
  64. ],
  65. 'no-unused-vars': [
  66. 'error',
  67. {
  68. argsIgnorePattern: '^_',
  69. varsIgnorePattern: '^_',
  70. },
  71. ],
  72. // vue
  73. 'vue/no-v-html': 'off',
  74. 'vue/require-default-prop': 'off',
  75. 'vue/require-explicit-emits': 'off',
  76. 'vue/multi-word-component-names': 'off',
  77. // prettier
  78. 'prettier/prettier': 'error',
  79. // import
  80. 'import/first': 'error',
  81. 'import/no-duplicates': 'error',
  82. 'import/order': [
  83. 'error',
  84. {
  85. groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'],
  86. pathGroups: [
  87. {
  88. pattern: 'vue',
  89. group: 'external',
  90. position: 'before',
  91. },
  92. {
  93. pattern: '@vue/**',
  94. group: 'external',
  95. position: 'before',
  96. },
  97. {
  98. pattern: 'ant-design-vue',
  99. group: 'internal',
  100. },
  101. ],
  102. pathGroupsExcludedImportTypes: ['type'],
  103. },
  104. ],
  105. },
  106. };