Configuring ESLint for a project with separate backend and frontend folders #499
Replies: 3 comments
-
Use a single eslint.config.js in the root of your repo (docs). If you want to apply different rules to your directories, use globs to target the directory: import antfu from '@antfu/eslint-config';
export default antfu(
{
stylistic: {
indent: 'tab',
semi: true,
},
},
{
files: ['**/*'],
rules: {
'no-console': 'off',
},
},
{
files: ['apps/frontend/**/*'],
rules: {
'react/prefer-destructuring-assignment': 'off',
},
},
); If you are using pnpm, one caveat you should be aware of is that you should install any eslint plugins in the root of your repo as well. One piece of advice is to first focus on making eslint behave the way you want when running it from the command line (i.e. run Also see https://github.com/typescript-eslint/typescript-eslint/blob/main/docs/getting-started/typed-linting/Monorepos.mdx for typescript specific setup in monorepos. |
Beta Was this translation helpful? Give feedback.
-
You can configure both
This is one I am frequently using in my project. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your responses. Even though I like Anthony's settings, dealing with eslint has been very exhausting for me. Having to use a lot of packages, extensions, and other problems. I think every attempt is a complete waste of time for eslint. Therefore, I started using biomejs. Although I haven't yet achieved the configuration I want, I was able to get it working so quickly that I'm sure I won't use eslint again. |
Beta Was this translation helpful? Give feedback.
-
Hello,
Imagine a repository with two folders named
backend
andfrontend
, and we are opening the repository's main folder with VSCode.How should the ESLint configurations be set up? Should they be done separately for the backend and frontend, or can a configuration be made to cover both folders?
When I try to do it separately, VSCode gives the error "Extension 'Eslint' is configured as formatter but it cannot format 'TypeScript' -files" and it gives this error not only for TypeScript but also JavaScript and JSON file types, so I can't format any files.
Beta Was this translation helpful? Give feedback.
All reactions