prettier和eslint是真的烦,用一次骂一次,最近配置了一个,备份下。
.prettierrc
{
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"vueIndentScriptAndStyle": true,
"singleQuote": true,
"quoteProps": "as-needed",
"bracketSpacing": true,
"trailingComma": "es5",
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"arrowParens": "always",
"insertPragma": false,
"requirePragma": false,
"proseWrap": "never",
"htmlWhitespaceSensitivity": "strict",
"endOfLine": "auto",
"rangeStart": 0
}
.eslintrc.js
require('@rushstack/eslint-patch/modern-module-resolution');
module.exports = {
root: true,
parser: 'vue-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
ecmaVersion: 'latest',
sourceType: 'module',
},
extends: [
'plugin:vue/vue3-essential',
'airbnb-base',
'@vue/eslint-config-typescript',
'@vue/eslint-config-prettier/skip-formatting',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
'./.eslintrc-auto-import.json',
],
rules: {
indent: ['error', 2, { SwitchCase: 1 }],
'no-console': 0,
'linebreak-style': 0,
'no-trailing-spaces': 0,
'no-tabs': 0,
'max-len': 0,
'operator-linebreak': 0,
'no-mixed-spaces-and-tabs': 0,
'object-curly-newline': 0,
'comma-dangle': 0,
'import/no-unresolved': 0,
'guard-for-in': 0,
'import/no-webpack-loader-syntax': 0,
'import/prefer-default-export': 0,
'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
'no-restricted-syntax': 0,
'no-param-reassign': 0,
'class-methods-use-this': 0,
'no-continue': 0,
'no-void': 0,
'no-return-await': 1,
'no-empty-function': 0,
'@typescript-eslint/no-empty-function': 0,
eqeqeq: ['error', 'smart'],
camelcase: 2,
'vue/attributes-order': [
'error',
{
order: [
'DEFINITION',
'LIST_RENDERING',
'CONDITIONALS',
'RENDER_MODIFIERS',
'GLOBAL',
['UNIQUE', 'SLOT'],
'TWO_WAY_BINDING',
'OTHER_DIRECTIVES',
'OTHER_ATTR',
'EVENTS',
'CONTENT',
],
alphabetical: false,
},
],
'vue/script-indent': [
'error',
2,
{
baseIndent: 1,
switchCase: 0,
ignores: [],
},
],
'vue/multi-word-component-names': [
'error',
{
ignores: ['index', 'Main', 'Navbar', 'Sidebar', 'Breadcrumb'],
},
],
'vue/html-closing-bracket-newline': [
'warn',
{
singleline: 'never',
multiline: 'always',
},
],
'vue/block-lang': [
'error',
{
script: {
lang: ['ts'],
},
style: {
lang: ['scss', 'css'],
},
},
],
'import/extensions': [
'error',
{
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
vue: 'never',
},
],
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'off',
},
settings: {
'import/resolver': {
alias: {
map: [['@', './src']],
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
},
},
},
overrides: [
{
files: ['*.vue'],
rules: {
indent: 'off',
},
},
],
};
.editorconfig
# https://editorconfig.org
# 已经是顶层配置文件,不必继续向上搜索
root = true
[*]
# 编码字符集
charset = utf-8
# 缩进风格是空格
indent_style = space
# 一个缩进占用两个空格,因没有设置tab_with,一个Tab占用2列
indent_size = 2
# 换行符 lf
end_of_line = lf
# 文件以一个空白行结尾
insert_final_newline = true
# 去除行首的任意空白字符
trim_trailing_whitespace = true
[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
.stylelintignore
# 排除非css类型文件
*.js
*.jpg
*.png
*.eot
*.ttf
*.woff
*.json
# 排除打包目录以及依赖包目录
/dist/
/node_modules/