Skip to content

Commit

Permalink
feat(eslint-config): typescript-eslint 8 (#1326)
Browse files Browse the repository at this point in the history
# Overview
related #1240
<!--
    A clear and concise description of what this pr is about.
 -->

## PR Checklist

- [x] I did below actions if need

1. I read the [Contributing
Guide](https://github.com/toss/suspensive/blob/main/CONTRIBUTING.md)
2. I added documents and tests.

---------

Co-authored-by: Sol Lee <[email protected]>
Co-authored-by: Varad Gupta <[email protected]>
Co-authored-by: Jonghyeon Ko <[email protected]>
Co-authored-by: Jonghyeon Ko <[email protected]>
  • Loading branch information
5 people authored Oct 20, 2024
1 parent c906edb commit d2a3c1d
Show file tree
Hide file tree
Showing 60 changed files with 414 additions and 367 deletions.
2 changes: 1 addition & 1 deletion configs/eslint-config/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default [
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/no-floating-promises': 'warn',
'@typescript-eslint/no-unsafe-call': 'warn',
'@typescript-eslint/no-throw-literal': 'warn',
'@typescript-eslint/only-throw-error': 'warn',
'@typescript-eslint/no-confusing-void-expression': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/no-empty-function': 'warn',
Expand Down
4 changes: 2 additions & 2 deletions configs/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"scripts": {
"build": "tsup",
"ci:attw": "attw --pack",
"ci:eslint": "eslint \"**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}\"",
"ci:eslint": "eslint \"**/*.{ts,tsx,cts,mts}\"",
"ci:publint": "publint --strict",
"ci:type": "tsc --noEmit",
"clean": "rimraf ./dist && rimraf ./coverage",
Expand All @@ -43,7 +43,7 @@
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react-compiler": "0.0.0-experimental-9aef357-20240815",
"eslint-plugin-react-hooks": "^4.6.2",
"typescript-eslint": "^7.18.0"
"typescript-eslint": "^8.9.0"
},
"devDependencies": {
"@suspensive/tsconfig": "workspace:*"
Expand Down
8 changes: 4 additions & 4 deletions configs/eslint-config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const suspensiveTypeScriptConfig: ReturnType<typeof tseslint.config> = ts
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/no-floating-promises': 'warn',
'@typescript-eslint/no-unsafe-call': 'warn',
'@typescript-eslint/no-throw-literal': 'warn',
'@typescript-eslint/only-throw-error': 'warn',
'@typescript-eslint/no-confusing-void-expression': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/no-empty-function': 'warn',
Expand All @@ -94,7 +94,7 @@ export const suspensiveTypeScriptConfig: ReturnType<typeof tseslint.config> = ts
rules: vitest.configs.recommended.rules,
settings: { vitest: { typecheck: true } },
},
jestDom.configs['flat/recommended'] as unknown as ReturnType<typeof tseslint.config>[number],
jestDom.configs['flat/recommended'],

Check warning on line 97 in configs/eslint-config/src/index.ts

View workflow job for this annotation

GitHub Actions / Check quality (ci:eslint)

Unsafe member access .configs on an `error` typed value
{
plugins: {
import: importPlugin,

Check warning on line 100 in configs/eslint-config/src/index.ts

View workflow job for this annotation

GitHub Actions / Check quality (ci:eslint)

Unsafe assignment of an error typed value
Expand All @@ -113,14 +113,14 @@ export const suspensiveTypeScriptConfig: ReturnType<typeof tseslint.config> = ts
],
},
},
eslintPluginPrettierRecommended as unknown as ReturnType<typeof tseslint.config>[number]
eslintPluginPrettierRecommended
)

export const suspensiveReactTypeScriptConfig: ReturnType<typeof tseslint.config> = tseslint.config(
...suspensiveTypeScriptConfig,
{
files: ['**/*.{ts,tsx}'],
...(pluginReact.configs.recommended as unknown as ReturnType<typeof tseslint.config>[number]),
...pluginReact.configs.recommended,
ignores: ['**/*.mdx/**/*.{ts,tsx}'],
},
{
Expand Down
1 change: 0 additions & 1 deletion configs/tsconfig/nextjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
Expand Down
2 changes: 1 addition & 1 deletion configs/tsup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"scripts": {
"build": "tsup",
"ci:attw": "attw --pack",
"ci:eslint": "eslint \"**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}\"",
"ci:eslint": "eslint \"**/*.{ts,tsx,cts,mts}\"",
"ci:publint": "publint --strict",
"ci:type": "tsc --noEmit",
"clean": "rimraf ./dist && rimraf ./coverage",
Expand Down
2 changes: 1 addition & 1 deletion docs/suspensive.org/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"type": "commonjs",
"scripts": {
"build": "next build",
"ci:eslint": "eslint \"**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts,mdx}\"",
"ci:eslint": "eslint \"**/*.{ts,tsx,cts,mts,mdx}\"",
"ci:type": "tsc --noEmit",
"clean": "rimraf ./.next",
"dev": "next dev -p 4000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "module",
"scripts": {
"build": "tsc -b && vite build",
"ci:eslint": "eslint .",
"ci:eslint": "eslint \"**/*.{ts,tsx,cts,mts}\"",
"dev": "vite",
"preview": "vite preview"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const query = {
queryKey: ['dummy', ms],
queryFn: async () => {
console.log({ fetch: `fetch${ms + 1}` })
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return fetch(`https://dummyjson.com/users/${ms + 1}`).then((res) => res.json())
},
}),
Expand Down
3 changes: 3 additions & 0 deletions knip.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"packages/react-native": {
"ignoreDependencies": ["expo", "ts-node"],
"ignore": ["babel.config.cjs"]
},
"packages/react-dom": {
"ignoreDependencies": ["react-dom", "@types/react-dom"]
}
}
}
2 changes: 1 addition & 1 deletion packages/jotai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"scripts": {
"build": "tsup",
"ci:attw": "attw --pack",
"ci:eslint": "eslint \"**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}\"",
"ci:eslint": "eslint \"**/*.{ts,tsx,cts,mts}\"",
"ci:publint": "publint --strict",
"ci:test": "vitest run --coverage --typecheck",
"ci:type": "tsc --noEmit",
Expand Down
42 changes: 24 additions & 18 deletions packages/jotai/src/Atom.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,72 +15,78 @@ const loadableAtom = loadable(asyncAtom)

describe('<Atom/>', () => {
it('type check', () => {
;() => (
;(() => (
<Atom atom={countAtom}>
{(result) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const returnOfJotai = useAtom(countAtom)
expectTypeOf(result).toEqualTypeOf<typeof returnOfJotai>()
return <></>
}}
</Atom>
)
;() => (
))()
;(() => (
<Atom atom={readOnlyCountAtom}>
{(result) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const returnOfJotai = useAtom(readOnlyCountAtom)
expectTypeOf(result).toEqualTypeOf<typeof returnOfJotai>()
return <></>
}}
</Atom>
)
;() => (
))()
;(() => (
<Atom atom={writeOnlyCountAtom}>
{(result) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const returnOfJotai = useAtom(writeOnlyCountAtom)
expectTypeOf(result).toEqualTypeOf<typeof returnOfJotai>()
return <></>
}}
</Atom>
)
;() => (
))()
;(() => (
<Atom atom={asyncAtom}>
{(result) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const returnOfJotai = useAtom(asyncAtom)
expectTypeOf(result).toEqualTypeOf<typeof returnOfJotai>()
return <></>
}}
</Atom>
)
;() => (
))()
;(() => (
<Atom atom={asyncIncrementAtom}>
{(result) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const returnOfJotai = useAtom(asyncIncrementAtom)
expectTypeOf(result).toEqualTypeOf<typeof returnOfJotai>()
return <></>
}}
</Atom>
)
;() => (
))()
;(() => (
<Atom atom={loadableAtom}>
{(result) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const returnOfJotai = useAtom(loadableAtom)
expectTypeOf(result).toEqualTypeOf<typeof returnOfJotai>()
return <></>
}}
</Atom>
)
))()

expectTypeOf(<Atom atom={countAtom}>{() => <></>}</Atom>).toEqualTypeOf<JSX.Element>()
expectTypeOf(<Atom atom={countAtom}>{() => <></>}</Atom>).toEqualTypeOf<React.JSX.Element>()
expectTypeOf(<Atom atom={countAtom}>{() => <></>}</Atom>).not.toEqualTypeOf<ReactNode>()
expectTypeOf(<Atom atom={readOnlyCountAtom}>{() => <></>}</Atom>).toEqualTypeOf<JSX.Element>()
expectTypeOf(<Atom atom={readOnlyCountAtom}>{() => <></>}</Atom>).toEqualTypeOf<React.JSX.Element>()
expectTypeOf(<Atom atom={readOnlyCountAtom}>{() => <></>}</Atom>).not.toEqualTypeOf<ReactNode>()
expectTypeOf(<Atom atom={writeOnlyCountAtom}>{() => <></>}</Atom>).toEqualTypeOf<JSX.Element>()
expectTypeOf(<Atom atom={writeOnlyCountAtom}>{() => <></>}</Atom>).toEqualTypeOf<React.JSX.Element>()
expectTypeOf(<Atom atom={writeOnlyCountAtom}>{() => <></>}</Atom>).not.toEqualTypeOf<ReactNode>()
expectTypeOf(<Atom atom={asyncAtom}>{() => <></>}</Atom>).toEqualTypeOf<JSX.Element>()
expectTypeOf(<Atom atom={asyncAtom}>{() => <></>}</Atom>).toEqualTypeOf<React.JSX.Element>()
expectTypeOf(<Atom atom={asyncAtom}>{() => <></>}</Atom>).not.toEqualTypeOf<ReactNode>()
expectTypeOf(<Atom atom={asyncIncrementAtom}>{() => <></>}</Atom>).toEqualTypeOf<JSX.Element>()
expectTypeOf(<Atom atom={asyncIncrementAtom}>{() => <></>}</Atom>).toEqualTypeOf<React.JSX.Element>()
expectTypeOf(<Atom atom={asyncIncrementAtom}>{() => <></>}</Atom>).not.toEqualTypeOf<ReactNode>()
expectTypeOf(<Atom atom={loadableAtom}>{() => <></>}</Atom>).toEqualTypeOf<JSX.Element>()
expectTypeOf(<Atom atom={loadableAtom}>{() => <></>}</Atom>).toEqualTypeOf<React.JSX.Element>()
expectTypeOf(<Atom atom={loadableAtom}>{() => <></>}</Atom>).not.toEqualTypeOf<ReactNode>()
})
})
42 changes: 24 additions & 18 deletions packages/jotai/src/AtomValue.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,72 +15,78 @@ const loadableAtom = loadable(asyncAtom)

describe('<AtomValue/>', () => {
it('type check', () => {
;() => (
;(() => (
<AtomValue atom={countAtom}>
{(value) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const valueOfJotai = useAtomValue(countAtom)
expectTypeOf(value).toEqualTypeOf<typeof valueOfJotai>()
return <></>
}}
</AtomValue>
)
;() => (
))()
;(() => (
<AtomValue atom={readOnlyCountAtom}>
{(value) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const valueOfJotai = useAtomValue(readOnlyCountAtom)
expectTypeOf(value).toEqualTypeOf<typeof valueOfJotai>()
return <></>
}}
</AtomValue>
)
;() => (
))()
;(() => (
<AtomValue atom={writeOnlyCountAtom}>
{(value) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const valueOfJotai = useAtomValue(writeOnlyCountAtom)
expectTypeOf(value).toEqualTypeOf<typeof valueOfJotai>()
return <></>
}}
</AtomValue>
)
;() => (
))()
;(() => (
<AtomValue atom={asyncAtom}>
{(value) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const valueOfJotai = useAtomValue(asyncAtom)
expectTypeOf(value).toEqualTypeOf<typeof valueOfJotai>()
return <></>
}}
</AtomValue>
)
;() => (
))()
;(() => (
<AtomValue atom={asyncIncrementAtom}>
{(value) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const valueOfJotai = useAtomValue(asyncIncrementAtom)
expectTypeOf(value).toEqualTypeOf<typeof valueOfJotai>()
return <></>
}}
</AtomValue>
)
;() => (
))()
;(() => (
<AtomValue atom={loadableAtom}>
{(value) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const valueOfJotai = useAtomValue(loadableAtom)
expectTypeOf(value).toEqualTypeOf<typeof valueOfJotai>()
return <></>
}}
</AtomValue>
)
))()

expectTypeOf(<AtomValue atom={countAtom}>{() => <></>}</AtomValue>).toEqualTypeOf<JSX.Element>()
expectTypeOf(<AtomValue atom={countAtom}>{() => <></>}</AtomValue>).toEqualTypeOf<React.JSX.Element>()
expectTypeOf(<AtomValue atom={countAtom}>{() => <></>}</AtomValue>).not.toEqualTypeOf<ReactNode>()
expectTypeOf(<AtomValue atom={readOnlyCountAtom}>{() => <></>}</AtomValue>).toEqualTypeOf<JSX.Element>()
expectTypeOf(<AtomValue atom={readOnlyCountAtom}>{() => <></>}</AtomValue>).toEqualTypeOf<React.JSX.Element>()
expectTypeOf(<AtomValue atom={readOnlyCountAtom}>{() => <></>}</AtomValue>).not.toEqualTypeOf<ReactNode>()
expectTypeOf(<AtomValue atom={writeOnlyCountAtom}>{() => <></>}</AtomValue>).toEqualTypeOf<JSX.Element>()
expectTypeOf(<AtomValue atom={writeOnlyCountAtom}>{() => <></>}</AtomValue>).toEqualTypeOf<React.JSX.Element>()
expectTypeOf(<AtomValue atom={writeOnlyCountAtom}>{() => <></>}</AtomValue>).not.toEqualTypeOf<ReactNode>()
expectTypeOf(<AtomValue atom={asyncAtom}>{() => <></>}</AtomValue>).toEqualTypeOf<JSX.Element>()
expectTypeOf(<AtomValue atom={asyncAtom}>{() => <></>}</AtomValue>).toEqualTypeOf<React.JSX.Element>()
expectTypeOf(<AtomValue atom={asyncAtom}>{() => <></>}</AtomValue>).not.toEqualTypeOf<ReactNode>()
expectTypeOf(<AtomValue atom={asyncIncrementAtom}>{() => <></>}</AtomValue>).toEqualTypeOf<JSX.Element>()
expectTypeOf(<AtomValue atom={asyncIncrementAtom}>{() => <></>}</AtomValue>).toEqualTypeOf<React.JSX.Element>()
expectTypeOf(<AtomValue atom={asyncIncrementAtom}>{() => <></>}</AtomValue>).not.toEqualTypeOf<ReactNode>()
expectTypeOf(<AtomValue atom={loadableAtom}>{() => <></>}</AtomValue>).toEqualTypeOf<JSX.Element>()
expectTypeOf(<AtomValue atom={loadableAtom}>{() => <></>}</AtomValue>).toEqualTypeOf<React.JSX.Element>()
expectTypeOf(<AtomValue atom={loadableAtom}>{() => <></>}</AtomValue>).not.toEqualTypeOf<ReactNode>()
})
})
21 changes: 12 additions & 9 deletions packages/jotai/src/SetAtom.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,42 @@ const asyncIncrementAtom = atom(null, async (get, set) => {

describe('<SetAtom/>', () => {
it('type check', () => {
;() => (
;(() => (
<SetAtom atom={countAtom}>
{(value) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const valueOfJotai = useSetAtom(countAtom)
expectTypeOf(value).toEqualTypeOf<typeof valueOfJotai>()
return <></>
}}
</SetAtom>
)
;() => (
))()
;(() => (
<SetAtom atom={writeOnlyCountAtom}>
{(value) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const valueOfJotai = useSetAtom(writeOnlyCountAtom)
expectTypeOf(value).toEqualTypeOf<typeof valueOfJotai>()
return <></>
}}
</SetAtom>
)
;() => (
))()
;(() => (
<SetAtom atom={asyncIncrementAtom}>
{(value) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const valueOfJotai = useSetAtom(asyncIncrementAtom)
expectTypeOf(value).toEqualTypeOf<typeof valueOfJotai>()
return <></>
}}
</SetAtom>
)
))()

expectTypeOf(<SetAtom atom={countAtom}>{() => <></>}</SetAtom>).toEqualTypeOf<JSX.Element>()
expectTypeOf(<SetAtom atom={countAtom}>{() => <></>}</SetAtom>).toEqualTypeOf<React.JSX.Element>()
expectTypeOf(<SetAtom atom={countAtom}>{() => <></>}</SetAtom>).not.toEqualTypeOf<ReactNode>()
expectTypeOf(<SetAtom atom={writeOnlyCountAtom}>{() => <></>}</SetAtom>).toEqualTypeOf<JSX.Element>()
expectTypeOf(<SetAtom atom={writeOnlyCountAtom}>{() => <></>}</SetAtom>).toEqualTypeOf<React.JSX.Element>()
expectTypeOf(<SetAtom atom={writeOnlyCountAtom}>{() => <></>}</SetAtom>).not.toEqualTypeOf<ReactNode>()
expectTypeOf(<SetAtom atom={asyncIncrementAtom}>{() => <></>}</SetAtom>).toEqualTypeOf<JSX.Element>()
expectTypeOf(<SetAtom atom={asyncIncrementAtom}>{() => <></>}</SetAtom>).toEqualTypeOf<React.JSX.Element>()
expectTypeOf(<SetAtom atom={asyncIncrementAtom}>{() => <></>}</SetAtom>).not.toEqualTypeOf<ReactNode>()
})
})
2 changes: 1 addition & 1 deletion packages/jotai/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "@suspensive/tsconfig/react-library.json",
"include": [".", "eslint.config.mjs"],
"include": ["."],
"compilerOptions": {
"types": ["@testing-library/jest-dom/vitest", "vitest/globals"]
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"scripts": {
"build": "tsup",
"ci:attw": "attw --pack",
"ci:eslint": "eslint \"**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}\"",
"ci:eslint": "eslint \"**/*.{ts,tsx,cts,mts}\"",
"ci:publint": "publint --strict",
"ci:test": "vitest run --coverage --typecheck",
"ci:type": "tsc --noEmit",
Expand Down
Loading

0 comments on commit d2a3c1d

Please sign in to comment.