|
@@ -0,0 +1,36 @@
|
|
|
+module.exports = {
|
|
|
+ root: true,
|
|
|
+ parser: "@typescript-eslint/parser",
|
|
|
+ extends: [
|
|
|
+ "plugin:@typescript-eslint/recommended",
|
|
|
+ // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
|
|
|
+ "prettier/@typescript-eslint",
|
|
|
+ // 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.
|
|
|
+ // 此行必须在最后
|
|
|
+ "plugin:prettier/recommended"
|
|
|
+ ],
|
|
|
+ env: {
|
|
|
+ es6: true,
|
|
|
+ node: true
|
|
|
+ },
|
|
|
+ parserOptions: {
|
|
|
+ // 支持最新 JavaScript
|
|
|
+ ecmaVersion: 2018,
|
|
|
+ sourceType: "module"
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ // 注释
|
|
|
+ // 文件
|
|
|
+ "max-classes-per-file": ["error", 1], // 一个文件中只能定义一个类
|
|
|
+ "max-lines-per-function": ["error", 200], // 一个函数最多200行代码
|
|
|
+ "max-statements-per-line": ["error", {max: 1}], // 一行只允许有一条语句
|
|
|
+ // 缩进
|
|
|
+ "indent": ["error", 4], // 缩进控制4空格
|
|
|
+ "max-len": ["error", 120], // 每行字符不超过120
|
|
|
+ "no-mixed-spaces-and-tabs": "error", // 禁止使用空格和tab混合缩进
|
|
|
+ // 语句
|
|
|
+ "curly": ["error", "multi-line"], // if、else if、else、for、while强制使用大括号,但允许在单行中省略大括号。
|
|
|
+ "semi": ["error", "always"], // 不得省略语句结束的分号
|
|
|
+ "@typescript-eslint/explicit-member-accessibility": ["error", { accessibility: "no-public" }], // public访问不需加访问修饰符
|
|
|
+ }
|
|
|
+};
|