question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

next lint not working

See original GitHub issue

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

0 verbose cli /home/lance/.nvm/versions/node/v14.19.1/bin/node /home/lance/.nvm/versions/node/v14.19.1/lib/node_modules/npm/bin/npm-cli.js 1 info using npm@8.10.0 2 info using node@v14.19.1 3 timing npm:load:whichnode Completed in 1ms 4 timing config:load:defaults Completed in 3ms 5 timing config:load:file:/home/lance/.nvm/versions/node/v14.19.1/lib/node_modules/npm/npmrc Completed in 16ms 6 timing config:load:builtin Completed in 16ms 7 timing config:load:cli Completed in 3ms 8 timing config:load:env Completed in 0ms 9 timing config:load:file:/home/lance/nextjs-eslint/.npmrc Completed in 0ms 10 timing config:load:project Completed in 2ms 11 timing config:load:file:/home/lance/.npmrc Completed in 0ms 12 timing config:load:user Completed in 0ms 13 timing config:load:file:/home/lance/.nvm/versions/node/v14.19.1/etc/npmrc Completed in 0ms 14 timing config:load:global Completed in 0ms 15 timing config:load:validate Completed in 0ms 16 timing config:load:credentials Completed in 1ms 17 timing config:load:setEnvs Completed in 1ms 18 timing config:load Completed in 27ms 19 timing npm:load:configload Completed in 28ms 20 timing npm:load:mkdirpcache Completed in 1ms 21 timing npm:load:mkdirplogs Completed in 1ms 22 verbose title npm exec next info 23 verbose argv “exec” “–yes” “false” “–” “next” “info” 24 timing npm:load:setTitle Completed in 1ms 25 timing config:load:flatten Completed in 2ms 26 timing npm:load:display Completed in 4ms 27 verbose logfile logs-max:10 dir:/home/lance/.npm/_logs 28 verbose logfile /home/lance/.npm/_logs/2022-06-29T03_40_33_537Z-debug-0.log 29 timing npm:load:logFile Completed in 5ms 30 timing npm:load:timers Completed in 0ms 31 timing npm:load:configScope Completed in 0ms 32 timing npm:load Completed in 42ms 33 silly logfile start cleaning logs, removing 1 files 34 silly logfile done cleaning log files 35 timing arborist:ctor Completed in 2ms 36 http fetch GET 200 https://registry.npmjs.org/next 23586ms (cache miss) 37 timing arborist:ctor Completed in 0ms 38 timing command:exec Completed in 23756ms 39 verbose stack Error: canceled 39 verbose stack at exec (/home/lance/.nvm/versions/node/v14.19.1/lib/node_modules/npm/node_modules/libnpmexec/lib/index.js:177:17) 39 verbose stack at async module.exports (/home/lance/.nvm/versions/node/v14.19.1/lib/node_modules/npm/lib/cli.js:78:5) 40 verbose cwd /home/lance/nextjs-eslint 41 verbose Linux 5.13.0-51-generic 42 verbose node v14.19.1 43 verbose npm v8.10.0 44 error canceled 45 verbose exit 1 46 timing npm Completed in 24817ms 47 verbose code 1 48 error A complete log of this run can be found in: 48 error /home/lance/.npm/_logs/2022-06-29T03_40_33_537Z-debug-0.log

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

I’m confused as to why there is a next lint command if it does not work. Running yarn lint shows no errors but yarn build shows errors and can also see errors in vscode and the browser.

Expected Behavior

running lint script should show errors

Link to reproduction

https://github.com/laclance/nextjs-eslint

To Reproduce

yarn && yarn lint

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
laclancecommented, Jul 2, 2022

OK thanks @balazsorban44 I am using @typescript-eslint/recommended and was still not seeing errors, however errors starting appearing again and I didn’t change anything so I don’t know what went wrong.

1reaction
balazsorban44commented, Jun 30, 2022

I looked at the OP’s reproduction, and I could not find an issue. Our default next/core-web-vitals is supposed to catch Next.js related issues, if you want to warn about unused variables, you can try extending your ESLint configuration, eg.:

// .eslintrc.json
{ "extends": ["next/core-web-vitals", "eslint:recommended"] }

Please see the docs: https://nextjs.org/docs/basic-features/eslint#additional-configurations

@cnotethegr8 from our docs:

By default, Next.js will run ESLint for all files in the pages/, components/, and lib/ directories. However, you can specify which directories using the dirs option in the eslint config in next.config.js for production builds

So in your case, since you put the error in the temp folder, you need to add it to dirs like so:

// next.config.js

module.exports = {
  // ...
  eslint: {
    dirs: ["temp", "pages"]
  }
}

https://nextjs.org/docs/basic-features/eslint#linting-custom-directories-and-files

(@mlarcher without seeing a reproduction, I’m just guessing you have a similar issue to one of these above)

So I’m closing this as it works as intended, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Next lint not working on files anywhere other than the ones ...
According to the docs, next lint runs ESLint for files in the following folders: pages , components , and lib .
Read more >
Troubleshooting a Next.js app with ESLint - LogRocket Blog
Troubleshooting a Next.js app with ESLint ... Inside your Next.js app, add a new script called lint — its value should be next...
Read more >
Basic Features: ESLint - Next.js
You can now run next lint every time you want to run ESLint to catch errors. Once ESLint has been set up, it...
Read more >
Can't run next lint because ESLint can't be found #29951
I'm trying to run the default NextJS linter as described here, but the system is having trouble finding ESLint, even though it's installed....
Read more >
Configure ESLint for Next.js - Devin Shoemaker
Now that we have ESLint working properly with Next.js, we need to add a file to tell ESLint to ignore certain files that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found