Skip to content

Commit 4424e2c

Browse files
authored
Merge pull request #25 from rogerchappel/agent/oss-978-next-lint
fix: generate supported Next.js lint setup
2 parents 2d500df + a43b37f commit 4424e2c

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

‎scripts/smoke-init.sh‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,5 +172,12 @@ node "$repo_root/dist/index.js" init python-api py-api > py.json
172172
test -f py-api/src/py_api/main.py
173173
node "$repo_root/dist/index.js" init next-app web-app > next.json
174174
test -f web-app/src/app/page.tsx
175+
test -f web-app/eslint.config.mjs
176+
(
177+
cd web-app
178+
npm install
179+
npm run lint
180+
bash scripts/validate.sh
181+
)
175182

176183
echo "smoke-init ok"

‎src/index.ts‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ const templateScaffolds: Record<TemplateKey, TemplateScaffold> = {
8080
{ source: 'templates/repo-docs/README.md', destination: 'docs/README.md' },
8181
{ source: 'templates/repo-validate/validate.sh', destination: 'scripts/validate.sh' },
8282
{ destination: 'package.json', content: nextPackageJsonTemplate() },
83+
{ destination: 'eslint.config.mjs', content: nextEslintConfigTemplate() },
8384
{ destination: 'src/app/page.tsx', content: "export default function Home() {\n return <main>{{PROJECT_NAME}}</main>;\n}\n" },
8485
{ destination: 'src/app/layout.tsx', content: "export default function RootLayout({ children }: { children: React.ReactNode }) {\n return (\n <html lang=\"en\">\n <body>{children}</body>\n </html>\n );\n}\n" }
8586
]
@@ -518,7 +519,7 @@ function nextPackageJsonTemplate(): string {
518519
"dev": "next dev",
519520
"build": "next build",
520521
"start": "next start",
521-
"lint": "next lint"
522+
"lint": "eslint ."
522523
},
523524
"dependencies": {
524525
"next": "latest",
@@ -528,12 +529,25 @@ function nextPackageJsonTemplate(): string {
528529
"devDependencies": {
529530
"@types/node": "latest",
530531
"@types/react": "latest",
532+
"eslint": "latest",
533+
"eslint-config-next": "latest",
531534
"typescript": "latest"
532535
}
533536
}
534537
`;
535538
}
536539

540+
function nextEslintConfigTemplate(): string {
541+
return `import { defineConfig, globalIgnores } from "eslint/config";
542+
import nextVitals from "eslint-config-next/core-web-vitals";
543+
544+
export default defineConfig([
545+
...nextVitals,
546+
globalIgnores([".next/**", "out/**", "build/**", "next-env.d.ts"])
547+
]);
548+
`;
549+
}
550+
537551
function pythonProjectTemplate(): string {
538552
return `[project]
539553
name = "{{PROJECT_NAME}}"

0 commit comments

Comments
 (0)