-
Notifications
You must be signed in to change notification settings - Fork 27.6k
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] Introduce a new setup process when next lint
is run for the first time
#26584
Conversation
next lint
is run for the first timenext lint
is run for the first time
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@@ -0,0 +1,114 @@ | |||
/* eslint-disable import/no-extraneous-dependencies */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file, along with the other helper/
files in the PR, were ported over directly from 'package/create-next-app`.
If there is a preferred way to re-use the same logic without duplicating these files, let me know 🙏
packages/next/package.json
Outdated
@@ -98,6 +99,7 @@ | |||
"pnp-webpack-plugin": "1.6.4", | |||
"postcss": "8.2.13", | |||
"process": "0.11.10", | |||
"prompts": "2.4.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Introduced this to the repo (14.3KB gzipped) to show the prompt to the user when they run next lint
.
If I shouldn't be including a dep for this, or if there's another smaller one I can use, let me know 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its actually 200KB since this is under dependencies
so we could us ncc
to bundle it down (maybe 100KB).
I'll defer to @timneutkens and @ijjk here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof, you're right. Tried nccing
it but it was showing some buggy behavior when compiled unfortunately. Switched to using another library, cli-select, that's a lot lighter (28 KB). It doesn't have nearly as many downloads, but is light as it needs to be since I'm only using a single select prompt here.
Also used ncc
+ a dynamic import. That brought down the total increase to node_modules
from 350 to 184 KB, but happy to consider any other alternatives if need be.
This comment has been minimized.
This comment has been minimized.
if (!checkTSDeps && !checkESLintDeps) { | ||
return { resolved: undefined! } | ||
if (!checkDeps) { | ||
return { resolved: undefined!, missing: [] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be resolved: new Map()
so the consumers don't try to access a property on undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or not pass this prop to this function at all and handle the edge case in verifyTypeScriptSetup.ts
with if statement ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call @LetItRock. Removed the prop altogether along with the return statement and just handled the logic in verifyTypeScriptSetup.ts
.
|
||
if (deps.length) { | ||
console.log() | ||
console.log(`Installing package${deps.length > 1 ? 's' : ''}:`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this say "Installing devDependencies" instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to say either devDependencies
or dependencies
:)
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Failing test suitesCommit: 25d271b test/integration/eslint/test/index.test.js
Expand output● ESLint › Next Lint › success message when no warnings or errors
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good after we update the mentioned dependencies
This comment has been minimized.
This comment has been minimized.
Stats from current PRDefault Build (Increase detected
|
vercel/next.js canary | housseindjirdeh/next.js eslint-update-7 | Change | |
---|---|---|---|
buildDuration | 16.6s | 15.8s | -827ms |
buildDurationCached | 3.7s | 3.7s | -19ms |
nodeModulesSize | 50.1 MB | 50.2 MB |
Page Load Tests Overall increase ✓
vercel/next.js canary | housseindjirdeh/next.js eslint-update-7 | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.938 | 2.872 | -0.07 |
/ avg req/sec | 850.88 | 870.58 | +19.7 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.828 | 1.786 | -0.04 |
/error-in-render avg req/sec | 1367.54 | 1399.76 | +32.22 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | housseindjirdeh/next.js eslint-update-7 | Change | |
---|---|---|---|
745.HASH.js gzip | 179 B | 179 B | ✓ |
framework-HASH.js gzip | 42.2 kB | 42.2 kB | ✓ |
main-HASH.js gzip | 23.1 kB | 23.1 kB | ✓ |
webpack-HASH.js gzip | 1.5 kB | 1.5 kB | ✓ |
Overall change | 67 kB | 67 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | housseindjirdeh/next.js eslint-update-7 | 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-update-7 | Change | |
---|---|---|---|
_app-HASH.js gzip | 980 B | 980 B | ✓ |
_error-HASH.js gzip | 194 B | 194 B | ✓ |
amp-HASH.js gzip | 312 B | 312 B | ✓ |
css-HASH.js gzip | 329 B | 329 B | ✓ |
dynamic-HASH.js gzip | 2.52 kB | 2.52 kB | ✓ |
head-HASH.js gzip | 350 B | 350 B | ✓ |
hooks-HASH.js gzip | 904 B | 904 B | ✓ |
image-HASH.js gzip | 4.12 kB | 4.12 kB | ✓ |
index-HASH.js gzip | 261 B | 261 B | ✓ |
link-HASH.js gzip | 1.66 kB | 1.66 kB | ✓ |
routerDirect..HASH.js gzip | 319 B | 319 B | ✓ |
script-HASH.js gzip | 387 B | 387 B | ✓ |
withRouter-HASH.js gzip | 320 B | 320 B | ✓ |
bb14e60e810b..30f.css gzip | 125 B | 125 B | ✓ |
Overall change | 12.8 kB | 12.8 kB | ✓ |
Client Build Manifests
vercel/next.js canary | housseindjirdeh/next.js eslint-update-7 | Change | |
---|---|---|---|
_buildManifest.js gzip | 490 B | 490 B | ✓ |
Overall change | 490 B | 490 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | housseindjirdeh/next.js eslint-update-7 | Change | |
---|---|---|---|
index.html gzip | 531 B | 531 B | ✓ |
link.html gzip | 542 B | 542 B | ✓ |
withRouter.html gzip | 523 B | 523 B | ✓ |
Overall change | 1.6 kB | 1.6 kB | ✓ |
Webpack 4 Mode (Increase detected ⚠️ )
General Overall increase ⚠️
vercel/next.js canary | housseindjirdeh/next.js eslint-update-7 | Change | |
---|---|---|---|
buildDuration | 13.1s | 12.8s | -328ms |
buildDurationCached | 5.1s | 4.9s | -232ms |
nodeModulesSize | 50.1 MB | 50.2 MB |
Page Load Tests Overall increase ✓
vercel/next.js canary | housseindjirdeh/next.js eslint-update-7 | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.968 | 3.005 | |
/ avg req/sec | 842.28 | 832 | |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.826 | 1.792 | -0.03 |
/error-in-render avg req/sec | 1369.3 | 1394.74 | +25.44 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | housseindjirdeh/next.js eslint-update-7 | Change | |
---|---|---|---|
17.HASH.js gzip | 185 B | 185 B | ✓ |
677f882d2ed8..HASH.js gzip | 14 kB | 14 kB | ✓ |
framework.HASH.js gzip | 41.9 kB | 41.9 kB | ✓ |
main-HASH.js gzip | 10.5 kB | 10.5 kB | ✓ |
webpack-HASH.js gzip | 1.19 kB | 1.19 kB | ✓ |
Overall change | 67.8 kB | 67.8 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | housseindjirdeh/next.js eslint-update-7 | 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-update-7 | Change | |
---|---|---|---|
_app-HASH.js gzip | 965 B | 965 B | ✓ |
_error-HASH.js gzip | 3.74 kB | 3.74 kB | ✓ |
amp-HASH.js gzip | 552 B | 552 B | ✓ |
css-HASH.js gzip | 333 B | 333 B | ✓ |
dynamic-HASH.js gzip | 2.71 kB | 2.71 kB | ✓ |
head-HASH.js gzip | 2.97 kB | 2.97 kB | ✓ |
hooks-HASH.js gzip | 911 B | 911 B | ✓ |
index-HASH.js gzip | 231 B | 231 B | ✓ |
link-HASH.js gzip | 1.64 kB | 1.64 kB | ✓ |
routerDirect..HASH.js gzip | 298 B | 298 B | ✓ |
script-HASH.js gzip | 2.94 kB | 2.94 kB | ✓ |
withRouter-HASH.js gzip | 294 B | 294 B | ✓ |
e025d2764813..52f.css gzip | 125 B | 125 B | ✓ |
Overall change | 17.7 kB | 17.7 kB | ✓ |
Client Build Manifests
vercel/next.js canary | housseindjirdeh/next.js eslint-update-7 | Change | |
---|---|---|---|
_buildManifest.js gzip | 499 B | 499 B | ✓ |
Overall change | 499 B | 499 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | housseindjirdeh/next.js eslint-update-7 | Change | |
---|---|---|---|
index.html gzip | 577 B | 577 B | ✓ |
link.html gzip | 589 B | 589 B | ✓ |
withRouter.html gzip | 570 B | 570 B | ✓ |
Overall change | 1.74 kB | 1.74 kB | ✓ |
…e first time (vercel#26584) This PR introduces an improved developer experience when `next lint` is run for the first time. ### Current behavior `eslint-config-next` is a required package that must be installed before proceeding with `next lint` or `next build`: ![image](https://user-images.githubusercontent.com/12476932/123468791-43088100-d5c0-11eb-9ad0-5beb80b6c968.png) Although this has helped many developers start using the new ESLint config, this has also resulted in a few issues: - Users are required to install the full config (`eslint-config-next`) even if they do not use it or use the Next.js plugin directly (`eslint-plugin-next`). - vercel#26348 - There's some confusion on why `eslint-config-next` needs to be installed or how it should be used instead of `eslint-plugin-next`. - vercel#26574 - vercel#26475 - vercel#26438 ### New behavior Instead of enforcing `eslint-config-next` as a required package, this PR prompts the user by asking what config they would like to start. This happens when `next lint` is run for the first time **and** if no ESLint configuration is detected in the application. <img src="https://user-images.githubusercontent.com/12476932/124331177-e1668a80-db5c-11eb-8915-38d3dc20f5d4.gif" width="800" /> - The CLI will take care of installing `eslint` or `eslint-config-next` if either is not already installed - Users now have the option to choose between a strict configuration (`next/core-web-vitals`) or just the base configuration (`next`) - For users that decide to create their own ESLint configuration, or already have an existing one, **installing `eslint-config-next` will not be a requirement for `next lint` or `next build` to run**. A warning message will just show if the Next.js ESLint plugin is not detected in an ESLint config. <img width="682" alt="Screen Shot 2021-06-25 at 3 02 12 PM" src="https://user-images.githubusercontent.com/12476932/123473329-6cc4a680-d5c6-11eb-9a57-d5c0b89a2732.png"> --- In addition, this PR also: - Fixes vercel#26348 - Updates documentation to make it more clear what approach to take for new and existing ESLint configurations
This PR introduces an improved developer experience when
next lint
is run for the first time.Current behavior
eslint-config-next
is a required package that must be installed before proceeding withnext lint
ornext build
:Although this has helped many developers start using the new ESLint config, this has also resulted in a few issues:
Users are required to install the full config (
eslint-config-next
) even if they do not use it or use the Next.js plugin directly (eslint-plugin-next
).There's some confusion on why
eslint-config-next
needs to be installed or how it should be used instead ofeslint-plugin-next
.New behavior
Instead of enforcing
eslint-config-next
as a required package, this PR prompts the user by asking what config they would like to start. This happens whennext lint
is run for the first time and if no ESLint configuration is detected in the application.The CLI will take care of installing
eslint
oreslint-config-next
if either is not already installedUsers now have the option to choose between a strict configuration (
next/core-web-vitals
) or just the base configuration (next
)For users that decide to create their own ESLint configuration, or already have an existing one, installing
eslint-config-next
will not be a requirement fornext lint
ornext build
to run. A warning message will just show if the Next.js ESLint plugin is not detected in an ESLint config.In addition, this PR also: