.eslintrc.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536
  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. // 文件
  24. "max-classes-per-file": ["error", 1], // 一个文件中只能定义一个类
  25. "max-lines-per-function": ["error", 200], // 一个函数最多200行代码
  26. "max-statements-per-line": ["error", {max: 1}], // 一行只允许有一条语句
  27. // 缩进
  28. "indent": ["error", 4], // 缩进控制4空格
  29. "max-len": ["error", 120], // 每行字符不超过120
  30. "no-mixed-spaces-and-tabs": "error", // 禁止使用空格和tab混合缩进
  31. // 语句
  32. "curly": ["error", "multi-line"], // if、else if、else、for、while强制使用大括号,但允许在单行中省略大括号。
  33. "semi": ["error", "always"], // 不得省略语句结束的分号
  34. "@typescript-eslint/explicit-member-accessibility": ["error", { accessibility: "no-public" }], // public访问不需加访问修饰符
  35. }
  36. };