@lntvow/eslint-config 9.18.0 → 9.18.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/.commitlintrc +6 -0
- package/.czrc +3 -0
- package/.editorconfig +14 -0
- package/.github/workflows/publish-npm.yml +45 -0
- package/.lintstagedrc +4 -0
- package/.prettierrc +10 -0
- package/.simple-git-hooks.json +4 -0
- package/.vscode/settings.json +18 -0
- package/cli/basic.js +48 -0
- package/cli/vue.js +36 -0
- package/eslint.config.mjs +8 -0
- package/package.json +5 -46
- package/packages/eslint-config/build.config.ts +11 -0
- package/packages/eslint-config/package.json +63 -0
- package/packages/eslint-config/scripts/typegen.ts +49 -0
- package/packages/eslint-config/src/configs/custom.ts +13 -0
- package/packages/eslint-config/src/configs/disables.ts +47 -0
- package/packages/eslint-config/src/configs/gitignore.ts +45 -0
- package/packages/eslint-config/src/configs/ignores.ts +11 -0
- package/packages/eslint-config/src/configs/imports.ts +78 -0
- package/packages/eslint-config/src/configs/index.ts +23 -0
- package/packages/eslint-config/src/configs/javascript.ts +196 -0
- package/packages/eslint-config/src/configs/prettier.ts +21 -0
- package/packages/eslint-config/src/configs/regexp.ts +27 -0
- package/packages/eslint-config/src/configs/stylistic.ts +46 -0
- package/packages/eslint-config/src/configs/test.ts +26 -0
- package/packages/eslint-config/src/configs/typescript.ts +64 -0
- package/packages/eslint-config/src/configs/vue.ts +298 -0
- package/packages/eslint-config/src/factory.ts +182 -0
- package/packages/eslint-config/src/globs.ts +89 -0
- package/packages/eslint-config/src/index.ts +7 -0
- package/packages/eslint-config/src/types.ts +152 -0
- package/packages/eslint-config/src/typings/index.d.ts +4 -0
- package/packages/eslint-config/src/utils/index.ts +38 -0
- package/packages/eslint-plugin/build.config.ts +14 -0
- package/packages/eslint-plugin/package.json +34 -0
- package/packages/eslint-plugin/src/index.ts +15 -0
- package/packages/eslint-plugin/src/rules/newline-before-describe-test.ts +53 -0
- package/packages/eslint-plugin/src/utils/index.ts +5 -0
- package/packages/eslint-plugin/tests/get.test.js +39 -0
- package/packages/eslint-plugin/tsconfig.json +20 -0
- package/pnpm-workspace.yaml +2 -0
- package/tsconfig.json +22 -0
- package/dist/index.cjs +0 -1
- package/dist/index.d.cts +0 -10375
- package/dist/index.d.ts +0 -10375
- package/dist/index.mjs +0 -1
package/.commitlintrc
ADDED
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
|
|
@@ -0,0 +1,45 @@
|
|
|
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@v4
|
|
16
|
+
|
|
17
|
+
- name: Set Node
|
|
18
|
+
uses: actions/setup-node@v4
|
|
19
|
+
with:
|
|
20
|
+
node-version: 20
|
|
21
|
+
registry-url: https://registry.npmjs.org
|
|
22
|
+
|
|
23
|
+
- name: Set pnpm
|
|
24
|
+
uses: pnpm/action-setup@v4
|
|
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@v4
|
|
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 build
|
|
43
|
+
- run: pnpm -r publish --access public
|
|
44
|
+
env:
|
|
45
|
+
NODE_AUTH_TOKEN: ${{secrets.NPM_PUBLISH}}
|
package/.lintstagedrc
ADDED
package/.prettierrc
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cSpell.words": [
|
|
3
|
+
"astro",
|
|
4
|
+
"backreference",
|
|
5
|
+
"bumpp",
|
|
6
|
+
"chunkname",
|
|
7
|
+
"esno",
|
|
8
|
+
"estree",
|
|
9
|
+
"JETBRAINS",
|
|
10
|
+
"nonconstructor",
|
|
11
|
+
"nonoctal",
|
|
12
|
+
"plusplus",
|
|
13
|
+
"tsup",
|
|
14
|
+
"typedefs",
|
|
15
|
+
"unignore"
|
|
16
|
+
],
|
|
17
|
+
"typescript.tsdk": "node_modules\\typescript\\lib"
|
|
18
|
+
}
|
package/cli/basic.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import * as cheerio from 'cheerio'
|
|
3
|
+
import axios from 'axios'
|
|
4
|
+
import { javascript, notInRecommendedRules } from '../dist/index.js'
|
|
5
|
+
|
|
6
|
+
axios.get('https://eslint.org/docs/latest/rules/').then(async res => {
|
|
7
|
+
const $ = cheerio.load(res.data)
|
|
8
|
+
const allRule = $('.rule').filter((i, e) => !($(e).is('.rule--deprecated') || $(e).is('.rule--removed')))
|
|
9
|
+
|
|
10
|
+
const allRulesList = []
|
|
11
|
+
allRule.each((i, el) => {
|
|
12
|
+
const ruleName = $(el).find('.rule__name').text()
|
|
13
|
+
allRulesList.push(ruleName)
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
const recommendedRuleList = []
|
|
17
|
+
const customRuleList = []
|
|
18
|
+
|
|
19
|
+
allRule.each((i, el) => {
|
|
20
|
+
const ruleName = $(el).find('.rule__name').text()
|
|
21
|
+
// .rule__categories__type[aria-hidden="true"]
|
|
22
|
+
const flag = $(el).find('.rule__categories').children().eq(1).is('.rule__categories__type[aria-hidden="true"]')
|
|
23
|
+
if (flag) {
|
|
24
|
+
// console.log('custom', ruleName)
|
|
25
|
+
customRuleList.push(ruleName)
|
|
26
|
+
} else {
|
|
27
|
+
// console.log('recommended', ruleName)
|
|
28
|
+
recommendedRuleList.push(ruleName)
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
// fs.writeFileSync('customRuleList.json', JSON.stringify(customRuleList, null, 2))
|
|
33
|
+
// fs.writeFileSync('recommendedRuleList.json', JSON.stringify(recommendedRuleList, null, 2))
|
|
34
|
+
|
|
35
|
+
// //
|
|
36
|
+
|
|
37
|
+
// const keyList = Object.keys(rulesMap)
|
|
38
|
+
const rulesList = Object.keys((await javascript())[0].rules)
|
|
39
|
+
|
|
40
|
+
const configNotInRecommendedRulesList = Object.keys(notInRecommendedRules)
|
|
41
|
+
console.log(
|
|
42
|
+
'notInRecommendedRules diff: ',
|
|
43
|
+
configNotInRecommendedRulesList.length,
|
|
44
|
+
customRuleList.length,
|
|
45
|
+
customRuleList.filter(key => !configNotInRecommendedRulesList.includes(key))
|
|
46
|
+
)
|
|
47
|
+
//
|
|
48
|
+
})
|
package/cli/vue.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/* eslint-disable id-length */
|
|
2
|
+
|
|
3
|
+
const axios = require('axios')
|
|
4
|
+
const cheerio = require('cheerio')
|
|
5
|
+
const { rules } = require('../packages/eslint-config-vue')
|
|
6
|
+
|
|
7
|
+
const keys = Object.keys(rules)
|
|
8
|
+
const eslintKeys = []
|
|
9
|
+
|
|
10
|
+
axios.get('https://eslint.vuejs.org/rules/').then(res => {
|
|
11
|
+
const $ = cheerio.load(res.data)
|
|
12
|
+
|
|
13
|
+
const filteredElements = $('.group').filter((i, e) =>
|
|
14
|
+
['Extension Rules', 'Uncategorized'].includes($(e).find('.item[tabindex="0"] .text').text())
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
filteredElements.each((i, el) => {
|
|
18
|
+
const list = $(el).find('.items .is-link')
|
|
19
|
+
list.each((_index, e) => {
|
|
20
|
+
const ruleName = $(e).find('.item .text').text()
|
|
21
|
+
eslintKeys.push(ruleName)
|
|
22
|
+
})
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const diff = eslintKeys.filter(key => !keys.includes(key))
|
|
26
|
+
console.log('eslintKeys: ', eslintKeys)
|
|
27
|
+
console.log('diff: ', diff)
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated 使用 isEmail
|
|
32
|
+
*/
|
|
33
|
+
export function validatorEmail(value) {
|
|
34
|
+
// eslint-disable-next-line regexp/no-unused-capturing-group
|
|
35
|
+
return /^([\w-])+@([\w-])+(\.[\w-])+/.test(value)
|
|
36
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lntvow/eslint-config",
|
|
3
|
-
"version": "9.18.
|
|
3
|
+
"version": "9.18.3",
|
|
4
4
|
"description": "eslint-config",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -12,19 +12,6 @@
|
|
|
12
12
|
"type": "git",
|
|
13
13
|
"url": "https://github.com/lntvow/eslint-config.git"
|
|
14
14
|
},
|
|
15
|
-
"files": [
|
|
16
|
-
"dist"
|
|
17
|
-
],
|
|
18
|
-
"main": "./dist/index.cjs",
|
|
19
|
-
"module": "./dist/index.mjs",
|
|
20
|
-
"types": "./dist/index.d.ts",
|
|
21
|
-
"exports": {
|
|
22
|
-
".": {
|
|
23
|
-
"import": "./dist/index.mjs",
|
|
24
|
-
"require": "./dist/index.cjs",
|
|
25
|
-
"types": "./dist/index.d.ts"
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
15
|
"devDependencies": {
|
|
29
16
|
"@lntvow/dev": "^3.3.3",
|
|
30
17
|
"@types/node": "^22.9.0",
|
|
@@ -34,42 +21,14 @@
|
|
|
34
21
|
"esno": "^4.8.0",
|
|
35
22
|
"tsup": "^8.3.5",
|
|
36
23
|
"vitest": "^2.1.8",
|
|
37
|
-
"
|
|
38
|
-
},
|
|
39
|
-
"peerDependencies": {
|
|
40
|
-
"eslint": ">=9.0.0",
|
|
41
|
-
"prettier": ">=3.0.0"
|
|
42
|
-
},
|
|
43
|
-
"dependencies": {
|
|
44
|
-
"@eslint/js": "^9.17.0",
|
|
45
|
-
"@lntvow/utils": "^3.2.2",
|
|
46
|
-
"@stylistic/eslint-plugin": "^2.10.1",
|
|
47
|
-
"@typescript-eslint/eslint-plugin": "^8.13.0",
|
|
48
|
-
"@typescript-eslint/parser": "^8.13.0",
|
|
49
|
-
"eslint": "^9.17.0",
|
|
50
|
-
"eslint-config-prettier": "^9.1.0",
|
|
51
|
-
"eslint-flat-config-utils": "^0.4.0",
|
|
52
|
-
"eslint-import-resolver-alias": "^1.1.2",
|
|
53
|
-
"eslint-plugin-import-x": "^4.4.0",
|
|
54
|
-
"eslint-plugin-prettier": "^5.2.1",
|
|
55
|
-
"eslint-plugin-regexp": "^2.6.0",
|
|
56
|
-
"eslint-plugin-vitest": "^0.5.4",
|
|
57
|
-
"eslint-plugin-vue": "^9.30.0",
|
|
58
|
-
"find-up-simple": "^1.0.0",
|
|
59
|
-
"globals": "^15.12.0",
|
|
60
|
-
"local-pkg": "^0.5.0",
|
|
61
|
-
"parse-gitignore": "^2.0.0",
|
|
62
|
-
"typescript": "^5.6.3",
|
|
63
|
-
"vue-eslint-parser": "^9.4.3",
|
|
64
|
-
"@lntvow/eslint-plugin": "^9.18.0"
|
|
24
|
+
"unbuild": "^2.0.0"
|
|
65
25
|
},
|
|
26
|
+
"dependencies": {},
|
|
66
27
|
"scripts": {
|
|
67
|
-
"
|
|
68
|
-
"build": "pnpm -r build && pnpm typegen && tsup",
|
|
69
|
-
"typegen": "esno scripts/typegen.ts",
|
|
28
|
+
"build": "pnpm -r build",
|
|
70
29
|
"inspect": "pnpm eslint --inspect-config",
|
|
71
30
|
"type-check": "tsc --noEmit",
|
|
72
|
-
"rimraf": "rimraf ./node_modules/",
|
|
31
|
+
"rimraf": "rimraf ./node_modules/ && pnpm -r rimraf",
|
|
73
32
|
"commit": "git add . && git-cz",
|
|
74
33
|
"release": "git add . && bumpp package.json packages/*/package.json --all --commit --no-tag --push"
|
|
75
34
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lntvow/eslint-config",
|
|
3
|
+
"version": "9.18.3",
|
|
4
|
+
"description": "eslint-config",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"eslint",
|
|
8
|
+
"eslint-config"
|
|
9
|
+
],
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/lntvow/eslint-config.git"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"main": "./dist/index.cjs",
|
|
19
|
+
"module": "./dist/index.mjs",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.mjs",
|
|
25
|
+
"require": "./dist/index.cjs"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"dev": "tsup --format esm",
|
|
30
|
+
"build": "pnpm typegen && unbuild",
|
|
31
|
+
"typegen": "esno scripts/typegen.ts",
|
|
32
|
+
"rimraf": "rimraf ./node_modules/",
|
|
33
|
+
"commit": "git add . && git-cz",
|
|
34
|
+
"release": "git add . && bumpp package.json packages/*/package.json --all --commit --no-tag --push"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"eslint": ">=9.0.0",
|
|
38
|
+
"prettier": ">=3.0.0"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@eslint/js": "^9.17.0",
|
|
42
|
+
"@lntvow/eslint-plugin": "workspace:^",
|
|
43
|
+
"@lntvow/utils": "^3.2.2",
|
|
44
|
+
"@stylistic/eslint-plugin": "^2.10.1",
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "^8.13.0",
|
|
46
|
+
"@typescript-eslint/parser": "^8.13.0",
|
|
47
|
+
"eslint": "^9.17.0",
|
|
48
|
+
"eslint-config-prettier": "^9.1.0",
|
|
49
|
+
"eslint-flat-config-utils": "^0.4.0",
|
|
50
|
+
"eslint-import-resolver-alias": "^1.1.2",
|
|
51
|
+
"eslint-plugin-import-x": "^4.4.0",
|
|
52
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
53
|
+
"eslint-plugin-regexp": "^2.6.0",
|
|
54
|
+
"eslint-plugin-vitest": "^0.5.4",
|
|
55
|
+
"eslint-plugin-vue": "^9.30.0",
|
|
56
|
+
"find-up-simple": "^1.0.0",
|
|
57
|
+
"globals": "^15.12.0",
|
|
58
|
+
"local-pkg": "^0.5.0",
|
|
59
|
+
"parse-gitignore": "^2.0.0",
|
|
60
|
+
"typescript": "^5.6.3",
|
|
61
|
+
"vue-eslint-parser": "^9.4.3"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import { flatConfigsToRulesDTS } from 'eslint-typegen/core'
|
|
3
|
+
import { builtinRules } from 'eslint/use-at-your-own-risk'
|
|
4
|
+
import {
|
|
5
|
+
combine,
|
|
6
|
+
custom,
|
|
7
|
+
disables,
|
|
8
|
+
imports,
|
|
9
|
+
javascript,
|
|
10
|
+
prettier,
|
|
11
|
+
regexp,
|
|
12
|
+
stylistic,
|
|
13
|
+
test,
|
|
14
|
+
typescript,
|
|
15
|
+
vue,
|
|
16
|
+
} from '../src'
|
|
17
|
+
|
|
18
|
+
const configs = await combine(
|
|
19
|
+
{
|
|
20
|
+
plugins: {
|
|
21
|
+
'': {
|
|
22
|
+
rules: Object.fromEntries(builtinRules.entries()),
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
custom(),
|
|
27
|
+
javascript(),
|
|
28
|
+
prettier(),
|
|
29
|
+
imports(),
|
|
30
|
+
typescript(),
|
|
31
|
+
vue(),
|
|
32
|
+
regexp(),
|
|
33
|
+
test(),
|
|
34
|
+
stylistic(),
|
|
35
|
+
disables()
|
|
36
|
+
)
|
|
37
|
+
// todo 作用
|
|
38
|
+
const configNames = configs.map(i => i.name).filter(Boolean) as string[]
|
|
39
|
+
|
|
40
|
+
let dts = await flatConfigsToRulesDTS(configs, {
|
|
41
|
+
includeAugmentation: false,
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
dts += `
|
|
45
|
+
// Names of all the configs
|
|
46
|
+
export type ConfigNames = ${configNames.map(i => `'${i}'`).join(' | ')}
|
|
47
|
+
`
|
|
48
|
+
|
|
49
|
+
fs.writeFileSync('src/typegen.d.ts', dts)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import lntvowPlugin from '@lntvow/eslint-plugin'
|
|
2
|
+
import type { TypedFlatConfigItem } from '../types'
|
|
3
|
+
|
|
4
|
+
export async function custom(): Promise<TypedFlatConfigItem[]> {
|
|
5
|
+
return [
|
|
6
|
+
{
|
|
7
|
+
name: 'lntvow/custom/setup',
|
|
8
|
+
plugins: {
|
|
9
|
+
lntvow: lntvowPlugin,
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
]
|
|
13
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { GLOB_SRC, GLOB_SRC_EXT } from '../globs'
|
|
2
|
+
import type { TypedFlatConfigItem } from '../types'
|
|
3
|
+
|
|
4
|
+
export async function disables(): Promise<TypedFlatConfigItem[]> {
|
|
5
|
+
return [
|
|
6
|
+
{
|
|
7
|
+
files: [`scripts/${GLOB_SRC}`],
|
|
8
|
+
name: 'lntvow/disables/scripts',
|
|
9
|
+
rules: {
|
|
10
|
+
'no-console': 'off',
|
|
11
|
+
// 'ts/explicit-function-return-type': 'off',
|
|
12
|
+
// 'unicorn/consistent-function-scoping': 'off',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
files: [`cli/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
|
|
17
|
+
name: 'lntvow/disables/cli',
|
|
18
|
+
rules: {
|
|
19
|
+
'no-console': 'off',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
files: ['**/*.d.?([cm])ts'],
|
|
24
|
+
name: 'lntvow/disables/dts',
|
|
25
|
+
rules: {
|
|
26
|
+
// 'eslint-comments/no-unlimited-disable': 'off',
|
|
27
|
+
// 'import/no-duplicates': 'off',
|
|
28
|
+
// 'no-restricted-syntax': 'off',
|
|
29
|
+
// 'unused-imports/no-unused-vars': 'off',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
files: ['**/*.{test,spec}.([tj])s?(x)'],
|
|
34
|
+
name: 'lntvow/disables/test',
|
|
35
|
+
rules: {
|
|
36
|
+
'no-unused-expressions': 'off',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
files: ['**/*.js', '**/*.cjs'],
|
|
41
|
+
name: 'lntvow/disables/cjs',
|
|
42
|
+
rules: {
|
|
43
|
+
'ts/no-require-imports': 'off',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
]
|
|
47
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import { castArray } from '@lntvow/utils'
|
|
3
|
+
import parse from 'parse-gitignore'
|
|
4
|
+
import type { FlatGitignoreOptions, TypedFlatConfigItem } from '../types'
|
|
5
|
+
|
|
6
|
+
export async function gitignore(options: FlatGitignoreOptions): Promise<TypedFlatConfigItem[]> {
|
|
7
|
+
const { findUpSync } = await import('find-up-simple')
|
|
8
|
+
|
|
9
|
+
const {
|
|
10
|
+
name = '.gitignore',
|
|
11
|
+
root = false,
|
|
12
|
+
files: _files = root ? name : findUpSync(name) || [],
|
|
13
|
+
strict = false,
|
|
14
|
+
} = options
|
|
15
|
+
|
|
16
|
+
const files = castArray(_files)
|
|
17
|
+
|
|
18
|
+
const ignores = []
|
|
19
|
+
for (const file of files) {
|
|
20
|
+
let content
|
|
21
|
+
try {
|
|
22
|
+
content = fs.readFileSync(file, 'utf8')
|
|
23
|
+
} catch (error) {
|
|
24
|
+
if (strict) throw error
|
|
25
|
+
continue
|
|
26
|
+
}
|
|
27
|
+
const globs = parse(content).globs()
|
|
28
|
+
for (const glob of globs) {
|
|
29
|
+
if (glob.type === 'ignore') {
|
|
30
|
+
ignores.push(...glob.patterns)
|
|
31
|
+
} else if (glob.type === 'unignore') {
|
|
32
|
+
ignores.push(...glob.patterns.map((pattern: string) => `!${pattern}`))
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (strict && files.length === 0) throw new Error('No .gitignore file found')
|
|
38
|
+
|
|
39
|
+
return [
|
|
40
|
+
{
|
|
41
|
+
name: 'lntvow/gitignore',
|
|
42
|
+
ignores,
|
|
43
|
+
},
|
|
44
|
+
]
|
|
45
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GLOB_EXCLUDE } from '../globs'
|
|
2
|
+
import type { TypedFlatConfigItem } from '../types'
|
|
3
|
+
|
|
4
|
+
export async function ignores(ignoresList: string[] = []): Promise<TypedFlatConfigItem[]> {
|
|
5
|
+
return [
|
|
6
|
+
{
|
|
7
|
+
name: 'lntvow/ignores',
|
|
8
|
+
ignores: [...GLOB_EXCLUDE, ...ignoresList],
|
|
9
|
+
},
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import pluginImport from 'eslint-plugin-import-x'
|
|
2
|
+
import type { TypedFlatConfigItem } from '../types'
|
|
3
|
+
|
|
4
|
+
export async function imports(options: { typescript?: boolean } = {}): Promise<TypedFlatConfigItem[]> {
|
|
5
|
+
const { typescript = false } = options
|
|
6
|
+
|
|
7
|
+
return [
|
|
8
|
+
{
|
|
9
|
+
name: 'lntvow/imports/rules',
|
|
10
|
+
plugins: {
|
|
11
|
+
import: pluginImport,
|
|
12
|
+
},
|
|
13
|
+
rules: {
|
|
14
|
+
// Helpful warnings
|
|
15
|
+
// 'import/export': 'error',
|
|
16
|
+
// 'import/no-deprecated': 'error',
|
|
17
|
+
// 'import/no-empty-named-blocks': 'error',
|
|
18
|
+
// // 幽灵依赖
|
|
19
|
+
// 'import/no-extraneous-dependencies': 'off',
|
|
20
|
+
// 'import/no-mutable-exports': 'error',
|
|
21
|
+
// 'import/no-named-as-default': 'error',
|
|
22
|
+
// 'import/no-named-as-default-member': 'error',
|
|
23
|
+
// 'import/no-unused-modules': 'error',
|
|
24
|
+
|
|
25
|
+
// Module systems
|
|
26
|
+
// 'import/no-amd': 'off',
|
|
27
|
+
// 'import/no-commonjs': 'off',
|
|
28
|
+
// 'import/no-import-module-exports': 'off',
|
|
29
|
+
// 'import/no-nodejs-modules': 'off',
|
|
30
|
+
// 'import/unambiguous': 'off',
|
|
31
|
+
|
|
32
|
+
// Static analysis
|
|
33
|
+
// 'import/default': 'error',
|
|
34
|
+
// 'import/named': 'error',
|
|
35
|
+
// 'import/namespace': 'error',
|
|
36
|
+
// 'import/no-absolute-path': 'error',
|
|
37
|
+
// 'import/no-cycle': 'off',
|
|
38
|
+
// 'import/no-dynamic-require': 'off',
|
|
39
|
+
// 'import/no-internal-modules': 'off',
|
|
40
|
+
// 'import/no-relative-packages': 'off',
|
|
41
|
+
// 'import/no-relative-parent-imports': 'off',
|
|
42
|
+
// 'import/no-restricted-paths': 'off',
|
|
43
|
+
// 'import/no-self-import': 'off',
|
|
44
|
+
'import/no-unresolved': 'error',
|
|
45
|
+
// 'import/no-useless-path-segments': 'error',
|
|
46
|
+
// 'import/no-webpack-loader-syntax': 'error',
|
|
47
|
+
|
|
48
|
+
// Style guide
|
|
49
|
+
// 'import/consistent-type-specifier-style': 'off',
|
|
50
|
+
// 'import/dynamic-import-chunkname': 'off',
|
|
51
|
+
// 'import/exports-last': 'off',
|
|
52
|
+
// 'import/extensions': 'off',
|
|
53
|
+
'import/first': 'error',
|
|
54
|
+
// 'import/group-exports': 'off',
|
|
55
|
+
// 'import/max-dependencies': 'off',
|
|
56
|
+
'import/newline-after-import': 'error',
|
|
57
|
+
// 'import/no-anonymous-default-export': 'off',
|
|
58
|
+
// 'import/no-default-export': 'off',
|
|
59
|
+
'import/no-duplicates': 'error',
|
|
60
|
+
// 'import/no-named-default': 'off',
|
|
61
|
+
// 'import/no-named-export': 'off',
|
|
62
|
+
// 'import/no-namespace': 'off',
|
|
63
|
+
// 'import/no-unassigned-import': 'off',
|
|
64
|
+
'import/order': 'error',
|
|
65
|
+
// 'import/prefer-default-export': 'off',
|
|
66
|
+
},
|
|
67
|
+
settings: {
|
|
68
|
+
'import-x/resolver': {
|
|
69
|
+
alias: {
|
|
70
|
+
map: [['@', './src']],
|
|
71
|
+
extensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'],
|
|
72
|
+
},
|
|
73
|
+
node: true,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
]
|
|
78
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export * from './custom'
|
|
2
|
+
|
|
3
|
+
export * from './disables'
|
|
4
|
+
|
|
5
|
+
export * from './gitignore'
|
|
6
|
+
|
|
7
|
+
export * from './ignores'
|
|
8
|
+
|
|
9
|
+
export * from './imports'
|
|
10
|
+
|
|
11
|
+
export * from './javascript'
|
|
12
|
+
|
|
13
|
+
export * from './prettier'
|
|
14
|
+
|
|
15
|
+
export * from './regexp'
|
|
16
|
+
|
|
17
|
+
export * from './stylistic'
|
|
18
|
+
|
|
19
|
+
export * from './test'
|
|
20
|
+
|
|
21
|
+
export * from './typescript'
|
|
22
|
+
|
|
23
|
+
export * from './vue'
|