#How do I get Next.JS to ignore certain files for linting during the build phase

8 messages · Page 1 of 1 (latest)

buoyant terrace
#

When I run 'next build', it doesn't exclude files such as src/components/abc.test.tsx

It does exclude the __tests__ folder.

My tsconig exclude is:

"exclude": ["node_modules"]

I did try modifying it to:

"exclude": ["node_modules", "**/*.test.tsx"]

but no joy. It still compiles a .test.tsx file in the src/components folder.

Can anyone please provide some guidance on this? I didn't find documentation regarding the default excludes behaviour in Next.

mystic patrolBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

deft juniper
#

Next only builds code that you actually use inside your pages and route handlers. If a test file is getting compiled it's likely because you imported it somewhere where you shouldn't have.

buoyant terrace
#

hi, i've verified that this is not the case and that it's not being imported anywhere. I did this by checking git grep 'abc.test' and it yields nothing.

#

bump

deft juniper
#

Can you post the build logs? Censor any sensitive information if you need to.

From your initial request it's not clear if you're getting errors at build time or not.

buoyant terrace
#

i did some more digging and noticed that it's actually failing at the lint stage:

./node_modules/.bin/next build                                   INT ✘  02:35:30 PM
info  - Loaded env from /Users/vina/software/unibloom/primary/.env.local

Failed to compile.

./src/modules/analytics/components/EmissionWaterfall/EmissionWaterfall.test.tsx
264:9  Error: 'a' is assigned a value but never used. Allowed unused vars must match /^_/u.  @typescript-eslint/no-unused-vars
264:9  Error: 'a' is never reassigned. Use 'const' instead.  prefer-const

info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
info  - Linting and checking validity of types .%

And then i found these docs.

There's the dirs option, but i only want to ignore .*test.* files during next's linting phase.

Next.js provides an integrated ESLint experience by default. These conformance rules help you use Next.js in an optimal way.

#

How do I get Next.JS to ignore certain files for linting during the build phase