@lntvow/eslint-config 9.1.2 → 9.2.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.
Files changed (49) hide show
  1. package/dist/index.cjs +1 -0
  2. package/{src/typegen.d.ts → dist/index.d.cts} +186 -28
  3. package/dist/index.d.ts +15281 -0
  4. package/dist/index.js +1 -0
  5. package/package.json +5 -2
  6. package/.czrc +0 -3
  7. package/.editorconfig +0 -14
  8. package/.env.development +0 -1
  9. package/.env.production +0 -1
  10. package/.env.uat +0 -1
  11. package/.github/workflows/publish-npm.yml +0 -44
  12. package/.husky/commit-msg +0 -4
  13. package/.husky/pre-commit +0 -4
  14. package/.lintstagedrc +0 -4
  15. package/.prettierrc +0 -10
  16. package/.vscode/settings.json +0 -14
  17. package/api/basic.js +0 -22
  18. package/api/vue.js +0 -34
  19. package/commitlint.config.cjs +0 -4
  20. package/eslint.config.js +0 -21
  21. package/packages/eslint-config-ts/index.js +0 -85
  22. package/packages/eslint-config-ts/package.json +0 -18
  23. package/packages/eslint-plugin/index.js +0 -5
  24. package/packages/eslint-plugin/package.json +0 -16
  25. package/packages/eslint-plugin/rules/get.js +0 -18
  26. package/packages/eslint-plugin/test/get.test.js +0 -39
  27. package/src/configs/gitignore.ts +0 -34
  28. package/src/configs/ignores.ts +0 -10
  29. package/src/configs/imports.ts +0 -17
  30. package/src/configs/index.ts +0 -8
  31. package/src/configs/javascript.ts +0 -161
  32. package/src/configs/prettier.ts +0 -18
  33. package/src/configs/stylistic.ts +0 -59
  34. package/src/configs/typescript.ts +0 -63
  35. package/src/configs/vue.ts +0 -316
  36. package/src/factory.ts +0 -167
  37. package/src/globs.ts +0 -86
  38. package/src/index.ts +0 -7
  39. package/src/types.ts +0 -127
  40. package/src/typings/index.d.ts +0 -3
  41. package/src/utils/index.ts +0 -30
  42. package/test/js.vue +0 -28
  43. package/test/jsx.vue +0 -27
  44. package/test/test.js +0 -11
  45. package/test/test.ts +0 -18
  46. package/test/ts.vue +0 -26
  47. package/test/tsx.vue +0 -23
  48. package/tsconfig.json +0 -20
  49. package/tsup.config.ts +0 -10
package/src/factory.ts DELETED
@@ -1,167 +0,0 @@
1
- import { FlatConfigComposer } from 'eslint-flat-config-utils'
2
- import type { Linter } from 'eslint'
3
- import { isBoolean } from '@lntvow/utils'
4
- import { isPackageExists } from 'local-pkg'
5
- import { gitignore, ignores, javascript, typescript, vue } from './configs'
6
- import type { Awaitable, ConfigNames, OptionsConfig, TypedFlatConfigItem } from './types'
7
- import { stylistic } from './configs/stylistic'
8
- import { imports } from './configs/imports'
9
- import { prettier } from './configs/prettier'
10
-
11
- const flatConfigProps: (keyof TypedFlatConfigItem)[] = [
12
- 'name',
13
- 'files',
14
- 'ignores',
15
- 'languageOptions',
16
- 'linterOptions',
17
- 'processor',
18
- 'plugins',
19
- 'rules',
20
- 'settings',
21
- ]
22
-
23
- export function lntvow(
24
- options: OptionsConfig & TypedFlatConfigItem = {},
25
- ...userConfigs: Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[] | FlatConfigComposer | Linter.FlatConfig[]>[]
26
- ): FlatConfigComposer<TypedFlatConfigItem, ConfigNames> {
27
- const {
28
- // autoRenamePlugins = true,
29
- componentExts = [],
30
- gitignore: enableGitignore = true,
31
- // regexp: enableRegexp = true,
32
- typescript: enableTypeScript = isPackageExists('typescript'),
33
- vue: enableVue = ['vue', 'nuxt', 'vitepress'].some(i => isPackageExists(i)),
34
- } = options
35
-
36
- const stylisticOptions =
37
- options.stylistic === false ? false : typeof options.stylistic === 'object' ? options.stylistic : {}
38
-
39
- // if (stylisticOptions && !('jsx' in stylisticOptions)) stylisticOptions.jsx = options.jsx ?? true
40
-
41
- const configs: Awaitable<TypedFlatConfigItem[]>[] = []
42
-
43
- // Base configs
44
- configs.push(
45
- ignores(),
46
- javascript({
47
- ...resolveSubOptions(options, 'javascript'),
48
- }),
49
- imports()
50
- // comments(),
51
- // node(),
52
- // jsdoc({
53
- // stylistic: stylisticOptions,
54
- // }),
55
- // unicorn(),
56
- // command(),
57
-
58
- // Optional plugins (installed but not enabled by default)
59
- // perfectionist(),
60
- )
61
-
62
- if (enableGitignore) {
63
- configs.push(gitignore(resolveSubOptions(options, 'gitignore')))
64
- }
65
-
66
- if (enableVue) {
67
- componentExts.push('vue')
68
- }
69
-
70
- if (enableTypeScript) {
71
- configs.push(typescript({ ...resolveSubOptions(options, 'typescript'), componentExts }))
72
- }
73
-
74
- if (stylisticOptions) {
75
- configs.push(stylistic({ ...stylisticOptions }))
76
- }
77
-
78
- // if (enableRegexp)
79
- // configs.push(regexp(typeof enableRegexp === 'boolean' ? {} : enableRegexp))
80
-
81
- // if (options.test ?? true) {
82
- // configs.push(test({
83
- // isInEditor,
84
- // overrides: getOverrides(options, 'test'),
85
- // }))
86
- // }
87
-
88
- if (enableVue) {
89
- configs.push(vue({ ...resolveSubOptions(options, 'vue') }))
90
- }
91
-
92
- // if (options.jsonc ?? true) {
93
- // configs.push(
94
- // jsonc({
95
- // overrides: getOverrides(options, 'jsonc'),
96
- // stylistic: stylisticOptions,
97
- // }),
98
- // sortPackageJson(),
99
- // sortTsconfig(),
100
- // )
101
- // }
102
-
103
- // if (options.yaml ?? true) {
104
- // configs.push(yaml({
105
- // overrides: getOverrides(options, 'yaml'),
106
- // stylistic: stylisticOptions,
107
- // }))
108
- // }
109
-
110
- // if (options.toml ?? true) {
111
- // configs.push(toml({
112
- // overrides: getOverrides(options, 'toml'),
113
- // stylistic: stylisticOptions,
114
- // }))
115
- // }
116
-
117
- // if (options.markdown ?? true) {
118
- // configs.push(
119
- // markdown(
120
- // {
121
- // componentExts,
122
- // overrides: getOverrides(options, 'markdown'),
123
- // },
124
- // ),
125
- // )
126
- // }
127
-
128
- // if (options.formatters) {
129
- // configs.push(formatters(
130
- // options.formatters,
131
- // typeof stylisticOptions === 'boolean' ? {} : stylisticOptions,
132
- // ))
133
- // }
134
-
135
- configs.push(prettier())
136
-
137
- // User can optionally pass a flat config item to the first argument
138
- const fusedConfig = flatConfigProps.reduce((acc, key) => {
139
- if (key in options) {
140
- acc[key] = options[key] as any
141
- }
142
- return acc
143
- }, {} as TypedFlatConfigItem)
144
-
145
- if (Object.keys(fusedConfig).length) {
146
- configs.push([fusedConfig])
147
- }
148
-
149
- // Merge all configs
150
- let composer = new FlatConfigComposer<TypedFlatConfigItem, ConfigNames>()
151
- composer = composer.append(...configs, ...(userConfigs as any))
152
-
153
- // if (autoRenamePlugins) {
154
- // composer = composer.renamePlugins(defaultPluginRenaming)
155
- // }
156
-
157
- return composer
158
- }
159
-
160
- export type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>
161
-
162
- export function resolveSubOptions<K extends keyof OptionsConfig>(
163
- options: OptionsConfig,
164
- key: K
165
- ): ResolvedOptions<OptionsConfig[K]> {
166
- return isBoolean(options[key]) ? ({} as any) : options[key] || {}
167
- }
package/src/globs.ts DELETED
@@ -1,86 +0,0 @@
1
- export const GLOB_SRC_EXT = '?([cm])[jt]s?(x)'
2
- export const GLOB_SRC = '**/*.?([cm])[jt]s?(x)'
3
-
4
- export const GLOB_JS = '**/*.?([cm])js'
5
- export const GLOB_JSX = '**/*.?([cm])jsx'
6
-
7
- export const GLOB_TS = '**/*.?([cm])ts'
8
- export const GLOB_TSX = '**/*.?([cm])tsx'
9
-
10
- export const GLOB_STYLE = '**/*.{c,le,sc}ss'
11
- export const GLOB_CSS = '**/*.css'
12
- export const GLOB_POSTCSS = '**/*.{p,post}css'
13
- export const GLOB_LESS = '**/*.less'
14
- export const GLOB_SCSS = '**/*.scss'
15
-
16
- export const GLOB_JSON = '**/*.json'
17
- export const GLOB_JSON5 = '**/*.json5'
18
- export const GLOB_JSONC = '**/*.jsonc'
19
-
20
- export const GLOB_MARKDOWN = '**/*.md'
21
- export const GLOB_MARKDOWN_IN_MARKDOWN = '**/*.md/*.md'
22
- export const GLOB_SVELTE = '**/*.svelte'
23
- export const GLOB_VUE = '**/*.vue'
24
- export const GLOB_YAML = '**/*.y?(a)ml'
25
- export const GLOB_TOML = '**/*.toml'
26
- export const GLOB_XML = '**/*.xml'
27
- export const GLOB_HTML = '**/*.htm?(l)'
28
- export const GLOB_ASTRO = '**/*.astro'
29
- export const GLOB_GRAPHQL = '**/*.{g,graph}ql'
30
-
31
- export const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`
32
-
33
- export const GLOB_TESTS = [
34
- `**/__tests__/**/*.${GLOB_SRC_EXT}`,
35
- `**/*.spec.${GLOB_SRC_EXT}`,
36
- `**/*.test.${GLOB_SRC_EXT}`,
37
- `**/*.bench.${GLOB_SRC_EXT}`,
38
- `**/*.benchmark.${GLOB_SRC_EXT}`,
39
- ]
40
-
41
- export const GLOB_ALL_SRC = [
42
- GLOB_SRC,
43
- GLOB_STYLE,
44
- GLOB_JSON,
45
- GLOB_JSON5,
46
- GLOB_MARKDOWN,
47
- GLOB_SVELTE,
48
- GLOB_VUE,
49
- GLOB_YAML,
50
- GLOB_XML,
51
- GLOB_HTML,
52
- ]
53
-
54
- export const GLOB_EXCLUDE = [
55
- '**/node_modules',
56
- '**/dist',
57
- '**/package-lock.json',
58
- '**/yarn.lock',
59
- '**/pnpm-lock.yaml',
60
- '**/bun.lockb',
61
-
62
- '**/output',
63
- '**/coverage',
64
- '**/temp',
65
- '**/.temp',
66
- '**/tmp',
67
- '**/.tmp',
68
- '**/.history',
69
- '**/.vitepress/cache',
70
- '**/.nuxt',
71
- '**/.next',
72
- '**/.vercel',
73
- '**/.changeset',
74
- '**/.idea',
75
- '**/.cache',
76
- '**/.output',
77
- '**/.vite-inspect',
78
- '**/.yarn',
79
-
80
- '**/CHANGELOG*.md',
81
- '**/*.min.*',
82
- '**/LICENSE*',
83
- '**/__snapshots__',
84
- '**/auto-import?(s).d.ts',
85
- '**/components.d.ts',
86
- ]
package/src/index.ts DELETED
@@ -1,7 +0,0 @@
1
- import { lntvow } from './factory'
2
-
3
- export * from './utils'
4
- export * from './configs'
5
- export * from './globs'
6
- export { lntvow } from './factory'
7
- export default lntvow
package/src/types.ts DELETED
@@ -1,127 +0,0 @@
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
- }
@@ -1,3 +0,0 @@
1
- declare module 'eslint-plugin-vue'
2
- declare module '@eslint/js'
3
- declare module 'parse-gitignore'
@@ -1,30 +0,0 @@
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 DELETED
@@ -1,28 +0,0 @@
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 DELETED
@@ -1,27 +0,0 @@
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 DELETED
@@ -1,11 +0,0 @@
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 DELETED
@@ -1,18 +0,0 @@
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 DELETED
@@ -1,26 +0,0 @@
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 DELETED
@@ -1,23 +0,0 @@
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 DELETED
@@ -1,20 +0,0 @@
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 DELETED
@@ -1,10 +0,0 @@
1
- import { defineConfig } from 'tsup'
2
-
3
- export default defineConfig({
4
- format: ['esm'],
5
- dts: true,
6
- clean: true,
7
- entry: ['src/index.ts'],
8
- shims: true,
9
- // minify: true,
10
- })