@20i/eslint-config 中文文档教程
eslint-config-20i
Auto Install
使用 mrm 安装所有依赖项并添加配置文件
npx mrm eslint --preset @20i/mrm-preset
Manual Install
- Install dev dependencies:
yarn add -D eslint prettier typescript @20i/eslint-config
# or
npm i -D eslint prettier typescript @20i/eslint-config
- Create a new file
.eslintrc.js
in the directory of your project. - Add the following code to the file.
module.exports = {
extends: ["@20i/eslint-config"],
parserOptions: {
project: ["./tsconfig.eslint.json"],
},
ignorePatterns: [],
}
对于 React 项目,请改用
@20i/eslint-config/react
。
- Add a special
tsconfig.json
file to your project:tsconfig.eslint.json
to enable full type checking.
{
// extend your base config to share compilerOptions, etc
"extends": "./tsconfig.json",
"compilerOptions": {
// ensure that nobody can accidentally use this config for a build
"noEmit": true
},
"include": [
"**/*",
"**/.*"
],
}
- Add the following to your
.prettierrc
file:
{
"endOfLine": "auto",
"semi": false,
"trailingComma": "es5"
}
Configure VS Code
- Install the extension
eslint-vscode
- Install the extension
prettier-vscode
- Add the following to your
.vscode/settings.json
file:
"editor.codeActionsOnSave": {
"source.fixAll": true
},
// format on save for everything but what prettier will handle through eslint
"editor.formatOnSave": true,
"[javascriptreact]": {
"editor.formatOnSave": false,
},
"[javascript]": {
"editor.formatOnSave": false,
},
"[typescript]": {
"editor.formatOnSave": false,
},
"[typescriptreact]": {
"editor.formatOnSave": false,
},
- Restart VS Code
深受 eslint-config-wesbos 启发
eslint-config-20i
Auto Install
Use mrm to install all dependencies and add config files
npx mrm eslint --preset @20i/mrm-preset
Manual Install
- Install dev dependencies:
yarn add -D eslint prettier typescript @20i/eslint-config
# or
npm i -D eslint prettier typescript @20i/eslint-config
- Create a new file
.eslintrc.js
in the directory of your project. - Add the following code to the file.
module.exports = {
extends: ["@20i/eslint-config"],
parserOptions: {
project: ["./tsconfig.eslint.json"],
},
ignorePatterns: [],
}
For React projects, use
@20i/eslint-config/react
instead.
- Add a special
tsconfig.json
file to your project:tsconfig.eslint.json
to enable full type checking.
{
// extend your base config to share compilerOptions, etc
"extends": "./tsconfig.json",
"compilerOptions": {
// ensure that nobody can accidentally use this config for a build
"noEmit": true
},
"include": [
"**/*",
"**/.*"
],
}
- Add the following to your
.prettierrc
file:
{
"endOfLine": "auto",
"semi": false,
"trailingComma": "es5"
}
Configure VS Code
- Install the extension
eslint-vscode
- Install the extension
prettier-vscode
- Add the following to your
.vscode/settings.json
file:
"editor.codeActionsOnSave": {
"source.fixAll": true
},
// format on save for everything but what prettier will handle through eslint
"editor.formatOnSave": true,
"[javascriptreact]": {
"editor.formatOnSave": false,
},
"[javascript]": {
"editor.formatOnSave": false,
},
"[typescript]": {
"editor.formatOnSave": false,
},
"[typescriptreact]": {
"editor.formatOnSave": false,
},
- Restart VS Code
Inspired heavily by eslint-config-wesbos
更多
你可能也喜欢
- 2yy-ngx-ellipsis 中文文档教程
- @10xcompany/nest-neo4j 中文文档教程
- @1ziton/react-native-scancode 中文文档教程
- @2003scape/rsc-data 中文文档教程
- @22g/tb-register 中文文档教程
- @2players/generator-nm 中文文档教程
- @40three/ngx-autofocus-directive 中文文档教程
- @a11ycore/utils 中文文档教程
- @aakashsuryawanshi/angular-material-fileupload 中文文档教程
- @ab-inbev-z-tech/fintech-identity 中文文档教程