Skip to content

Commit f4177a1

Browse files
committed
pref(all): 完全开始使用 eslint9
1 parent 2bc3419 commit f4177a1

File tree

84 files changed

+558
-194
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+558
-194
lines changed

api-model-node/eslint.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import {defineFlatConfig} from 'eslint-define-config'
2+
import {DefinedConfig} from '@compose/eslint9-config'
3+
4+
export default defineFlatConfig(DefinedConfig)

api-model-node/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
22
"name": "@compose/api-model-node",
3-
"version": "1.1.20",
3+
"version": "1.1.21",
44
"description": "yan100 client nodejs kit",
55
"author": "TrueNine",
66
"license": "private",
77
"scripts": {
88
"build-c": "vite build",
9-
"build": "run-s type-check build-c",
9+
"lint": "eslint --fix",
10+
"build": "run-s lint type-check build-c",
1011
"type-check": "vue-tsc --noEmit",
1112
"pub": "run-s build pub-c",
1213
"pub-c": "pnpm --dir dist pub"

api-model/eslint.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import {defineFlatConfig} from 'eslint-define-config'
2+
import {DefinedConfig} from '@compose/eslint9-config'
3+
4+
export default defineFlatConfig(DefinedConfig)

api-model/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
{
22
"name": "@compose/api-model",
3-
"version": "1.1.131",
3+
"version": "1.1.132",
44
"description": "yan100 js dev kit",
55
"author": "TrueNine",
66
"license": "private",
77
"scripts": {
88
"build-v": "vite build",
99
"build-c": "rollup --config rollup.config.ts --configPlugin typescript",
10-
"build": "run-s build-v build-c",
10+
"build": "run-s lint build-v build-c",
1111
"pub": "run-s build pub-c",
1212
"pub-c": "pnpm --dir ./dist pub",
1313
"test": "vitest",
14+
"lint": "eslint --fix",
1415
"fmt": "prettier --write \"**/*.{ts,tsx,vue,scss,d.ts,js}\" --ignore-unknown"
1516
},
1617
"type": "module",

api-model/src/data/idcard/IdcardUtils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class IdcardUtils {
1010
const month = Number(trimIdcard.substring(10, 12))
1111
const day = Number(trimIdcard.substring(12, 14))
1212
const d = new Date(year, month - 1, day)
13-
if (d.getTime() >= Date.now()) return undefined
13+
if (d.getTime() >= Date.now()) return void 0
1414

1515
const birthday = d.getTime()
1616

@@ -20,6 +20,6 @@ export class IdcardUtils {
2020
gender: Number(trimIdcard.substring(16, 17)) % 2 === 0 ? GenderTyping.WOMAN : GenderTyping.MAN,
2121
birthday: birthday satisfies timestamp
2222
}
23-
} else return undefined
23+
} else return void 0
2424
}
2525
}

api-model/src/defineds/RouteStream.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ function _toRouteTable(raw: RouteRecordRaw[], parent?: RouteOption) {
261261
path = e.path
262262
} else path = e.path
263263
} else path = STR_SLASH
264-
if (e.path === STR_EMPTY) return undefined
264+
if (e.path === STR_EMPTY) return void 0
265265

266266
const o = {
267267
uri: path,

api-model/src/references/DayJs.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class DayJs {
3939
date: p?.date || date,
4040
format: p?.format || format || ISO8601Format.datetime,
4141
utc: p?.utc || this.DEFAULT_UTC || false,
42-
tz: p?.tz || (p?.utc ? ISO8601TimeZone.UTC : undefined) || this.DEFAULT_TZ
42+
tz: p?.tz || (p?.utc ? ISO8601TimeZone.UTC : void 0) || this.DEFAULT_TZ
4343
}
4444
}
4545

@@ -69,7 +69,7 @@ export class DayJs {
6969
_p.utc = true
7070
_p.tz = ISO8601TimeZone.UTC
7171
const dg = this.timestampToTimeTimestamp(_p.date, _p)
72-
if (dg === undefined) return NaN
72+
if (dg === void 0) return NaN
7373
else return dg
7474
}
7575
}

api-model/src/references/Vue.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class Vue {
4949
if (!_p.name) _p = {..._p, name: _p.__name}
5050
_p.install = app => {
5151
for (const c of [_p, ...Object.values(_r != null ? _r : {})]) {
52-
const {name = undefined, __name = undefined} = _p
52+
const {name = void 0, __name = void 0} = _p
5353
app.component(__name || name || Vue.UNDEFINED_NAME, _p)
5454
app.component(_p.name || Vue.UNDEFINED_NAME, c)
5555
}

api-model/src/references/VueRouter.ts

+6-11
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const SUB_PAGE = 'SubPage'
3232
const VIEW_PAGE = 'View'
3333

3434
function resolvePageConfigToConfig(importMeta?: HandleRouteOption) {
35-
return importMeta ? (importMeta.source as unknown as late<AutoRouterConfig>) : undefined
35+
return importMeta ? (importMeta.source as unknown as late<AutoRouterConfig>) : void 0
3636
}
3737

3838
function processUrlAndName(tp: [string, ImportMeta]) {
@@ -125,27 +125,22 @@ export function resolveSubPath(pathRouteOption: HandledRouteOptions): CustomRout
125125
return path[0] === STR_SLASH ? path.substring(1) : path
126126
}
127127

128-
function deepFind(
129-
routes: RouteRecordRaw[],
130-
paths: Late<string[]> = undefined,
131-
startLength = 0,
132-
last: Late<RouteRecordRaw> = undefined
133-
): Late<RouteRecordRaw> {
134-
if (!paths || paths.length === 0) return undefined
135-
if (routes.length === 0 && startLength === 0) return undefined
128+
function deepFind(routes: RouteRecordRaw[], paths: Late<string[]> = void 0, startLength = 0, last: Late<RouteRecordRaw> = void 0): Late<RouteRecordRaw> {
129+
if (!paths || paths.length === 0) return void 0
130+
if (routes.length === 0 && startLength === 0) return void 0
136131
if (paths.length === startLength) return last
137132
const currentPath = paths[startLength]
138133
for (let i = 0; i < routes.length; i++) {
139134
if (cleanFirstSlash(currentPath) === cleanFirstSlash(routes[i].path)) {
140135
return deepFind(routes[i].children!, paths, startLength + 1, routes[i])
141136
}
142137
}
143-
return undefined
138+
return void 0
144139
}
145140

146141
view.forEach(e => {
147142
const root = deepFind(result, e.paths.slice(0, -1))
148-
if (root && root.children !== undefined) {
143+
if (root && root.children !== void 0) {
149144
const child = root.children
150145
const initPath = child.find(e => e.path === STR_EMPTY)
151146
if (initPath) initPath.components![e.name] = e.source

api-model/src/references/VueRouterMenu.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@ function combineURIs(uri1: string, uri2: string): string {
3737
* @param matchFn
3838
* @param clipPath
3939
*/
40-
export function generateMenu(routes: RouteRecordRaw[], matchFn: late<RouteMatchFn> = undefined, clipPath: late<string> = undefined): MenuObject[] {
40+
export function generateMenu(routes: RouteRecordRaw[], matchFn: late<RouteMatchFn> = void 0, clipPath: late<string> = void 0): MenuObject[] {
4141
return generateMenuInternal(routes, matchFn, clipPath)
42+
4243
function generateMenuInternal(
4344
routes: RouteRecordRaw[],
44-
matchFn: late<RouteMatchFn> = undefined,
45-
clipPath: late<string> = undefined,
45+
matchFn: late<RouteMatchFn> = void 0,
46+
clipPath: late<string> = void 0,
4647
parentPath: string = '',
4748
deepLevel = 0
4849
): MenuObject[] {
@@ -72,6 +73,7 @@ export function generateMenu(routes: RouteRecordRaw[], matchFn: late<RouteMatchF
7273
}
7374
return menuObj
7475
})
76+
7577
function clip(routes: RouteRecordRaw[], clipPath: string): RouteRecordRaw[] {
7678
for (const r of routes) {
7779
const fullPath = combineURIs(parentPath, r.path)

api-model/src/tools/Array.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export function mergeToMap<T extends object>(key: keyof T, arr: T[]): {[key in k
109109
}))
110110
return ks.reduce(
111111
(acc, cur) => {
112-
if (acc[cur.key] !== undefined) acc[cur.key].push(cur.value)
112+
if (acc[cur.key] !== void 0) acc[cur.key].push(cur.value)
113113
else acc[cur.key] = [cur.value]
114114
return acc
115115
},
@@ -123,7 +123,7 @@ export function mergeToMap<T extends object>(key: keyof T, arr: T[]): {[key in k
123123
* @param conditional 条件
124124
*/
125125
export function sameValue<T>(arr: T[], conditional: (t: T, old: T) => boolean = (t, old) => t === old): late<T> {
126-
if (arr.length === 0) return undefined
126+
if (arr.length === 0) return void 0
127127
const old = arr[0]
128-
return arr.every((v, i) => i === 0 || conditional(v, old)) ? old : undefined
128+
return arr.every((v, i) => i === 0 || conditional(v, old)) ? old : void 0
129129
}

api-model/src/tools/KotlinMock.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type {late} from '@compose/api-types'
22

33
export function takeIf<T>(value: late<T>, predicate: (value: T) => boolean = v => !!v): late<T> {
4-
return value && predicate(value) ? value : undefined
4+
return value && predicate(value) ? value : void 0
55
}
66

77
export function takeUnless<T>(value: late<T>, predicate: (value: T) => boolean = v => !!v): late<T> {
8-
return value && !predicate(value) ? value : undefined
8+
return value && !predicate(value) ? value : void 0
99
}

api-model/src/tools/Strings.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export function numberToChinese(num?: number, upperCase: boolean = false): late<
1010
const AA = upperCase ? __UPPERS_CHINESE_NUMBERS : __LOWVERS_CHINESE_NUMBERS
1111
const BB = upperCase ? __UPPERS_CHINESE_NUMBER_HEXS : __LOWERS_CHINESE_NUMBER_HEXS
1212

13-
if (num == null) return undefined
14-
if (!/^\d*(\.\d*)?$/.test(num.toString())) return undefined
13+
if (num == null) return void 0
14+
if (!/^\d*(\.\d*)?$/.test(num.toString())) return void 0
1515

1616
// eslint-disable-next-line
1717
let a: string[] = num.toString().replace(/(^0*)/g, '').split('.'),

api-model/src/tools/Values.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export function deepResolve<T extends Record<dynamic, dynamic> | dynamic[] = dyn
109109
const resolver = options.resolve ?? (v => v)
110110

111111
function _deepResolve<T = dynamic>(obj: T, depth = 0): T {
112-
if (obj === undefined || obj === null) return obj
112+
if (obj === void 0 || obj === null) return obj
113113
const isArr = Array.isArray(obj)
114114
if (typeof obj !== 'object' && !isArr) return obj
115115
const result: dynamic = isArr ? [] : {}

api-types/eslint.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import {defineFlatConfig} from 'eslint-define-config'
2+
import {DefinedConfig} from '@compose/eslint9-config'
3+
4+
export default defineFlatConfig(DefinedConfig)

api-types/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
{
22
"name": "@compose/api-types",
3-
"version": "1.0.126",
3+
"version": "1.0.127",
44
"description": "yan100 client ui kit",
55
"author": "TrueNine",
66
"license": "private",
77
"scripts": {
8-
"build": "run-s type-check build-c",
8+
"build": "run-s lint type-check build-c",
99
"build-c": "vite build",
1010
"type-check": "vue-tsc --noEmit",
1111
"pub": "run-s build pub-c",
1212
"pub-c": "pnpm --dir ./dist pub",
13+
"lint": "eslint --fix",
1314
"fmt": "prettier --write \"**/*.{ts,tsx,vue,scss,d.ts,js}\" --ignore-unknown"
1415
},
1516
"type": "module",

api-types/src/orm/address/Address.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ export interface Address extends ITreeEntity {
1111
leaf?: bool
1212
}
1313
// TODO 确定其类型
14-
export interface FullAddress extends Address {}
14+
export type FullAddress = Address

api-typings/eslint.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import {defineFlatConfig} from 'eslint-define-config'
2+
import {DefinedConfig} from '@compose/eslint9-config'
3+
4+
export default defineFlatConfig(DefinedConfig)

api-typings/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
{
22
"name": "@compose/api-typings",
3-
"version": "1.0.18",
3+
"version": "1.0.20",
44
"description": "yan100 enum defines",
55
"author": "TrueNine",
66
"license": "private",
77
"scripts": {
8-
"build": "run-s type-check build-c",
8+
"build": "run-s lint type-check build-c",
99
"build-c": "vite build",
1010
"type-check": "vue-tsc --noEmit",
1111
"pub": "run-s build pub-c",
1212
"pub-c": "pnpm --dir ./dist pub",
13+
"lint": "eslint --fix",
1314
"fmt": "prettier --write \"**/*.{ts,tsx,vue,scss,d.ts,js}\" --ignore-unknown"
1415
},
1516
"type": "module",

configs/eslint9/.npmignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.idea
2+
.vscode
3+
4+
node_modules
5+
6+
tsconfig.json
7+
8+
__test__**
9+
__tests__**
10+
__build-src__**
11+
12+
env.d.ts
13+
rollup.config.**
14+
vite.config.**
15+
vitest.config.**

configs/eslint9/package.json

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "@compose/eslint9-config",
3+
"version": "0.0.3",
4+
"scripts": {
5+
"build": "vite build",
6+
"pub": "run-s build pub-c",
7+
"pub-c": "pnpm --dir ./dist pub"
8+
},
9+
"type": "module",
10+
"module": "dist/index.js",
11+
"main": "dist/index.cjs",
12+
"types": "dist/index.d.ts",
13+
"exports": {
14+
".": {
15+
"types": "./dist/index.d.ts",
16+
"import": "./dist/index.js",
17+
"require": "./dist/index.cjs"
18+
},
19+
"./rules": {
20+
"types": "./dist/rules/index.d.ts",
21+
"import": "./dist/rules/index.js",
22+
"require": "./dist/rules/index.cjs"
23+
},
24+
"./globals": {
25+
"types": "./dist/globals/index.d.ts",
26+
"import": "./dist/globals/index.js",
27+
"require": "./dist/globals/index.cjs"
28+
},
29+
"./*": "./*"
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const ComposeGlobals = {
2+
TMap: true
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const WxpaGlobals = {
2+
wx: true
3+
}

configs/eslint9/src/globals/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './ComposeGlobals'
2+
export * from './WxpaGlobals'

configs/eslint9/src/index.ts

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import globals from 'globals'
2+
3+
import pluginJs from '@eslint/js'
4+
import tseslint from 'typescript-eslint'
5+
import pluginVue from 'eslint-plugin-vue'
6+
import {ComposeGlobals} from '@/globals'
7+
import pluginPrettierRecommendedConfigs from 'eslint-plugin-prettier/recommended'
8+
9+
import parserVue from 'vue-eslint-parser'
10+
import type {FlatESLintConfig, Parser, Rules} from 'eslint-define-config'
11+
import {VueRules} from '@/rules'
12+
import {TypescriptRules} from '@/rules/TypescriptRules'
13+
import {EcmaRules} from '@/rules/EcmaRules'
14+
15+
export {globals}
16+
17+
export const DefinedConfig = [
18+
{
19+
ignores: [
20+
'dist',
21+
'__build-src__',
22+
'vite.config.*',
23+
'vitest.config.*',
24+
'rollup.config.*',
25+
'uno.config.*',
26+
'**/example/**',
27+
'**/examples/**',
28+
'node_modules',
29+
'__tests__',
30+
'__test__',
31+
'playground'
32+
]
33+
},
34+
{
35+
languageOptions: {
36+
globals: {
37+
...globals.browser,
38+
...ComposeGlobals
39+
}
40+
}
41+
},
42+
pluginJs.configs.recommended,
43+
...tseslint.configs.recommended,
44+
...pluginVue.configs['flat/strongly-recommended'],
45+
pluginPrettierRecommendedConfigs,
46+
{
47+
rules: {
48+
...EcmaRules,
49+
...TypescriptRules
50+
} as Partial<Rules>
51+
},
52+
{
53+
files: ['**/*.vue'],
54+
rules: {...VueRules},
55+
languageOptions: {
56+
ecmaVersion: 'latest',
57+
parser: parserVue,
58+
parserOptions: {
59+
ecmaFeatures: {jsx: true},
60+
parser: tseslint.parser as unknown as Parser
61+
}
62+
}
63+
} as FlatESLintConfig
64+
]

0 commit comments

Comments
 (0)