ESLint + Prettier Setup for Next.js 15
raw JSON → 0.1.11 verified Sat Apr 25 auth: no javascript
eslint-prettier-next-15 (v0.1.11) is an automated CLI tool that configures ESLint (v9) and Prettier (v3) for Next.js 15 projects. It detects the package manager (npm, yarn, pnpm, or bun), removes old configurations, installs recommended dependencies (including @typescript-eslint, eslint-config-next, prettier plugins for import sorting and JSON formatting), and generates flat ESLint config and .prettierrc files. Designed for fresh or existing Next.js 15 apps, it enforces consistent code quality rules with zero manual setup. Updated irregularly; relies on flat config (eslint.config.mjs) and ESM-only imports.
Common errors
error Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'next' ↓
cause The script is run in a directory that is not a Next.js project or lacks node_modules.
fix
Run the command in a Next.js 15 project root after installing dependencies.
error SyntaxError: Unexpected token 'export' (at eslint.config.mjs:1:1) ↓
cause Using an outdated Node.js version (<18) that does not support ES modules or top-level await.
fix
Upgrade Node.js to v18 or later, or ensure "type": "module" is in package.json.
error Error: Cannot find module '@eslint/eslintrc' ↓
cause Script dependencies were not fully installed due to network issue or failed npm install.
fix
Delete node_modules and package-lock.json, then run npm install again, or run the script again.
error eslint: 'import' is not defined (no-undef) ↓
cause The generated config does not include eslint-plugin-import, but the eslint:recommended rule may report this.
fix
Add 'eslint-plugin-import' to the plugins and extend 'plugin:import/errors' or disable the rule.
Warnings
breaking This script deletes existing ESLint and Prettier configuration files (.eslintrc.*, .prettierrc, .editorconfig, .vscode/settings.json) without backup. ↓
fix Manually backup your configuration files before running the script, or reapply them after setup.
deprecated The script installs eslint-config-next@15.1.4 which is pinned; it may become outdated as Next.js updates its ESLint config. ↓
fix After running the script, update eslint-config-next to the latest version manually: npm install eslint-config-next@latest --save-dev
gotcha Script expected to be run in a Next.js 15 project root. Running elsewhere will create config files in wrong directory. ↓
fix Ensure you are in the root directory of your Next.js 15 project before executing the command.
gotcha The generated eslint.config.mjs uses FlatCompat to extend 'next' and 'next/core-web-vitals'. This may not work if ESLint is not v9 or if next/core-web-vitals is not installed. ↓
fix Verify that eslint and eslint-config-next are installed and compatible.
Install
npm install eslint-prettier-next-15 yarn add eslint-prettier-next-15 pnpm add eslint-prettier-next-15 Imports
- CLI usage wrong
npm install -g eslint-prettier-next-15 && eslint-prettier-next-15correctnpx eslint-prettier-next-15 - eslint.config.mjs wrong
.eslintrc.json or .eslintrc.jscorrecteslint.config.mjs (flat config file generated by script) - .prettierrc.json wrong
prettier.config.js or .prettierrc.jscorrect.prettierrc.json (JSON with plugins array)
Quickstart
mkdir my-next-app && cd my-next-app
npx create-next-app@15 . --typescript --eslint=false --src-dir --app --import-alias '@/*' --no-tailwind
echo 'y' | npx eslint-prettier-next-15
npx eslint . --ext .ts,.tsx 2>/dev/null | head -5 || echo "No lint errors"
npx prettier --check "app/**/*.ts" 2>/dev/null | head -5 || echo "All files formatted"