Adding ignore folders to flat file eslint config
Unanswered
joostschuur posted this in #help-forum
I'm trying to get eslint to ignore an additional folder (or just what's in .gitignore), but can't seem to get this to work with the new flat filesystem format (I'm on Next.js 15.3) and at build time.
It looks like I'm trying to combine these two approaches, and I'm not sure if I'm doing this right:
https://nextjs.org/docs/app/api-reference/config/eslint#additional-configurations
https://eslint.org/docs/latest/use/configure/ignore#including-gitignore-files
next lint
isn't processing files in tmp
(which is also in .gitignore
), but next build
returns a linting error from a .ts file in tmp
which I'm trying to ignore.It looks like I'm trying to combine these two approaches, and I'm not sure if I'm doing this right:
https://nextjs.org/docs/app/api-reference/config/eslint#additional-configurations
https://eslint.org/docs/latest/use/configure/ignore#including-gitignore-files
3 Replies
import { FlatCompat } from '@eslint/eslintrc';
import { defineConfig } from 'eslint/config';
import { fileURLToPath } from 'url';
const gitignorePath = fileURLToPath(new URL('.gitignore', import.meta.url));
const compat = new FlatCompat({
baseDirectory: import.meta.dirname,
});
const eslintConfig = defineConfig([
includeIgnoreFile(gitignorePath, compat),
{
linterOptions: {
reportUnusedDisableDirectives: true,
},
},
// Custom rules would go here
{
rules: {},
},
...compat.config({
extends: ['next/core-web-vitals', 'next/typescript'],
}),
]);
export default eslintConfig;
using
https://nextjs.org/docs/app/api-reference/config/eslint#linting-custom-directories-and-files
dirs
in next.config.ts
doesn't seem to work either. eslint: { dirs: ['src'] }
still gives me the same linting error from tmp
which is a sibling directory.https://nextjs.org/docs/app/api-reference/config/eslint#linting-custom-directories-and-files
Well, it looks like the solution is to put the additional folder into
Not fully intuitive, but I guess it's because using @typescript/eslint under the hood? I don't think the docs were helpful in pointing this out 😦
tsconfig.json
's exclude
folder list.Not fully intuitive, but I guess it's because using @typescript/eslint under the hood? I don't think the docs were helpful in pointing this out 😦