@lntvow/eslint-config 8.5.0 → 9.1.2
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 +46 -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/src/types.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { Linter } from 'eslint'
|
|
2
|
+
import type { ParserOptions } from '@typescript-eslint/parser'
|
|
3
|
+
import type { StylisticCustomizeOptions } from '@stylistic/eslint-plugin'
|
|
4
|
+
import type { ConfigNames, RuleOptions } from './typegen'
|
|
5
|
+
|
|
6
|
+
export type Awaitable<T> = T | Promise<T>
|
|
7
|
+
|
|
8
|
+
export type Rules = RuleOptions
|
|
9
|
+
|
|
10
|
+
export type { ConfigNames }
|
|
11
|
+
|
|
12
|
+
export type TypedFlatConfigItem = Omit<Linter.FlatConfig<Linter.RulesRecord & Rules>, 'plugins'> & {
|
|
13
|
+
// Relax plugins type limitation, as most of the plugins did not have correct type info yet.
|
|
14
|
+
/**
|
|
15
|
+
* An object containing a name-value mapping of plugin names to plugin objects. When `files` is specified, these plugins are only available to the matching files.
|
|
16
|
+
*
|
|
17
|
+
* @see [Using plugins in your configuration](https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new#using-plugins-in-your-configuration)
|
|
18
|
+
*/
|
|
19
|
+
plugins?: Record<string, any>
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface OptionsVue extends OptionsOverrides {
|
|
23
|
+
/**
|
|
24
|
+
* Vue version. Apply different rules set from `eslint-plugin-vue`.
|
|
25
|
+
*
|
|
26
|
+
* @default auto-detect based on the dependencies
|
|
27
|
+
*/
|
|
28
|
+
// eslint-disable-next-line no-magic-numbers
|
|
29
|
+
vueVersion?: 2 | 3
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface OptionsComponentExts {
|
|
33
|
+
/**
|
|
34
|
+
* Additional extensions for components.
|
|
35
|
+
*
|
|
36
|
+
* @example ['vue']
|
|
37
|
+
* @default []
|
|
38
|
+
*/
|
|
39
|
+
componentExts?: string[]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface OptionsTypeScript extends OptionsOverrides {
|
|
43
|
+
/**
|
|
44
|
+
* When this options is provided, type aware rules will be enabled.
|
|
45
|
+
* @see https://typescript-eslint.io/linting/typed-linting/
|
|
46
|
+
*/
|
|
47
|
+
tsconfigPath?: string | string[]
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Additional parser options for TypeScript.
|
|
51
|
+
*/
|
|
52
|
+
parserOptions?: Partial<ParserOptions>
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Glob patterns for files that should be type aware.
|
|
56
|
+
* @default ['**\/*.{ts,tsx}']
|
|
57
|
+
*/
|
|
58
|
+
filesTypeAware?: string[]
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface StylisticConfig
|
|
62
|
+
extends Pick<StylisticCustomizeOptions, 'indent' | 'quotes' | 'jsx' | 'semi'>,
|
|
63
|
+
OptionsOverrides {}
|
|
64
|
+
|
|
65
|
+
export interface OptionsOverrides {
|
|
66
|
+
overrides?: TypedFlatConfigItem['rules']
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface FlatGitignoreOptions {
|
|
70
|
+
/**
|
|
71
|
+
* Name of the configuration.
|
|
72
|
+
* @default 'gitignore'
|
|
73
|
+
*/
|
|
74
|
+
name?: string
|
|
75
|
+
/**
|
|
76
|
+
* Path to `.gitignore` files, or files with compatible formats like `.eslintignore`.
|
|
77
|
+
*/
|
|
78
|
+
files?: string | string[]
|
|
79
|
+
/**
|
|
80
|
+
* Mark the current working directory as the root directory,
|
|
81
|
+
* disable searching for `.gitignore` files in parent directories.
|
|
82
|
+
*
|
|
83
|
+
* This option is not effective when `files` is explicitly specified.
|
|
84
|
+
* @default false
|
|
85
|
+
*/
|
|
86
|
+
root?: boolean
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface OptionsConfig extends OptionsComponentExts {
|
|
90
|
+
/**
|
|
91
|
+
* Core rules. Can't be disabled.
|
|
92
|
+
*/
|
|
93
|
+
javascript?: OptionsOverrides
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Enable TypeScript support.
|
|
97
|
+
*
|
|
98
|
+
* Passing an object to enable TypeScript Language Server support.
|
|
99
|
+
*
|
|
100
|
+
* @default auto-detect based on the dependencies
|
|
101
|
+
*/
|
|
102
|
+
typescript?: boolean | OptionsTypeScript
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Enable Vue support.
|
|
106
|
+
*
|
|
107
|
+
* @default auto-detect based on the dependencies
|
|
108
|
+
*/
|
|
109
|
+
vue?: boolean | OptionsVue
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Enable stylistic rules.
|
|
113
|
+
*
|
|
114
|
+
* @see https://eslint.style/
|
|
115
|
+
* @default true
|
|
116
|
+
*/
|
|
117
|
+
stylistic?: boolean | StylisticConfig
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Enable gitignore support.
|
|
121
|
+
*
|
|
122
|
+
* Passing an object to configure the options.
|
|
123
|
+
*
|
|
124
|
+
* @default true
|
|
125
|
+
*/
|
|
126
|
+
gitignore?: boolean | FlatGitignoreOptions
|
|
127
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { AnyObject } from '@lntvow/utils'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Rename plugin prefixes in a rule object.
|
|
5
|
+
* Accepts a map of prefixes to rename.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { renameRules } from '@lntvow/eslint-config'
|
|
10
|
+
*
|
|
11
|
+
* export default [{
|
|
12
|
+
* rules: renameRules(
|
|
13
|
+
* {
|
|
14
|
+
* '@typescript-eslint/indent': 'error'
|
|
15
|
+
* },
|
|
16
|
+
* { '@typescript-eslint': 'ts' }
|
|
17
|
+
* )
|
|
18
|
+
* }]
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export function renameRules(rules: AnyObject, map: Record<string, string>) {
|
|
22
|
+
return Object.fromEntries(
|
|
23
|
+
Object.entries(rules).map(([key, value]) => {
|
|
24
|
+
for (const [from, to] of Object.entries(map)) {
|
|
25
|
+
if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value]
|
|
26
|
+
}
|
|
27
|
+
return [key, value]
|
|
28
|
+
})
|
|
29
|
+
)
|
|
30
|
+
}
|
package/test/js.vue
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script setup lang="js">
|
|
2
|
+
import { computed, ref } from 'vue'
|
|
3
|
+
|
|
4
|
+
// interface Props {
|
|
5
|
+
// name: string
|
|
6
|
+
// age: number
|
|
7
|
+
// }
|
|
8
|
+
// defineProps<{
|
|
9
|
+
// name: string
|
|
10
|
+
// age: number
|
|
11
|
+
// }>()
|
|
12
|
+
|
|
13
|
+
console.log('computed: ')
|
|
14
|
+
|
|
15
|
+
console.log('pro: ', pro)
|
|
16
|
+
|
|
17
|
+
const a = 10
|
|
18
|
+
|
|
19
|
+
function test(str) {
|
|
20
|
+
return <div>{{ str }}</div>
|
|
21
|
+
}
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<template>
|
|
25
|
+
<div>111</div>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<style lang="scss"></style>
|
package/test/jsx.vue
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script setup lang="jsx">
|
|
2
|
+
import { computed, ref } from 'vue'
|
|
3
|
+
// interface Props {
|
|
4
|
+
// name: string
|
|
5
|
+
// age: number
|
|
6
|
+
// }
|
|
7
|
+
// defineProps<{
|
|
8
|
+
// name: string
|
|
9
|
+
// age: number
|
|
10
|
+
// }>()
|
|
11
|
+
|
|
12
|
+
console.log('computed: ')
|
|
13
|
+
|
|
14
|
+
console.log('pro: ', pro)
|
|
15
|
+
|
|
16
|
+
const a = 10
|
|
17
|
+
|
|
18
|
+
function test(str) {
|
|
19
|
+
return <div>{{ str }}</div>
|
|
20
|
+
}
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<div>111</div>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<style lang="scss"></style>
|
package/test/test.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { computed, defineComponent } from 'vue'
|
|
2
|
+
export const test = defineComponent({
|
|
3
|
+
setup() {
|
|
4
|
+
console.log('computed: ')
|
|
5
|
+
|
|
6
|
+
const pro = computed(() => Promise.all([new Promise((resolve, reject) => {})]))
|
|
7
|
+
console.log('pro: ', pro)
|
|
8
|
+
|
|
9
|
+
const a = 10
|
|
10
|
+
},
|
|
11
|
+
})
|
package/test/test.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { computed, defineComponent } from 'vue'
|
|
2
|
+
|
|
3
|
+
export const test = defineComponent({
|
|
4
|
+
setup() {
|
|
5
|
+
console.log('computed: ')
|
|
6
|
+
|
|
7
|
+
const pro = computed(() => Promise.all([new Promise((resolve, reject) => {})]))
|
|
8
|
+
console.log('pro: ', pro)
|
|
9
|
+
|
|
10
|
+
const a = 10
|
|
11
|
+
},
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
function b() {
|
|
15
|
+
return a
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const a = 10
|
package/test/ts.vue
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, ref } from 'vue'
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
name: string
|
|
6
|
+
age: number
|
|
7
|
+
}
|
|
8
|
+
defineProps<{
|
|
9
|
+
name: string
|
|
10
|
+
age: number
|
|
11
|
+
}>()
|
|
12
|
+
|
|
13
|
+
console.log('computed: ')
|
|
14
|
+
|
|
15
|
+
const a = 10
|
|
16
|
+
|
|
17
|
+
function test(str: string) {
|
|
18
|
+
return <div>{{ str }}</div>
|
|
19
|
+
}
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<template>
|
|
23
|
+
<div>111</div>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<style lang="scss"></style>
|
package/test/tsx.vue
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script setup lang="tsx">
|
|
2
|
+
import { computed, ref } from 'vue'
|
|
3
|
+
defineProps<{
|
|
4
|
+
name: string
|
|
5
|
+
age: number
|
|
6
|
+
}>()
|
|
7
|
+
|
|
8
|
+
console.log('computed: ')
|
|
9
|
+
|
|
10
|
+
console.log('pro: ', pro)
|
|
11
|
+
|
|
12
|
+
const a = 10
|
|
13
|
+
|
|
14
|
+
function test(str: string) {
|
|
15
|
+
return <div>{{ str }}</div>
|
|
16
|
+
}
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<template>
|
|
20
|
+
<div>111</div>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<style lang="scss"></style>
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"strict": true,
|
|
4
|
+
"target": "ESNext",
|
|
5
|
+
"jsx": "preserve",
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"moduleResolution": "Bundler",
|
|
8
|
+
"resolveJsonModule": true, // 允许从 .json 文件中导入模块
|
|
9
|
+
|
|
10
|
+
"baseUrl": ".",
|
|
11
|
+
"noImplicitThis": false,
|
|
12
|
+
"verbatimModuleSyntax": true,
|
|
13
|
+
"allowSyntheticDefaultImports": true
|
|
14
|
+
},
|
|
15
|
+
// "ts-node": {
|
|
16
|
+
// "esm": true
|
|
17
|
+
// },
|
|
18
|
+
"include": ["src/**/*", "tests/**/*"],
|
|
19
|
+
"exclude": ["node_modules", "dist"]
|
|
20
|
+
}
|
package/tsup.config.ts
ADDED
package/index.js
DELETED