eslint.config.mjs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. 'style/brace-style': 'off', // 参考 https://github.com/antfu/eslint-config/issues/322 帖子:关闭此规则,使用下面的 brace-style 规则
  35. 'vue/singleline-html-element-content-newline': [
  36. 'error',
  37. {
  38. externalIgnores: ['text'],
  39. },
  40. ],
  41. // vue SFC 调换顺序改这里
  42. // 解释 by 芋艿:为什么 script 开始放在 template 前面:https://yb.tencent.com/s/1fYYlgBopLAT
  43. 'vue/block-order': ['error', {
  44. order: [['script', 'template'], 'style'],
  45. }],
  46. // add by 芋艿:else、catch、} 等,不换行:https://zh-hans.eslint.org/docs/latest/rules/brace-style
  47. 'brace-style': ['error', '1tbs', {
  48. allowSingleLine: true,
  49. }],
  50. },
  51. formatters: {
  52. /**
  53. * Format CSS, LESS, SCSS files, also the `<style>` blocks in Vue
  54. * By default uses Prettier
  55. */
  56. css: true,
  57. /**
  58. * Format HTML files
  59. * By default uses Prettier
  60. */
  61. html: true,
  62. },
  63. })