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: lint entire src directory

See original GitHub issue

Describe the feature you’d like to request

By default, the next lint only lints a select few directories:

https://github.com/vercel/next.js/blob/68047112d6ad9ac293161ecd3d594b05eda4d258/packages/next/lib/constants.ts#L60-L67

Which is also confirmed in the docs here so this seems like it is the intentional behavior.

I believe linting the entire /src directory would be a good default behavior.

Describe the solution you’d like

By default, next-lint should lint the entire /src directory as well as the other select few directories outside src (pages, components, lib) for people not adopting the src structure.

Describe alternatives you’ve considered

You can achieve this today by modifying the lint script like this:

”lint”: “next lint —dir src”

I feel like if you are adopting putting all files in src instead of having the directories in the project root (like the default examples have), there is no real point in not running the linter over all subdirectories. Outside src there might be directories you would want to treat differently (perhaps script etc) so limiting it to a select few here seems reasonable.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:9
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
housseindjirdehcommented, Jul 12, 2022

Thanks for the feedback here folks. There’s no particular reason why the entire src/ isn’t linted to be honest aside from my thinking that there may be some directory structures that folks would want to treat differently inside of src/. But I agree that’s not likely the case.

I can submit an update to fix this behavior 🙏

0reactions
github-actions[bot]commented, Aug 19, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Basic Features: ESLint - Next.js
You can now run next lint every time you want to run ESLint to catch errors. ... for all files in the pages/...
Read more >
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 >
eslint command line options supported by next lint (incl. --fix)
The short answer is: it doesn't. At least not all of them, but a whole lot more than the only one documented by...
Read more >
How to Automate Code Linting in Next.js with ESLint & Husky ...
json . In your terminal, run: npm set-script pre-commit "next lint". Note: again, make sure ...
Read more >
Next.js Setup | ESLint Jest React Testing Library and Absolute ...
I've made a couple updates here including the use of the src directory, ... If you npm run lint now, you can also...
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