Skip to content

Commit 7e9ea82

Browse files
committed
Refactor: Migrate ESLint configuration to new format and update dependencies
1 parent cf2bf43 commit 7e9ea82

16 files changed

+2325
-1007
lines changed

.eslintrc.yml

-3
This file was deleted.

.github/workflows/e2e.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
version: 8
2121
- uses: actions/setup-node@v4
2222
with:
23-
node-version: 20
23+
node-version: 22
2424
cache: 'pnpm'
2525
- run: pnpm install
2626
- run: pnpm exec playwright install --with-deps

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
version: 8
2424
- uses: actions/setup-node@v4
2525
with:
26-
node-version: 20
26+
node-version: 22
2727
cache: "pnpm"
2828
- run: pnpm install
2929
- run: pnpm install semantic-release-config-techor --workspace-root

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"url": "https://github.com/master-co/styled.git"
2121
},
2222
"dependencies": {
23-
"@techor/repo": "^3.0.17"
23+
"@techor/repo": "^3.1.4",
24+
"eslint": "^9.16.0"
2425
},
2526
"devDependencies": {
2627
"class-variant": "workspace:^"

packages/core/.eslintrc.yml

-2
This file was deleted.

packages/core/eslint.config.mjs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import techor from 'eslint-config-techor'
2+
3+
export default [
4+
techor.configs.base,
5+
techor.configs.stylistic,
6+
techor.configs.typescript,
7+
]

packages/core/src/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ type ReturnType<T> = { default?: Partial<T> } & ((valueByProp?: T) => string)
2222
* 5. { intent: { primary: 'bg:blue-50 fg:white', secondary: 'bg:white fg:gray-80' }, size: { sm: 'font:20 py:1 px:2', md: 'font:16 py:2 px:4' }, disabled: 'opacity:.5' }
2323
* 6. ({ $intent, $size }) => $intent && $size && 'font:italic'
2424
*/
25-
function cv<T extends Record<string, string | number | boolean>>(...params: Array<Param<T>>): ReturnType<T>
26-
function cv<T extends Record<string, string | number | boolean>>(firstParam: TemplateStringsArray, ...params: Array<Param<T>>): ReturnType<T>
27-
function cv<T extends Record<string, string | number | boolean>>(firstParam: TemplateStringsArray | Param<T>, ...params: Array<Param<T>>): ReturnType<T> {
25+
function cv<T extends Record<string, string | number | boolean>>(...params: Param<T>[]): ReturnType<T>
26+
function cv<T extends Record<string, string | number | boolean>>(firstParam: TemplateStringsArray, ...params: Param<T>[]): ReturnType<T>
27+
function cv<T extends Record<string, string | number | boolean>>(firstParam: TemplateStringsArray | Param<T>, ...params: Param<T>[]): ReturnType<T> {
2828
return function getClassNames(valueByProp: T = {} as any) {
2929
// 如果 valueByProps 中的屬性是 undefined 或是 null,則使用 default 中的值
3030
const defaultProps = (getClassNames as ReturnType<T>).default

packages/react/.eslintrc.yml

-32
This file was deleted.

packages/react/eslint.config.mjs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import techor from 'eslint-config-techor'
2+
3+
export default [
4+
techor.configs.base,
5+
techor.configs.stylistic,
6+
techor.configs.typescript,
7+
techor.configs.react
8+
]

packages/react/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
},
7070
"devDependencies": {
7171
"@playwright/experimental-ct-react": "1.49.0",
72-
"@playwright/test": "1.49.0",
73-
"eslint-plugin-react-hooks": "^4.6.0"
72+
"@playwright/test": "1.49.0"
7473
}
7574
}

packages/react/src/index.tsx

+7-13
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ type baseType<E> = string
77
| Record<string, boolean>
88
| [string, { [key in keyof E]?: E[key] }]
99
| { [key in keyof E]?: E[key] extends boolean | undefined ? string : Record<string, string> }
10-
type baseLoopType<E> = baseType<E> | Array<baseType<E>>;
11-
type extraType<E> = { className?: baseLoopType<E> | undefined, [key: string]: any };
12-
type TagParams = Array<[TemplateStringsArray, any[]]>;
10+
type baseLoopType<E> = baseType<E> | baseType<E>[];
11+
interface extraType<E> { className?: baseLoopType<E> | undefined, [key: string]: any }
12+
type TagParams = [TemplateStringsArray, any[]][];
1313

1414
type IntrinsicElementsKeys = keyof JSX.IntrinsicElements;
1515
type MasterComponentProps<K extends IntrinsicElementsKeys | React.ComponentType<any>, E extends object = object> = extraType<E> & (Omit<(K extends IntrinsicElementsKeys
@@ -22,7 +22,7 @@ type MasterComponentProps<K extends IntrinsicElementsKeys | React.ComponentType<
2222
type MasterExoticComponent<K extends IntrinsicElementsKeys | React.ComponentType<any>, E extends object = object> = React.ForwardRefExoticComponent<MasterComponentProps<K, E> & React.RefAttributes<K>> & { tag: K, params: TagParams, default?: MasterComponentProps<K, E> };
2323

2424
type ParamType<K extends IntrinsicElementsKeys | React.ComponentType<any>, E extends object = object> = ((props: MasterComponentProps<K, E>) => baseLoopType<MasterComponentProps<K, E>> | undefined) | baseLoopType<MasterComponentProps<K, E>>
25-
type ParamsType<K extends IntrinsicElementsKeys | React.ComponentType<any>, E extends object = object> = Array<ParamType<K, E>>;
25+
type ParamsType<K extends IntrinsicElementsKeys | React.ComponentType<any>, E extends object = object> = ParamType<K, E>[];
2626

2727
type ReturnType<K extends IntrinsicElementsKeys | React.ComponentType<any>, E extends object = object> = <F extends TemplateStringsArray | MasterExoticComponent<any> | baseType<E>>(
2828
firstParam: F,
@@ -36,14 +36,8 @@ type ReturnType<K extends IntrinsicElementsKeys | React.ComponentType<any>, E ex
3636
const styled: {
3737
[key in IntrinsicElementsKeys]: (<E extends object = object>(firstParam: TemplateStringsArray | ParamType<key, E>, ...params: ParamsType<key, E>) => MasterExoticComponent<key, E>)
3838
& (<F extends MasterExoticComponent<any, any>, E extends object = object>(firstParam: F) => F extends MasterExoticComponent<any, infer ME> ? ReturnType<key, ME & E> : never)
39-
} & {
40-
<F extends MasterExoticComponent<any>, E extends object = object>(firstParam: F): F extends MasterExoticComponent<infer K, infer ME> ? ReturnType<K, ME & E> : never
41-
} & {
42-
<E extends object = object>(firstParam: TemplateStringsArray | ParamType<'div', E>, ...params: ParamsType<'div', E>): MasterExoticComponent<'div', E>
43-
} & {
44-
//@ts-ignore
45-
<F extends React.ComponentType<any>, E extends object = object>(firstParam: F, ...params: F extends React.ComponentType<infer RE> ? ParamsType<'div', RE & E> : never): F extends React.ComponentType<infer RE> ? ReturnType<React.ComponentType<RE & E>> : never
46-
} = new Proxy(
39+
} & (<F extends MasterExoticComponent<any>, E extends object = object>(firstParam: F) => F extends MasterExoticComponent<infer K, infer ME> ? ReturnType<K, ME & E> : never) & (<E extends object = object>(firstParam: TemplateStringsArray | ParamType<'div', E>, ...params: ParamsType<'div', E>) => MasterExoticComponent<'div', E>) & //@ts-ignore
40+
(<F extends React.ComponentType<any>, E extends object = object>(firstParam: F, ...params: F extends React.ComponentType<infer RE> ? ParamsType<'div', RE & E> : never) => F extends React.ComponentType<infer RE> ? ReturnType<React.ComponentType<RE & E>> : never) = new Proxy(
4741
((firstParam: any, ...params: any[]) => {
4842
return (Array.isArray(firstParam) && 'raw' in firstParam || typeof firstParam !== 'object' || !('render' in firstParam))
4943
? styled.div(firstParam as any, ...params)
@@ -139,7 +133,7 @@ function handle<K extends IntrinsicElementsKeys | React.ComponentType<any>, E ex
139133
}
140134
break
141135
case 'function':
142-
// eslint-disable-next-line no-case-declarations
136+
143137
const transformedParam = param(props)
144138
if (typeof transformedParam === 'object' && handleParam(transformedParam))
145139
return true

packages/vue/.eslintrc.yml

-32
This file was deleted.

packages/vue/eslint.config.mjs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import techor from 'eslint-config-techor'
2+
import vue from 'eslint-plugin-vue'
3+
4+
export default [
5+
techor.configs.base,
6+
techor.configs.stylistic,
7+
techor.configs.typescript,
8+
...vue.configs['flat/essential'],
9+
{
10+
files: ['**/*.vue'],
11+
rules: {
12+
'vue/multi-word-component-names': 'off'
13+
},
14+
languageOptions: {
15+
parserOptions: {
16+
parser: '@typescript-eslint/parser'
17+
}
18+
}
19+
}
20+
]

packages/vue/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"@vue/server-renderer": "^3.4.19",
7474
"@vue/test-utils": "^2.4.4",
7575
"@vue/tsconfig": "^0.7.0",
76+
"eslint-plugin-vue": "^9.32.0",
7677
"typescript": "5.6.2",
7778
"vite": "^6.0.1",
7879
"vue-tsc": "^2.0.29"

packages/vue/src/index.ts

+8-16
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ type IfEquals<X, Y, A = X, B = never> = (<T>() => T extends X ? 1 : 2) extends (
88
: B
99
type WritableKeys<T> = {
1010
[P in keyof T]-?: IfEquals<
11-
{ [Q in P]: T[P]; },
12-
{ -readonly [Q in P]: T[P] },
11+
Record<P, T[P]>,
12+
Record<P, T[P]>,
1313
P
1414
>
1515
}[keyof T];
@@ -23,15 +23,15 @@ type BaseType<E> = string
2323
| string[]
2424
| Record<string, boolean>
2525
| (
26-
E extends Array<any>
26+
E extends any[]
2727
? never
2828
: [string, { [key in keyof E]?: E[key] }]
2929
| { [key in keyof E]?: E[key] extends boolean | undefined ? string : Record<string, string> }
3030
)
31-
type BaseLoopType<E> = BaseType<E> | Array<BaseType<E>>
32-
type TagParams = Array<[TemplateStringsArray, any[]]>;
31+
type BaseLoopType<E> = BaseType<E> | BaseType<E>[]
32+
type TagParams = [TemplateStringsArray, any[]][];
3333
type ParamType<K extends HTMLElementTagNameKeys | VNode, E extends object = object> = ((props: MasterComponentProps<K, E>) => BaseLoopType<MasterComponentProps<K, E>> | undefined) | BaseLoopType<MasterComponentProps<K, E>>
34-
type ParamsType<K extends HTMLElementTagNameKeys | VNode, E extends object = object> = Array<ParamType<K, E>>;
34+
type ParamsType<K extends HTMLElementTagNameKeys | VNode, E extends object = object> = ParamType<K, E>[];
3535
type MasterComponentProps<K extends HTMLElementTagNameKeys | VNode, E extends object = object> =
3636
Partial<E>
3737
& { className?: BaseLoopType<E> | undefined, [key: string]: any }
@@ -55,15 +55,7 @@ const styled: {
5555
& (<E extends object>(firstParam: TemplateStringsArray | ParamType<K, E>, ...params: ParamsType<K, E>) => MasterComponent<K, E>)
5656
& (<F extends MasterComponent<any>, E extends object = object>(firstParam: F) => F extends MasterComponent<any, infer ME> ? ReturnType<K, ME & E> : never)
5757
& (<F extends VNode, E extends object = object>(firstParam: F) => ReturnType<K, E>)
58-
} & {
59-
<F extends MasterComponent<any>, E extends object = object>(firstParam: F): F extends MasterComponent<infer K, infer ME> ? ReturnType<K, ME & E> : never
60-
} & {
61-
<F extends VNode, E extends object = object>(firstParam: F): ReturnType<F, E>
62-
} & {
63-
(firstParam: TemplateStringsArray | ParamType<'div'>, ...params: ParamsType<'div'>): MasterComponent<'div'>
64-
} & {
65-
<E extends object = object>(firstParam: TemplateStringsArray | ParamType<'div', E>, ...params: ParamsType<'div', E>): MasterComponent<'div', E>
66-
} = new Proxy(
58+
} & (<F extends MasterComponent<any>, E extends object = object>(firstParam: F) => F extends MasterComponent<infer K, infer ME> ? ReturnType<K, ME & E> : never) & (<F extends VNode, E extends object = object>(firstParam: F) => ReturnType<F, E>) & ((firstParam: TemplateStringsArray | ParamType<'div'>, ...params: ParamsType<'div'>) => MasterComponent<'div'>) & (<E extends object = object>(firstParam: TemplateStringsArray | ParamType<'div', E>, ...params: ParamsType<'div', E>) => MasterComponent<'div', E>) = new Proxy(
6759
// @ts-ignore
6860
((firstParam, ...params) => {
6961
return (
@@ -161,7 +153,7 @@ function handle<K extends string | VNode, E extends object = object>(tag: K, tag
161153
}
162154
break
163155
case 'function':
164-
// eslint-disable-next-line no-case-declarations
156+
165157
const transformedParam = param(mergedProps)
166158
if (typeof transformedParam === 'object' && handleParam(transformedParam))
167159
return true

0 commit comments

Comments
 (0)