eslint.config.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import globals from 'globals';
  2. import pluginJs from '@eslint/js';
  3. import tseslint from 'typescript-eslint';
  4. import pluginVue from 'eslint-plugin-vue';
  5. import { readFile } from 'node:fs/promises';
  6. import prettier from 'eslint-plugin-prettier';
  7. /**
  8. * https://blog.csdn.net/sayUonly/article/details/123482912
  9. * 自动导入的配置
  10. */
  11. const autoImportFile = new URL('./.eslintrc-auto-import.json', import.meta.url);
  12. const autoImportGlobals = JSON.parse(await readFile(autoImportFile, 'utf8'));
  13. /** @type {import('eslint').Linter.Config[]} */
  14. export default [
  15. {
  16. /**
  17. * 不需要.eslintignore文件 而是在这里配置
  18. */
  19. ignores: [
  20. '*.sh',
  21. 'node_modules',
  22. '*.md',
  23. '*.woff',
  24. '*.ttf',
  25. '.vscode',
  26. '.idea',
  27. 'dist',
  28. '/public',
  29. '/docs',
  30. '.husky',
  31. '.local',
  32. '/bin',
  33. '.eslintrc.cjs',
  34. 'prettier.config.js',
  35. 'src/assets',
  36. 'tailwind.config.js'
  37. ]
  38. },
  39. { files: ['**/*.{js,mjs,cjs,ts,vue}'] },
  40. {
  41. languageOptions: {
  42. globals: globals.browser
  43. }
  44. },
  45. pluginJs.configs.recommended,
  46. ...tseslint.configs.recommended,
  47. ...pluginVue.configs['flat/essential'],
  48. {
  49. files: ['**/*.vue'],
  50. languageOptions: {
  51. parserOptions: {
  52. parser: tseslint.parser
  53. }
  54. }
  55. },
  56. {
  57. languageOptions: {
  58. globals: {
  59. // 自动导入的配置 undef
  60. ...autoImportGlobals.globals,
  61. DialogOption: 'readonly',
  62. LayoutSetting: 'readonly'
  63. }
  64. },
  65. plugins: { prettier },
  66. rules: {
  67. '@typescript-eslint/no-empty-function': 'off',
  68. '@typescript-eslint/no-explicit-any': 'off',
  69. '@typescript-eslint/no-unused-vars': 'off',
  70. '@typescript-eslint/no-this-alias': 'off',
  71. // vue
  72. 'vue/multi-word-component-names': 'off',
  73. 'vue/valid-define-props': 'off',
  74. 'vue/no-v-model-argument': 'off',
  75. 'prefer-rest-params': 'off',
  76. // prettier
  77. 'prettier/prettier': 'error',
  78. // 允许使用空Object类型 {}
  79. '@typescript-eslint/no-empty-object-type': 'off',
  80. '@typescript-eslint/no-unused-expressions': 'off'
  81. }
  82. }
  83. ];