116 lines
4.0 KiB
JavaScript
116 lines
4.0 KiB
JavaScript
|
module.exports = {
|
|||
|
root: true,
|
|||
|
parser: 'vue-eslint-parser',
|
|||
|
env: {
|
|||
|
es6: true,
|
|||
|
browser: true,
|
|||
|
node: true
|
|||
|
},
|
|||
|
extends: ['alloy', 'prettier'],
|
|||
|
plugins: ['prettier'],
|
|||
|
parserOptions: {
|
|||
|
parser: '@typescript-eslint/parser',
|
|||
|
sourceType: 'module'
|
|||
|
},
|
|||
|
rules: {
|
|||
|
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|||
|
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|||
|
'no-undef': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|||
|
'no-unused-vars': 1, // 不能有声明后未被使用的变量或参数
|
|||
|
'no-irregular-whitespace': 2, // 不能有不规则的空格
|
|||
|
'no-param-reassign': 0,
|
|||
|
'arrow-spacing': [
|
|||
|
2,
|
|||
|
{
|
|||
|
before: true,
|
|||
|
after: true
|
|||
|
}
|
|||
|
], // 要求箭头函数的箭头之前或之后有空格
|
|||
|
eqeqeq: [1, 'always', { null: 'ignore' }], // 要求使用 === 和 !==
|
|||
|
indent: ['error', 2, { SwitchCase: 1 }],
|
|||
|
'keyword-spacing': [
|
|||
|
2,
|
|||
|
{
|
|||
|
before: true,
|
|||
|
after: true
|
|||
|
}
|
|||
|
],
|
|||
|
'brace-style': [
|
|||
|
2,
|
|||
|
'1tbs',
|
|||
|
{
|
|||
|
allowSingleLine: true
|
|||
|
}
|
|||
|
], // 大括号风格要求
|
|||
|
camelcase: [
|
|||
|
1,
|
|||
|
{
|
|||
|
properties: 'always'
|
|||
|
}
|
|||
|
], // 要求使用骆驼拼写法
|
|||
|
'comma-dangle': [2, 'never'], // 要求或禁止使用拖尾逗号
|
|||
|
'comma-spacing': [
|
|||
|
2,
|
|||
|
{
|
|||
|
before: false,
|
|||
|
after: true
|
|||
|
}
|
|||
|
], // 强制在逗号周围使用空格
|
|||
|
'comma-style': [2, 'last'], // 逗号风格 要求逗号放在数组元素、对象属性或变量声明之后,且在同一行
|
|||
|
'new-parens': 2, // 要求调用无参构造函数时带括号
|
|||
|
quotes: [
|
|||
|
2,
|
|||
|
'single',
|
|||
|
{
|
|||
|
avoidEscape: true,
|
|||
|
allowTemplateLiterals: true
|
|||
|
}
|
|||
|
], // 强制使用一致的反勾号、双引号或单引号 double:双引号 single:单引号 backtick:反勾号
|
|||
|
'semi-spacing': [
|
|||
|
2,
|
|||
|
{
|
|||
|
before: false,
|
|||
|
after: true
|
|||
|
}
|
|||
|
], // 分号前后空格
|
|||
|
'space-infix-ops': 2, // 中缀操作符周围要不要有空格
|
|||
|
'space-unary-ops': [
|
|||
|
2,
|
|||
|
{
|
|||
|
words: true,
|
|||
|
nonwords: false
|
|||
|
}
|
|||
|
], // 一元运算符的前/后要不要加空格
|
|||
|
'spaced-comment': [
|
|||
|
2,
|
|||
|
'always',
|
|||
|
{
|
|||
|
markers: ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
|
|||
|
}
|
|||
|
], // 要求或禁止在注释前有空白
|
|||
|
'arrow-parens': [2, 'always'], // 要求箭头函数的参数使用圆括号
|
|||
|
'linebreak-style': 1, // 强制使用一致的换行符风格
|
|||
|
radix: 0,
|
|||
|
'no-var': 2, // 禁用var,用let和const代替
|
|||
|
'prettier/prettier': [
|
|||
|
2,
|
|||
|
{
|
|||
|
printWidth: 150, // 一行代码的最大字符数
|
|||
|
tabWidth: 2, // tab宽度为2空格
|
|||
|
useTabs: false, // 是否使用tab来缩进
|
|||
|
semi: false, // 结尾是否添加分号
|
|||
|
singleQuote: true, // 使用单引号
|
|||
|
quoteProps: 'as-needed', // object对象中key值是否加引号 as-needed只有在需求要的情况下加引号,consistent是有一个需要引号就统一加,preserve是保留用户输入的引号
|
|||
|
proseWrap: 'preserve', // 换行方式 默认值。因为使用了一些折行敏感型的渲染器(如GitHub comment)而按照markdown文本样式进行折行
|
|||
|
arrowParens: 'always', // 箭头函数单个参数的情况是否省略括号,默认always是总是带括号 avoid:省略括号
|
|||
|
bracketSpacing: true, // object对象里面的key和value值和括号间的空格 默认true
|
|||
|
jsxBracketSameLine: false, // jsx标签多行属性写法时中把'>' 是否单独放一行
|
|||
|
endOfLine: 'auto', // endOfLine: "<lf|crlf|cr|auto>" 行尾换行符,默认是lf
|
|||
|
htmlWhitespaceSensitivity: 'ignore',
|
|||
|
trailingComma: 'none', // 尾部逗号设置,es5是尾部逗号兼容es5,none就是没有尾部逗号,all是指所有可能的情况
|
|||
|
jsxSingleQuote: true // 在jsx中使用单引号代替双引号
|
|||
|
}
|
|||
|
]
|
|||
|
}
|
|||
|
}
|