.eslintrc.js 1.5 KB

12345678910111213141516171819202122232425262728293031
  1. module.exports = {
  2. root: true,
  3. parser: "@typescript-eslint/parser",
  4. extends: [
  5. "plugin:@typescript-eslint/recommended",
  6. // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
  7. "prettier/@typescript-eslint",
  8. // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
  9. // 此行必须在最后
  10. "plugin:prettier/recommended"
  11. ],
  12. env: {
  13. es6: true,
  14. node: true
  15. },
  16. parserOptions: {
  17. // 支持最新 JavaScript
  18. ecmaVersion: 2018,
  19. sourceType: "module"
  20. },
  21. rules: {
  22. // 缩进
  23. 'indent': ['error', 4, { SwitchCase: 1 }], // 缩进控制4空格
  24. 'max-len': ['error', 120], // 每行字符不超过120
  25. 'no-mixed-spaces-and-tabs': 'error', // 禁止使用空格和tab混合缩进
  26. // 语句
  27. 'curly': ["error", "multi-line"], // if、else if、else、for、while强制使用大括号,但允许在单行中省略大括号。
  28. 'semi': ['error', 'always'], //不得省略语句结束的分号
  29. '@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }] // public访问不需加访问修饰符
  30. }
  31. };