包含ts的编译及js的编译
module.exports = {// 限制在一个特定的父级别目录内root: true,// 将 TypeScript 转换成与 estree 兼容的形式,以便在ESLint中使用parser: '@typescript-eslint/parser',// 要在配置文件里指定环境,使用 env 关键字指定你想启用的环境,并设置它们为 trueenv: {browser: true,es6: true,node: true,},plugins: ["@typescript-eslint"],// 一个配置文件可以被基础配置中的已启用的规则继承。extends: ['eslint:recommended', "plugin:@typescript-eslint/recommended"],// 注意,在使用自定义解析器时,为了让 ESLint 在处理非 ECMAScript 5 特性时正常工作,配置属性 parserOptions 仍然是必须的。解析器会被传入 parserOptionsparserOptions: {// 指定ECMAScript 版本, 默认是是3,5;ecmaVersion: 2018,// 设置为 "script" (默认) 或 "module"(如果你的代码是 ECMAScript 模块)。sourceType: 'module',},/*** rules* "off" 或 0 - 关闭规则* "warn" 或 1 - 开启规则,使用警告级别的错误:warn (不会导致程序退出)* "error" 或 2 - 开启规则,使用错误级别的错误:error (当被触发的时候,程序会退出)*/rules: {// 强制使用一致的反勾号、双引号或单引号quotes: [2, 'single'],// 强制在 parseInt() 使用基数参数radix: [2, 'always'],// 强制使用骆驼拼写法命名约定camelcase: [2, { properties: 'always' }],// 强制使用一致的缩进indent: ['error', 2],// 'prettier/prettier': 2,// 要求使用 let 或 const 而不是 var'no-var': 2,// 禁用未声明的变量,除非它们在 /*global */ 注释中被提到'no-undef': 2,// 禁用 alert、confirm 和 prompt'no-alert': 2,// 禁用 console'no-console': [2, { allow: ['warn', 'error'] }],// 禁用 debugger'no-debugger': 2,// 禁用 Object 的构造函数'no-new-object': 2,// 禁止出现未使用过的变量'no-unused-vars': 1,// 禁止对 String,Number 和 Boolean 使用 new 操作符'no-new-wrappers': 2,// 禁止在变量定义之前使用它们'no-use-before-define': ['error', { functions: false, classes: false }],// 禁用 Array 构造函数'no-array-constructor': 2,// 禁用不必要的构造函数'no-useless-constructor': 1,// 禁止对 function 的参数进行重新赋值'no-param-reassign': [1, { props: true }],// 禁止 if 语句中 return 语句之后有 else 块'no-else-return': [2, { allowElseIf: false }],// 禁用一元操作符 ++ 和 --'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],// 禁用特定的语法'no-restricted-syntax': [2, 'BinaryExpression[operator="in"]'],// 禁用嵌套的三元表达式'no-nested-ternary': 2,// 禁止可以在有更简单的可替代的表达式时使用三元操作符'no-unneeded-ternary': [2, { defaultAssignment: false }],// 禁止混合使用不同的操作符'no-mixed-operators': [1,{groups: [['+', '-', '*', '/', '%', '**'],['==', '!=', '===', '!==', '>', '>=', '<', '<='],],// 同级别的可以省略括号allowSamePrecedence: true,},],// 要求使用模板字面量而非字符串连接'prefer-template': 2,// 要求回调函数使用箭头函数'prefer-arrow-callback': 1,// 优先使用数组和对象解构'prefer-destructuring': [1, { object: true, array: false }],// 要求或禁止对象字面量中方法和属性使用简写语法'object-shorthand': [2, 'always', { avoidQuotes: true }],// 强制函数中的变量要么一起声明要么分开声明'one-var': [2, 'never'],// 要求或禁止模板字符串中的嵌入表达式周围空格的使用'template-curly-spacing': 2,// 强制在 function的左括号之前使用一致的空格'space-before-function-paren': ['error', { anonymous: 'never', named: 'never', asyncArrow: 'always' }],// 强制尽可能地使用点号'dot-notation': [1, { allowKeywords: true }],// 制单个语句的位置'nonblock-statement-body-position': [2, 'below'],// 强制一致的缩进 关闭 ts/indent,base里面已经配置了 indent'@typescript-eslint/indent': 0,// 除导入语句外,禁止使用require语句'@typescript-eslint/no-var-requires': 0,// 在函数和类方法上需要显式的返回类型'@typescript-eslint/explicit-function-return-type': 0,// 在类属性和方法上需要显式的可访问性修饰符'@typescript-eslint/explicit-member-accessibility': [2, { accessibility: 'no-public' }],// 禁止使用任何类型'@typescript-eslint/no-explicit-any': 1,// 不允许对初始化为数字,字符串或布尔值的变量或参数进行显式类型声明'@typescript-eslint/no-inferrable-types': [2, { ignoreParameters: true, ignoreProperties: true }],// 官方没有找到这个配置'@typescript-eslint/interface-name-prefix': [2, 'always'],// 需要对数组使用T []或Array <T>'@typescript-eslint/array-type': 0,// 强制默认参数为最后'@typescript-eslint/default-param-last': 2,// 禁止使用自定义TypeScript模块和名称空间'@typescript-eslint/no-namespace': 0,// 在定义变量之前禁止使用变量 此处由 eslint-config-base 的 no-use-before-define 定义'@typescript-eslint/no-use-before-define': 0,// 禁止使用特定类型'@typescript-eslint/ban-types': [2,{types: {Object: {message: 'Use object instead',fixWith: 'object',},'{}': {message: 'Use object instead',fixWith: 'object',},},},],},};
