Commit 6890dd720135b52e2d810fd85ae44062bec0c661
1 parent
762e5dee
perf: 新包使用更严格的eslint
Showing
20 changed files
with
96 additions
and
46 deletions
internal/eslint-config/.eslintrc.js
internal/eslint-config/src/strict.ts
1 | -import baseLintConfig from './index'; | |
2 | - | |
3 | 1 | export default { |
4 | - extends: [baseLintConfig], | |
2 | + extends: ['@vben'], | |
5 | 3 | plugins: ['simple-import-sort'], |
6 | 4 | rules: { |
7 | 5 | 'simple-import-sort/imports': 'error', |
8 | 6 | 'simple-import-sort/exports': 'error', |
9 | 7 | |
10 | - '@typescript-eslint/ban-types': 'error', | |
11 | - '@typescript-eslint/ban-ts-ignore': 'error', | |
12 | - '@typescript-eslint/ban-ts-comment': 'error', | |
13 | - '@typescript-eslint/no-explicit-any': 'error', | |
8 | + '@typescript-eslint/ban-ts-comment': [ | |
9 | + 'error', | |
10 | + { | |
11 | + 'ts-expect-error': 'allow-with-description', | |
12 | + 'ts-ignore': 'allow-with-description', | |
13 | + 'ts-nocheck': 'allow-with-description', | |
14 | + 'ts-check': false, | |
15 | + }, | |
16 | + ], | |
17 | + | |
18 | + /** | |
19 | + * 【强制】关键字前后有一个空格 | |
20 | + * @link https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/keyword-spacing.md | |
21 | + */ | |
22 | + 'keyword-spacing': 'off', | |
23 | + '@typescript-eslint/keyword-spacing': [ | |
24 | + 'error', | |
25 | + { | |
26 | + before: true, | |
27 | + after: true, | |
28 | + overrides: { | |
29 | + return: { after: true }, | |
30 | + throw: { after: true }, | |
31 | + case: { after: true }, | |
32 | + }, | |
33 | + }, | |
34 | + ], | |
35 | + | |
36 | + /** | |
37 | + * 禁止出现空函数,普通函数(非 async/await/generator)、箭头函数、类上的方法除外 | |
38 | + * @link https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-empty-function.md | |
39 | + */ | |
40 | + 'no-empty-function': 'off', | |
41 | + '@typescript-eslint/no-empty-function': [ | |
42 | + 'error', | |
43 | + { | |
44 | + allow: ['arrowFunctions', 'functions', 'methods'], | |
45 | + }, | |
46 | + ], | |
47 | + | |
48 | + /** | |
49 | + * 优先使用 interface 而不是 type 定义对象类型 | |
50 | + * @link https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-type-definitions.md | |
51 | + */ | |
52 | + '@typescript-eslint/consistent-type-definitions': ['warn', 'interface'], | |
14 | 53 | |
15 | 54 | 'vue/attributes-order': 'error', |
16 | 55 | 'vue/require-default-prop': 'error', | ... | ... |
internal/stylelint-config/.eslintrc.js
internal/vite-config/.eslintrc.js
internal/vite-config/src/config/application.ts
1 | -import { type UserConfig, defineConfig, mergeConfig, loadEnv } from 'vite'; | |
2 | 1 | import { resolve } from 'node:path'; |
2 | + | |
3 | +import dayjs from 'dayjs'; | |
3 | 4 | import { readPackageJSON } from 'pkg-types'; |
5 | +import { defineConfig, loadEnv, mergeConfig, type UserConfig } from 'vite'; | |
6 | + | |
7 | +import { createPlugins } from '../plugins'; | |
4 | 8 | import { generateModifyVars } from '../utils/modifyVars'; |
5 | 9 | import { commonConfig } from './common'; |
6 | -import { createPlugins } from '../plugins'; | |
7 | -import dayjs from 'dayjs'; | |
8 | 10 | |
9 | 11 | interface DefineOptions { |
10 | 12 | overrides?: UserConfig; |
11 | - options?: {}; | |
13 | + options?: { | |
14 | + // | |
15 | + }; | |
12 | 16 | } |
13 | 17 | |
14 | 18 | function defineApplicationConfig(defineOptions: DefineOptions = {}) { | ... | ... |
internal/vite-config/src/config/common.ts
internal/vite-config/src/config/package.ts
1 | -import { type UserConfig, defineConfig, mergeConfig } from 'vite'; | |
2 | 1 | import { readPackageJSON } from 'pkg-types'; |
3 | -import { commonConfig } from './common'; | |
2 | +import { defineConfig, mergeConfig, type UserConfig } from 'vite'; | |
4 | 3 | import dts from 'vite-plugin-dts'; |
5 | 4 | |
5 | +import { commonConfig } from './common'; | |
6 | + | |
6 | 7 | interface DefineOptions { |
7 | 8 | overrides?: UserConfig; |
8 | - options?: {}; | |
9 | + options?: { | |
10 | + // | |
11 | + }; | |
9 | 12 | } |
10 | 13 | |
11 | 14 | function definePackageConfig(defineOptions: DefineOptions = {}) { | ... | ... |
internal/vite-config/src/plugins/appConfig.ts
1 | +import colors from 'picocolors'; | |
2 | +import { readPackageJSON } from 'pkg-types'; | |
1 | 3 | import { type PluginOption } from 'vite'; |
4 | + | |
2 | 5 | import { getEnvConfig } from '../utils/env'; |
3 | 6 | import { createContentHash } from '../utils/hash'; |
4 | -import { readPackageJSON } from 'pkg-types'; | |
5 | -import colors from 'picocolors'; | |
6 | 7 | |
7 | 8 | const GLOBAL_CONFIG_FILE_NAME = '_app.config.js'; |
8 | 9 | const PLUGIN_NAME = 'app-config'; | ... | ... |
internal/vite-config/src/plugins/index.ts
1 | +import vue from '@vitejs/plugin-vue'; | |
2 | +import vueJsx from '@vitejs/plugin-vue-jsx'; | |
3 | +// @ts-ignore: type unless | |
4 | +import DefineOptions from 'unplugin-vue-define-options/vite'; | |
1 | 5 | import { type PluginOption } from 'vite'; |
6 | +import purgeIcons from 'vite-plugin-purge-icons'; | |
7 | + | |
8 | +import { createAppConfigPlugin } from './appConfig'; | |
9 | +import { configCompressPlugin } from './compress'; | |
2 | 10 | import { configHtmlPlugin } from './html'; |
3 | 11 | import { configMockPlugin } from './mock'; |
4 | -import { configCompressPlugin } from './compress'; | |
5 | -import { configVisualizerConfig } from './visualizer'; | |
6 | 12 | import { configSvgIconsPlugin } from './svgSprite'; |
7 | -import { createAppConfigPlugin } from './appConfig'; | |
8 | -import vue from '@vitejs/plugin-vue'; | |
9 | -import vueJsx from '@vitejs/plugin-vue-jsx'; | |
10 | -import purgeIcons from 'vite-plugin-purge-icons'; | |
11 | -// @ts-ignore | |
12 | -import DefineOptions from 'unplugin-vue-define-options/vite'; | |
13 | +import { configVisualizerConfig } from './visualizer'; | |
13 | 14 | |
14 | 15 | interface Options { |
15 | 16 | isBuild: boolean; | ... | ... |
internal/vite-config/src/plugins/svgSprite.ts
... | ... | @@ -3,9 +3,10 @@ |
3 | 3 | * https://github.com/anncwb/vite-plugin-svg-icons |
4 | 4 | */ |
5 | 5 | |
6 | -import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'; | |
7 | 6 | import { resolve } from 'node:path'; |
7 | + | |
8 | 8 | import type { PluginOption } from 'vite'; |
9 | +import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'; | |
9 | 10 | |
10 | 11 | export function configSvgIconsPlugin({ isBuild }: { isBuild: boolean }) { |
11 | 12 | const svgIconsPlugin = createSvgIconsPlugin({ | ... | ... |
internal/vite-config/src/plugins/visualizer.ts
internal/vite-config/src/utils/env.ts
internal/vite-config/src/utils/modifyVars.ts
packages/hooks/.eslintrc.js
packages/hooks/src/index.ts
packages/hooks/src/onMountedOrActivated.ts
packages/hooks/src/useAttrs.ts
packages/hooks/src/useRefs.ts
packages/types/.eslintrc.js
packages/types/src/utils.ts
... | ... | @@ -31,9 +31,9 @@ type Recordable<T> = Record<string, T>; |
31 | 31 | /** |
32 | 32 | * 字符串类型对象(只读) |
33 | 33 | */ |
34 | -type ReadonlyRecordable<T = any> = { | |
34 | +interface ReadonlyRecordable<T = any> { | |
35 | 35 | readonly [key: string]: T; |
36 | -}; | |
36 | +} | |
37 | 37 | |
38 | 38 | /** |
39 | 39 | * setTimeout 返回值类型 |
... | ... | @@ -47,12 +47,12 @@ type IntervalHandle = ReturnType<typeof setInterval>; |
47 | 47 | |
48 | 48 | export { |
49 | 49 | type AnyFunction, |
50 | - type AnyPromiseFunction, | |
51 | 50 | type AnyNormalFunction, |
52 | - type Nullable, | |
51 | + type AnyPromiseFunction, | |
52 | + type IntervalHandle, | |
53 | 53 | type NonNullable, |
54 | - type Recordable, | |
54 | + type Nullable, | |
55 | 55 | type ReadonlyRecordable, |
56 | + type Recordable, | |
56 | 57 | type TimeoutHandle, |
57 | - type IntervalHandle, | |
58 | 58 | }; | ... | ... |