2021-10-31 22:58:00 +08:00
# @antfu/eslint-config
2022-03-11 04:46:10 +08:00
[![npm ](https://img.shields.io/npm/v/@antfu/eslint-config?color=a1b858&label= )](https://npmjs.com/package/@antfu/eslint-config)
2021-10-31 22:58:00 +08:00
2022-03-11 04:43:17 +08:00
- Single quotes, no semi
- Auto fix for formatting (aimed to be used standalone without Prettier)
2022-09-19 10:30:50 +08:00
- Designed to work with TypeScript, Vue out-of-box
2022-03-11 04:43:17 +08:00
- Lint also for json, yaml, markdown
- Sorted imports, dangling commas for cleaner commit diff
- Reasonable defaults, best practices, only one-line of config
2021-10-31 22:58:00 +08:00
## Usage
### Install
```bash
pnpm add -D eslint @antfu/eslint -config
```
### Config `.eslintrc`
```json
{
2022-03-10 20:22:02 +08:00
"extends": "@antfu"
2021-10-31 22:58:00 +08:00
}
```
2022-03-11 04:43:17 +08:00
> You don't need `.eslintignore` normally as it has been provided by the preset.
2021-10-31 22:58:00 +08:00
### Add script for package.json
For example:
```json
{
"scripts": {
2022-04-06 20:45:50 +08:00
"lint": "eslint .",
"lint:fix": "eslint . --fix"
2021-10-31 22:58:00 +08:00
}
}
```
2022-03-10 20:26:31 +08:00
### Config VS Code auto fix
2021-10-31 22:58:00 +08:00
2022-10-22 17:09:14 +08:00
Install [VS Code ESLint extension ](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint ) and create `.vscode/settings.json`
2021-10-31 22:58:00 +08:00
```json
{
"prettier.enable": false,
2022-10-01 02:45:37 +08:00
"editor.formatOnSave": false,
2021-10-31 22:58:00 +08:00
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
```
2022-03-11 04:46:10 +08:00
2022-11-30 09:02:21 +08:00
### TypeScript Aware Rules
Type aware rules are enabled when a `tsconfig.eslint.json` is found in the project root. Refer to [this file ](https://github.com/antfu/eslint-config/blob/main/packages/typescript/index.js#L17 ).
2022-10-10 07:33:09 +08:00
## Extended Reading
Learn more about the context - [Why I don't use Prettier ](https://antfu.me/posts/why-not-prettier ).
2022-03-11 04:46:10 +08:00
## Check Also
2022-04-05 04:45:55 +08:00
- [antfu/dotfiles ](https://github.com/antfu/dotfiles ) - My dotfiles
2022-03-11 04:46:10 +08:00
- [antfu/vscode-settings ](https://github.com/antfu/vscode-settings ) - My VS Code settings
- [antfu/ts-starter ](https://github.com/antfu/ts-starter ) - My starter template for TypeScript library
- [antfu/vitesse ](https://github.com/antfu/vitesse ) - My starter template for Vue & Vite app
## License
2022-07-10 10:44:34 +08:00
[MIT ](./LICENSE ) License © 2019-PRESENT [Anthony Fu ](https://github.com/antfu )