@lntvow/eslint-config 8.5.0 → 9.1.1
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/.czrc +3 -0
- package/.editorconfig +14 -0
- package/.env.development +1 -0
- package/.env.production +1 -0
- package/.env.uat +1 -0
- package/.github/workflows/publish-npm.yml +44 -0
- package/.husky/commit-msg +4 -0
- package/.husky/pre-commit +4 -0
- package/.lintstagedrc +4 -0
- package/.prettierrc +10 -0
- package/.vscode/settings.json +14 -0
- package/README.md +19 -27
- package/api/basic.js +22 -0
- package/api/vue.js +34 -0
- package/commitlint.config.cjs +4 -0
- package/eslint.config.js +21 -0
- package/package.json +45 -11
- package/packages/eslint-config-ts/index.js +85 -0
- package/packages/eslint-config-ts/package.json +18 -0
- package/packages/eslint-plugin/index.js +5 -0
- package/packages/eslint-plugin/package.json +16 -0
- package/packages/eslint-plugin/rules/get.js +18 -0
- package/packages/eslint-plugin/test/get.test.js +39 -0
- package/src/configs/gitignore.ts +34 -0
- package/src/configs/ignores.ts +10 -0
- package/src/configs/imports.ts +17 -0
- package/src/configs/index.ts +8 -0
- package/src/configs/javascript.ts +161 -0
- package/src/configs/prettier.ts +18 -0
- package/src/configs/stylistic.ts +59 -0
- package/src/configs/typescript.ts +63 -0
- package/src/configs/vue.ts +316 -0
- package/src/factory.ts +167 -0
- package/src/globs.ts +86 -0
- package/src/index.ts +7 -0
- package/src/typegen.d.ts +15123 -0
- package/src/types.ts +127 -0
- package/src/typings/index.d.ts +3 -0
- package/src/utils/index.ts +30 -0
- package/test/js.vue +28 -0
- package/test/jsx.vue +27 -0
- package/test/test.js +11 -0
- package/test/test.ts +18 -0
- package/test/ts.vue +26 -0
- package/test/tsx.vue +23 -0
- package/tsconfig.json +20 -0
- package/tsup.config.ts +10 -0
- package/index.js +0 -3
package/.czrc
ADDED
package/.editorconfig
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# https://editorconfig.org
|
|
2
|
+
root = true
|
|
3
|
+
|
|
4
|
+
[*]
|
|
5
|
+
charset = utf-8
|
|
6
|
+
indent_style = space
|
|
7
|
+
indent_size = 2
|
|
8
|
+
end_of_line = lf
|
|
9
|
+
insert_final_newline = true
|
|
10
|
+
trim_trailing_whitespace = true
|
|
11
|
+
|
|
12
|
+
[*.md]
|
|
13
|
+
insert_final_newline = false
|
|
14
|
+
trim_trailing_whitespace = false
|
package/.env.development
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VITE_BASE = '/xxxxx/'
|
package/.env.production
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VITE_BASE = '/xxxxx/'
|
package/.env.uat
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VITE_BASE = '/xxxxx/'
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
name: publish-npm
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
push:
|
|
6
|
+
paths:
|
|
7
|
+
# - 'package.json'
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
publish-npm:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
timeout-minutes: 10
|
|
13
|
+
steps:
|
|
14
|
+
- name: Checkout
|
|
15
|
+
uses: actions/checkout@v3
|
|
16
|
+
|
|
17
|
+
- name: Set Node
|
|
18
|
+
uses: actions/setup-node@v3
|
|
19
|
+
with:
|
|
20
|
+
node-version: 20
|
|
21
|
+
registry-url: https://registry.npmjs.org
|
|
22
|
+
|
|
23
|
+
- name: Set pnpm
|
|
24
|
+
uses: pnpm/action-setup@v2
|
|
25
|
+
with:
|
|
26
|
+
version: 9
|
|
27
|
+
|
|
28
|
+
- name: Get pnpm store directory
|
|
29
|
+
shell: bash
|
|
30
|
+
run: |
|
|
31
|
+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
|
32
|
+
|
|
33
|
+
- uses: actions/cache@v3
|
|
34
|
+
name: Setup pnpm cache
|
|
35
|
+
with:
|
|
36
|
+
path: ${{ env.STORE_PATH }}
|
|
37
|
+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
38
|
+
restore-keys: |
|
|
39
|
+
${{ runner.os }}-pnpm-store-
|
|
40
|
+
|
|
41
|
+
- run: pnpm install
|
|
42
|
+
- run: pnpm publish --access public
|
|
43
|
+
env:
|
|
44
|
+
NODE_AUTH_TOKEN: ${{secrets.NPM_PUBLISH}}
|
package/.lintstagedrc
ADDED
package/.prettierrc
ADDED
package/README.md
CHANGED
|
@@ -1,37 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
# @lntvow/eslint-config
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Usage
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
install @lntvow/eslint-config
|
|
6
|
+
|
|
7
|
+
```bash
|
|
6
8
|
pnpm install -D @lntvow/eslint-config
|
|
7
9
|
```
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
create `eslint.config.mjs` in your project root
|
|
10
12
|
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
```
|
|
13
|
+
```js
|
|
14
|
+
// eslint.config.mjs
|
|
15
|
+
import lntvow from '@lntvow/eslint-config'
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
export default lntvow()
|
|
18
|
+
```
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
2. 由于 `pnpm` 软链和 `eslint` 以及 `prettier` 功能冲突 所以部分包必须平铺在 `node_modules` 根目录下
|
|
21
|
-
3. 项目根目录下新建文件 `.npmrc` 并写入 `shamefully-hoist=true` 该指令表示平铺依赖到 `node_modules` 根目录
|
|
20
|
+
## Plugins
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
shamefully-hoist=true
|
|
25
|
-
```
|
|
22
|
+
Since flat config requires us to explicitly provide the plugin names (instead of the mandatory convention from npm package name), we renamed some plugins to make the overall scope more consistent and easier to write.
|
|
26
23
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
- [eslint]
|
|
30
|
-
|
|
31
|
-
- [eslint-plugin-
|
|
32
|
-
|
|
33
|
-
- [eslint-import-resolver-alias]
|
|
34
|
-
- [eslint-plugin-unicorn]
|
|
35
|
-
- [@typescript-eslint/eslint-plugin]
|
|
36
|
-
- [@typescript-eslint/parser]
|
|
37
|
-
- [eslint-plugin-vue]
|
|
24
|
+
| New Prefix | Original Prefix | Source Plugin |
|
|
25
|
+
| -------------- | ---------------------- | ------------------------------------------------------------------------------------------ |
|
|
26
|
+
| `typescript/*` | `@typescript-eslint/*` | [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint) |
|
|
27
|
+
| `vue/*` | `@vue/*` | [eslint-plugin-vue](https://github.com/vuejs/eslint-plugin-vue) |
|
|
28
|
+
| `import/*` | `import-x/*` | [eslint-plugin-import-x](https://github.com/un-es/eslint-plugin-import-x) |
|
|
29
|
+
| `style/*` | `@stylistic/*` | [@stylistic/eslint-plugin](https://github.com/eslint-stylistic/eslint-stylistic) |
|
package/api/basic.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as cheerio from 'cheerio'
|
|
2
|
+
import axios from 'axios'
|
|
3
|
+
import { javascript } from '../dist/index.js'
|
|
4
|
+
|
|
5
|
+
// Const basicKeys = Object.keys(basicRules);
|
|
6
|
+
const rulesMap = {}
|
|
7
|
+
|
|
8
|
+
axios.get('https://eslint.org/docs/latest/rules/').then(async res => {
|
|
9
|
+
const $ = cheerio.load(res.data),
|
|
10
|
+
filteredElements = $('.rule').filter((i, e) => !($(e).is('.rule--deprecated') || $(e).is('.rule--removed')))
|
|
11
|
+
|
|
12
|
+
filteredElements.each((i, el) => {
|
|
13
|
+
const ruleName = $(el).find('.rule__name').text()
|
|
14
|
+
rulesMap[ruleName] = 2
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const keyList = Object.keys(rulesMap)
|
|
18
|
+
const rulesList = Object.keys((await javascript())[0].rules)
|
|
19
|
+
|
|
20
|
+
const diff = keyList.filter(key => !rulesList.includes(key))
|
|
21
|
+
console.log('diff: ', diff)
|
|
22
|
+
})
|
package/api/vue.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/* eslint-disable unicorn/prefer-top-level-await */
|
|
2
|
+
const axios = require('axios')
|
|
3
|
+
const cheerio = require('cheerio')
|
|
4
|
+
const { rules } = require('../packages/eslint-config-vue')
|
|
5
|
+
|
|
6
|
+
const keys = Object.keys(rules)
|
|
7
|
+
const eslintKeys = []
|
|
8
|
+
|
|
9
|
+
axios.get('https://eslint.vuejs.org/rules/').then(res => {
|
|
10
|
+
const $ = cheerio.load(res.data)
|
|
11
|
+
|
|
12
|
+
const filteredElements = $('.group').filter((i, e) => {
|
|
13
|
+
return ['Extension Rules', 'Uncategorized'].includes($(e).find('.item[tabindex="0"] .text').text())
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
filteredElements.each((i, el) => {
|
|
17
|
+
const list = $(el).find('.items .is-link')
|
|
18
|
+
list.each((i, e) => {
|
|
19
|
+
const ruleName = $(e).find('.item .text').text()
|
|
20
|
+
eslintKeys.push(ruleName)
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
const diff = eslintKeys.filter(key => !keys.includes(key))
|
|
25
|
+
console.log('eslintKeys: ', eslintKeys)
|
|
26
|
+
console.log('diff: ', diff)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated 使用 isEmail
|
|
31
|
+
*/
|
|
32
|
+
export function validatorEmail(value) {
|
|
33
|
+
return /^([\w-])+@([\w-])+(\.[\w-])+/.test(value)
|
|
34
|
+
}
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import pluginStylistic from '@stylistic/eslint-plugin'
|
|
2
|
+
import { lntvow, GLOB_SRC, renameRules } from './dist/index.js'
|
|
3
|
+
|
|
4
|
+
const config = await lntvow({
|
|
5
|
+
vue: true,
|
|
6
|
+
typescript: true,
|
|
7
|
+
gitignore: {
|
|
8
|
+
},
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
const files = [GLOB_SRC]
|
|
12
|
+
|
|
13
|
+
// 1
|
|
14
|
+
export default [
|
|
15
|
+
...config,
|
|
16
|
+
{
|
|
17
|
+
// rules: {
|
|
18
|
+
// 'style/quotes': 'error',
|
|
19
|
+
// },
|
|
20
|
+
},
|
|
21
|
+
]
|
package/package.json
CHANGED
|
@@ -1,19 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lntvow/eslint-config",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "eslint配置文件",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"keywords": [],
|
|
3
|
+
"version": "9.1.1",
|
|
7
4
|
"author": "lntvow",
|
|
5
|
+
"type": "module",
|
|
8
6
|
"license": "MIT",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=18.12.0",
|
|
9
|
+
"pnpm": ">=9.0.0"
|
|
10
|
+
},
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"module": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@types/eslint": "^8.56.10",
|
|
16
|
+
"@types/eslint-config-prettier": "^6.11.3",
|
|
17
|
+
"@types/node": "^20.12.12",
|
|
18
|
+
"axios": "^1.7.2",
|
|
19
|
+
"bumpp": "^9.4.1",
|
|
20
|
+
"cheerio": "1.0.0-rc.12",
|
|
21
|
+
"rimraf": "^5.0.7",
|
|
22
|
+
"tsup": "^8.0.2",
|
|
23
|
+
"typescript": "^5.4.5",
|
|
24
|
+
"vue": "^3.4.27"
|
|
25
|
+
},
|
|
13
26
|
"dependencies": {
|
|
14
|
-
"@
|
|
27
|
+
"@eslint/js": "^9.3.0",
|
|
28
|
+
"@lntvow/utils": "^3.0.3",
|
|
29
|
+
"@stylistic/eslint-plugin": "^2.1.0",
|
|
30
|
+
"@typescript-eslint/eslint-plugin": "^7.10.0",
|
|
31
|
+
"@typescript-eslint/parser": "^7.10.0",
|
|
32
|
+
"eslint": "^9.3.0",
|
|
33
|
+
"eslint-config-prettier": "^9.1.0",
|
|
34
|
+
"eslint-flat-config-utils": "^0.2.5",
|
|
35
|
+
"eslint-plugin-import-x": "^0.5.0",
|
|
36
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
37
|
+
"eslint-plugin-vue": "^9.26.0",
|
|
38
|
+
"find-up": "^7.0.0",
|
|
39
|
+
"globals": "^15.3.0",
|
|
40
|
+
"local-pkg": "^0.5.0",
|
|
41
|
+
"parse-gitignore": "^2.0.0",
|
|
42
|
+
"tslib": "^2.6.2",
|
|
43
|
+
"typescript": "^5.4.5",
|
|
44
|
+
"vue-eslint-parser": "^9.4.2"
|
|
15
45
|
},
|
|
16
|
-
"
|
|
17
|
-
"
|
|
46
|
+
"scripts": {
|
|
47
|
+
"dev": "pnpm build --watch",
|
|
48
|
+
"build": "tsup",
|
|
49
|
+
"commit": "git add . && git-cz",
|
|
50
|
+
"rimraf": "rimraf ./node_modules/",
|
|
51
|
+
"release": "git add . && bumpp package.json --all --commit --no-tag --push"
|
|
18
52
|
}
|
|
19
53
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: [
|
|
3
|
+
'@lntvow/eslint-config-basic',
|
|
4
|
+
'plugin:import/typescript',
|
|
5
|
+
'plugin:@typescript-eslint/strict',
|
|
6
|
+
'plugin:@typescript-eslint/stylistic',
|
|
7
|
+
],
|
|
8
|
+
settings: {
|
|
9
|
+
'import/resolver': { typescript: true },
|
|
10
|
+
},
|
|
11
|
+
overrides: [
|
|
12
|
+
{
|
|
13
|
+
files: ['*.js', '*.cjs'],
|
|
14
|
+
// 禁用js文件的类型检查
|
|
15
|
+
extends: ['plugin:@typescript-eslint/disable-type-checked'],
|
|
16
|
+
rules: {
|
|
17
|
+
'@typescript-eslint/no-var-requires': 0, // 允许使用require
|
|
18
|
+
'@typescript-eslint/consistent-type-assertions': 0, // 禁用js文件的类型检查
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
files: ['*.ts', '*.tsx', '*.d.ts'],
|
|
23
|
+
// 禁用js文件的类型检查
|
|
24
|
+
rules: {
|
|
25
|
+
'spaced-comment': 0, // 警用注释检查
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
files: ['*.ts', '*.tsx', '*.vue'],
|
|
30
|
+
rules: {
|
|
31
|
+
/**
|
|
32
|
+
* 重写import规则
|
|
33
|
+
*/
|
|
34
|
+
'import/namespace': 0, // 导入校验
|
|
35
|
+
'import/no-cycle': 0, // 循环导入
|
|
36
|
+
'import/no-unused-modules': 0, // 导入未使用的模块
|
|
37
|
+
'import/no-named-as-default': 0, // 校验导出名称
|
|
38
|
+
'import/no-unresolved': 0, // 导入目录校验
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 重写ts规则
|
|
42
|
+
*/
|
|
43
|
+
'@typescript-eslint/no-non-null-assertion': 0, // 允许使用!断言
|
|
44
|
+
'@typescript-eslint/ban-types': 0, // 允许使用object
|
|
45
|
+
'@typescript-eslint/no-explicit-any': 0, // 允许使用any
|
|
46
|
+
'@typescript-eslint/ban-ts-comment': 0, // 允许使用ts注释
|
|
47
|
+
|
|
48
|
+
'@typescript-eslint/no-unused-vars': 1, // 未使用的变量 警告
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 重写js规则
|
|
52
|
+
*/
|
|
53
|
+
'no-undef': 0, // ts自带 允许使用未定义的变量
|
|
54
|
+
'no-use-before-define': 0,
|
|
55
|
+
'@typescript-eslint/no-use-before-define': [
|
|
56
|
+
2,
|
|
57
|
+
{
|
|
58
|
+
functions: false,
|
|
59
|
+
classes: true,
|
|
60
|
+
variables: false,
|
|
61
|
+
allowNamedExports: false,
|
|
62
|
+
enums: true,
|
|
63
|
+
typedefs: true,
|
|
64
|
+
ignoreTypeReferences: true,
|
|
65
|
+
},
|
|
66
|
+
], // 变量定义前禁止使用
|
|
67
|
+
'lines-around-comment': 'off',
|
|
68
|
+
'@typescript-eslint/lines-around-comment': [
|
|
69
|
+
2,
|
|
70
|
+
{
|
|
71
|
+
allowBlockStart: true,
|
|
72
|
+
allowObjectStart: true,
|
|
73
|
+
allowArrayStart: true,
|
|
74
|
+
allowClassStart: true,
|
|
75
|
+
allowEnumStart: true,
|
|
76
|
+
allowInterfaceStart: true,
|
|
77
|
+
allowModuleStart: true,
|
|
78
|
+
allowTypeStart: true,
|
|
79
|
+
},
|
|
80
|
+
], // 注释空行,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
rules: {},
|
|
85
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lntvow/eslint-config-ts",
|
|
3
|
+
"version": "8.5.0",
|
|
4
|
+
"description": "eslint/ts配置文件",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"keywords": [],
|
|
7
|
+
"author": "lntvow",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"files": [
|
|
10
|
+
"index.js"
|
|
11
|
+
],
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@lntvow/eslint-config-basic": "workspace:*",
|
|
14
|
+
"@typescript-eslint/eslint-plugin": "^6.2.0",
|
|
15
|
+
"@typescript-eslint/parser": "^6.2.0",
|
|
16
|
+
"eslint-import-resolver-typescript": "^3.5.5"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lntvow/eslint-plugin",
|
|
3
|
+
"version": "8.5.0",
|
|
4
|
+
"description": "eslint/plugin文件",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"keywords": [],
|
|
7
|
+
"author": "lntvow",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"files": [
|
|
10
|
+
"index.js"
|
|
11
|
+
],
|
|
12
|
+
"dependencies": {},
|
|
13
|
+
"peerDependencies": {
|
|
14
|
+
"eslint": ">=8.43.0"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
create(content) {
|
|
3
|
+
const options = content.options[1]
|
|
4
|
+
return {
|
|
5
|
+
ExpressionStatement(node) {
|
|
6
|
+
const callee = node.expression.callee
|
|
7
|
+
console.log('callee: ', callee)
|
|
8
|
+
const name = callee.property.name
|
|
9
|
+
if (options[name] === 2) {
|
|
10
|
+
content.report({
|
|
11
|
+
node,
|
|
12
|
+
message: `不能使用console.${name}`,
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const rule = require('../rules/get')
|
|
2
|
+
const RuleTester = require('eslint').RuleTester
|
|
3
|
+
|
|
4
|
+
const ruleTester = new RuleTester()
|
|
5
|
+
|
|
6
|
+
ruleTester.run('get', rule, {
|
|
7
|
+
valid: [
|
|
8
|
+
{
|
|
9
|
+
name: 'success',
|
|
10
|
+
code: 'var a = 10',
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
invalid: [
|
|
14
|
+
{
|
|
15
|
+
name: 'hash log',
|
|
16
|
+
code: "console.log('context: ', context.options)",
|
|
17
|
+
options: [
|
|
18
|
+
2,
|
|
19
|
+
{
|
|
20
|
+
log: 2,
|
|
21
|
+
warn: 2,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
errors: [{ message: '不能使用console.log' }],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'hash warn',
|
|
28
|
+
code: "console.warn('context: ', context.options)",
|
|
29
|
+
options: [
|
|
30
|
+
2,
|
|
31
|
+
{
|
|
32
|
+
log: 2,
|
|
33
|
+
warn: 2,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
errors: [{ message: '不能使用console.warn' }],
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
})
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import { findUpSync } from 'find-up'
|
|
3
|
+
import { castArray } from '@lntvow/utils'
|
|
4
|
+
import parse from 'parse-gitignore'
|
|
5
|
+
import type { FlatGitignoreOptions, TypedFlatConfigItem } from '../types'
|
|
6
|
+
|
|
7
|
+
export async function gitignore(options: FlatGitignoreOptions): Promise<TypedFlatConfigItem[]> {
|
|
8
|
+
const { name = '.gitignore', root = false, files: _files = root ? name : findUpSync(name) || [] } = options
|
|
9
|
+
const files = castArray(_files)
|
|
10
|
+
|
|
11
|
+
const ignores = []
|
|
12
|
+
for (const file of files) {
|
|
13
|
+
try {
|
|
14
|
+
const content = fs.readFileSync(file, 'utf8')
|
|
15
|
+
|
|
16
|
+
const globs = parse(content).globs()
|
|
17
|
+
for (const glob of globs) {
|
|
18
|
+
if (glob.type === 'ignore') {
|
|
19
|
+
ignores.push(...glob.patterns)
|
|
20
|
+
} else if (glob.type === 'unignore') {
|
|
21
|
+
ignores.push(...glob.patterns.map((pattern: string) => `!${pattern}`))
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
} catch (error) {
|
|
25
|
+
throw new Error(`Failed to read file: ${file}`)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return [
|
|
30
|
+
{
|
|
31
|
+
ignores,
|
|
32
|
+
},
|
|
33
|
+
]
|
|
34
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import pluginImport from 'eslint-plugin-import-x'
|
|
2
|
+
import type { TypedFlatConfigItem } from '../types'
|
|
3
|
+
|
|
4
|
+
export async function imports(): Promise<TypedFlatConfigItem[]> {
|
|
5
|
+
return [
|
|
6
|
+
{
|
|
7
|
+
name: 'lntvow/imports/rules',
|
|
8
|
+
plugins: {
|
|
9
|
+
import: pluginImport,
|
|
10
|
+
},
|
|
11
|
+
rules: {
|
|
12
|
+
'import/order': 'error',
|
|
13
|
+
'import/newline-after-import': 'error',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
]
|
|
17
|
+
}
|