#can't find fix for this issue in nextjs
1 messages · Page 1 of 1 (latest)
Next.js provides an integrated ESLint experience out of the box. If you're seeing linting issues in files you haven't touched, it could be because Next.js is running ESLint for all files in certain directories by default. These directories include pages/, app/, components/, lib/, and src/ directories.
You can specify which directories to lint using the dirs option in the eslint config in next.config.js for production builds. For example, if you only want to lint the 'pages' and 'utils' directories during production builds, you can do so like this:
module.exports = {
eslint: {
dirs: ['pages', 'utils'], // Only run ESLint on the 'pages' and 'utils' directories during production builds (next build)
},
}
You can also use the --dir and --file flags for next lint to lint specific directories and files. For example:
next lint --dir pages --dir utils --file bar.js
If you want Next.js to produce production code even when your application has ESLint errors, you can disable the built-in linting step completely. This is not recommended unless you already have ESLint configured to run in a separate part of your workflow (for example, in CI or a pre-commit hook). You can disable it like this:
module.exports = {
eslint: {
// Warning: This allows production builds to successfully complete even if
// your project has ESLint errors.
ignoreDuringBuilds: true,
},
}