You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{flatConfigasnextPlugin}from'@next/eslint-plugin-next';import{defineConfig,globalIgnores}from'eslint/config';import{configsastseslintConfigs}from'typescript-eslint';exportdefaultdefineConfig([globalIgnores(['.next/','next-env.d.ts']),{files: ['**/*.{js,jsx,ts,tsx}'],extends: [js.configs.recommended],},{files: ['**/*.{js,jsx,ts,tsx}'],extends: [nextPlugin.coreWebVitals],},{files: ['**/*.{js,jsx,ts,tsx}'],extends: [tseslintConfigs.strictTypeChecked],},{files: ['**/*.{js,jsx,ts,tsx}'],// Required for typescript-eslint and "TypeChecked" ruleslanguageOptions: {parserOptions: {projectService: true,tsconfigRootDir: import.meta.dirname,},},},]);
This gives an error on the line with extends: [nextPlugin.coreWebVitals], that says:
Type '{ name: string; plugins: { '@next/next': { rules: { 'google-font-display': RuleModule; 'google-font-preconnect': RuleModule; 'inline-script-id': RuleModule; ... 17 more ...; 'no-unwanted-polyfillio': RuleModule; }; configs: { ...; }; }; }; rules: { ...; }; }' is not assignable to type 'ExtendsElement'.
Type '{ name: string; plugins: { '@next/next': { rules: { 'google-font-display': RuleModule; 'google-font-preconnect': RuleModule; 'inline-script-id': RuleModule; ... 17 more ...; 'no-unwanted-polyfillio': RuleModule; }; configs: { ...; }; }; }; rules: { ...; }; }' is not assignable to type 'ConfigObject<RulesConfig>'.
Types of property 'plugins' are incompatible.
Type '{ '@next/next': { rules: { 'google-font-display': RuleModule; 'google-font-preconnect': RuleModule; 'inline-script-id': RuleModule; 'next-script-for-ga': RuleModule; ... 16 more ...; 'no-unwanted-polyfillio': RuleModule; }; configs: { ...; }; }; }' is not assignable to type 'Record<string, Plugin>'.
Property ''@next/next'' is incompatible with index signature.
Type '{ rules: { 'google-font-display': RuleModule; 'google-font-preconnect': RuleModule; 'inline-script-id': RuleModule; 'next-script-for-ga': RuleModule; ... 16 more ...; 'no-unwanted-polyfillio': RuleModule; }; configs: { ...; }; }' is not assignable to type 'Plugin'.
Types of property 'configs' are incompatible.
Type '{ recommended: { plugins: string[]; rules: { '@next/next/google-font-display': string; '@next/next/google-font-preconnect': string; '@next/next/next-script-for-ga': string; '@next/next/no-async-client-component': string; ... 16 more ...; '@next/next/no-script-component-in-head': string; }; }; 'core-web-vitals': { .....' is not assignable to type 'Record<string, ConfigObject<RulesConfig> | LegacyConfigObject<RulesConfig, RulesConfig> | ConfigObject<RulesConfig>[]>'.
Property 'recommended' is incompatible with index signature.
Type '{ plugins: string[]; rules: { '@next/next/google-font-display': string; '@next/next/google-font-preconnect': string; '@next/next/next-script-for-ga': string; '@next/next/no-async-client-component': string; ... 16 more ...; '@next/next/no-script-component-in-head': string; }; }' is not assignable to type 'ConfigObject<RulesConfig> | LegacyConfigObject<RulesConfig, RulesConfig> | ConfigObject<RulesConfig>[]'.
Type '{ plugins: string[]; rules: { '@next/next/google-font-display': string; '@next/next/google-font-preconnect': string; '@next/next/next-script-for-ga': string; '@next/next/no-async-client-component': string; ... 16 more ...; '@next/next/no-script-component-in-head': string; }; }' is not assignable to type 'LegacyConfigObject<RulesConfig, RulesConfig>'.
Types of property 'rules' are incompatible.
Type '{ '@next/next/google-font-display': string; '@next/next/google-font-preconnect': string; '@next/next/next-script-for-ga': string; '@next/next/no-async-client-component': string; '@next/next/no-before-interactive-script-outside-document': string; ... 15 more ...; '@next/next/no-script-component-in-head': string; }' is not assignable to type 'Partial<RulesConfig>'.
Property ''@next/next/google-font-display'' is incompatible with index signature.
Type 'string' is not assignable to type 'RuleConfig<unknown[]> | undefined'.ts(2322)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Be able to use ESLint
defineConfig()
without TypeScript errors.https://eslint.org/blog/2025/03/flat-config-extends-define-config-global-ignores/#introducing-defineconfig()-for-eslint.
Non-Goals
No response
Background
This gives an error on the line with
extends: [nextPlugin.coreWebVitals],
that says:Proposal
Fix the TypeScript error.
Beta Was this translation helpful? Give feedback.
All reactions