Skip to content

Commit

Permalink
feat(eslint-config): extend rules for next.js app router
Browse files Browse the repository at this point in the history
  • Loading branch information
rozsival committed Jun 22, 2024
1 parent bdd6e22 commit a275aad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/real-carpets-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@apitree.cz/eslint-config': patch
---

Extend rules for Next.js App Router.
14 changes: 10 additions & 4 deletions packages/eslint-config/src/nextjs/overrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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 <head/> 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[];

0 comments on commit a275aad

Please sign in to comment.