eslint.config.mjs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. 'vue/first-attribute-linebreak': ['error', {
  42. singleline: 'ignore', // 单行元素忽略此规则
  43. multiline: 'always', // 多行元素强制在第一个属性前换行
  44. }],
  45. },
  46. formatters: {
  47. /**
  48. * Format CSS, LESS, SCSS files, also the `<style>` blocks in Vue
  49. * By default uses Prettier
  50. */
  51. css: true,
  52. /**
  53. * Format HTML files
  54. * By default uses Prettier
  55. */
  56. html: true,
  57. }
  58. })