@cuiqg/eslint-config 2.5.8 → 2.5.9
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/.editorconfig +12 -0
- package/.gitattributes +1 -0
- package/.vscode/settings.json +8 -0
- package/LICENSE +24 -24
- package/README.md +45 -45
- package/bump.config.js +6 -0
- package/eslint-inspector.config.js +7 -0
- package/eslint.config.js +3 -0
- package/package.json +25 -26
- package/pnpm-workspace.yaml +3 -0
- package/src/configs/compat.js +17 -0
- package/src/configs/ignores.js +16 -0
- package/src/configs/index.js +11 -0
- package/src/configs/javascript.js +38 -0
- package/src/configs/jsdoc.js +33 -0
- package/src/configs/macros.js +12 -0
- package/src/configs/package-json.js +29 -0
- package/src/configs/prettier.js +21 -0
- package/src/configs/stylistic.js +24 -0
- package/src/configs/unicorn.js +17 -0
- package/src/configs/unocss.js +19 -0
- package/src/configs/vue.js +143 -0
- package/src/env.js +27 -0
- package/src/globs.js +70 -0
- package/src/index.js +8 -0
- package/src/presets.js +70 -0
- package/src/utils.js +24 -0
- package/tsdown.config.js +9 -0
- package/vercel.json +7 -0
- package/dist/index.js +0 -407
package/.editorconfig
ADDED
package/.gitattributes
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* text=auto eol=lf
|
package/LICENSE
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
This is free and unencumbered software released into the public domain.
|
|
2
|
-
|
|
3
|
-
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
4
|
-
distribute this software, either in source code form or as a compiled
|
|
5
|
-
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
-
means.
|
|
7
|
-
|
|
8
|
-
In jurisdictions that recognize copyright laws, the author or authors
|
|
9
|
-
of this software dedicate any and all copyright interest in the
|
|
10
|
-
software to the public domain. We make this dedication for the benefit
|
|
11
|
-
of the public at large and to the detriment of our heirs and
|
|
12
|
-
successors. We intend this dedication to be an overt act of
|
|
13
|
-
relinquishment in perpetuity of all present and future rights to this
|
|
14
|
-
software under copyright law.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
-
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
-
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
-
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
-
OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
-
|
|
24
|
-
For more information, please refer to <https://unlicense.org/>
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
4
|
+
distribute this software, either in source code form or as a compiled
|
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
+
means.
|
|
7
|
+
|
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
|
9
|
+
of this software dedicate any and all copyright interest in the
|
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
|
11
|
+
of the public at large and to the detriment of our heirs and
|
|
12
|
+
successors. We intend this dedication to be an overt act of
|
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
|
14
|
+
software under copyright law.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
|
24
|
+
For more information, please refer to <https://unlicense.org/>
|
package/README.md
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
# @cuiqg/eslint-config [](https://npmmirror.com/package/@cuiqg/eslint-config)
|
|
2
|
-
|
|
3
|
-
## 使用
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
npm i -D eslint @cuiqg/eslint-config
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
修改 `package.json` 文件
|
|
10
|
-
|
|
11
|
-
```diff
|
|
12
|
-
{
|
|
13
|
-
+ "type": "module",
|
|
14
|
-
"scripts": {
|
|
15
|
-
+ "lint": "eslint .",
|
|
16
|
-
+ "lint:fix": "eslint . --fix"
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
创建 `eslint.config.js` 文件
|
|
22
|
-
|
|
23
|
-
```js
|
|
24
|
-
import cuiqg from '@cuiqg/eslint-config'
|
|
25
|
-
|
|
26
|
-
export default cuiqg()
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## 插件配置
|
|
30
|
-
|
|
31
|
-
安装 [VS Code ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
|
|
32
|
-
|
|
33
|
-
创建配置文件 `.vscode/settings.json`
|
|
34
|
-
|
|
35
|
-
```json
|
|
36
|
-
{
|
|
37
|
-
"prettier.enable": false,
|
|
38
|
-
"editor.formatOnSave": false,
|
|
39
|
-
"eslint.useFlatConfig": true,
|
|
40
|
-
"editor.codeActionsOnSave": {
|
|
41
|
-
"source.fixAll.eslint": "explicit",
|
|
42
|
-
"source.organizeImports": "never"
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
```
|
|
1
|
+
# @cuiqg/eslint-config [](https://npmmirror.com/package/@cuiqg/eslint-config)
|
|
2
|
+
|
|
3
|
+
## 使用
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm i -D eslint @cuiqg/eslint-config
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
修改 `package.json` 文件
|
|
10
|
+
|
|
11
|
+
```diff
|
|
12
|
+
{
|
|
13
|
+
+ "type": "module",
|
|
14
|
+
"scripts": {
|
|
15
|
+
+ "lint": "eslint .",
|
|
16
|
+
+ "lint:fix": "eslint . --fix"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
创建 `eslint.config.js` 文件
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
import cuiqg from '@cuiqg/eslint-config'
|
|
25
|
+
|
|
26
|
+
export default cuiqg()
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 插件配置
|
|
30
|
+
|
|
31
|
+
安装 [VS Code ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
|
|
32
|
+
|
|
33
|
+
创建配置文件 `.vscode/settings.json`
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"prettier.enable": false,
|
|
38
|
+
"editor.formatOnSave": false,
|
|
39
|
+
"eslint.useFlatConfig": true,
|
|
40
|
+
"editor.codeActionsOnSave": {
|
|
41
|
+
"source.fixAll.eslint": "explicit",
|
|
42
|
+
"source.organizeImports": "never"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
package/bump.config.js
ADDED
package/eslint.config.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cuiqg/eslint-config",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.9",
|
|
4
4
|
"description": "Eslint config for @cuiqg",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint-config"
|
|
@@ -14,44 +14,43 @@
|
|
|
14
14
|
"license": "Unlicense",
|
|
15
15
|
"author": "Tsuiqg <i@tsuiqg.me>",
|
|
16
16
|
"type": "module",
|
|
17
|
+
"main": "./dist/index.mjs",
|
|
18
|
+
"module": "./dist/index.mjs",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": "./dist/index.mjs",
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
17
23
|
"devDependencies": {
|
|
18
24
|
"@cuiqg/prettier-config": "latest",
|
|
19
|
-
"@eslint/config-inspector": "^1.
|
|
20
|
-
"@eslint/eslintrc": "^3.3.
|
|
21
|
-
"bumpp": "^10.
|
|
22
|
-
"eslint": "^9.
|
|
23
|
-
"
|
|
24
|
-
"tsdown": "^0.13.3"
|
|
25
|
+
"@eslint/config-inspector": "^1.4.2",
|
|
26
|
+
"@eslint/eslintrc": "^3.3.3",
|
|
27
|
+
"bumpp": "^10.3.2",
|
|
28
|
+
"eslint": "^9.39.1",
|
|
29
|
+
"tsdown": "^0.16.8"
|
|
25
30
|
},
|
|
26
31
|
"peerDependencies": {
|
|
27
32
|
"eslint": ">=9.28.0"
|
|
28
33
|
},
|
|
29
34
|
"dependencies": {
|
|
30
|
-
"@eslint/js": "^9.
|
|
31
|
-
"@stylistic/eslint-plugin": "^5.
|
|
32
|
-
"@unocss/eslint-plugin": "^66.
|
|
35
|
+
"@eslint/js": "^9.39.1",
|
|
36
|
+
"@stylistic/eslint-plugin": "^5.6.1",
|
|
37
|
+
"@unocss/eslint-plugin": "^66.5.9",
|
|
33
38
|
"@vue-macros/eslint-config": "3.0.0-beta.21",
|
|
34
39
|
"eslint-config-flat-gitignore": "^2.1.0",
|
|
35
40
|
"eslint-config-prettier": "^10.1.8",
|
|
36
|
-
"eslint-flat-config-utils": "^2.1.
|
|
37
|
-
"eslint-plugin-
|
|
38
|
-
"eslint-plugin-
|
|
39
|
-
"eslint-plugin-
|
|
41
|
+
"eslint-flat-config-utils": "^2.1.4",
|
|
42
|
+
"eslint-plugin-compat": "^6.0.2",
|
|
43
|
+
"eslint-plugin-jsdoc": "^61.4.1",
|
|
44
|
+
"eslint-plugin-package-json": "^0.85.0",
|
|
45
|
+
"eslint-plugin-perfectionist": "^4.15.1",
|
|
40
46
|
"eslint-plugin-prettier": "^5.5.4",
|
|
41
|
-
"eslint-plugin-unicorn": "^
|
|
42
|
-
"eslint-plugin-vue": "^10.
|
|
43
|
-
"globals": "^16.
|
|
44
|
-
"jsonc-eslint-parser": "^2.4.
|
|
45
|
-
"local-pkg": "^1.1.
|
|
47
|
+
"eslint-plugin-unicorn": "^62.0.0",
|
|
48
|
+
"eslint-plugin-vue": "^10.6.2",
|
|
49
|
+
"globals": "^16.5.0",
|
|
50
|
+
"jsonc-eslint-parser": "^2.4.1",
|
|
51
|
+
"local-pkg": "^1.1.2",
|
|
46
52
|
"vue-eslint-parser": "^10.2.0"
|
|
47
53
|
},
|
|
48
|
-
"main": "./dist/index.js",
|
|
49
|
-
"exports": {
|
|
50
|
-
".": "./dist/index.js"
|
|
51
|
-
},
|
|
52
|
-
"files": [
|
|
53
|
-
"./dist"
|
|
54
|
-
],
|
|
55
54
|
"scripts": {
|
|
56
55
|
"build": "tsdown",
|
|
57
56
|
"dev": "tsdown --watch",
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { interopDefault } from '../utils'
|
|
2
|
+
|
|
3
|
+
export async function compat() {
|
|
4
|
+
const pluginCompat = await interopDefault(import('eslint-plugin-compat'))
|
|
5
|
+
|
|
6
|
+
return [
|
|
7
|
+
{
|
|
8
|
+
name: 'cuiqg/compat',
|
|
9
|
+
plugins: {
|
|
10
|
+
compat: pluginCompat
|
|
11
|
+
},
|
|
12
|
+
rules: {
|
|
13
|
+
...pluginCompat.configs.recommended.rules
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { GLOB_EXCLUDE } from '../globs'
|
|
2
|
+
import { interopDefault } from '../utils'
|
|
3
|
+
export async function ignores() {
|
|
4
|
+
const configGitignore = await interopDefault(import('eslint-config-flat-gitignore'))
|
|
5
|
+
|
|
6
|
+
return [
|
|
7
|
+
{
|
|
8
|
+
ignores: [...GLOB_EXCLUDE],
|
|
9
|
+
name: 'cuiqg/ignores'
|
|
10
|
+
},
|
|
11
|
+
configGitignore({
|
|
12
|
+
name: 'cuiqg/gitignore',
|
|
13
|
+
strict: false
|
|
14
|
+
})
|
|
15
|
+
]
|
|
16
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './ignores'
|
|
2
|
+
export * from './javascript'
|
|
3
|
+
export * from './jsdoc'
|
|
4
|
+
export * from './macros'
|
|
5
|
+
export * from './package-json'
|
|
6
|
+
export * from './prettier'
|
|
7
|
+
export * from './stylistic'
|
|
8
|
+
export * from './unocss'
|
|
9
|
+
export * from './vue'
|
|
10
|
+
export * from './compat'
|
|
11
|
+
export * from './unicorn'
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import globals from 'globals'
|
|
2
|
+
import { interopDefault } from '../utils'
|
|
3
|
+
export async function javascript() {
|
|
4
|
+
const [pluginJs] = await Promise.all([
|
|
5
|
+
interopDefault(import('@eslint/js'))
|
|
6
|
+
])
|
|
7
|
+
|
|
8
|
+
return [
|
|
9
|
+
{
|
|
10
|
+
languageOptions: {
|
|
11
|
+
ecmaVersion: 'latest',
|
|
12
|
+
globals: {
|
|
13
|
+
...globals.browser,
|
|
14
|
+
...globals.es2025,
|
|
15
|
+
...globals.node
|
|
16
|
+
},
|
|
17
|
+
parserOptions: {
|
|
18
|
+
ecmaFeatures: {
|
|
19
|
+
jsx: true
|
|
20
|
+
},
|
|
21
|
+
ecmaVersion: 'latest',
|
|
22
|
+
sourceType: 'module'
|
|
23
|
+
},
|
|
24
|
+
sourceType: 'module'
|
|
25
|
+
},
|
|
26
|
+
linterOptions: {
|
|
27
|
+
reportUnusedDisableDirectives: true
|
|
28
|
+
},
|
|
29
|
+
name: 'cuiqg/javascript',
|
|
30
|
+
plugins: {
|
|
31
|
+
js: pluginJs
|
|
32
|
+
},
|
|
33
|
+
rules: {
|
|
34
|
+
...pluginJs.configs.recommended.rules
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { interopDefault } from '../utils'
|
|
2
|
+
|
|
3
|
+
export async function jsdoc() {
|
|
4
|
+
const pluginJsdoc = await interopDefault(import('eslint-plugin-jsdoc'))
|
|
5
|
+
|
|
6
|
+
return [
|
|
7
|
+
{
|
|
8
|
+
name: 'cuiqg/jsdoc',
|
|
9
|
+
plugins: {
|
|
10
|
+
jsdoc: pluginJsdoc
|
|
11
|
+
},
|
|
12
|
+
rules: {
|
|
13
|
+
'jsdoc/check-access': 'warn',
|
|
14
|
+
'jsdoc/check-param-names': 'warn',
|
|
15
|
+
'jsdoc/check-property-names': 'warn',
|
|
16
|
+
'jsdoc/check-types': 'warn',
|
|
17
|
+
'jsdoc/empty-tags': 'warn',
|
|
18
|
+
'jsdoc/implements-on-classes': 'warn',
|
|
19
|
+
'jsdoc/no-defaults': 'warn',
|
|
20
|
+
'jsdoc/no-multi-asterisks': 'warn',
|
|
21
|
+
'jsdoc/require-param-name': 'warn',
|
|
22
|
+
'jsdoc/require-property': 'warn',
|
|
23
|
+
'jsdoc/require-property-description': 'warn',
|
|
24
|
+
'jsdoc/require-property-name': 'warn',
|
|
25
|
+
'jsdoc/require-returns-check': 'warn',
|
|
26
|
+
'jsdoc/require-returns-description': 'warn',
|
|
27
|
+
'jsdoc/require-yields-check': 'warn',
|
|
28
|
+
'jsdoc/check-alignment': 'warn',
|
|
29
|
+
'jsdoc/multiline-blocks': 'warn'
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { interopDefault } from '../utils'
|
|
2
|
+
|
|
3
|
+
export async function packageJson() {
|
|
4
|
+
const [pluginPackageJson, parserJsonc] = await Promise.all([
|
|
5
|
+
interopDefault(import('eslint-plugin-package-json')),
|
|
6
|
+
interopDefault(import('jsonc-eslint-parser'))
|
|
7
|
+
])
|
|
8
|
+
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
files: ['**/package.json'],
|
|
12
|
+
languageOptions: {
|
|
13
|
+
parser: parserJsonc
|
|
14
|
+
},
|
|
15
|
+
name: 'cuiqg/package-json',
|
|
16
|
+
plugins: {
|
|
17
|
+
'package-json': pluginPackageJson
|
|
18
|
+
},
|
|
19
|
+
rules: {
|
|
20
|
+
...pluginPackageJson.configs.recommended.rules
|
|
21
|
+
},
|
|
22
|
+
settings: {
|
|
23
|
+
packageJson: {
|
|
24
|
+
enforceForPrivate: false
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { interopDefault } from '../utils'
|
|
2
|
+
|
|
3
|
+
export async function prettier() {
|
|
4
|
+
const [pluginPrettier, recommendedPrettier] = await Promise.all([
|
|
5
|
+
interopDefault(import('eslint-plugin-prettier')),
|
|
6
|
+
interopDefault(import('eslint-plugin-prettier/recommended'))
|
|
7
|
+
])
|
|
8
|
+
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
name: 'cuiqg/prettier',
|
|
12
|
+
plugins: {
|
|
13
|
+
prettier: pluginPrettier
|
|
14
|
+
},
|
|
15
|
+
rules: {
|
|
16
|
+
...recommendedPrettier.rules,
|
|
17
|
+
'prettier/prettier': 'warn'
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { interopDefault } from '../utils'
|
|
2
|
+
|
|
3
|
+
export async function stylistic() {
|
|
4
|
+
const pluginStylistic = await interopDefault(import('@stylistic/eslint-plugin'))
|
|
5
|
+
|
|
6
|
+
const config = pluginStylistic.configs.customize({
|
|
7
|
+
commaDangle: 'never',
|
|
8
|
+
indent: 2,
|
|
9
|
+
pluginName: 'style',
|
|
10
|
+
quotes: 'single',
|
|
11
|
+
semi: false
|
|
12
|
+
})
|
|
13
|
+
return [
|
|
14
|
+
{
|
|
15
|
+
name: 'cuiqg/stylistic',
|
|
16
|
+
plugins: {
|
|
17
|
+
style: pluginStylistic
|
|
18
|
+
},
|
|
19
|
+
rules: {
|
|
20
|
+
...config.rules
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { interopDefault } from '../utils'
|
|
2
|
+
|
|
3
|
+
export async function unicorn() {
|
|
4
|
+
const pluginUnicorn = await interopDefault(import('eslint-plugin-unicorn'))
|
|
5
|
+
|
|
6
|
+
return [
|
|
7
|
+
{
|
|
8
|
+
name: 'cuiqg/unicorn',
|
|
9
|
+
plugins: {
|
|
10
|
+
unicorn: pluginUnicorn
|
|
11
|
+
},
|
|
12
|
+
rules: {
|
|
13
|
+
...pluginUnicorn.configs?.recommended?.rules
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { interopDefault, renameRules } from '../utils'
|
|
2
|
+
|
|
3
|
+
export async function unocss() {
|
|
4
|
+
const pluginUnoCSS = await interopDefault(import('@unocss/eslint-plugin'))
|
|
5
|
+
|
|
6
|
+
return [
|
|
7
|
+
{
|
|
8
|
+
name: 'cuiqg/unocss',
|
|
9
|
+
plugins: {
|
|
10
|
+
unocss: pluginUnoCSS
|
|
11
|
+
},
|
|
12
|
+
rules: {
|
|
13
|
+
...renameRules(pluginUnoCSS.configs.recommended.rules, {
|
|
14
|
+
'@unocss': 'unocss'
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { GLOB_VUE } from '../globs'
|
|
2
|
+
import { interopDefault } from '../utils'
|
|
3
|
+
|
|
4
|
+
export async function vue() {
|
|
5
|
+
const files = [GLOB_VUE]
|
|
6
|
+
|
|
7
|
+
const [pluginVue, parserVue] = await Promise.all([
|
|
8
|
+
interopDefault(import('eslint-plugin-vue')),
|
|
9
|
+
interopDefault(import('vue-eslint-parser'))
|
|
10
|
+
])
|
|
11
|
+
|
|
12
|
+
return [
|
|
13
|
+
{
|
|
14
|
+
files,
|
|
15
|
+
languageOptions: {
|
|
16
|
+
globals: {
|
|
17
|
+
computed: 'readonly',
|
|
18
|
+
defineEmits: 'readonly',
|
|
19
|
+
defineExpose: 'readonly',
|
|
20
|
+
defineModel: 'readonly',
|
|
21
|
+
defineOptions: 'readonly',
|
|
22
|
+
defineProps: 'readonly',
|
|
23
|
+
defineSlots: 'readonly',
|
|
24
|
+
onActivated: 'readonly',
|
|
25
|
+
onDeactivated: 'readonly',
|
|
26
|
+
onMounted: 'readonly',
|
|
27
|
+
onUnmounted: 'readonly',
|
|
28
|
+
reactive: 'readonly',
|
|
29
|
+
ref: 'readonly',
|
|
30
|
+
toRef: 'readonly',
|
|
31
|
+
toRefs: 'readonly',
|
|
32
|
+
useAttrs: 'readonly',
|
|
33
|
+
useSlots: 'readonly',
|
|
34
|
+
watch: 'readonly',
|
|
35
|
+
watchEffect: 'readonly'
|
|
36
|
+
},
|
|
37
|
+
parser: parserVue,
|
|
38
|
+
parserOptions: {
|
|
39
|
+
ecmaFeatures: {
|
|
40
|
+
jsx: true
|
|
41
|
+
},
|
|
42
|
+
extraFileExtensions: ['.vue'],
|
|
43
|
+
parser: null,
|
|
44
|
+
sourceType: 'module'
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
name: 'cuiqg/vue',
|
|
48
|
+
plugins: {
|
|
49
|
+
vue: pluginVue
|
|
50
|
+
},
|
|
51
|
+
processor: pluginVue.processors['.vue'],
|
|
52
|
+
rules: {
|
|
53
|
+
...(pluginVue.configs['flat/recommended']
|
|
54
|
+
.map(c => c.rules)
|
|
55
|
+
.reduce((acc, c) => ({ ...acc, ...c }), {})),
|
|
56
|
+
|
|
57
|
+
'node/prefer-global/process': 'off',
|
|
58
|
+
'vue/array-bracket-spacing': ['error', 'never'],
|
|
59
|
+
'vue/arrow-spacing': ['error', { after: true, before: true }],
|
|
60
|
+
'vue/block-order': [
|
|
61
|
+
'error',
|
|
62
|
+
{
|
|
63
|
+
order: ['script', 'template', 'style']
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
'vue/block-spacing': ['error', 'always'],
|
|
67
|
+
'vue/block-tag-newline': [
|
|
68
|
+
'error',
|
|
69
|
+
{
|
|
70
|
+
multiline: 'always',
|
|
71
|
+
singleline: 'always'
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
'vue/brace-style': ['error', 'stroustrup', { allowSingleLine: true }],
|
|
75
|
+
'vue/comma-dangle': ['error', 'always-multiline'],
|
|
76
|
+
'vue/comma-spacing': ['error', { after: true, before: false }],
|
|
77
|
+
'vue/comma-style': ['error', 'last'],
|
|
78
|
+
'vue/custom-event-name-casing': ['error', 'camelCase'],
|
|
79
|
+
'vue/define-macros-order': [
|
|
80
|
+
'error',
|
|
81
|
+
{
|
|
82
|
+
order: ['defineOptions', 'defineProps', 'defineEmits', 'defineSlots']
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
'vue/dot-location': ['error', 'property'],
|
|
86
|
+
'vue/dot-notation': ['error', { allowKeywords: true }],
|
|
87
|
+
'vue/eqeqeq': ['error', 'smart'],
|
|
88
|
+
'vue/html-comment-content-spacing': [
|
|
89
|
+
'error',
|
|
90
|
+
'always',
|
|
91
|
+
{
|
|
92
|
+
exceptions: ['-']
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
'vue/html-indent': ['error', 2],
|
|
96
|
+
'vue/html-quotes': ['error', 'double'],
|
|
97
|
+
'vue/key-spacing': ['error', { afterColon: true, beforeColon: false }],
|
|
98
|
+
'vue/keyword-spacing': ['error', { after: true, before: true }],
|
|
99
|
+
'vue/max-attributes-per-line': 'off',
|
|
100
|
+
'vue/multi-word-component-names': 'off',
|
|
101
|
+
'vue/no-dupe-keys': 'off',
|
|
102
|
+
'vue/no-empty-pattern': 'error',
|
|
103
|
+
'vue/no-irregular-whitespace': 'error',
|
|
104
|
+
'vue/no-loss-of-precision': 'error',
|
|
105
|
+
'vue/no-restricted-syntax': [
|
|
106
|
+
'error',
|
|
107
|
+
'DebuggerStatement',
|
|
108
|
+
'LabeledStatement',
|
|
109
|
+
'WithStatement'
|
|
110
|
+
],
|
|
111
|
+
'vue/no-restricted-v-bind': ['error', '/^v-/'],
|
|
112
|
+
'vue/no-setup-props-reactivity-loss': 'off',
|
|
113
|
+
'vue/no-sparse-arrays': 'error',
|
|
114
|
+
'vue/no-unused-refs': 'error',
|
|
115
|
+
'vue/no-useless-v-bind': 'error',
|
|
116
|
+
'vue/no-v-html': 'off',
|
|
117
|
+
'vue/object-curly-newline': 'off',
|
|
118
|
+
'vue/object-curly-spacing': ['error', 'always'],
|
|
119
|
+
'vue/object-property-newline': ['error', { allowAllPropertiesOnSameLine: true }],
|
|
120
|
+
'vue/object-shorthand': [
|
|
121
|
+
'error',
|
|
122
|
+
'always',
|
|
123
|
+
{
|
|
124
|
+
avoidQuotes: true,
|
|
125
|
+
ignoreConstructors: false
|
|
126
|
+
}
|
|
127
|
+
],
|
|
128
|
+
'vue/operator-linebreak': ['error', 'before'],
|
|
129
|
+
'vue/padding-line-between-blocks': ['error', 'always'],
|
|
130
|
+
'vue/prefer-separate-static-class': 'error',
|
|
131
|
+
'vue/prefer-template': 'error',
|
|
132
|
+
'vue/prop-name-casing': ['error', 'camelCase'],
|
|
133
|
+
'vue/quote-props': ['error', 'consistent-as-needed'],
|
|
134
|
+
'vue/require-default-prop': 'off',
|
|
135
|
+
'vue/require-prop-types': 'off',
|
|
136
|
+
'vue/space-in-parens': ['error', 'never'],
|
|
137
|
+
'vue/space-infix-ops': 'error',
|
|
138
|
+
'vue/space-unary-ops': ['error', { nonwords: false, words: true }],
|
|
139
|
+
'vue/template-curly-spacing': 'error'
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
}
|
package/src/env.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { isPackageExists } from 'local-pkg'
|
|
3
|
+
|
|
4
|
+
export const isInGitHookOrLintStaged = () => {
|
|
5
|
+
return !!(
|
|
6
|
+
process.env.GIT_PARAMS
|
|
7
|
+
|| process.env.VSCODE_GIT_COMMAND
|
|
8
|
+
|| process.env.npm_lifecycle_script?.startsWith('lint-staged')
|
|
9
|
+
)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const isInEditor = () => {
|
|
13
|
+
if (process.env.CI) return false
|
|
14
|
+
if (isInGitHookOrLintStaged()) return false
|
|
15
|
+
return !!(
|
|
16
|
+
process.env.VSCODE_PID
|
|
17
|
+
|| process.env.VSCODE_CWD
|
|
18
|
+
|| process.env.JETBRAINS_IDE
|
|
19
|
+
|| process.env.VIM
|
|
20
|
+
|| process.env.NVIM
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const hasVue = () =>
|
|
25
|
+
['vue', 'nuxt', 'vitepress', '@slidev/cli'].some(i => isPackageExists(i))
|
|
26
|
+
export const hasTypeScript = () => isPackageExists('typescript')
|
|
27
|
+
export const hasUnoCss = () => isPackageExists('unocss')
|
package/src/globs.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export const GLOB_SRC_EXT = '?([cm])[jt]s?(x)'
|
|
2
|
+
export const GLOB_SRC = `**/*.${GLOB_SRC_EXT}`
|
|
3
|
+
|
|
4
|
+
export const GLOB_TS = `**/*.?([cm])ts`
|
|
5
|
+
export const GLOB_TSX = `**/*.?([cm])tsx`
|
|
6
|
+
|
|
7
|
+
export const GLOB_JS = `**/*.?([cm])js`
|
|
8
|
+
export const GLOB_JSX = `**/*.?([cm])jsx`
|
|
9
|
+
|
|
10
|
+
export const GLOB_STYLE = '**/*.{c,le,sc}ss'
|
|
11
|
+
export const GLOB_CSS = '**/*.css'
|
|
12
|
+
export const GLOB_SCSS = '**/*.scss'
|
|
13
|
+
export const GLOB_LESS = '**/*.less'
|
|
14
|
+
export const GLOB_STYLUS = '**/*.styl'
|
|
15
|
+
export const GLOB_POSTCSS = '**/*.{p,post}css'
|
|
16
|
+
|
|
17
|
+
export const GLOB_JSON = '**/*.json'
|
|
18
|
+
export const GLOB_JSON5 = '**/*.json5'
|
|
19
|
+
export const GLOB_JSONC = '**/*.jsonc'
|
|
20
|
+
|
|
21
|
+
export const GLOB_MARKDOWN = '**/*.md'
|
|
22
|
+
export const GLOB_VUE = '**/*.vue'
|
|
23
|
+
export const GLOB_YAML = '**/*.y?(a)ml'
|
|
24
|
+
export const GLOB_TOML = '**/*.toml'
|
|
25
|
+
export const GLOB_XML = '**/*.xml'
|
|
26
|
+
export const GLOB_SVG = '**/*.svg'
|
|
27
|
+
export const GLOB_HTML = '**/*.htm?(l)'
|
|
28
|
+
|
|
29
|
+
export const GLOB_EXCLUDE = [
|
|
30
|
+
'**/node_modules',
|
|
31
|
+
'**/dist',
|
|
32
|
+
'**/package-lock.json',
|
|
33
|
+
'**/yarn.lock',
|
|
34
|
+
'**/pnpm-lock.yaml',
|
|
35
|
+
'**/bun.lockb',
|
|
36
|
+
|
|
37
|
+
'**/output',
|
|
38
|
+
'**/coverage',
|
|
39
|
+
'**/temp',
|
|
40
|
+
'**/.temp',
|
|
41
|
+
'**/tmp',
|
|
42
|
+
'**/.tmp',
|
|
43
|
+
'**/.history',
|
|
44
|
+
'**/.vitepress/cache',
|
|
45
|
+
'**/.nuxt',
|
|
46
|
+
'**/.next',
|
|
47
|
+
'**/.svelte-kit',
|
|
48
|
+
'**/.vercel',
|
|
49
|
+
'**/.changeset',
|
|
50
|
+
'**/.idea',
|
|
51
|
+
'**/.DS_Store',
|
|
52
|
+
'**/Thumbs.db',
|
|
53
|
+
'**/ehthumbs.db',
|
|
54
|
+
'**/Desktop.ini',
|
|
55
|
+
'**/$RECYCLE.BIN',
|
|
56
|
+
'**/.cache',
|
|
57
|
+
'**/.output',
|
|
58
|
+
'**/.vite-inspect',
|
|
59
|
+
'**/.yarn',
|
|
60
|
+
'**/vite.config.*.timestamp-*',
|
|
61
|
+
|
|
62
|
+
'**/CHANGELOG*.md',
|
|
63
|
+
'**/*.min.*',
|
|
64
|
+
'**/LICENSE*',
|
|
65
|
+
'**/__snapshots__',
|
|
66
|
+
'**/auto-import?(s).d.ts',
|
|
67
|
+
'**/components.d.ts',
|
|
68
|
+
'**/typed-router.d.ts',
|
|
69
|
+
'**/.eslint-config-inspector'
|
|
70
|
+
]
|
package/src/index.js
ADDED
package/src/presets.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { FlatConfigComposer } from 'eslint-flat-config-utils'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
compat,
|
|
5
|
+
ignores,
|
|
6
|
+
javascript,
|
|
7
|
+
jsdoc,
|
|
8
|
+
macros,
|
|
9
|
+
packageJson,
|
|
10
|
+
prettier,
|
|
11
|
+
stylistic,
|
|
12
|
+
unocss,
|
|
13
|
+
vue,
|
|
14
|
+
unicorn
|
|
15
|
+
} from './configs'
|
|
16
|
+
|
|
17
|
+
import { hasUnoCss, hasVue } from './env'
|
|
18
|
+
|
|
19
|
+
export const defaultPluginRenaming = {
|
|
20
|
+
'@stylistic': 'style'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @param {object} options - 设置选项
|
|
26
|
+
* @param {...any} userConfigs - 用户配置
|
|
27
|
+
* @returns {Promise<any[]>} 合并后的配置
|
|
28
|
+
*/
|
|
29
|
+
export function cuiqg(
|
|
30
|
+
options = {},
|
|
31
|
+
...userConfigs
|
|
32
|
+
) {
|
|
33
|
+
const {
|
|
34
|
+
prettier: enablePrettier = false,
|
|
35
|
+
unocss: enableUnocss = hasUnoCss(),
|
|
36
|
+
vue: enableVue = hasVue()
|
|
37
|
+
} = options
|
|
38
|
+
|
|
39
|
+
const configs = []
|
|
40
|
+
|
|
41
|
+
configs.push(
|
|
42
|
+
compat(),
|
|
43
|
+
ignores(),
|
|
44
|
+
javascript(),
|
|
45
|
+
jsdoc(),
|
|
46
|
+
stylistic(),
|
|
47
|
+
packageJson(),
|
|
48
|
+
unicorn()
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
if (enableVue) {
|
|
52
|
+
configs.push(vue(), macros())
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (enableUnocss) {
|
|
56
|
+
configs.push(unocss())
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (enablePrettier) {
|
|
60
|
+
configs.push(prettier())
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
let composer = new FlatConfigComposer()
|
|
64
|
+
|
|
65
|
+
composer = composer
|
|
66
|
+
.append(...configs, ...userConfigs)
|
|
67
|
+
.renamePlugins(defaultPluginRenaming)
|
|
68
|
+
|
|
69
|
+
return composer
|
|
70
|
+
}
|
package/src/utils.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export async function interopDefault(
|
|
2
|
+
module
|
|
3
|
+
) {
|
|
4
|
+
try {
|
|
5
|
+
let resolved = await module
|
|
6
|
+
return resolved?.default || resolved
|
|
7
|
+
}
|
|
8
|
+
catch (error) {
|
|
9
|
+
throw new Error(`Cannot import module: ${String(error)}`)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function renameRules(rules, map) {
|
|
14
|
+
return Object.fromEntries(
|
|
15
|
+
Object.entries(rules).map(([key, value]) => {
|
|
16
|
+
for (const [from, to] of Object.entries(map)) {
|
|
17
|
+
if (key.startsWith(`${from}/`)) {
|
|
18
|
+
return [to + key.slice(from.length), value]
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return [key, value]
|
|
22
|
+
})
|
|
23
|
+
)
|
|
24
|
+
}
|
package/tsdown.config.js
ADDED
package/vercel.json
ADDED
package/dist/index.js
DELETED
|
@@ -1,407 +0,0 @@
|
|
|
1
|
-
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
2
|
-
import globals from "globals";
|
|
3
|
-
import process from "node:process";
|
|
4
|
-
import { isPackageExists } from "local-pkg";
|
|
5
|
-
|
|
6
|
-
//#region src/globs.js
|
|
7
|
-
const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
8
|
-
const GLOB_SRC = `**/*.${GLOB_SRC_EXT}`;
|
|
9
|
-
const GLOB_TS = `**/*.?([cm])ts`;
|
|
10
|
-
const GLOB_TSX = `**/*.?([cm])tsx`;
|
|
11
|
-
const GLOB_JS = `**/*.?([cm])js`;
|
|
12
|
-
const GLOB_JSX = `**/*.?([cm])jsx`;
|
|
13
|
-
const GLOB_STYLE = "**/*.{c,le,sc}ss";
|
|
14
|
-
const GLOB_CSS = "**/*.css";
|
|
15
|
-
const GLOB_SCSS = "**/*.scss";
|
|
16
|
-
const GLOB_LESS = "**/*.less";
|
|
17
|
-
const GLOB_STYLUS = "**/*.styl";
|
|
18
|
-
const GLOB_POSTCSS = "**/*.{p,post}css";
|
|
19
|
-
const GLOB_JSON = "**/*.json";
|
|
20
|
-
const GLOB_JSON5 = "**/*.json5";
|
|
21
|
-
const GLOB_JSONC = "**/*.jsonc";
|
|
22
|
-
const GLOB_MARKDOWN = "**/*.md";
|
|
23
|
-
const GLOB_VUE = "**/*.vue";
|
|
24
|
-
const GLOB_YAML = "**/*.y?(a)ml";
|
|
25
|
-
const GLOB_TOML = "**/*.toml";
|
|
26
|
-
const GLOB_XML = "**/*.xml";
|
|
27
|
-
const GLOB_SVG = "**/*.svg";
|
|
28
|
-
const GLOB_HTML = "**/*.htm?(l)";
|
|
29
|
-
const GLOB_EXCLUDE = [
|
|
30
|
-
"**/node_modules",
|
|
31
|
-
"**/dist",
|
|
32
|
-
"**/package-lock.json",
|
|
33
|
-
"**/yarn.lock",
|
|
34
|
-
"**/pnpm-lock.yaml",
|
|
35
|
-
"**/bun.lockb",
|
|
36
|
-
"**/output",
|
|
37
|
-
"**/coverage",
|
|
38
|
-
"**/temp",
|
|
39
|
-
"**/.temp",
|
|
40
|
-
"**/tmp",
|
|
41
|
-
"**/.tmp",
|
|
42
|
-
"**/.history",
|
|
43
|
-
"**/.vitepress/cache",
|
|
44
|
-
"**/.nuxt",
|
|
45
|
-
"**/.next",
|
|
46
|
-
"**/.svelte-kit",
|
|
47
|
-
"**/.vercel",
|
|
48
|
-
"**/.changeset",
|
|
49
|
-
"**/.idea",
|
|
50
|
-
"**/.cache",
|
|
51
|
-
"**/.output",
|
|
52
|
-
"**/.vite-inspect",
|
|
53
|
-
"**/.yarn",
|
|
54
|
-
"**/vite.config.*.timestamp-*",
|
|
55
|
-
"**/CHANGELOG*.md",
|
|
56
|
-
"**/*.min.*",
|
|
57
|
-
"**/LICENSE*",
|
|
58
|
-
"**/__snapshots__",
|
|
59
|
-
"**/auto-import?(s).d.ts",
|
|
60
|
-
"**/components.d.ts",
|
|
61
|
-
"**/typed-router.d.ts",
|
|
62
|
-
"**/.eslint-config-inspector"
|
|
63
|
-
];
|
|
64
|
-
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region src/utils.js
|
|
67
|
-
async function interopDefault(module) {
|
|
68
|
-
try {
|
|
69
|
-
let resolved = await module;
|
|
70
|
-
return resolved?.default || resolved;
|
|
71
|
-
} catch (error) {
|
|
72
|
-
throw new Error(`Cannot import module: ${String(error)}`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
function renameRules(rules, map) {
|
|
76
|
-
return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
|
|
77
|
-
for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
|
|
78
|
-
return [key, value];
|
|
79
|
-
}));
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
//#endregion
|
|
83
|
-
//#region src/configs/ignores.js
|
|
84
|
-
async function ignores() {
|
|
85
|
-
const configGitignore = await interopDefault(import("eslint-config-flat-gitignore"));
|
|
86
|
-
return [{
|
|
87
|
-
ignores: [...GLOB_EXCLUDE],
|
|
88
|
-
name: "cuiqg/ignores"
|
|
89
|
-
}, configGitignore({
|
|
90
|
-
name: "cuiqg/gitignore",
|
|
91
|
-
strict: false
|
|
92
|
-
})];
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
//#endregion
|
|
96
|
-
//#region src/configs/javascript.js
|
|
97
|
-
async function javascript() {
|
|
98
|
-
const [pluginJs] = await Promise.all([interopDefault(import("@eslint/js"))]);
|
|
99
|
-
return [{
|
|
100
|
-
languageOptions: {
|
|
101
|
-
ecmaVersion: "latest",
|
|
102
|
-
globals: {
|
|
103
|
-
...globals.browser,
|
|
104
|
-
...globals.es2025,
|
|
105
|
-
...globals.node
|
|
106
|
-
},
|
|
107
|
-
parserOptions: {
|
|
108
|
-
ecmaFeatures: { jsx: true },
|
|
109
|
-
ecmaVersion: "latest",
|
|
110
|
-
sourceType: "module"
|
|
111
|
-
},
|
|
112
|
-
sourceType: "module"
|
|
113
|
-
},
|
|
114
|
-
linterOptions: { reportUnusedDisableDirectives: true },
|
|
115
|
-
name: "cuiqg/javascript",
|
|
116
|
-
plugins: { js: pluginJs },
|
|
117
|
-
rules: { ...pluginJs.configs.recommended.rules }
|
|
118
|
-
}];
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
//#endregion
|
|
122
|
-
//#region src/configs/jsdoc.js
|
|
123
|
-
async function jsdoc() {
|
|
124
|
-
const pluginJsdoc = await interopDefault(import("eslint-plugin-jsdoc"));
|
|
125
|
-
return [{
|
|
126
|
-
name: "cuiqg/jsdoc",
|
|
127
|
-
plugins: { jsdoc: pluginJsdoc },
|
|
128
|
-
rules: {
|
|
129
|
-
"jsdoc/check-access": "warn",
|
|
130
|
-
"jsdoc/check-param-names": "warn",
|
|
131
|
-
"jsdoc/check-property-names": "warn",
|
|
132
|
-
"jsdoc/check-types": "warn",
|
|
133
|
-
"jsdoc/empty-tags": "warn",
|
|
134
|
-
"jsdoc/implements-on-classes": "warn",
|
|
135
|
-
"jsdoc/no-defaults": "warn",
|
|
136
|
-
"jsdoc/no-multi-asterisks": "warn",
|
|
137
|
-
"jsdoc/require-param-name": "warn",
|
|
138
|
-
"jsdoc/require-property": "warn",
|
|
139
|
-
"jsdoc/require-property-description": "warn",
|
|
140
|
-
"jsdoc/require-property-name": "warn",
|
|
141
|
-
"jsdoc/require-returns-check": "warn",
|
|
142
|
-
"jsdoc/require-returns-description": "warn",
|
|
143
|
-
"jsdoc/require-yields-check": "warn",
|
|
144
|
-
"jsdoc/check-alignment": "warn",
|
|
145
|
-
"jsdoc/multiline-blocks": "warn"
|
|
146
|
-
}
|
|
147
|
-
}];
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
//#endregion
|
|
151
|
-
//#region src/configs/macros.js
|
|
152
|
-
async function macros() {
|
|
153
|
-
const configMacros = await interopDefault(import("@vue-macros/eslint-config"));
|
|
154
|
-
return [{
|
|
155
|
-
...configMacros,
|
|
156
|
-
name: "cuiqg/macros"
|
|
157
|
-
}];
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
//#endregion
|
|
161
|
-
//#region src/configs/package-json.js
|
|
162
|
-
async function packageJson() {
|
|
163
|
-
const [pluginPackageJson, parserJsonc] = await Promise.all([interopDefault(import("eslint-plugin-package-json")), interopDefault(import("jsonc-eslint-parser"))]);
|
|
164
|
-
return [{
|
|
165
|
-
files: ["**/package.json"],
|
|
166
|
-
languageOptions: { parser: parserJsonc },
|
|
167
|
-
name: "cuiqg/package-json",
|
|
168
|
-
plugins: { "package-json": pluginPackageJson },
|
|
169
|
-
rules: { ...pluginPackageJson.configs.recommended.rules },
|
|
170
|
-
settings: { packageJson: { enforceForPrivate: false } }
|
|
171
|
-
}];
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
//#endregion
|
|
175
|
-
//#region src/configs/prettier.js
|
|
176
|
-
async function prettier() {
|
|
177
|
-
const [pluginPrettier, recommendedPrettier] = await Promise.all([interopDefault(import("eslint-plugin-prettier")), interopDefault(import("eslint-plugin-prettier/recommended"))]);
|
|
178
|
-
return [{
|
|
179
|
-
name: "cuiqg/prettier",
|
|
180
|
-
plugins: { prettier: pluginPrettier },
|
|
181
|
-
rules: {
|
|
182
|
-
...recommendedPrettier.rules,
|
|
183
|
-
"prettier/prettier": "warn"
|
|
184
|
-
}
|
|
185
|
-
}];
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
//#endregion
|
|
189
|
-
//#region src/configs/stylistic.js
|
|
190
|
-
async function stylistic() {
|
|
191
|
-
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
192
|
-
const config = pluginStylistic.configs.customize({
|
|
193
|
-
commaDangle: "never",
|
|
194
|
-
indent: 2,
|
|
195
|
-
pluginName: "style",
|
|
196
|
-
quotes: "single",
|
|
197
|
-
semi: false
|
|
198
|
-
});
|
|
199
|
-
return [{
|
|
200
|
-
name: "cuiqg/stylistic",
|
|
201
|
-
plugins: { style: pluginStylistic },
|
|
202
|
-
rules: { ...config.rules }
|
|
203
|
-
}];
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
//#endregion
|
|
207
|
-
//#region src/configs/unocss.js
|
|
208
|
-
async function unocss() {
|
|
209
|
-
const pluginUnoCSS = await interopDefault(import("@unocss/eslint-plugin"));
|
|
210
|
-
return [{
|
|
211
|
-
name: "cuiqg/unocss",
|
|
212
|
-
plugins: { unocss: pluginUnoCSS },
|
|
213
|
-
rules: { ...renameRules(pluginUnoCSS.configs.recommended.rules, { "@unocss": "unocss" }) }
|
|
214
|
-
}];
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
//#endregion
|
|
218
|
-
//#region src/configs/vue.js
|
|
219
|
-
async function vue() {
|
|
220
|
-
const files = [GLOB_VUE];
|
|
221
|
-
const [pluginVue, parserVue] = await Promise.all([interopDefault(import("eslint-plugin-vue")), interopDefault(import("vue-eslint-parser"))]);
|
|
222
|
-
return [{
|
|
223
|
-
files,
|
|
224
|
-
languageOptions: {
|
|
225
|
-
globals: {
|
|
226
|
-
computed: "readonly",
|
|
227
|
-
defineEmits: "readonly",
|
|
228
|
-
defineExpose: "readonly",
|
|
229
|
-
defineModel: "readonly",
|
|
230
|
-
defineOptions: "readonly",
|
|
231
|
-
defineProps: "readonly",
|
|
232
|
-
defineSlots: "readonly",
|
|
233
|
-
onActivated: "readonly",
|
|
234
|
-
onDeactivated: "readonly",
|
|
235
|
-
onMounted: "readonly",
|
|
236
|
-
onUnmounted: "readonly",
|
|
237
|
-
reactive: "readonly",
|
|
238
|
-
ref: "readonly",
|
|
239
|
-
toRef: "readonly",
|
|
240
|
-
toRefs: "readonly",
|
|
241
|
-
useAttrs: "readonly",
|
|
242
|
-
useSlots: "readonly",
|
|
243
|
-
watch: "readonly",
|
|
244
|
-
watchEffect: "readonly"
|
|
245
|
-
},
|
|
246
|
-
parser: parserVue,
|
|
247
|
-
parserOptions: {
|
|
248
|
-
ecmaFeatures: { jsx: true },
|
|
249
|
-
extraFileExtensions: [".vue"],
|
|
250
|
-
parser: null,
|
|
251
|
-
sourceType: "module"
|
|
252
|
-
}
|
|
253
|
-
},
|
|
254
|
-
name: "cuiqg/vue",
|
|
255
|
-
plugins: { vue: pluginVue },
|
|
256
|
-
processor: pluginVue.processors[".vue"],
|
|
257
|
-
rules: {
|
|
258
|
-
...pluginVue.configs["flat/recommended"].map((c) => c.rules).reduce((acc, c) => ({
|
|
259
|
-
...acc,
|
|
260
|
-
...c
|
|
261
|
-
}), {}),
|
|
262
|
-
"node/prefer-global/process": "off",
|
|
263
|
-
"vue/array-bracket-spacing": ["error", "never"],
|
|
264
|
-
"vue/arrow-spacing": ["error", {
|
|
265
|
-
after: true,
|
|
266
|
-
before: true
|
|
267
|
-
}],
|
|
268
|
-
"vue/block-order": ["error", { order: [
|
|
269
|
-
"script",
|
|
270
|
-
"template",
|
|
271
|
-
"style"
|
|
272
|
-
] }],
|
|
273
|
-
"vue/block-spacing": ["error", "always"],
|
|
274
|
-
"vue/block-tag-newline": ["error", {
|
|
275
|
-
multiline: "always",
|
|
276
|
-
singleline: "always"
|
|
277
|
-
}],
|
|
278
|
-
"vue/brace-style": [
|
|
279
|
-
"error",
|
|
280
|
-
"stroustrup",
|
|
281
|
-
{ allowSingleLine: true }
|
|
282
|
-
],
|
|
283
|
-
"vue/comma-dangle": ["error", "always-multiline"],
|
|
284
|
-
"vue/comma-spacing": ["error", {
|
|
285
|
-
after: true,
|
|
286
|
-
before: false
|
|
287
|
-
}],
|
|
288
|
-
"vue/comma-style": ["error", "last"],
|
|
289
|
-
"vue/custom-event-name-casing": ["error", "camelCase"],
|
|
290
|
-
"vue/define-macros-order": ["error", { order: [
|
|
291
|
-
"defineOptions",
|
|
292
|
-
"defineProps",
|
|
293
|
-
"defineEmits",
|
|
294
|
-
"defineSlots"
|
|
295
|
-
] }],
|
|
296
|
-
"vue/dot-location": ["error", "property"],
|
|
297
|
-
"vue/dot-notation": ["error", { allowKeywords: true }],
|
|
298
|
-
"vue/eqeqeq": ["error", "smart"],
|
|
299
|
-
"vue/html-comment-content-spacing": [
|
|
300
|
-
"error",
|
|
301
|
-
"always",
|
|
302
|
-
{ exceptions: ["-"] }
|
|
303
|
-
],
|
|
304
|
-
"vue/html-indent": ["error", 2],
|
|
305
|
-
"vue/html-quotes": ["error", "double"],
|
|
306
|
-
"vue/key-spacing": ["error", {
|
|
307
|
-
afterColon: true,
|
|
308
|
-
beforeColon: false
|
|
309
|
-
}],
|
|
310
|
-
"vue/keyword-spacing": ["error", {
|
|
311
|
-
after: true,
|
|
312
|
-
before: true
|
|
313
|
-
}],
|
|
314
|
-
"vue/max-attributes-per-line": "off",
|
|
315
|
-
"vue/multi-word-component-names": "off",
|
|
316
|
-
"vue/no-dupe-keys": "off",
|
|
317
|
-
"vue/no-empty-pattern": "error",
|
|
318
|
-
"vue/no-irregular-whitespace": "error",
|
|
319
|
-
"vue/no-loss-of-precision": "error",
|
|
320
|
-
"vue/no-restricted-syntax": [
|
|
321
|
-
"error",
|
|
322
|
-
"DebuggerStatement",
|
|
323
|
-
"LabeledStatement",
|
|
324
|
-
"WithStatement"
|
|
325
|
-
],
|
|
326
|
-
"vue/no-restricted-v-bind": ["error", "/^v-/"],
|
|
327
|
-
"vue/no-setup-props-reactivity-loss": "off",
|
|
328
|
-
"vue/no-sparse-arrays": "error",
|
|
329
|
-
"vue/no-unused-refs": "error",
|
|
330
|
-
"vue/no-useless-v-bind": "error",
|
|
331
|
-
"vue/no-v-html": "off",
|
|
332
|
-
"vue/object-curly-newline": "off",
|
|
333
|
-
"vue/object-curly-spacing": ["error", "always"],
|
|
334
|
-
"vue/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
|
|
335
|
-
"vue/object-shorthand": [
|
|
336
|
-
"error",
|
|
337
|
-
"always",
|
|
338
|
-
{
|
|
339
|
-
avoidQuotes: true,
|
|
340
|
-
ignoreConstructors: false
|
|
341
|
-
}
|
|
342
|
-
],
|
|
343
|
-
"vue/operator-linebreak": ["error", "before"],
|
|
344
|
-
"vue/padding-line-between-blocks": ["error", "always"],
|
|
345
|
-
"vue/prefer-separate-static-class": "error",
|
|
346
|
-
"vue/prefer-template": "error",
|
|
347
|
-
"vue/prop-name-casing": ["error", "camelCase"],
|
|
348
|
-
"vue/quote-props": ["error", "consistent-as-needed"],
|
|
349
|
-
"vue/require-default-prop": "off",
|
|
350
|
-
"vue/require-prop-types": "off",
|
|
351
|
-
"vue/space-in-parens": ["error", "never"],
|
|
352
|
-
"vue/space-infix-ops": "error",
|
|
353
|
-
"vue/space-unary-ops": ["error", {
|
|
354
|
-
nonwords: false,
|
|
355
|
-
words: true
|
|
356
|
-
}],
|
|
357
|
-
"vue/template-curly-spacing": "error"
|
|
358
|
-
}
|
|
359
|
-
}];
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
//#endregion
|
|
363
|
-
//#region src/env.js
|
|
364
|
-
const isInGitHookOrLintStaged = () => {
|
|
365
|
-
return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
366
|
-
};
|
|
367
|
-
const isInEditor = () => {
|
|
368
|
-
if (process.env.CI) return false;
|
|
369
|
-
if (isInGitHookOrLintStaged()) return false;
|
|
370
|
-
return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
|
|
371
|
-
};
|
|
372
|
-
const hasVue = () => [
|
|
373
|
-
"vue",
|
|
374
|
-
"nuxt",
|
|
375
|
-
"vitepress",
|
|
376
|
-
"@slidev/cli"
|
|
377
|
-
].some((i) => isPackageExists(i));
|
|
378
|
-
const hasTypeScript = () => isPackageExists("typescript");
|
|
379
|
-
const hasUnoCss = () => isPackageExists("unocss");
|
|
380
|
-
|
|
381
|
-
//#endregion
|
|
382
|
-
//#region src/presets.js
|
|
383
|
-
const defaultPluginRenaming = { "@stylistic": "style" };
|
|
384
|
-
/**
|
|
385
|
-
*
|
|
386
|
-
* @param {object} options - 设置选项
|
|
387
|
-
* @param {...any} userConfigs - 用户配置
|
|
388
|
-
* @returns {Promise<any[]>} 合并后的配置
|
|
389
|
-
*/
|
|
390
|
-
function cuiqg(options = {}, ...userConfigs) {
|
|
391
|
-
const { prettier: enablePrettier = false, unocss: enableUnocss = hasUnoCss(), vue: enableVue = hasVue() } = options;
|
|
392
|
-
const configs = [];
|
|
393
|
-
configs.push(ignores(), javascript(), jsdoc(), stylistic(), packageJson());
|
|
394
|
-
if (enableVue) configs.push(vue(), macros());
|
|
395
|
-
if (enableUnocss) configs.push(unocss());
|
|
396
|
-
if (enablePrettier) configs.push(prettier());
|
|
397
|
-
let composer = new FlatConfigComposer();
|
|
398
|
-
composer = composer.append(...configs, ...userConfigs).renamePlugins(defaultPluginRenaming);
|
|
399
|
-
return composer;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
//#endregion
|
|
403
|
-
//#region src/index.js
|
|
404
|
-
var src_default = cuiqg;
|
|
405
|
-
|
|
406
|
-
//#endregion
|
|
407
|
-
export { GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_STYLUS, GLOB_SVG, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, cuiqg, src_default as default, defaultPluginRenaming, hasTypeScript, hasUnoCss, hasVue, ignores, isInEditor, isInGitHookOrLintStaged, javascript, jsdoc, macros, packageJson, prettier, stylistic, unocss, vue };
|