Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESLint Updates #25895

Merged
merged 8 commits into from Jun 8, 2021
Merged

ESLint Updates #25895

merged 8 commits into from Jun 8, 2021

Conversation

housseindjirdeh
Copy link
Collaborator

@housseindjirdeh housseindjirdeh commented Jun 8, 2021

ESLint updates per review comments on #24900

  • Documentation updates

  • --no-lint command line flag has been "removed" in place of an next.config.js flag ({ eslint: ignoreDuringBuilds })

    • --no-lint command is still present but has been removed from docs, etc... It's currently being used in the PnP test script to not fail on build because of missing ESLint deps
  • When checks successfully pass for next lint, a new success message is shown:

    Screen Shot 2021-06-07 at 1 43 00 PM

  • "Need to disable some rules?" message is added at the end of the ESLint output

    image

  • pages, components, and lib directories are all now linted by default and an additional flag has been added to next.config.js to modify which directories to lint during production builds:

    module.exports = {
      eslint: {
        dirs: ['pages', 'components'] // Only run ESLint on pages and components directories during builds
      }
    }
    

docs/api-reference/next.config.js/ignoring-eslint.md Outdated Show resolved Hide resolved
docs/api-reference/next.config.js/ignoring-eslint.md Outdated Show resolved Hide resolved

## Linting Custom Directories

By default, Next.js will only run ESLint for all files in the `pages/` directory. However, you can specify other custom directories to run by using the `--dir` flag in `next lint`:
By default, Next.js will run ESLint for all files in the `pages/`, `components/`, and `lib/` directories. However, you can specify other custom directories to run by using the `--dir` flag in `next lint`:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to change these defaults? E.g. maybe I don't want lib. Could be follow up later 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just added the option to configure this via next.config.js:

module.exports = {
  eslint: {
    dirs: ['pages', 'components'] // Only run ESLint on pages and components directories during builds
  }
}

f57a046#diff-ea22ff5b8d78b521a09affbcc239809dc95143cda0370d9992420ab86172ea58

@@ -7,13 +7,13 @@ description: Next.js provides an integrated ESLint experience by default. These
Since version **11.0.0**, Next.js provides an integrated [ESLint](https://eslint.org/) experience out of the box. To get started, run `next lint`:

```bash
next lint
npx next lint
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally I'd want to recommend npm run lint or yarn run lint to ensure it's always using the Next.js version that is installed in the project. This would mean we'd create a project with "lint": "next lint" in scripts as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good point, updated!

@ijjk

This comment has been minimized.

docs/basic-features/eslint.md Outdated Show resolved Hide resolved
: '')
? `remove the ${chalk.bold('eslintConfig')} field from package.json`
: '') +
' or disable it in next.config.js.\n\nSee https://nextjs.org/docs/api-reference/next.config.js/ignoring-eslint.'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we only recommend this config option instead of recommending deleting the configuration? Would make it easier to toggle removing a bad config from editing right away.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that probably makes sense (I only recently added that config option)

Fixed here: #25917

@ijjk ijjk requested a review from leerob June 8, 2021 20:33
@ijjk
Copy link
Member

ijjk commented Jun 8, 2021

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary housseindjirdeh/next.js eslint-updates Change
buildDuration 14.8s 14.6s -136ms
buildDurationCached 3.6s 3.6s ⚠️ +51ms
nodeModulesSize 46.5 MB 46.5 MB ⚠️ +2.39 kB
Page Load Tests Overall increase ✓
vercel/next.js canary housseindjirdeh/next.js eslint-updates Change
/ failed reqs 0 0
/ total time (seconds) 3.143 3.009 -0.13
/ avg req/sec 795.48 830.75 +35.27
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.918 1.92 0
/error-in-render avg req/sec 1303.46 1302.02 ⚠️ -1.44
Client Bundles (main, webpack, commons)
vercel/next.js canary housseindjirdeh/next.js eslint-updates Change
framework-HASH.js gzip 39.3 kB 39.3 kB
main-HASH.js gzip 20.2 kB 20.2 kB
webpack-HASH.js gzip 804 B 804 B
Overall change 60.3 kB 60.3 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary housseindjirdeh/next.js eslint-updates Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary housseindjirdeh/next.js eslint-updates Change
_app-HASH.js gzip 801 B 801 B
_error-HASH.js gzip 3.07 kB 3.07 kB
amp-HASH.js gzip 527 B 527 B
css-HASH.js gzip 334 B 334 B
hooks-HASH.js gzip 890 B 890 B
index-HASH.js gzip 263 B 263 B
link-HASH.js gzip 1.64 kB 1.64 kB
routerDirect..HASH.js gzip 333 B 333 B
withRouter-HASH.js gzip 330 B 330 B
bb14e60e810b..30f.css gzip 125 B 125 B
Overall change 8.31 kB 8.31 kB
Client Build Manifests
vercel/next.js canary housseindjirdeh/next.js eslint-updates Change
_buildManifest.js gzip 392 B 392 B
Overall change 392 B 392 B
Rendered Page Sizes
vercel/next.js canary housseindjirdeh/next.js eslint-updates Change
index.html gzip 573 B 573 B
link.html gzip 580 B 580 B
withRouter.html gzip 567 B 567 B
Overall change 1.72 kB 1.72 kB

Serverless Mode
General Overall increase ⚠️
vercel/next.js canary housseindjirdeh/next.js eslint-updates Change
buildDuration 16.6s 16.6s -19ms
buildDurationCached 4.8s 4.8s -17ms
nodeModulesSize 46.5 MB 46.5 MB ⚠️ +2.39 kB
Client Bundles (main, webpack, commons)
vercel/next.js canary housseindjirdeh/next.js eslint-updates Change
framework-HASH.js gzip 39.3 kB 39.3 kB
main-HASH.js gzip 20.2 kB 20.2 kB
webpack-HASH.js gzip 804 B 804 B
Overall change 60.3 kB 60.3 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary housseindjirdeh/next.js eslint-updates Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary housseindjirdeh/next.js eslint-updates Change
_app-HASH.js gzip 801 B 801 B
_error-HASH.js gzip 3.07 kB 3.07 kB
amp-HASH.js gzip 527 B 527 B
css-HASH.js gzip 334 B 334 B
hooks-HASH.js gzip 890 B 890 B
index-HASH.js gzip 263 B 263 B
link-HASH.js gzip 1.64 kB 1.64 kB
routerDirect..HASH.js gzip 333 B 333 B
withRouter-HASH.js gzip 330 B 330 B
bb14e60e810b..30f.css gzip 125 B 125 B
Overall change 8.31 kB 8.31 kB
Client Build Manifests
vercel/next.js canary housseindjirdeh/next.js eslint-updates Change
_buildManifest.js gzip 392 B 392 B
Overall change 392 B 392 B
Serverless bundles
vercel/next.js canary housseindjirdeh/next.js eslint-updates Change
_error.js 16.9 kB 16.9 kB
404.html 2.44 kB 2.44 kB
500.html 2.43 kB 2.43 kB
amp.amp.html 10.8 kB 10.8 kB
amp.html 1.63 kB 1.63 kB
css.html 1.81 kB 1.81 kB
hooks.html 1.69 kB 1.69 kB
index.js 17.2 kB 17.2 kB
link.js 17.4 kB 17.4 kB
routerDirect.js 17.4 kB 17.4 kB
withRouter.js 17.4 kB 17.4 kB
Overall change 107 kB 107 kB

Webpack 4 Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary housseindjirdeh/next.js eslint-updates Change
buildDuration 12.6s 12.8s ⚠️ +144ms
buildDurationCached 5.3s 5.3s ⚠️ +7ms
nodeModulesSize 46.5 MB 46.5 MB ⚠️ +2.39 kB
Page Load Tests Overall increase ✓
vercel/next.js canary housseindjirdeh/next.js eslint-updates Change
/ failed reqs 0 0
/ total time (seconds) 3.046 3.099 ⚠️ +0.05
/ avg req/sec 820.74 806.79 ⚠️ -13.95
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.909 1.842 -0.07
/error-in-render avg req/sec 1309.82 1357.16 +47.34
Client Bundles (main, webpack, commons)
vercel/next.js canary housseindjirdeh/next.js eslint-updates Change
677f882d2ed8..HASH.js gzip 13.4 kB 13.4 kB
framework.HASH.js gzip 39 kB 39 kB
main-HASH.js gzip 7.99 kB 7.99 kB
webpack-HASH.js gzip 751 B 751 B
Overall change 61.1 kB 61.1 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary housseindjirdeh/next.js eslint-updates Change
polyfills-HASH.js gzip 31.3 kB 31.3 kB
Overall change 31.3 kB 31.3 kB
Client Pages
vercel/next.js canary housseindjirdeh/next.js eslint-updates Change
_app-HASH.js gzip 1.07 kB 1.07 kB
_error-HASH.js gzip 3.74 kB 3.74 kB
amp-HASH.js gzip 536 B 536 B
css-HASH.js gzip 339 B 339 B
hooks-HASH.js gzip 887 B 887 B
index-HASH.js gzip 227 B 227 B
link-HASH.js gzip 1.63 kB 1.63 kB
routerDirect..HASH.js gzip 303 B 303 B
withRouter-HASH.js gzip 302 B 302 B
e025d2764813..52f.css gzip 125 B 125 B
Overall change 9.17 kB 9.17 kB
Client Build Manifests
vercel/next.js canary housseindjirdeh/next.js eslint-updates Change
_buildManifest.js gzip 420 B 420 B
Overall change 420 B 420 B
Rendered Page Sizes
vercel/next.js canary housseindjirdeh/next.js eslint-updates Change
index.html gzip 625 B 625 B
link.html gzip 632 B 632 B
withRouter.html gzip 620 B 620 B
Overall change 1.88 kB 1.88 kB
Commit: 4ec4712

@ijjk ijjk merged commit 50a36ee into vercel:canary Jun 8, 2021
kodiakhq bot pushed a commit that referenced this pull request Jun 9, 2021
@leodr
Copy link
Contributor

leodr commented Jun 9, 2021

Since src/pages is also a valid location for pages, should the src directory also be linted by default?

flybayer pushed a commit to blitz-js/next.js that referenced this pull request Jun 16, 2021
* lots of eslint updates

* adds eslint: dirs flag to next.config.js

* update lint command in docs

* update per review comments

* re-add --no-lint command for build

* Apply suggestions from code review

Co-authored-by: JJ Kasper <jj@jjsweb.site>
flybayer pushed a commit to blitz-js/next.js that referenced this pull request Jun 16, 2021
@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants