1.配置eslintrc.js
在.eslintrc.js文件里
设置
indent: ['off', 2],
rules: {
'quote-props': 0,
'dot-notation': 0,
'consistent-return': 0,
'no-multiple-empty-lines': 0,
'prefer-arrow-callback': 0,
'wrap-iife': 0,
'no-undef-init': 0,
'no-new-wrappers': 0,
'linebreak-style': 0,
'max-len': [0, 160],
'lines-between-class-members': 0,
'prefer-const': 0,
'no-plusplus': 0,
'comma-dangle': 0,
'func-names': 0,
'space-before-function-paren': 0,
'prefer-template': 0,
'no-else-return': 0,
'object-curly-newline': 0,
'no-bitwise': 0,
'max-classes-per-file': 0,
'class-methods-use-this': 0,
'no-useless-constructor': 0,
'no-unused-expressions': 0,
'no-param-reassign': 0,
'no-empty-function': 0,
'no-console': 0,
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-unused-vars': 0,
'no-underscore-dangle': 0,
'arrow-body-style': 0,
'consistent-return': 0,
'one-var': 0,
'one-var-declaration-per-line': 0,
'prefer-promise-reject-errors': 0,
eqeqeq: 0,
camelcase: 0,
'object-shorthand': 0,
indent: ['off', 2],
'import/prefer-default-export': 0,
'prefer-destructuring': 0,
}
2.配置.prettierrc.js
module.exports = {
// 一行最多 100 字符
printWidth: 100,
// 不使用缩进符,而使用空格
useTabs: false,
// 使用 2 个空格缩进
tabWidth: 4,
tabSize: 4,
// 行尾需要有分号
semi: true,
// 使用单引号
singleQuote: true,
// 对象的 key 仅在必要时用引号
quoteProps: 'as-needed',
// jsx 不使用单引号,而使用双引号
jsxSingleQuote: false,
// 末尾不需要逗号
trailingComma: 'es5',
// 大括号内的首尾需要空格
bracketSpacing: true,
// jsx 标签的反尖括号需要换行
jsxBracketSameLine: false,
// 箭头函数,只有一个参数的时候,也需要括号
arrowParens: 'always',
// 每个文件格式化的范围是文件的全部内容
rangeStart: 0,
rangeEnd: Infinity,
// 不需要写文件开头的 @prettier
requirePragma: false,
// 不需要自动在文件开头插入 @prettier
insertPragma: false,
// 使用默认的折行标准
proseWrap: 'preserve',
// 根据显示样式决定 html 要不要折行
htmlWhitespaceSensitivity: 'css',
// 换行符使用 lf 结尾是 \n \r \n\r auto
endOfLine: 'lf',
};