eslint.config.mjs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import uniHelper from '@uni-helper/eslint-config'
  2. export default uniHelper({
  3. unocss: true,
  4. vue: true,
  5. markdown: false,
  6. ignores: [
  7. // 忽略uni_modules目录
  8. '**/uni_modules/',
  9. // 忽略原生插件目录
  10. '**/nativeplugins/',
  11. 'dist',
  12. // unplugin-auto-import 生成的类型文件,每次提交都改变,所以加入这里吧,与 .gitignore 配合使用
  13. 'auto-import.d.ts',
  14. // vite-plugin-uni-pages 生成的类型文件,每次切换分支都一堆不同的,所以直接 .gitignore
  15. 'uni-pages.d.ts',
  16. // 插件生成的文件
  17. 'src/pages.json',
  18. 'src/manifest.json',
  19. // 忽略自动生成文件
  20. 'src/service/**'
  21. ],
  22. // https://eslint-config.antfu.me/rules
  23. rules: {
  24. 'no-useless-return': 'off',
  25. 'no-console': 'off',
  26. 'no-unused-vars': 'off',
  27. 'vue/no-unused-refs': 'off',
  28. 'unused-imports/no-unused-vars': 'off',
  29. 'eslint-comments/no-unlimited-disable': 'off',
  30. 'jsdoc/check-param-names': 'off',
  31. 'jsdoc/require-returns-description': 'off',
  32. 'ts/no-empty-object-type': 'off',
  33. 'no-extend-native': 'off',
  34. // 缩进规则:4个空格
  35. indent: ['error', 4, { SwitchCase: 1 }],
  36. 'vue/html-indent': ['error', 4],
  37. 'vue/script-indent': ['error', 4, { baseIndent: 0, switchCase: 1 }],
  38. 'vue/singleline-html-element-content-newline': ['error', { externalIgnores: ['text'] }],
  39. // vue SFC 调换顺序改这里
  40. 'vue/block-order': ['error', { order: [['script', 'template'], 'style'] }],
  41. },
  42. formatters: {
  43. /**
  44. * Format CSS, LESS, SCSS files, also the `<style>` blocks in Vue
  45. * By default uses Prettier
  46. */
  47. css: true,
  48. /**
  49. * Format HTML files
  50. * By default uses Prettier
  51. */
  52. html: true,
  53. }
  54. })