@kirklin/eslint-config 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +150 -150
- package/README.zh-cn.md +138 -138
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,150 +1,150 @@
|
|
|
1
|
-
# @kirklin/eslint-config
|
|
2
|
-
|
|
3
|
-
[![CI][ci-image]][ci-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript_code style][code-style-image]][code-style-url]
|
|
4
|
-
|
|
5
|
-
[ci-image]: https://github.com/kirklin/eslint-config/actions/workflows/release.yml/badge.svg?branch=master
|
|
6
|
-
[ci-url]: https://github.com/kirklin/eslint-config/actions/workflows/release.yml
|
|
7
|
-
[npm-image]: https://img.shields.io/npm/v/@kirklin/eslint-config.svg
|
|
8
|
-
[npm-url]: https://npmjs.org/package/@kirklin/eslint-config
|
|
9
|
-
[downloads-image]: https://img.shields.io/npm/dm/@kirklin/eslint-config.svg
|
|
10
|
-
[downloads-url]: https://npmjs.org/package/@kirklin/eslint-config
|
|
11
|
-
[code-style-image]: https://img.shields.io/badge/code__style-%40kirklin%2Feslint--config-brightgreen
|
|
12
|
-
[code-style-url]: https://github.com/kirklin/eslint-config/
|
|
13
|
-
|
|
14
|
-
<div align='left'>
|
|
15
|
-
<b>English</b> | <a href="README.zh-cn.md">简体中文</a>
|
|
16
|
-
<br>
|
|
17
|
-
</div>
|
|
18
|
-
|
|
19
|
-
## Features
|
|
20
|
-
|
|
21
|
-
- "double quotes", must semi;
|
|
22
|
-
- Auto fix for formatting (aimed to be used standalone without Prettier)
|
|
23
|
-
- TypeScript, Vue out-of-box
|
|
24
|
-
- Lint also for JSON、YAML、Markdown
|
|
25
|
-
- Sorted imports, dangling commas for cleaner commit diff
|
|
26
|
-
- Reasonable defaults, best practices, only one-line of config
|
|
27
|
-
|
|
28
|
-
## Usage
|
|
29
|
-
|
|
30
|
-
Shareable configs are designed to work with the `extends` feature of `.eslintrc` files.
|
|
31
|
-
You can learn more about
|
|
32
|
-
[Shareable Configs](http://eslint.org/docs/developer-guide/shareable-configs) on the
|
|
33
|
-
official ESLint website.
|
|
34
|
-
|
|
35
|
-
#### run the following command:
|
|
36
|
-
|
|
37
|
-
### Install
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
pnpm add -D eslint @kirklin/eslint-config
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### add this to your `.eslintrc` file:
|
|
44
|
-
|
|
45
|
-
```json
|
|
46
|
-
{
|
|
47
|
-
"extends": "@kirklin"
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
> You don't need `.eslintignore` normally as it has been provided by the preset.
|
|
52
|
-
|
|
53
|
-
### Add script for package.json
|
|
54
|
-
|
|
55
|
-
For example:
|
|
56
|
-
|
|
57
|
-
```json
|
|
58
|
-
{
|
|
59
|
-
"scripts": {
|
|
60
|
-
"lint": "eslint .",
|
|
61
|
-
"lint:fix": "eslint . --fix"
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### Config VS Code auto fix
|
|
67
|
-
|
|
68
|
-
Create `.vscode/settings.json`
|
|
69
|
-
|
|
70
|
-
```json
|
|
71
|
-
{
|
|
72
|
-
"prettier.enable": false,
|
|
73
|
-
"editor.formatOnSave": false,
|
|
74
|
-
"editor.codeActionsOnSave": {
|
|
75
|
-
"source.fixAll.eslint": true,
|
|
76
|
-
"source.organizeImports": false
|
|
77
|
-
},
|
|
78
|
-
// The following section is optional.
|
|
79
|
-
// It is recommended to place it in the project's .vscode/settings.json file
|
|
80
|
-
// to avoid conflicts when working with different eslint configurations
|
|
81
|
-
// that may not support all formats.
|
|
82
|
-
"eslint.validate": [
|
|
83
|
-
"javascript",
|
|
84
|
-
"javascriptreact",
|
|
85
|
-
"typescript",
|
|
86
|
-
"typescriptreact",
|
|
87
|
-
"vue",
|
|
88
|
-
"html",
|
|
89
|
-
"markdown",
|
|
90
|
-
"json",
|
|
91
|
-
"jsonc",
|
|
92
|
-
"yaml"
|
|
93
|
-
]
|
|
94
|
-
}
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### Customization rules
|
|
98
|
-
|
|
99
|
-
add you like rules to your `.eslintrc` file:
|
|
100
|
-
|
|
101
|
-
```json
|
|
102
|
-
{
|
|
103
|
-
"extends": ["@kirklin"],
|
|
104
|
-
"rules": {
|
|
105
|
-
"vue/
|
|
106
|
-
"error",
|
|
107
|
-
{
|
|
108
|
-
"order": ["template", "script", "style"]
|
|
109
|
-
}
|
|
110
|
-
]
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### TypeScript Aware Rules
|
|
116
|
-
|
|
117
|
-
Type aware rules are enabled when a `tsconfig.eslint.json` is found in the project root. If you want to enable it while have no `tsconfig.eslint.json` in the project root, you can change tsconfig name by modifying `ESLINT_TSCONFIG` env.
|
|
118
|
-
|
|
119
|
-
```js
|
|
120
|
-
// .eslintrc.js
|
|
121
|
-
const process = require("node:process");
|
|
122
|
-
|
|
123
|
-
process.env.ESLINT_TSCONFIG = "tsconfig.json";
|
|
124
|
-
|
|
125
|
-
module.exports = {
|
|
126
|
-
extends: "@kirklin",
|
|
127
|
-
};
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
## Badge
|
|
131
|
-
|
|
132
|
-
Use this in one of your projects? Include one of these badges in your readme to
|
|
133
|
-
let people know that your code is using the standard style.
|
|
134
|
-
|
|
135
|
-
[](https://github.com/kirklin/eslint-config/)
|
|
136
|
-
|
|
137
|
-
```markdown
|
|
138
|
-
[](https://github.com/kirklin/eslint-config/)
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
[code-style-image]: https://img.shields.io/badge/code__style-%40kirklin%2Feslint--config-brightgreen
|
|
142
|
-
[code-style-url]: https://github.com/kirklin/eslint-config/
|
|
143
|
-
|
|
144
|
-
## Thanks
|
|
145
|
-
|
|
146
|
-
This project is based on [@antfu/eslint-config](https://github.com/antfu/eslint-config)
|
|
147
|
-
|
|
148
|
-
## License
|
|
149
|
-
|
|
150
|
-
[MIT](./LICENSE) License © 2019-PRESENT [Kirk Lin](https://github.com/kirklin)
|
|
1
|
+
# @kirklin/eslint-config
|
|
2
|
+
|
|
3
|
+
[![CI][ci-image]][ci-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript_code style][code-style-image]][code-style-url]
|
|
4
|
+
|
|
5
|
+
[ci-image]: https://github.com/kirklin/eslint-config/actions/workflows/release.yml/badge.svg?branch=master
|
|
6
|
+
[ci-url]: https://github.com/kirklin/eslint-config/actions/workflows/release.yml
|
|
7
|
+
[npm-image]: https://img.shields.io/npm/v/@kirklin/eslint-config.svg
|
|
8
|
+
[npm-url]: https://npmjs.org/package/@kirklin/eslint-config
|
|
9
|
+
[downloads-image]: https://img.shields.io/npm/dm/@kirklin/eslint-config.svg
|
|
10
|
+
[downloads-url]: https://npmjs.org/package/@kirklin/eslint-config
|
|
11
|
+
[code-style-image]: https://img.shields.io/badge/code__style-%40kirklin%2Feslint--config-brightgreen
|
|
12
|
+
[code-style-url]: https://github.com/kirklin/eslint-config/
|
|
13
|
+
|
|
14
|
+
<div align='left'>
|
|
15
|
+
<b>English</b> | <a href="README.zh-cn.md">简体中文</a>
|
|
16
|
+
<br>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
- "double quotes", must semi;
|
|
22
|
+
- Auto fix for formatting (aimed to be used standalone without Prettier)
|
|
23
|
+
- TypeScript, Vue out-of-box
|
|
24
|
+
- Lint also for JSON、YAML、Markdown
|
|
25
|
+
- Sorted imports, dangling commas for cleaner commit diff
|
|
26
|
+
- Reasonable defaults, best practices, only one-line of config
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
Shareable configs are designed to work with the `extends` feature of `.eslintrc` files.
|
|
31
|
+
You can learn more about
|
|
32
|
+
[Shareable Configs](http://eslint.org/docs/developer-guide/shareable-configs) on the
|
|
33
|
+
official ESLint website.
|
|
34
|
+
|
|
35
|
+
#### run the following command:
|
|
36
|
+
|
|
37
|
+
### Install
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pnpm add -D eslint @kirklin/eslint-config
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### add this to your `.eslintrc` file:
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"extends": "@kirklin"
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
> You don't need `.eslintignore` normally as it has been provided by the preset.
|
|
52
|
+
|
|
53
|
+
### Add script for package.json
|
|
54
|
+
|
|
55
|
+
For example:
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"scripts": {
|
|
60
|
+
"lint": "eslint .",
|
|
61
|
+
"lint:fix": "eslint . --fix"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Config VS Code auto fix
|
|
67
|
+
|
|
68
|
+
Create `.vscode/settings.json`
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"prettier.enable": false,
|
|
73
|
+
"editor.formatOnSave": false,
|
|
74
|
+
"editor.codeActionsOnSave": {
|
|
75
|
+
"source.fixAll.eslint": true,
|
|
76
|
+
"source.organizeImports": false
|
|
77
|
+
},
|
|
78
|
+
// The following section is optional.
|
|
79
|
+
// It is recommended to place it in the project's .vscode/settings.json file
|
|
80
|
+
// to avoid conflicts when working with different eslint configurations
|
|
81
|
+
// that may not support all formats.
|
|
82
|
+
"eslint.validate": [
|
|
83
|
+
"javascript",
|
|
84
|
+
"javascriptreact",
|
|
85
|
+
"typescript",
|
|
86
|
+
"typescriptreact",
|
|
87
|
+
"vue",
|
|
88
|
+
"html",
|
|
89
|
+
"markdown",
|
|
90
|
+
"json",
|
|
91
|
+
"jsonc",
|
|
92
|
+
"yaml"
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Customization rules
|
|
98
|
+
|
|
99
|
+
add you like rules to your `.eslintrc` file:
|
|
100
|
+
|
|
101
|
+
```json
|
|
102
|
+
{
|
|
103
|
+
"extends": ["@kirklin"],
|
|
104
|
+
"rules": {
|
|
105
|
+
"vue/block-order": [
|
|
106
|
+
"error",
|
|
107
|
+
{
|
|
108
|
+
"order": ["template", "script", "style"]
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### TypeScript Aware Rules
|
|
116
|
+
|
|
117
|
+
Type aware rules are enabled when a `tsconfig.eslint.json` is found in the project root. If you want to enable it while have no `tsconfig.eslint.json` in the project root, you can change tsconfig name by modifying `ESLINT_TSCONFIG` env.
|
|
118
|
+
|
|
119
|
+
```js
|
|
120
|
+
// .eslintrc.js
|
|
121
|
+
const process = require("node:process");
|
|
122
|
+
|
|
123
|
+
process.env.ESLINT_TSCONFIG = "tsconfig.json";
|
|
124
|
+
|
|
125
|
+
module.exports = {
|
|
126
|
+
extends: "@kirklin",
|
|
127
|
+
};
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Badge
|
|
131
|
+
|
|
132
|
+
Use this in one of your projects? Include one of these badges in your readme to
|
|
133
|
+
let people know that your code is using the standard style.
|
|
134
|
+
|
|
135
|
+
[](https://github.com/kirklin/eslint-config/)
|
|
136
|
+
|
|
137
|
+
```markdown
|
|
138
|
+
[](https://github.com/kirklin/eslint-config/)
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
[code-style-image]: https://img.shields.io/badge/code__style-%40kirklin%2Feslint--config-brightgreen
|
|
142
|
+
[code-style-url]: https://github.com/kirklin/eslint-config/
|
|
143
|
+
|
|
144
|
+
## Thanks
|
|
145
|
+
|
|
146
|
+
This project is based on [@antfu/eslint-config](https://github.com/antfu/eslint-config)
|
|
147
|
+
|
|
148
|
+
## License
|
|
149
|
+
|
|
150
|
+
[MIT](./LICENSE) License © 2019-PRESENT [Kirk Lin](https://github.com/kirklin)
|
package/README.zh-cn.md
CHANGED
|
@@ -1,138 +1,138 @@
|
|
|
1
|
-
# @kirklin/eslint-config
|
|
2
|
-
|
|
3
|
-
[![CI][ci-image]][ci-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript_code style][code-style-image]][code-style-url]
|
|
4
|
-
|
|
5
|
-
[ci-image]: https://github.com/kirklin/eslint-config/actions/workflows/release.yml/badge.svg?branch=master
|
|
6
|
-
[ci-url]: https://github.com/kirklin/eslint-config/actions/workflows/release.yml
|
|
7
|
-
[npm-image]: https://img.shields.io/npm/v/@kirklin/eslint-config.svg
|
|
8
|
-
[npm-url]: https://npmjs.org/package/@kirklin/eslint-config
|
|
9
|
-
[downloads-image]: https://img.shields.io/npm/dm/@kirklin/eslint-config.svg
|
|
10
|
-
[downloads-url]: https://npmjs.org/package/@kirklin/eslint-config
|
|
11
|
-
[code-style-image]: https://img.shields.io/badge/code__style-%40kirklin-brightgreen.svg
|
|
12
|
-
[code-style-url]: https://github.com/kirklin/eslint-config/
|
|
13
|
-
|
|
14
|
-
<div align='left'>
|
|
15
|
-
<a href="README.md">English</a> | <b>简体中文</b>
|
|
16
|
-
<br>
|
|
17
|
-
</div>
|
|
18
|
-
|
|
19
|
-
## 特性
|
|
20
|
-
|
|
21
|
-
- "双引号",必须加分号;
|
|
22
|
-
- 格式化的自动修复(旨在独立使用,不需要 Prettier)。
|
|
23
|
-
- TypeScript,Vue 开箱即用
|
|
24
|
-
- 对 JSON、YAML、Markdown 也支持格式化
|
|
25
|
-
- 导入自动排序,需要尾随逗号,更干净的提交差异
|
|
26
|
-
- 合理的默认值,最佳实践,只有一行的配置
|
|
27
|
-
|
|
28
|
-
## 如何使用
|
|
29
|
-
|
|
30
|
-
可共享的配置被设计在`.eslintrc`文件的`extends`。
|
|
31
|
-
你可以了解更多关于
|
|
32
|
-
[Shareable Configs](http://eslint.org/docs/developer-guide/shareable-configs) 在
|
|
33
|
-
官方 ESLint 网站上
|
|
34
|
-
|
|
35
|
-
### 运行以下命令开始使用:
|
|
36
|
-
|
|
37
|
-
### 安装
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
pnpm add -D eslint @kirklin/eslint-config
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### 在你的`.eslintrc`文件中加入这个。
|
|
44
|
-
|
|
45
|
-
```json
|
|
46
|
-
{
|
|
47
|
-
"extends": "@kirklin"
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
> 你通常不需要`.eslintignore`,因为它已经由预设提供了。
|
|
52
|
-
|
|
53
|
-
### 为 package.json 添加脚本配置
|
|
54
|
-
|
|
55
|
-
例如:
|
|
56
|
-
|
|
57
|
-
```json
|
|
58
|
-
{
|
|
59
|
-
"scripts": {
|
|
60
|
-
"lint": "eslint .",
|
|
61
|
-
"lint:fix": "eslint . --fix"
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### 在 Vscode 中 配置自动修复
|
|
67
|
-
|
|
68
|
-
创建 `.vscode/settings.json`
|
|
69
|
-
|
|
70
|
-
```json
|
|
71
|
-
{
|
|
72
|
-
"prettier.enable": false,
|
|
73
|
-
"editor.formatOnSave": false,
|
|
74
|
-
"editor.codeActionsOnSave": {
|
|
75
|
-
"source.fixAll.eslint": true,
|
|
76
|
-
"source.organizeImports": false
|
|
77
|
-
},
|
|
78
|
-
// 以下内容为可选项。
|
|
79
|
-
// 建议将其放置在项目的 .vscode/settings.json 文件中,
|
|
80
|
-
// 以避免在使用不同的 eslint 配置时出现冲突,
|
|
81
|
-
// 这些配置可能不支持所有格式。
|
|
82
|
-
"eslint.validate": [
|
|
83
|
-
"javascript",
|
|
84
|
-
"javascriptreact",
|
|
85
|
-
"typescript",
|
|
86
|
-
"typescriptreact",
|
|
87
|
-
"vue",
|
|
88
|
-
"html",
|
|
89
|
-
"markdown",
|
|
90
|
-
"json",
|
|
91
|
-
"jsonc",
|
|
92
|
-
"yaml"
|
|
93
|
-
]
|
|
94
|
-
}
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### 自定义规则
|
|
98
|
-
|
|
99
|
-
在你的`.eslintrc`文件中添加你喜欢的规则。
|
|
100
|
-
|
|
101
|
-
```json
|
|
102
|
-
{
|
|
103
|
-
"extends": ["@kirklin"],
|
|
104
|
-
"rules": {
|
|
105
|
-
"vue/
|
|
106
|
-
"error",
|
|
107
|
-
{
|
|
108
|
-
"order": ["template", "script", "style"]
|
|
109
|
-
}
|
|
110
|
-
]
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### TypeScript Aware Rules
|
|
116
|
-
|
|
117
|
-
当在项目根目录中找到`tsconfig.eslint.json`时,将启用 Type Aware Rules, [参阅此处](https://github.com/kirklin/eslint-config/blob/master/packages/typescript/index.js#L17).
|
|
118
|
-
|
|
119
|
-
## 徽章
|
|
120
|
-
|
|
121
|
-
在你的 README 中包括一个这样的徽章,以便让人们知道你的代码使用的是哪种 ESLint 样式。
|
|
122
|
-
|
|
123
|
-
[](https://github.com/kirklin/eslint-config/)
|
|
124
|
-
|
|
125
|
-
```markdown
|
|
126
|
-
[](https://github.com/kirklin/eslint-config/)
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
[code-style-image]: https://img.shields.io/badge/code__style-%40kirklin%2Feslint--config-brightgreen
|
|
130
|
-
[code-style-url]: https://github.com/kirklin/eslint-config/
|
|
131
|
-
|
|
132
|
-
## 致谢
|
|
133
|
-
|
|
134
|
-
本项目基于 [@antfu/eslint-config](https://github.com/antfu/eslint-config)
|
|
135
|
-
|
|
136
|
-
## 开源协议
|
|
137
|
-
|
|
138
|
-
[MIT](./LICENSE) License © 2019-PRESENT [Kirk Lin](https://github.com/kirklin)
|
|
1
|
+
# @kirklin/eslint-config
|
|
2
|
+
|
|
3
|
+
[![CI][ci-image]][ci-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript_code style][code-style-image]][code-style-url]
|
|
4
|
+
|
|
5
|
+
[ci-image]: https://github.com/kirklin/eslint-config/actions/workflows/release.yml/badge.svg?branch=master
|
|
6
|
+
[ci-url]: https://github.com/kirklin/eslint-config/actions/workflows/release.yml
|
|
7
|
+
[npm-image]: https://img.shields.io/npm/v/@kirklin/eslint-config.svg
|
|
8
|
+
[npm-url]: https://npmjs.org/package/@kirklin/eslint-config
|
|
9
|
+
[downloads-image]: https://img.shields.io/npm/dm/@kirklin/eslint-config.svg
|
|
10
|
+
[downloads-url]: https://npmjs.org/package/@kirklin/eslint-config
|
|
11
|
+
[code-style-image]: https://img.shields.io/badge/code__style-%40kirklin-brightgreen.svg
|
|
12
|
+
[code-style-url]: https://github.com/kirklin/eslint-config/
|
|
13
|
+
|
|
14
|
+
<div align='left'>
|
|
15
|
+
<a href="README.md">English</a> | <b>简体中文</b>
|
|
16
|
+
<br>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
## 特性
|
|
20
|
+
|
|
21
|
+
- "双引号",必须加分号;
|
|
22
|
+
- 格式化的自动修复(旨在独立使用,不需要 Prettier)。
|
|
23
|
+
- TypeScript,Vue 开箱即用
|
|
24
|
+
- 对 JSON、YAML、Markdown 也支持格式化
|
|
25
|
+
- 导入自动排序,需要尾随逗号,更干净的提交差异
|
|
26
|
+
- 合理的默认值,最佳实践,只有一行的配置
|
|
27
|
+
|
|
28
|
+
## 如何使用
|
|
29
|
+
|
|
30
|
+
可共享的配置被设计在`.eslintrc`文件的`extends`。
|
|
31
|
+
你可以了解更多关于
|
|
32
|
+
[Shareable Configs](http://eslint.org/docs/developer-guide/shareable-configs) 在
|
|
33
|
+
官方 ESLint 网站上
|
|
34
|
+
|
|
35
|
+
### 运行以下命令开始使用:
|
|
36
|
+
|
|
37
|
+
### 安装
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pnpm add -D eslint @kirklin/eslint-config
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 在你的`.eslintrc`文件中加入这个。
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"extends": "@kirklin"
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
> 你通常不需要`.eslintignore`,因为它已经由预设提供了。
|
|
52
|
+
|
|
53
|
+
### 为 package.json 添加脚本配置
|
|
54
|
+
|
|
55
|
+
例如:
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"scripts": {
|
|
60
|
+
"lint": "eslint .",
|
|
61
|
+
"lint:fix": "eslint . --fix"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 在 Vscode 中 配置自动修复
|
|
67
|
+
|
|
68
|
+
创建 `.vscode/settings.json`
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"prettier.enable": false,
|
|
73
|
+
"editor.formatOnSave": false,
|
|
74
|
+
"editor.codeActionsOnSave": {
|
|
75
|
+
"source.fixAll.eslint": true,
|
|
76
|
+
"source.organizeImports": false
|
|
77
|
+
},
|
|
78
|
+
// 以下内容为可选项。
|
|
79
|
+
// 建议将其放置在项目的 .vscode/settings.json 文件中,
|
|
80
|
+
// 以避免在使用不同的 eslint 配置时出现冲突,
|
|
81
|
+
// 这些配置可能不支持所有格式。
|
|
82
|
+
"eslint.validate": [
|
|
83
|
+
"javascript",
|
|
84
|
+
"javascriptreact",
|
|
85
|
+
"typescript",
|
|
86
|
+
"typescriptreact",
|
|
87
|
+
"vue",
|
|
88
|
+
"html",
|
|
89
|
+
"markdown",
|
|
90
|
+
"json",
|
|
91
|
+
"jsonc",
|
|
92
|
+
"yaml"
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 自定义规则
|
|
98
|
+
|
|
99
|
+
在你的`.eslintrc`文件中添加你喜欢的规则。
|
|
100
|
+
|
|
101
|
+
```json
|
|
102
|
+
{
|
|
103
|
+
"extends": ["@kirklin"],
|
|
104
|
+
"rules": {
|
|
105
|
+
"vue/block-order": [
|
|
106
|
+
"error",
|
|
107
|
+
{
|
|
108
|
+
"order": ["template", "script", "style"]
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### TypeScript Aware Rules
|
|
116
|
+
|
|
117
|
+
当在项目根目录中找到`tsconfig.eslint.json`时,将启用 Type Aware Rules, [参阅此处](https://github.com/kirklin/eslint-config/blob/master/packages/typescript/index.js#L17).
|
|
118
|
+
|
|
119
|
+
## 徽章
|
|
120
|
+
|
|
121
|
+
在你的 README 中包括一个这样的徽章,以便让人们知道你的代码使用的是哪种 ESLint 样式。
|
|
122
|
+
|
|
123
|
+
[](https://github.com/kirklin/eslint-config/)
|
|
124
|
+
|
|
125
|
+
```markdown
|
|
126
|
+
[](https://github.com/kirklin/eslint-config/)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
[code-style-image]: https://img.shields.io/badge/code__style-%40kirklin%2Feslint--config-brightgreen
|
|
130
|
+
[code-style-url]: https://github.com/kirklin/eslint-config/
|
|
131
|
+
|
|
132
|
+
## 致谢
|
|
133
|
+
|
|
134
|
+
本项目基于 [@antfu/eslint-config](https://github.com/antfu/eslint-config)
|
|
135
|
+
|
|
136
|
+
## 开源协议
|
|
137
|
+
|
|
138
|
+
[MIT](./LICENSE) License © 2019-PRESENT [Kirk Lin](https://github.com/kirklin)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kirklin/eslint-config",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "Kirk Lin's ESLint config",
|
|
5
5
|
"author": "Kirk Lin <linkirk@163.com> (https://github.com/kirklin)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,22 +16,22 @@
|
|
|
16
16
|
"eslint": ">=7.4.0"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
20
|
-
"@typescript-eslint/parser": "^6.
|
|
19
|
+
"@typescript-eslint/eslint-plugin": "^6.5.0",
|
|
20
|
+
"@typescript-eslint/parser": "^6.5.0",
|
|
21
21
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
22
22
|
"eslint-plugin-html": "^7.1.0",
|
|
23
23
|
"eslint-plugin-import": "npm:eslint-plugin-i@2.28.0-2",
|
|
24
24
|
"eslint-plugin-jsonc": "^2.9.0",
|
|
25
|
-
"eslint-plugin-n": "^16.0.
|
|
25
|
+
"eslint-plugin-n": "^16.0.2",
|
|
26
26
|
"eslint-plugin-promise": "^6.1.1",
|
|
27
27
|
"eslint-plugin-unicorn": "^48.0.1",
|
|
28
28
|
"eslint-plugin-vue": "^9.17.0",
|
|
29
29
|
"eslint-plugin-yml": "^1.8.0",
|
|
30
30
|
"jsonc-eslint-parser": "^2.3.0",
|
|
31
31
|
"yaml-eslint-parser": "^1.2.2",
|
|
32
|
-
"@kirklin/eslint-config-vue": "0.5.
|
|
32
|
+
"@kirklin/eslint-config-vue": "0.5.3"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"eslint": "^8.
|
|
35
|
+
"eslint": "^8.48.0"
|
|
36
36
|
}
|
|
37
37
|
}
|