@gsc-basic/eslint-config 1.0.2 → 1.0.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 +187 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# @gsc-basic/eslint-config
|
|
2
|
+
|
|
3
|
+
> ESlint Config for GSC Basic Team
|
|
4
|
+
|
|
5
|
+
**DO NOT use it in your own project if you don't know what it's for**
|
|
6
|
+
|
|
7
|
+
## 说明
|
|
8
|
+
|
|
9
|
+
基于 [@antfu/eslint-config](https://github.com/antfu/eslint-config) 构建。使用更加简单,旨在独立使用,**无需 [Prettier](https://prettier.io/)**。
|
|
10
|
+
|
|
11
|
+
默认用于 `TypeScript`、`Vue`、`Jsx`、`Unocss`、`JSON`、`YAML`、`Toml`、`Markdown`等开箱即用。
|
|
12
|
+
|
|
13
|
+
可选 `React` 支持。
|
|
14
|
+
|
|
15
|
+
**风格原则**:Minimal for reading, stable for diff, consistent。
|
|
16
|
+
|
|
17
|
+
## 使用
|
|
18
|
+
|
|
19
|
+
ESLint v9.12.0+ is now required.
|
|
20
|
+
|
|
21
|
+
`pnpm i -D eslint @gsc-basic/eslint-config`
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
// eslint.config.mjs
|
|
25
|
+
import { gscEslint } from '@gsc-basic/eslint-config';
|
|
26
|
+
|
|
27
|
+
export default gscEslint();
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
// package.json
|
|
32
|
+
{
|
|
33
|
+
"scripts": {
|
|
34
|
+
"lint:eslint": "eslint \"{src,build,scripts,mock}/**/*.{vue,js,mjs,jsx}\" --fix"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 定制
|
|
40
|
+
|
|
41
|
+
- 您可以单独开启或关闭每个集成:
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
// eslint.config.mjs
|
|
45
|
+
import { gscEslint } from '@gsc-basic/eslint-config';
|
|
46
|
+
|
|
47
|
+
export default gscEslint({
|
|
48
|
+
type: 'app', // lib or app, default: app
|
|
49
|
+
unocss: true,
|
|
50
|
+
jsx: true,
|
|
51
|
+
vue: true,
|
|
52
|
+
react: false,
|
|
53
|
+
ignores: [], // 忽略的目录或文件
|
|
54
|
+
|
|
55
|
+
// 还可以配置任意数量的任意自定义配置覆盖
|
|
56
|
+
flatConfig: [
|
|
57
|
+
{
|
|
58
|
+
files: ['**/*.vue'],
|
|
59
|
+
rules: {},
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
rules: {},
|
|
63
|
+
}
|
|
64
|
+
// ...more
|
|
65
|
+
],
|
|
66
|
+
|
|
67
|
+
// ----------------------------------------
|
|
68
|
+
// 因本工具基于 @antfu/eslint-config 构建,所以也支持所有antfu的所有配置
|
|
69
|
+
// !!! 可以覆盖任意预设配置,优先级最高,慎用。
|
|
70
|
+
// ----------------------------------------
|
|
71
|
+
antfu: {
|
|
72
|
+
stylistic: {
|
|
73
|
+
indent: 4, // 2, or 'tab'
|
|
74
|
+
quotes: 'double', // or 'single'
|
|
75
|
+
},
|
|
76
|
+
typescript: false,
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Vue2支持
|
|
82
|
+
|
|
83
|
+
我们对 Vue 2 的支持有限(因为它已经 [达到 EOL](https://v2.vuejs.org/eol/) )。如果您仍在使用 Vue 2,则可以通过设置为手动配置`vueVersion: 2`:
|
|
84
|
+
|
|
85
|
+
```js
|
|
86
|
+
// eslint.config.mjs
|
|
87
|
+
import { gscEslint } from '@gsc-basic/eslint-config';
|
|
88
|
+
|
|
89
|
+
export default gscEslint({
|
|
90
|
+
vue: {
|
|
91
|
+
vueVersion: 2
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### React支持
|
|
97
|
+
|
|
98
|
+
要启用 `React` 支持,您需要明确打开它:
|
|
99
|
+
|
|
100
|
+
```js
|
|
101
|
+
// eslint.config.mjs
|
|
102
|
+
import { gscEslint } from '@gsc-basic/eslint-config';
|
|
103
|
+
|
|
104
|
+
export default gscEslint({
|
|
105
|
+
react: true,
|
|
106
|
+
});
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### lint-staged支持
|
|
110
|
+
|
|
111
|
+
`pnpm i lint-staged -D`
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
// package.json
|
|
115
|
+
{
|
|
116
|
+
"scripts": {
|
|
117
|
+
"lint-staged": "lint-staged"
|
|
118
|
+
},
|
|
119
|
+
"lint-staged": {
|
|
120
|
+
"*.{js,mjs,vue,jsx,json}": [
|
|
121
|
+
"eslint --fix"
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
```shell
|
|
128
|
+
# .husky/pre-commit
|
|
129
|
+
|
|
130
|
+
npm run lint-staged
|
|
131
|
+
|
|
132
|
+
echo Run pre-commit hook done.
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### VS code支持
|
|
136
|
+
|
|
137
|
+
安装 [VS Code ESLint 扩展](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
|
|
138
|
+
|
|
139
|
+
```json
|
|
140
|
+
// .vscode/settings.json
|
|
141
|
+
{
|
|
142
|
+
// Enable the ESlint flat config support
|
|
143
|
+
"eslint.useFlatConfig": true,
|
|
144
|
+
|
|
145
|
+
// Disable the default formatter, use eslint instead
|
|
146
|
+
"prettier.enable": false,
|
|
147
|
+
"editor.formatOnSave": false,
|
|
148
|
+
"editor.formatOnPaste": false,
|
|
149
|
+
|
|
150
|
+
// Auto fix
|
|
151
|
+
"editor.codeActionsOnSave": {
|
|
152
|
+
"source.fixAll.eslint": "explicit",
|
|
153
|
+
"source.organizeImports": "never"
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
// Silent the stylistic rules in you IDE, but still auto fix them
|
|
157
|
+
"eslint.rules.customizations": [
|
|
158
|
+
{ "rule": "style/*", "severity": "off" },
|
|
159
|
+
{ "rule": "format/*", "severity": "off" },
|
|
160
|
+
{ "rule": "*-indent", "severity": "off" },
|
|
161
|
+
{ "rule": "*-spacing", "severity": "off" },
|
|
162
|
+
{ "rule": "*-spaces", "severity": "off" },
|
|
163
|
+
{ "rule": "*-order", "severity": "off" },
|
|
164
|
+
{ "rule": "*-dangle", "severity": "off" },
|
|
165
|
+
{ "rule": "*-newline", "severity": "off" },
|
|
166
|
+
{ "rule": "*quotes", "severity": "off" },
|
|
167
|
+
{ "rule": "*semi", "severity": "off" }
|
|
168
|
+
],
|
|
169
|
+
|
|
170
|
+
// Enable eslint for all supported languages
|
|
171
|
+
"eslint.validate": [
|
|
172
|
+
"javascript",
|
|
173
|
+
"javascriptreact",
|
|
174
|
+
"typescript",
|
|
175
|
+
"typescriptreact",
|
|
176
|
+
"vue",
|
|
177
|
+
"html",
|
|
178
|
+
"markdown",
|
|
179
|
+
"json",
|
|
180
|
+
"jsonc",
|
|
181
|
+
"yaml",
|
|
182
|
+
"toml",
|
|
183
|
+
"gql",
|
|
184
|
+
"graphql"
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
```
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var u=Object.create;var
|
|
1
|
+
var u=Object.create;var s=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var m=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var f=(e,r)=>{for(var n in r)s(e,n,{get:r[n],enumerable:!0})},a=(e,r,n,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of c(r))!d.call(e,o)&&o!==n&&s(e,o,{get:()=>r[o],enumerable:!(t=l(r,o))||t.enumerable});return e};var p=(e,r,n)=>(n=e!=null?u(m(e)):{},a(r||!e||!e.__esModule?s(n,"default",{value:e,enumerable:!0}):n,e)),v=e=>a(s({},"__esModule",{value:!0}),e);var y={};f(y,{gscEslint:()=>g});module.exports=v(y);var i=p(require("@antfu/eslint-config"),1),g=(e={})=>(0,i.default)({type:e.type??"app",unocss:e.unocss??!0,jsx:e.jsx??!0,vue:e.vue??!0,react:e.react??!1,ignores:e.ignores??[],formatters:!0,isInEditor:!0,lessOpinionated:!0,stylistic:{indent:2,quotes:"single",semi:!0,quoteProps:"as-needed"},overrides:{vue:{"vue/html-self-closing":["error",{html:{void:"always",normal:"never",component:"always"},svg:"always",math:"always"}],"vue/attributes-order":2,"vue/order-in-components":2,"vue/v-on-event-hyphenation":["error","always",{autofix:!0,ignore:[]}],"vue/custom-event-name-casing":"off","vue/html-closing-bracket-spacing":"off","vue/multi-word-component-names":"off","vue/no-reserved-component-names":"off","vue/component-name-in-template-casing":"off","vue/max-attributes-per-line":["error",{singleline:{max:2},multiline:{max:1}}],"vue/block-order":["error",{order:[["template","script"],"style"]}]}},...e.antfu??{}},{rules:{"no-undef":2,"no-use-before-define":"off","no-console":2,"no-eval":2,curly:[2,"all"],eqeqeq:[2,"always",{null:"ignore"}],"prefer-promise-reject-errors":0,"sort-imports":0,"no-case-declarations":0,"import/order":0,"unicorn/prefer-dom-node-text-content":0,"style/indent-binary-ops":0,"style/no-tabs":0,"node/no-callback-literal":0,"node/prefer-global/process":0,"jsdoc/check-param-names":0,"jsdoc/require-param-name":0,"jsdoc/require-returns-description":0,"jsdoc/require-returns-check":0,"unicorn/consistent-function-scoping":0,"perfectionist/sort-imports":0,"perfectionist/sort-named-imports":0}},{files:["**/*.jsx"],rules:{"no-unused-vars":0,"unused-imports/no-unused-vars":0}},...e.flatConfig??[]);0&&(module.exports={gscEslint});
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import r from"@antfu/eslint-config";var t=(e={})=>r({type:e.type??"app",unocss:e.unocss??!0,
|
|
1
|
+
import r from"@antfu/eslint-config";var t=(e={})=>r({type:e.type??"app",unocss:e.unocss??!0,jsx:e.jsx??!0,vue:e.vue??!0,react:e.react??!1,ignores:e.ignores??[],formatters:!0,isInEditor:!0,lessOpinionated:!0,stylistic:{indent:2,quotes:"single",semi:!0,quoteProps:"as-needed"},overrides:{vue:{"vue/html-self-closing":["error",{html:{void:"always",normal:"never",component:"always"},svg:"always",math:"always"}],"vue/attributes-order":2,"vue/order-in-components":2,"vue/v-on-event-hyphenation":["error","always",{autofix:!0,ignore:[]}],"vue/custom-event-name-casing":"off","vue/html-closing-bracket-spacing":"off","vue/multi-word-component-names":"off","vue/no-reserved-component-names":"off","vue/component-name-in-template-casing":"off","vue/max-attributes-per-line":["error",{singleline:{max:2},multiline:{max:1}}],"vue/block-order":["error",{order:[["template","script"],"style"]}]}},...e.antfu??{}},{rules:{"no-undef":2,"no-use-before-define":"off","no-console":2,"no-eval":2,curly:[2,"all"],eqeqeq:[2,"always",{null:"ignore"}],"prefer-promise-reject-errors":0,"sort-imports":0,"no-case-declarations":0,"import/order":0,"unicorn/prefer-dom-node-text-content":0,"style/indent-binary-ops":0,"style/no-tabs":0,"node/no-callback-literal":0,"node/prefer-global/process":0,"jsdoc/check-param-names":0,"jsdoc/require-param-name":0,"jsdoc/require-returns-description":0,"jsdoc/require-returns-check":0,"unicorn/consistent-function-scoping":0,"perfectionist/sort-imports":0,"perfectionist/sort-named-imports":0}},{files:["**/*.jsx"],rules:{"no-unused-vars":0,"unused-imports/no-unused-vars":0}},...e.flatConfig??[]);export{t as gscEslint};
|