我在 AirBNB 风格指南中使用 ESLint 和 Prettier。
在我的一生中,我无法停止在文件的每一行使用空格对我大喊大叫。
.eslintrc.json
{
"env": {
"browser": true,
"es2021": true
},
"extends": ["airbnb-base", "prettier", "plugin:node/recommended"],
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error",
"indent": ["warn", "tab"],
"quotes": ["warn", "single"],
"no-unused-vars": "warn",
"no-console": "off",
"no-tabs": "off",
"no-restricted-syntax": "off",
"func-names": "off"
}
}
package.json 依赖项
"devDependencies": {
"autoprefixer": "^10.1.0",
"clean-css-cli": "^4.3.0",
"concurrently": "^5.3.0",
"cross-env": "^7.0.3",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.23.4",
"live-server": "^1.2.1",
"postcss-cli": "^8.3.1",
"postcss-import": "^14.0.2",
"pwa-asset-generator": "^4.1.1",
"tailwindcss": "^2.0.2"
}
设置.json
{
"editor.linkedEditing": true,
"editor.detectIndentation": true,
"notebook.cellToolbarLocation": {
"default": "right",
"jupyter-notebook": "left"
},
"prettier.tabWidth": 4,
"prettier.useTabs": true,
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"eslint.alwaysShowStatus": true,
"workbench.colorTheme": "Default Dark+",
"prettier.singleQuote": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}
我到处都设置了标签。这个确切的设置以前工作过(我不得不将我的机器恢复出厂设置)。我已经同步了我的 VS 代码设置,并且 eslintrc 和 pacakge.json 文件应该与以前完全相同......