Unverified Commit 9c1a97bf authored by Ben Gubler's avatar Ben Gubler Committed by GitHub

feat: deprecate 'next lint', add Biome support (#82266)

# Transition from `next lint` to explicit ESLint configs and add Biome support

## What?
This PR makes two major changes to Next.js linting:

1. **Transitions away from `next lint`**: `create-next-app` now generates explicit ESLint configurations instead of relying on the `next lint` command
2. **Adds Biome as a linter option**: Users can now choose between ESLint, Biome, or no linter during project setup

## Why?

**ESLint Transition**: Provides transparency (users see exact rules), better IDE integration, easier customization, and follows industry standards for explicit configuration.

**Biome Support**: Offers a faster, unified linting/formatting tool and gives users more choice in their developer experience.

## How?

### ESLint Configuration Generation
- Generates `eslint.config.mjs` files that extend `eslint-config-next` packages
- Includes proper ignores for build artifacts (`next-env.d.ts`, `.next/`, etc.)
- Package.json scripts call `eslint .` directly instead of `next lint`
- Maintains complete feature parity with current `next lint` behavior

### Biome Integration
- Added `--biome` flag and interactive prompt selection
- Generated `biome.json` configurations with Next.js and React domain rules
- Includes both `lint` and `format` scripts for Biome projects

### Linter Selection
Interactive prompt offers: **ESLint** (comprehensive rules), **Biome** (fast with fewer rules), **None** (skip linter)

### Deprecation
Added deprecation warning to `next lint` command (removed in Next.js 16)

## Testing
Added comprehensive test suites for both ESLint and Biome configuration generation across all template variants.

This change modernizes Next.js linting while providing users with more choice and transparency.
parent 64b69ff0
...@@ -21,11 +21,13 @@ The following options are available: ...@@ -21,11 +21,13 @@ The following options are available:
| --------------------------------------- | --------------------------------------------------------------- | | --------------------------------------- | --------------------------------------------------------------- |
| `-h` or `--help` | Show all available options | | `-h` or `--help` | Show all available options |
| `-v` or `--version` | Output the version number | | `-v` or `--version` | Output the version number |
| `--no-*` | Negate default options. E.g. `--no-eslint` | | `--no-*` | Negate default options. E.g. `--no-ts` |
| `--ts` or `--typescript` | Initialize as a TypeScript project (default) | | `--ts` or `--typescript` | Initialize as a TypeScript project (default) |
| `--js` or `--javascript` | Initialize as a JavaScript project | | `--js` or `--javascript` | Initialize as a JavaScript project |
| `--tailwind` | Initialize with Tailwind CSS config (default) | | `--tailwind` | Initialize with Tailwind CSS config (default) |
| `--eslint` | Initialize with ESLint config | | `--eslint` | Initialize with ESLint config |
| `--biome` | Initialize with Biome config |
| `--no-linter` | Skip linter configuration |
| `--app` | Initialize as an App Router project | | `--app` | Initialize as an App Router project |
| `--api` | Initialize a project with only route handlers | | `--api` | Initialize a project with only route handlers |
| `--src-dir` | Initialize inside a `src/` directory | | `--src-dir` | Initialize inside a `src/` directory |
...@@ -58,7 +60,7 @@ You will then be asked the following prompts: ...@@ -58,7 +60,7 @@ You will then be asked the following prompts:
```txt filename="Terminal" ```txt filename="Terminal"
What is your project named? my-app What is your project named? my-app
Would you like to use TypeScript? No / Yes Would you like to use TypeScript? No / Yes
Would you like to use ESLint? No / Yes Which linter would you like to use? ESLint / Biome / None
Would you like to use Tailwind CSS? No / Yes Would you like to use Tailwind CSS? No / Yes
Would you like your code inside a `src/` directory? No / Yes Would you like your code inside a `src/` directory? No / Yes
Would you like to use App Router? (recommended) No / Yes Would you like to use App Router? (recommended) No / Yes
...@@ -66,6 +68,16 @@ Would you like to use Turbopack? (recommended) No / Yes ...@@ -66,6 +68,16 @@ Would you like to use Turbopack? (recommended) No / Yes
Would you like to customize the import alias (`@/*` by default)? No / Yes Would you like to customize the import alias (`@/*` by default)? No / Yes
``` ```
### Linter Options
**ESLint**: The traditional and most popular JavaScript linter. Includes Next.js-specific rules from `eslint-plugin-next`.
**Biome**: A fast, modern linter and formatter that combines the functionality of ESLint and Prettier. Includes built-in Next.js and React domain support for optimal performance.
**None**: Skip linter configuration entirely. You can always add a linter later.
> **Note**: `next lint` command will be deprecated in Next.js 16. New projects should use the chosen linter directly (e.g., `biome check` or `eslint`).
Once you've answered the prompts, a new project will be created with your chosen configuration. Once you've answered the prompts, a new project will be created with your chosen configuration.
### With an official Next.js example ### With an official Next.js example
......
...@@ -31,6 +31,7 @@ export async function createApp({ ...@@ -31,6 +31,7 @@ export async function createApp({
typescript, typescript,
tailwind, tailwind,
eslint, eslint,
biome,
app, app,
srcDir, srcDir,
importAlias, importAlias,
...@@ -48,6 +49,7 @@ export async function createApp({ ...@@ -48,6 +49,7 @@ export async function createApp({
typescript: boolean typescript: boolean
tailwind: boolean tailwind: boolean
eslint: boolean eslint: boolean
biome: boolean
app: boolean app: boolean
srcDir: boolean srcDir: boolean
importAlias: string importAlias: string
...@@ -235,6 +237,7 @@ export async function createApp({ ...@@ -235,6 +237,7 @@ export async function createApp({
isOnline, isOnline,
tailwind, tailwind,
eslint, eslint,
biome,
srcDir, srcDir,
importAlias, importAlias,
skipInstall, skipInstall,
......
...@@ -50,6 +50,7 @@ const program = new Command(packageJson.name) ...@@ -50,6 +50,7 @@ const program = new Command(packageJson.name)
.option('--js, --javascript', 'Initialize as a JavaScript project.') .option('--js, --javascript', 'Initialize as a JavaScript project.')
.option('--tailwind', 'Initialize with Tailwind CSS config. (default)') .option('--tailwind', 'Initialize with Tailwind CSS config. (default)')
.option('--eslint', 'Initialize with ESLint config.') .option('--eslint', 'Initialize with ESLint config.')
.option('--biome', 'Initialize with Biome config.')
.option('--app', 'Initialize as an App Router project.') .option('--app', 'Initialize as an App Router project.')
.option('--src-dir', "Initialize inside a 'src/' directory.") .option('--src-dir', "Initialize inside a 'src/' directory.")
.option('--turbopack', 'Enable Turbopack by default for development.') .option('--turbopack', 'Enable Turbopack by default for development.')
...@@ -229,6 +230,7 @@ async function run(): Promise<void> { ...@@ -229,6 +230,7 @@ async function run(): Promise<void> {
const defaults: typeof preferences = { const defaults: typeof preferences = {
typescript: true, typescript: true,
eslint: false, eslint: false,
linter: 'none',
tailwind: true, tailwind: true,
app: true, app: true,
srcDir: false, srcDir: false,
...@@ -277,23 +279,63 @@ async function run(): Promise<void> { ...@@ -277,23 +279,63 @@ async function run(): Promise<void> {
} }
} }
if (!opts.eslint && !args.includes('--no-eslint') && !opts.api) { // Determine linter choice if not specified via CLI flags
// Support both --no-linter (new) and --no-eslint (legacy) for backward compatibility
const noLinter =
args.includes('--no-linter') || args.includes('--no-eslint')
if (!opts.eslint && !opts.biome && !noLinter && !opts.api) {
if (skipPrompt) { if (skipPrompt) {
opts.eslint = getPrefOrDefault('eslint') const preferredLinter = getPrefOrDefault('linter')
opts.eslint = preferredLinter === 'eslint'
opts.biome = preferredLinter === 'biome'
// No need to set noLinter flag since we check args at runtime
} else { } else {
const styledEslint = blue('ESLint') const { linter } = await prompts({
const { eslint } = await prompts({
onState: onPromptState, onState: onPromptState,
type: 'toggle', type: 'select',
name: 'eslint', name: 'linter',
message: `Would you like to use ${styledEslint}?`, message: 'Which linter would you like to use?',
initial: getPrefOrDefault('eslint'), choices: [
active: 'Yes', {
inactive: 'No', title: 'ESLint',
value: 'eslint',
description: 'More comprehensive lint rules',
},
{
title: 'Biome',
value: 'biome',
description: 'Fast formatter and linter (fewer rules)',
},
{
title: 'None',
value: 'none',
description: 'Skip linter configuration',
},
],
initial: 0,
}) })
opts.eslint = Boolean(eslint)
preferences.eslint = Boolean(eslint) opts.eslint = linter === 'eslint'
opts.biome = linter === 'biome'
preferences.linter = linter
// Keep backwards compatibility with old eslint preference
preferences.eslint = linter === 'eslint'
} }
} else if (opts.eslint) {
opts.biome = false
preferences.linter = 'eslint'
preferences.eslint = true
} else if (opts.biome) {
opts.eslint = false
preferences.linter = 'biome'
preferences.eslint = false
} else if (noLinter) {
opts.eslint = false
opts.biome = false
preferences.linter = 'none'
preferences.eslint = false
} }
if (!opts.tailwind && !args.includes('--no-tailwind') && !opts.api) { if (!opts.tailwind && !args.includes('--no-tailwind') && !opts.api) {
...@@ -426,6 +468,7 @@ async function run(): Promise<void> { ...@@ -426,6 +468,7 @@ async function run(): Promise<void> {
typescript: opts.typescript, typescript: opts.typescript,
tailwind: opts.tailwind, tailwind: opts.tailwind,
eslint: opts.eslint, eslint: opts.eslint,
biome: opts.biome,
app: opts.app, app: opts.app,
srcDir: opts.srcDir, srcDir: opts.srcDir,
importAlias: opts.importAlias, importAlias: opts.importAlias,
...@@ -459,6 +502,7 @@ async function run(): Promise<void> { ...@@ -459,6 +502,7 @@ async function run(): Promise<void> {
packageManager, packageManager,
typescript: opts.typescript, typescript: opts.typescript,
eslint: opts.eslint, eslint: opts.eslint,
biome: opts.biome,
tailwind: opts.tailwind, tailwind: opts.tailwind,
app: opts.app, app: opts.app,
srcDir: opts.srcDir, srcDir: opts.srcDir,
......
{
"$schema": "https://biomejs.dev/schemas/2.2.0/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": true,
"includes": ["**", "!node_modules", "!.next", "!dist", "!build"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
},
"domains": {
"next": "recommended",
"react": "recommended"
}
},
"assist": {
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
{
"$schema": "https://biomejs.dev/schemas/2.2.0/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": true,
"includes": ["**", "!node_modules", "!.next", "!dist", "!build"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
},
"domains": {
"next": "recommended",
"react": "recommended"
}
},
"assist": {
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
{
"$schema": "https://biomejs.dev/schemas/2.2.0/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": true,
"includes": ["**", "!node_modules", "!.next", "!dist", "!build"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
},
"domains": {
"next": "recommended",
"react": "recommended"
}
},
"assist": {
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
...@@ -9,6 +9,17 @@ const compat = new FlatCompat({ ...@@ -9,6 +9,17 @@ const compat = new FlatCompat({
baseDirectory: __dirname, baseDirectory: __dirname,
}); });
const eslintConfig = [...compat.extends("next/core-web-vitals")]; const eslintConfig = [
...compat.extends("next/core-web-vitals"),
{
ignores: [
"node_modules/**",
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
],
},
];
export default eslintConfig; export default eslintConfig;
{
"$schema": "https://biomejs.dev/schemas/2.2.0/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": true,
"includes": ["**", "!node_modules", "!.next", "!dist", "!build"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
},
"domains": {
"next": "recommended",
"react": "recommended"
}
},
"assist": {
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
...@@ -11,6 +11,15 @@ const compat = new FlatCompat({ ...@@ -11,6 +11,15 @@ const compat = new FlatCompat({
const eslintConfig = [ const eslintConfig = [
...compat.extends("next/core-web-vitals", "next/typescript"), ...compat.extends("next/core-web-vitals", "next/typescript"),
{
ignores: [
"node_modules/**",
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
],
},
]; ];
export default eslintConfig; export default eslintConfig;
{
"$schema": "https://biomejs.dev/schemas/2.2.0/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": true,
"includes": ["**", "!node_modules", "!.next", "!dist", "!build"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
},
"domains": {
"next": "recommended",
"react": "recommended"
}
},
"assist": {
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
...@@ -9,6 +9,17 @@ const compat = new FlatCompat({ ...@@ -9,6 +9,17 @@ const compat = new FlatCompat({
baseDirectory: __dirname, baseDirectory: __dirname,
}); });
const eslintConfig = [...compat.extends("next/core-web-vitals")]; const eslintConfig = [
...compat.extends("next/core-web-vitals"),
{
ignores: [
"node_modules/**",
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
],
},
];
export default eslintConfig; export default eslintConfig;
{
"$schema": "https://biomejs.dev/schemas/2.2.0/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": true,
"includes": ["**", "!node_modules", "!.next", "!dist", "!build"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
},
"domains": {
"next": "recommended",
"react": "recommended"
}
},
"assist": {
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
...@@ -11,6 +11,15 @@ const compat = new FlatCompat({ ...@@ -11,6 +11,15 @@ const compat = new FlatCompat({
const eslintConfig = [ const eslintConfig = [
...compat.extends("next/core-web-vitals", "next/typescript"), ...compat.extends("next/core-web-vitals", "next/typescript"),
{
ignores: [
"node_modules/**",
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
],
},
]; ];
export default eslintConfig; export default eslintConfig;
{
"$schema": "https://biomejs.dev/schemas/2.2.0/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": true,
"includes": ["**", "!node_modules", "!.next", "!dist", "!build"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
},
"domains": {
"next": "recommended",
"react": "recommended"
}
},
"assist": {
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
...@@ -9,6 +9,17 @@ const compat = new FlatCompat({ ...@@ -9,6 +9,17 @@ const compat = new FlatCompat({
baseDirectory: __dirname, baseDirectory: __dirname,
}); });
const eslintConfig = [...compat.extends("next/core-web-vitals")]; const eslintConfig = [
...compat.extends("next/core-web-vitals"),
{
ignores: [
"node_modules/**",
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
],
},
];
export default eslintConfig; export default eslintConfig;
{
"$schema": "https://biomejs.dev/schemas/2.2.0/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": true,
"includes": ["**", "!node_modules", "!.next", "!dist", "!build"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
},
"domains": {
"next": "recommended",
"react": "recommended"
}
},
"assist": {
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
...@@ -11,6 +11,15 @@ const compat = new FlatCompat({ ...@@ -11,6 +11,15 @@ const compat = new FlatCompat({
const eslintConfig = [ const eslintConfig = [
...compat.extends("next/core-web-vitals", "next/typescript"), ...compat.extends("next/core-web-vitals", "next/typescript"),
{
ignores: [
"node_modules/**",
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
],
},
]; ];
export default eslintConfig; export default eslintConfig;
{
"$schema": "https://biomejs.dev/schemas/2.2.0/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": true,
"includes": ["**", "!node_modules", "!.next", "!dist", "!build"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
},
"domains": {
"next": "recommended",
"react": "recommended"
}
},
"assist": {
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
...@@ -9,6 +9,17 @@ const compat = new FlatCompat({ ...@@ -9,6 +9,17 @@ const compat = new FlatCompat({
baseDirectory: __dirname, baseDirectory: __dirname,
}); });
const eslintConfig = [...compat.extends("next/core-web-vitals")]; const eslintConfig = [
...compat.extends("next/core-web-vitals"),
{
ignores: [
"node_modules/**",
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
],
},
];
export default eslintConfig; export default eslintConfig;
{
"$schema": "https://biomejs.dev/schemas/2.2.0/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": true,
"includes": ["**", "!node_modules", "!.next", "!dist", "!build"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
},
"domains": {
"next": "recommended",
"react": "recommended"
}
},
"assist": {
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
...@@ -11,6 +11,15 @@ const compat = new FlatCompat({ ...@@ -11,6 +11,15 @@ const compat = new FlatCompat({
const eslintConfig = [ const eslintConfig = [
...compat.extends("next/core-web-vitals", "next/typescript"), ...compat.extends("next/core-web-vitals", "next/typescript"),
{
ignores: [
"node_modules/**",
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
],
},
]; ];
export default eslintConfig; export default eslintConfig;
{
"$schema": "https://biomejs.dev/schemas/2.2.0/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": true,
"includes": ["**", "!node_modules", "!.next", "!dist", "!build"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
},
"domains": {
"next": "recommended",
"react": "recommended"
}
},
"assist": {
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
...@@ -9,6 +9,17 @@ const compat = new FlatCompat({ ...@@ -9,6 +9,17 @@ const compat = new FlatCompat({
baseDirectory: __dirname, baseDirectory: __dirname,
}); });
const eslintConfig = [...compat.extends("next/core-web-vitals")]; const eslintConfig = [
...compat.extends("next/core-web-vitals"),
{
ignores: [
"node_modules/**",
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
],
},
];
export default eslintConfig; export default eslintConfig;
{
"$schema": "https://biomejs.dev/schemas/2.2.0/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": true,
"includes": ["**", "!node_modules", "!.next", "!dist", "!build"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
},
"domains": {
"next": "recommended",
"react": "recommended"
}
},
"assist": {
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
...@@ -11,6 +11,15 @@ const compat = new FlatCompat({ ...@@ -11,6 +11,15 @@ const compat = new FlatCompat({
const eslintConfig = [ const eslintConfig = [
...compat.extends("next/core-web-vitals", "next/typescript"), ...compat.extends("next/core-web-vitals", "next/typescript"),
{
ignores: [
"node_modules/**",
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
],
},
]; ];
export default eslintConfig; export default eslintConfig;
{
"$schema": "https://biomejs.dev/schemas/2.2.0/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": true,
"includes": ["**", "!node_modules", "!.next", "!dist", "!build"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
},
"domains": {
"next": "recommended",
"react": "recommended"
}
},
"assist": {
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
...@@ -9,6 +9,17 @@ const compat = new FlatCompat({ ...@@ -9,6 +9,17 @@ const compat = new FlatCompat({
baseDirectory: __dirname, baseDirectory: __dirname,
}); });
const eslintConfig = [...compat.extends("next/core-web-vitals")]; const eslintConfig = [
...compat.extends("next/core-web-vitals"),
{
ignores: [
"node_modules/**",
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
],
},
];
export default eslintConfig; export default eslintConfig;
{
"$schema": "https://biomejs.dev/schemas/2.2.0/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": true,
"includes": ["**", "!node_modules", "!.next", "!dist", "!build"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
},
"domains": {
"next": "recommended",
"react": "recommended"
}
},
"assist": {
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
...@@ -11,6 +11,15 @@ const compat = new FlatCompat({ ...@@ -11,6 +11,15 @@ const compat = new FlatCompat({
const eslintConfig = [ const eslintConfig = [
...compat.extends("next/core-web-vitals", "next/typescript"), ...compat.extends("next/core-web-vitals", "next/typescript"),
{
ignores: [
"node_modules/**",
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
],
},
]; ];
export default eslintConfig; export default eslintConfig;
{
"$schema": "https://biomejs.dev/schemas/2.2.0/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": true,
"includes": ["**", "!node_modules", "!.next", "!dist", "!build"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
},
"domains": {
"next": "recommended",
"react": "recommended"
}
},
"assist": {
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
...@@ -9,6 +9,17 @@ const compat = new FlatCompat({ ...@@ -9,6 +9,17 @@ const compat = new FlatCompat({
baseDirectory: __dirname, baseDirectory: __dirname,
}); });
const eslintConfig = [...compat.extends("next/core-web-vitals")]; const eslintConfig = [
...compat.extends("next/core-web-vitals"),
{
ignores: [
"node_modules/**",
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
],
},
];
export default eslintConfig; export default eslintConfig;
{
"$schema": "https://biomejs.dev/schemas/2.2.0/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": true,
"includes": ["**", "!node_modules", "!.next", "!dist", "!build"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
},
"domains": {
"next": "recommended",
"react": "recommended"
}
},
"assist": {
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
...@@ -11,6 +11,15 @@ const compat = new FlatCompat({ ...@@ -11,6 +11,15 @@ const compat = new FlatCompat({
const eslintConfig = [ const eslintConfig = [
...compat.extends("next/core-web-vitals", "next/typescript"), ...compat.extends("next/core-web-vitals", "next/typescript"),
{
ignores: [
"node_modules/**",
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
],
},
]; ];
export default eslintConfig; export default eslintConfig;
{
"$schema": "https://biomejs.dev/schemas/2.2.0/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": true,
"includes": ["**", "!node_modules", "!.next", "!dist", "!build"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
},
"domains": {
"next": "recommended",
"react": "recommended"
}
},
"assist": {
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
...@@ -9,6 +9,17 @@ const compat = new FlatCompat({ ...@@ -9,6 +9,17 @@ const compat = new FlatCompat({
baseDirectory: __dirname, baseDirectory: __dirname,
}); });
const eslintConfig = [...compat.extends("next/core-web-vitals")]; const eslintConfig = [
...compat.extends("next/core-web-vitals"),
{
ignores: [
"node_modules/**",
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
],
},
];
export default eslintConfig; export default eslintConfig;
{
"$schema": "https://biomejs.dev/schemas/2.2.0/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": true,
"includes": ["**", "!node_modules", "!.next", "!dist", "!build"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
},
"domains": {
"next": "recommended",
"react": "recommended"
}
},
"assist": {
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
...@@ -11,6 +11,15 @@ const compat = new FlatCompat({ ...@@ -11,6 +11,15 @@ const compat = new FlatCompat({
const eslintConfig = [ const eslintConfig = [
...compat.extends("next/core-web-vitals", "next/typescript"), ...compat.extends("next/core-web-vitals", "next/typescript"),
{
ignores: [
"node_modules/**",
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
],
},
]; ];
export default eslintConfig; export default eslintConfig;
...@@ -40,6 +40,7 @@ export const installTemplate = async ({ ...@@ -40,6 +40,7 @@ export const installTemplate = async ({
mode, mode,
tailwind, tailwind,
eslint, eslint,
biome,
srcDir, srcDir,
importAlias, importAlias,
skipInstall, skipInstall,
...@@ -56,6 +57,7 @@ export const installTemplate = async ({ ...@@ -56,6 +57,7 @@ export const installTemplate = async ({
const templatePath = path.join(__dirname, template, mode); const templatePath = path.join(__dirname, template, mode);
const copySource = ["**"]; const copySource = ["**"];
if (!eslint) copySource.push("!eslint.config.mjs"); if (!eslint) copySource.push("!eslint.config.mjs");
if (!biome) copySource.push("!biome.json");
if (!tailwind) copySource.push("!postcss.config.mjs"); if (!tailwind) copySource.push("!postcss.config.mjs");
await copy(copySource, root, { await copy(copySource, root, {
...@@ -191,7 +193,8 @@ export const installTemplate = async ({ ...@@ -191,7 +193,8 @@ export const installTemplate = async ({
dev: `next dev${turbopack ? " --turbopack" : ""}`, dev: `next dev${turbopack ? " --turbopack" : ""}`,
build: `next build${turbopack ? " --turbopack" : ""}`, build: `next build${turbopack ? " --turbopack" : ""}`,
start: "next start", start: "next start",
lint: "next lint", ...(eslint && { lint: "eslint" }),
...(biome && { lint: "biome check", format: "biome format --write" }),
}, },
/** /**
* Default dependencies. * Default dependencies.
...@@ -252,6 +255,14 @@ export const installTemplate = async ({ ...@@ -252,6 +255,14 @@ export const installTemplate = async ({
}; };
} }
/* Biome dependencies. */
if (biome) {
packageJson.devDependencies = {
...packageJson.devDependencies,
"@biomejs/biome": "2.2.0",
};
}
if (isApi) { if (isApi) {
delete packageJson.dependencies.react; delete packageJson.dependencies.react;
delete packageJson.dependencies["react-dom"]; delete packageJson.dependencies["react-dom"];
...@@ -263,7 +274,9 @@ export const installTemplate = async ({ ...@@ -263,7 +274,9 @@ export const installTemplate = async ({
// if a type error was thrown at `distDir/types/app/page.ts`. // if a type error was thrown at `distDir/types/app/page.ts`.
delete packageJson.devDependencies["@types/react-dom"]; delete packageJson.devDependencies["@types/react-dom"];
// Remove linting scripts for API-only templates
delete packageJson.scripts.lint; delete packageJson.scripts.lint;
delete packageJson.scripts.format;
} }
const devDeps = Object.keys(packageJson.devDependencies).length; const devDeps = Object.keys(packageJson.devDependencies).length;
......
...@@ -26,6 +26,7 @@ export interface InstallTemplateArgs { ...@@ -26,6 +26,7 @@ export interface InstallTemplateArgs {
template: TemplateType; template: TemplateType;
mode: TemplateMode; mode: TemplateMode;
eslint: boolean; eslint: boolean;
biome: boolean;
tailwind: boolean; tailwind: boolean;
srcDir: boolean; srcDir: boolean;
importAlias: string; importAlias: string;
......
...@@ -6,7 +6,7 @@ import { isAbsolute, join } from 'path' ...@@ -6,7 +6,7 @@ import { isAbsolute, join } from 'path'
import loadConfig from '../server/config' import loadConfig from '../server/config'
import { printAndExit } from '../server/lib/utils' import { printAndExit } from '../server/lib/utils'
import { Telemetry } from '../telemetry/storage' import { Telemetry } from '../telemetry/storage'
import { green } from '../lib/picocolors' import { green, yellow, bold } from '../lib/picocolors'
import { ESLINT_DEFAULT_DIRS } from '../lib/constants' import { ESLINT_DEFAULT_DIRS } from '../lib/constants'
import { runLintCheck } from '../lib/eslint/runLintCheck' import { runLintCheck } from '../lib/eslint/runLintCheck'
import { CompileError } from '../lib/compile-error' import { CompileError } from '../lib/compile-error'
...@@ -64,6 +64,17 @@ const eslintOptions = ( ...@@ -64,6 +64,17 @@ const eslintOptions = (
}) })
const nextLint = async (options: NextLintOptions, directory?: string) => { const nextLint = async (options: NextLintOptions, directory?: string) => {
// Show deprecation warning
console.warn(
yellow('`next lint` is deprecated and will be removed in Next.js 16.\n') +
'For new projects, use ' +
bold('create-next-app') +
' to choose your preferred linter.\n' +
'For existing projects, migrate to explicit ESLint configuration and update your package.json scripts to use ' +
bold('"eslint"') +
' instead.\n'
)
const baseDir = getProjectDir(directory) const baseDir = getProjectDir(directory)
// Check if the provided directory exists // Check if the provided directory exists
......
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`create-next-app Biome configuration should match biome.json snapshot 1`] = `
"{
"$schema": "https://biomejs.dev/schemas/2.2.0/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": true,
"includes": ["**", "!node_modules", "!.next", "!dist", "!build"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
},
"domains": {
"next": "recommended",
"react": "recommended"
}
},
"assist": {
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
"
`;
import execa from 'execa'
import { readFile, writeFile } from 'fs/promises'
import { join } from 'path'
import { run, useTempDir } from './utils'
describe('create-next-app Biome configuration', () => {
let nextTgzFilename: string
beforeAll(() => {
if (!process.env.NEXT_TEST_PKG_PATHS) {
throw new Error('This test needs to be run with `node run-tests.js`.')
}
const pkgPaths = new Map<string, string>(
JSON.parse(process.env.NEXT_TEST_PKG_PATHS)
)
nextTgzFilename = pkgPaths.get('next')
})
it('should match biome.json snapshot', async () => {
await useTempDir(async (cwd) => {
const projectName = 'test-biome-snapshot'
const { exitCode } = await run(
[
projectName,
'--ts',
'--biome',
'--no-tailwind',
'--no-src-dir',
'--app',
'--no-turbopack',
'--no-import-alias',
'--skip-install',
],
nextTgzFilename,
{ cwd }
)
expect(exitCode).toBe(0)
const projectDir = join(cwd, projectName)
const biomeConfig = await readFile(join(projectDir, 'biome.json'), 'utf8')
expect(biomeConfig).toMatchSnapshot()
})
})
it('should run biome check successfully on generated TypeScript project', async () => {
await useTempDir(async (cwd) => {
const projectName = 'test-biome-ts-check'
const { exitCode } = await run(
[
projectName,
'--ts',
'--biome',
'--no-tailwind',
'--no-src-dir',
'--app',
'--no-turbopack',
'--no-import-alias',
],
nextTgzFilename,
{ cwd }
)
expect(exitCode).toBe(0)
const projectDir = join(cwd, projectName)
// Run biome check on the generated project
const { exitCode: biomeExitCode, stdout } = await execa(
'npm',
['run', 'lint'],
{
cwd: projectDir,
}
)
expect(biomeExitCode).toBe(0)
expect(stdout).toContain('Checked')
})
})
it('should run biome check successfully on generated JavaScript project', async () => {
await useTempDir(async (cwd) => {
const projectName = 'test-biome-js-check'
const { exitCode } = await run(
[
projectName,
'--js',
'--biome',
'--no-tailwind',
'--no-src-dir',
'--app',
'--no-turbopack',
'--no-import-alias',
],
nextTgzFilename,
{ cwd }
)
expect(exitCode).toBe(0)
const projectDir = join(cwd, projectName)
// Run biome check on the generated project
const { exitCode: biomeExitCode, stdout } = await execa(
'npm',
['run', 'lint'],
{
cwd: projectDir,
}
)
expect(biomeExitCode).toBe(0)
expect(stdout).toContain('Checked')
})
})
it('should format code with biome successfully', async () => {
await useTempDir(async (cwd) => {
const projectName = 'test-biome-format'
const { exitCode } = await run(
[
projectName,
'--ts',
'--biome',
'--no-tailwind',
'--no-src-dir',
'--app',
'--no-turbopack',
'--no-import-alias',
],
nextTgzFilename,
{ cwd }
)
expect(exitCode).toBe(0)
const projectDir = join(cwd, projectName)
// Run biome format on the generated project
const { exitCode: biomeFormatCode, stdout } = await execa(
'npm',
['run', 'format'],
{
cwd: projectDir,
}
)
expect(biomeFormatCode).toBe(0)
expect(stdout).toContain('Formatted')
})
})
it('should show errors when biome detects issues', async () => {
await useTempDir(async (cwd) => {
const projectName = 'test-biome-errors'
const { exitCode } = await run(
[
projectName,
'--ts',
'--biome',
'--no-tailwind',
'--no-src-dir',
'--app',
'--no-turbopack',
'--no-import-alias',
],
nextTgzFilename,
{ cwd }
)
expect(exitCode).toBe(0)
const projectDir = join(cwd, projectName)
// Add a file with linting issues
const problematicFile = join(projectDir, 'app', 'problematic.tsx')
await writeFile(
problematicFile,
`export default function Component() {
var unusedVar = 5;
const a = 1
const b = 2
// Double equals instead of triple
if (a == b) {
console.log("test")
}
// Debugger statement
debugger;
return <div>Test</div>
}`
)
// Run biome check on the project with the problematic file
try {
await execa('npm', ['run', 'lint'], {
cwd: projectDir,
})
// If we get here, the command succeeded when it shouldn't have
expect(true).toBe(false) // Force test to fail
} catch (error) {
// The command should fail with exit code 1
expect(error.exitCode).toBe(1)
expect(error.stdout + error.stderr).toContain('problematic.tsx')
// Check for specific error messages
const output = error.stdout + error.stderr
expect(output).toMatch(/debugger|no-debugger/)
}
})
})
})
import { existsSync } from 'fs'
import { readFile } from 'fs/promises'
import { join } from 'path'
import { run, useTempDir } from './utils'
describe('create-next-app ESLint configuration', () => {
let nextTgzFilename: string
beforeAll(() => {
if (!process.env.NEXT_TEST_PKG_PATHS) {
throw new Error('This test needs to be run with `node run-tests.js`.')
}
const pkgPaths = new Map<string, string>(
JSON.parse(process.env.NEXT_TEST_PKG_PATHS)
)
nextTgzFilename = pkgPaths.get('next')
})
it('should generate eslint.config.mjs for TypeScript project with ESLint', async () => {
await useTempDir(async (cwd) => {
const projectName = 'test-eslint-ts'
const { exitCode } = await run(
[
projectName,
'--ts',
'--eslint',
'--no-tailwind',
'--no-src-dir',
'--app',
'--no-turbopack',
'--no-import-alias',
'--skip-install',
],
nextTgzFilename,
{ cwd }
)
expect(exitCode).toBe(0)
const projectDir = join(cwd, projectName)
// Should have eslint.config.mjs
expect(existsSync(join(projectDir, 'eslint.config.mjs'))).toBe(true)
// Should NOT have biome.json
expect(existsSync(join(projectDir, 'biome.json'))).toBe(false)
// Check eslint.config.mjs content
const eslintConfig = await readFile(
join(projectDir, 'eslint.config.mjs'),
'utf8'
)
expect(eslintConfig).toContain('next/core-web-vitals')
expect(eslintConfig).toContain('next/typescript')
// Check package.json scripts
const packageJson = JSON.parse(
await readFile(join(projectDir, 'package.json'), 'utf8')
)
expect(packageJson.scripts.lint).toBe('eslint')
expect(packageJson.devDependencies.eslint).toBeTruthy()
expect(packageJson.devDependencies['eslint-config-next']).toBeTruthy()
expect(packageJson.devDependencies['@eslint/eslintrc']).toBeTruthy()
})
})
it('should generate eslint.config.mjs for JavaScript project with ESLint', async () => {
await useTempDir(async (cwd) => {
const projectName = 'test-eslint-js'
const { exitCode } = await run(
[
projectName,
'--js',
'--eslint',
'--no-tailwind',
'--no-src-dir',
'--app',
'--no-turbopack',
'--no-import-alias',
'--skip-install',
],
nextTgzFilename,
{ cwd }
)
expect(exitCode).toBe(0)
const projectDir = join(cwd, projectName)
// Should have eslint.config.mjs
expect(existsSync(join(projectDir, 'eslint.config.mjs'))).toBe(true)
// Check eslint.config.mjs content for JS project
const eslintConfig = await readFile(
join(projectDir, 'eslint.config.mjs'),
'utf8'
)
expect(eslintConfig).toContain('next/core-web-vitals')
expect(eslintConfig).not.toContain('next/typescript')
// Check package.json scripts
const packageJson = JSON.parse(
await readFile(join(projectDir, 'package.json'), 'utf8')
)
expect(packageJson.scripts.lint).toBe('eslint')
expect(packageJson.devDependencies.eslint).toBeTruthy()
expect(packageJson.devDependencies['eslint-config-next']).toBeTruthy()
})
})
})
...@@ -35,7 +35,7 @@ describe('create-next-app', () => { ...@@ -35,7 +35,7 @@ describe('create-next-app', () => {
'--ts', '--ts',
'--app', '--app',
'--no-turbopack', '--no-turbopack',
'--no-eslint', '--no-linter',
'--no-tailwind', '--no-tailwind',
'--no-src-dir', '--no-src-dir',
'--no-import-alias', '--no-import-alias',
...@@ -108,7 +108,7 @@ describe('create-next-app', () => { ...@@ -108,7 +108,7 @@ describe('create-next-app', () => {
'--ts', '--ts',
'--app', '--app',
'--no-turbopack', '--no-turbopack',
'--no-eslint', '--no-linter',
'--no-tailwind', '--no-tailwind',
'--no-src-dir', '--no-src-dir',
'--no-import-alias', '--no-import-alias',
......
...@@ -45,7 +45,7 @@ describe('create-next-app with package manager bun', () => { ...@@ -45,7 +45,7 @@ describe('create-next-app with package manager bun', () => {
'--app', '--app',
'--use-bun', '--use-bun',
'--no-turbopack', '--no-turbopack',
'--no-eslint', '--no-linter',
'--no-src-dir', '--no-src-dir',
'--no-tailwind', '--no-tailwind',
'--no-import-alias', '--no-import-alias',
...@@ -74,7 +74,7 @@ describe('create-next-app with package manager bun', () => { ...@@ -74,7 +74,7 @@ describe('create-next-app with package manager bun', () => {
'--ts', '--ts',
'--app', '--app',
'--no-turbopack', '--no-turbopack',
'--no-eslint', '--no-linter',
'--no-src-dir', '--no-src-dir',
'--no-tailwind', '--no-tailwind',
'--no-import-alias', '--no-import-alias',
......
...@@ -34,7 +34,7 @@ describe('create-next-app with package manager npm', () => { ...@@ -34,7 +34,7 @@ describe('create-next-app with package manager npm', () => {
'--app', '--app',
'--use-npm', '--use-npm',
'--no-turbopack', '--no-turbopack',
'--no-eslint', '--no-linter',
'--no-src-dir', '--no-src-dir',
'--no-tailwind', '--no-tailwind',
'--no-import-alias', '--no-import-alias',
...@@ -63,7 +63,7 @@ describe('create-next-app with package manager npm', () => { ...@@ -63,7 +63,7 @@ describe('create-next-app with package manager npm', () => {
'--ts', '--ts',
'--app', '--app',
'--no-turbopack', '--no-turbopack',
'--no-eslint', '--no-linter',
'--no-src-dir', '--no-src-dir',
'--no-tailwind', '--no-tailwind',
'--no-import-alias', '--no-import-alias',
......
...@@ -34,7 +34,7 @@ describe('create-next-app with package manager pnpm', () => { ...@@ -34,7 +34,7 @@ describe('create-next-app with package manager pnpm', () => {
'--app', '--app',
'--use-pnpm', '--use-pnpm',
'--no-turbopack', '--no-turbopack',
'--no-eslint', '--no-linter',
'--no-src-dir', '--no-src-dir',
'--no-tailwind', '--no-tailwind',
'--no-import-alias', '--no-import-alias',
...@@ -63,7 +63,7 @@ describe('create-next-app with package manager pnpm', () => { ...@@ -63,7 +63,7 @@ describe('create-next-app with package manager pnpm', () => {
'--ts', '--ts',
'--app', '--app',
'--no-turbopack', '--no-turbopack',
'--no-eslint', '--no-linter',
'--no-src-dir', '--no-src-dir',
'--no-tailwind', '--no-tailwind',
'--no-import-alias', '--no-import-alias',
......
...@@ -42,7 +42,7 @@ describe('create-next-app with package manager yarn', () => { ...@@ -42,7 +42,7 @@ describe('create-next-app with package manager yarn', () => {
'--app', '--app',
'--use-yarn', '--use-yarn',
'--no-turbopack', '--no-turbopack',
'--no-eslint', '--no-linter',
'--no-src-dir', '--no-src-dir',
'--no-tailwind', '--no-tailwind',
'--no-import-alias', '--no-import-alias',
...@@ -71,7 +71,7 @@ describe('create-next-app with package manager yarn', () => { ...@@ -71,7 +71,7 @@ describe('create-next-app with package manager yarn', () => {
'--ts', '--ts',
'--app', '--app',
'--no-turbopack', '--no-turbopack',
'--no-eslint', '--no-linter',
'--no-src-dir', '--no-src-dir',
'--no-tailwind', '--no-tailwind',
'--no-import-alias', '--no-import-alias',
......
...@@ -30,7 +30,7 @@ describe.each(['app', 'pages'] as const)( ...@@ -30,7 +30,7 @@ describe.each(['app', 'pages'] as const)(
'--no-import-alias', '--no-import-alias',
], ],
// doesn't affect if the app builds or not // doesn't affect if the app builds or not
// eslint: ['--eslint', '--no-eslint'], // eslint: ['--eslint', '--no-linter'],
eslint: ['--eslint'], eslint: ['--eslint'],
srcDir: ['--src-dir', '--no-src-dir'], srcDir: ['--src-dir', '--no-src-dir'],
......
...@@ -419,7 +419,6 @@ describe('Next Lint', () => { ...@@ -419,7 +419,6 @@ describe('Next Lint', () => {
} }
) )
expect(stderr).toEqual('')
expect(stderr).not.toContain( expect(stderr).not.toContain(
'Warning: Synchronous scripts should not be used.' 'Warning: Synchronous scripts should not be used.'
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment