diff --git a/.changeset/real-carpets-leave.md b/.changeset/real-carpets-leave.md new file mode 100644 index 0000000..34d15cf --- /dev/null +++ b/.changeset/real-carpets-leave.md @@ -0,0 +1,5 @@ +--- +'@apitree.cz/eslint-config': patch +--- + +Extend rules for Next.js App Router. diff --git a/packages/eslint-config/src/nextjs/overrides.ts b/packages/eslint-config/src/nextjs/overrides.ts index 191768a..07a17f0 100644 --- a/packages/eslint-config/src/nextjs/overrides.ts +++ b/packages/eslint-config/src/nextjs/overrides.ts @@ -8,10 +8,10 @@ export const overrides = [ }, }, { - files: ['src/pages/**/*.ts', 'src/pages/**/*.tsx'], + files: ['src/app/**/*.ts', 'src/app/**/*.tsx', 'src/pages/**/*.ts', 'src/pages/**/*.tsx'], rules: { 'react/function-component-definition': [ - // Allow components as function declarations in Next.js pages for shorthand default exports + // Allow components as function declarations in Next.js App and Page components for shorthand default exports 'error', { namedComponents: ['arrow-function', 'function-declaration'], @@ -21,9 +21,15 @@ export const overrides = [ }, }, { - files: ['src/pages/_app.tsx', 'src/pages/_document.tsx'], + files: ['src/app/**/layout.tsx', 'src/**/layouts/**/*.tsx'], rules: { - 'react/jsx-props-no-spreading': 'off', // Allow spreading props in Next.js _app.tsx and _document.tsx + '@next/next/no-head-element': 'off', // Allow element in Next.js App layouts + }, + }, + { + files: ['src/**/layouts/**/*.tsx', 'src/pages/_app.tsx', 'src/pages/_document.tsx'], + rules: { + 'react/jsx-props-no-spreading': 'off', // Allow spreading props in Next.js App layouts, _app.tsx and _document.tsx }, }, ] satisfies Linter.ConfigOverride[];