Commit graph

28 commits

Author SHA1 Message Date
JJ Kasper
8577c4f07b
Detect pnpm correctly when installing missing dependencies (#37813)
This ensures we properly detect `pnpm` when installing missing dependencies. This also adds test coverage to ensure we properly detect the correct package manager. 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

x-ref: [slack thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1655568091661719)
2022-06-19 12:33:23 +00:00
JJ Kasper
5730ed0f61
Ensure eslint-config warning/errors are correct (#37760)
* Ensure eslint-config warning/errors are correct

* fix tests
2022-06-16 16:04:44 -05:00
Michael Novotny
5211ac5cae
Adds consistency to ESLint rules. (#34335)
* Adds consistency to ESLint rules.

* Fixes lint errors.

* Fixes manifest.

* Adds missing title.

* Fixes copy / paste error.

Co-authored-by: Lee Robinson <me@leerob.io>

* Update errors/no-script-in-document.md

Co-authored-by: Lee Robinson <me@leerob.io>

* Update errors/no-sync-scripts.md

Co-authored-by: Lee Robinson <me@leerob.io>

* Updates a couple of rule descriptions.

* Adds redirects.

* Fixes unit tests.

* Removes duplicated section.

* Updates `no-before-interactive-script-outside-document` description.

* Fixes lint.

* Fixes integration tests.

* Adds description to `no-before-interactive-script-outside-document` documentation.

* Removes `link-passhref` from rules list.

* Updates remaining `pages/_middleware.js` references.

* Adds consistancy to messaging in new `no-styled-jsx-in-document` rule.

* Apply suggestions from code review

* Apply suggestions from code review

Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-06-13 21:17:42 -05:00
Jake Jarvis
f308826603
Add .eslintrc.cjs to list of supported next lint config files (#35440)
The logic for finding a user's custom `.eslintrc` config file is missing a check for `.eslintrc.cjs`, which is listed as one of the valid filenames in ESLint's docs:

https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats

...so this PR makes `next lint`'s list of possible config files consistent with ESLint's.

I stumbled upon this when trying to rename my own config file, since I've pretty much moved completely to ESM by now... but [ESLint doesn't support modules yet](https://github.com/eslint/eslint/issues/14137#issuecomment-785421664), so renaming the file to `.cjs` just keeps things cleaner (and VS Code happier). This is my first PR here so even though I've only changed a couple of lines, please let me know if I'm overlooking something! 😊

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-04-07 15:03:40 +00:00
Jiachi Liu
ff6b75027b
Enable import assertion syntax parsing (#33750)
## Feature

Enable import assertion syntax parsing for ecmascript/typescript. Since webpack has already supported it, enable import assertion parsing and leave them to webpack to handle

#### Upgration
* tooling: `@swc/core`, `@swc/cli`, prettier to support importAssertion related flags
* typescript related: `typescript` >= 4.5
* babel related: `@babel/plugin-syntax-import-assertions`
* lint parser: `@typescript-eslint/parser`


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-03-06 20:41:22 +00:00
Yamagishi Kazutoshi
32f0c9a403
Support ESLint v8 (#29865)
Co-authored-by: Michaël De Boey <info@michaeldeboey.be>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2021-11-16 10:18:27 +01:00
Othmane KINANE
39ef77cbe6
fix: support --cache-strategy ESLint argument (fixes #29926) (#29928)
* fix: support --cache-strategy ESLint argument

* add integration tests for --cache-strategy

* fix: add cacheStrategy to eslintOptions

* minor adjustments in next lint help message for --cache-strategy

Co-authored-by: Steven <steven@ceriously.com>
2021-11-08 12:17:42 -05:00
Houssein Djirdeh
c8f25ba70b
adds temporary eslint v8 error (#30113) 2021-10-20 17:28:08 -05:00
JJ Kasper
a92a5caec2
Update test set-up to leverage playwright when able to (#28634)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-09-13 14:36:25 +02:00
Houssein Djirdeh
4141aaefa5
[ESLint] Support single-file linting in next lint (necessary for lint-staged) (#28042)
Co-authored-by: Tim Neutkens <timneutkens@me.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-09-06 13:05:40 +02:00
Houssein Djirdeh
80921b6a54
enables eslint caching by default (#28349)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-08-23 12:56:21 -05:00
Houssein Djirdeh
7a1c9eb17e
[ESLint] Introduce a new setup process when next lint is run for the first time (#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`).
  - #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`.
  - #26574
  - #26475
  - #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 #26348
- Updates documentation to make it more clear what approach to take for new and existing ESLint configurations
2021-08-04 21:53:15 +00:00
stefanprobst
0833f83c86
Fix eslint config next/core-web-vitals (#27567)
fixes what i messed up in #27363. cf. https://github.com/vercel/next.js/pull/27363#issuecomment-888495697

also added an integration test for extending from `next/core-web-vitals` eslint config

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes
2021-07-28 19:07:54 +00:00
Michał Bundyra
7fe8a001e2
ESLint: custom directories from next.config.js (#26401)
Attempt to fix #26393

~~Sorry, I wasn't able to run tests on local, but I hope at least test should be valid.~~
Edit: Tests are working correctly on my local :) 

fixes #26393



## Bug

- [x] Related issues linked using `fixes #26393`
- [x] Integration tests added
2021-07-25 04:11:29 +00:00
Houssein Djirdeh
078cfb59f9
[ESLint] Adds --format flag to next lint (#27052)
Adds `--format` support to `next lint` to allow defining of additional formatters. Fixes #26387.
2021-07-24 01:35:56 +00:00
stefanprobst
daf54bb2b0
[eslint] move core-web-vitals config to eslint-plugin-next (#27363)
this pr moves the "core-web-vitals" config from `eslint-config-next` to `eslint-plugin-next`.

Fixes: #27292

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes
2021-07-23 17:58:53 +00:00
Houssein Djirdeh
6645248d41
[ESLint] Remove error when file patterns are unmatched + ESLint setup changes (#27119)
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2021-07-16 20:19:08 +02:00
Houssein Djirdeh
15afd97729
[ESLint] Adds --max-warnings flag to next lint (#26697)
Adds `--max-warnings` flag to `next lint` to enable setting of a maximum warning threshold.

Fixes #26671
2021-06-29 10:12:23 +00:00
Houssein Djirdeh
ce4f1e889e
[ESLint] Adds --quiet flag, TypeScript resolver and bug fixes (#26280) 2021-06-18 15:17:53 +02:00
JJ Kasper
8610ba4b5e
Fix eslint version check for older versions (#26212) 2021-06-16 14:16:01 -05:00
Vitaly Baev
66cb786df0
fix: don't create .eslintrc if package.json contains eslintConfig (#26025)
* fix: don't create .eslintrc if package.json contains eslintConfig

* tests: added integration tests for next lint

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-06-14 15:57:18 -05:00
Houssein Djirdeh
436e74bb04
ESLint: More updates and bug fixes (#25952)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-06-10 11:02:50 +02:00
Houssein Djirdeh
50a36eecd3
ESLint Updates (#25895)
* 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>
2021-06-08 17:46:00 -05:00
Houssein Djirdeh
bbc28ccae0
next lint + ESLint in Create Next App (#25064)
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: Tim Neutkens <timneutkens@me.com>
2021-06-03 14:01:24 +02:00
Houssein Djirdeh
e783b0a2e8
Adds ESLint with default rule-set (#23702)
This PR re-includes ESLint with some notable changes, namely a guided setup similar to how TypeScript is instantiated in a Next.js application.

To add ESLint to a project, developers will have to create an `.eslintrc` file in the root of their project or add an empty `eslintConfig` object to their `package.json` file.

```js
touch .eslintrc
```

Then running `next build` will show instructions to install the required packages needed:

<img width="862" alt="Screen Shot 2021-04-19 at 7 38 27 PM" src="https://user-images.githubusercontent.com/12476932/115316182-dfd51b00-a146-11eb-830c-90bad20ed151.png">

Once installed and `next build` is run again, `.eslintrc` will be automatically configured to include the default config:

```json
{
  "extends": "next"
}
```

In addition to this change:

- The feature is now under the experimental flag and requires opt-in. After testing and feedback, it will be switched to the top-level namespace and turned on by default.
- A new ESLint shareable configuration package is included that can be extended in any application with `{ extends: 'next' }`
  - This default config extends recommended rule sets from [`eslint-plugin-react`](https://www.npmjs.com/package/eslint-plugin-react), [`eslint-plugin-react-hooks`](https://www.npmjs.com/package/eslint-plugin-react-hooks), and [`eslint-plugin-next`](https://www.npmjs.com/package/@next/eslint-plugin-next)
- All rules in [`eslint-plugin-next`](https://www.npmjs.com/package/@next/eslint-plugin-next) have been modified to include actionable links that show more information to help resolve each issue
2021-04-30 11:09:07 +00:00
Joe Haddad
eecc3342cb
Temporarily remove experimental ESLint integration (#23521)
This pull request **temporarily** removes ESLint, as it was not landed in accordance with our standard experimental policies. We are fully committed to landing this change again.

This is being reverted because:

- Next.js has very strict goals for its install size. This feature resulted in adding over 17MB, or a 43.6% increase.
- The feature was not first landed under the `experimental` key in `next.config.js`, rather, it was added under the stable namespace (top-level)
- Using the feature doesn't do a "guided setup" like TypeScript, it should ask you to "bring your own" dependencies for ESLint
- It uses a undesirable ESLint plugin name: `plugin:@next/next/recommended`. This should read out as strictly `next`, or as short as we can get it.
- Does not provide actionable warnings (missing link to resolve issue)
- Does not follow appropriate console output styling. We need to revisit how these are presented.

To re-land this, we need to ensure the following minimums are met:
- Very minor change in install size
- Fully experimental (i.e. flagged) with warnings
- Finalized package name and configuration shape, preferably so we can do ` { extends: 'next' } `.
2021-03-30 08:26:35 +00:00
Tim Neutkens
2ec2ea8786
Make eslint opt-in until it lands on stable (#23509) 2021-03-29 17:58:55 +02:00
Houssein Djirdeh
e5ef60fecb
Add ESLint to Next.js (#22437)
For #22228

This PR:

- Adds ESLint to toolchain
  - Included by default for builds (`next build`)
  - Can be enabled for development (`next dev`)
  - Custom formatter built for output
- Adds appropriate tests
- Adds two documentation pages
2021-03-23 21:32:42 +00:00