Skip to content

Commit cb29b1a

Browse files
committed
chore: fix type errors
1 parent 115ce4b commit cb29b1a

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/configs/nextjs.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ export async function nextjs(
2424

2525
const pluginNextJS = await interopDefault(import('@next/eslint-plugin-next'))
2626

27+
function getRules(name: keyof typeof pluginNextJS.configs): Record<string, any> {
28+
const rules = pluginNextJS.configs?.[name]?.rules
29+
if (!rules)
30+
throw new Error(`[@antfu/eslint-config] Failed to find config ${name} in @next/eslint-plugin-next`)
31+
return normalizeRules(rules)
32+
}
33+
2734
return [
2835
{
2936
name: 'antfu/nextjs/setup',
@@ -43,8 +50,8 @@ export async function nextjs(
4350
},
4451
name: 'antfu/nextjs/rules',
4552
rules: {
46-
...normalizeRules(pluginNextJS.configs.recommended.rules),
47-
...normalizeRules(pluginNextJS.configs['core-web-vitals'].rules),
53+
...getRules('recommended'),
54+
...getRules('core-web-vitals'),
4855

4956
// overrides
5057
...overrides,

0 commit comments

Comments
 (0)