Skip to content

Commit

Permalink
feat!: drop eslint < 8 & Node.js < 18 (eslint#238)
Browse files Browse the repository at this point in the history
* feat!: drop eslint <8 & node.js < 18

* docs: update readme

* Apply suggestions from code review

Co-authored-by: Milos Djermanovic <[email protected]>

---------

Co-authored-by: Milos Djermanovic <[email protected]>
  • Loading branch information
aladdin-add and mdjermanovic authored Feb 29, 2024
1 parent a758163 commit f14f6a5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 37 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install Packages
Expand All @@ -30,20 +30,20 @@ jobs:
matrix:
os: [ubuntu-latest]
eslint: [8]
node: [16, 17, 18, 19, 20, 21]
node: [21.x, 20.x, 18.x, "18.18.0"]
include:
- os: windows-latest
eslint: 8
node: 16
node: 20
- os: macOS-latest
eslint: 8
node: 16
node: 20
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Install Packages
Expand Down
35 changes: 7 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ module.exports = {

Some rules that catch mistakes in regular code are less helpful in documentation.
For example, `no-undef` would flag variables that are declared outside of a code snippet because they aren't relevant to the example.
The `plugin:markdown/recommended` config disables these rules in Markdown files:
The `markdown.configs.recommended` config disables these rules in Markdown files:

- [`no-undef`](https://eslint.org/docs/rules/no-undef)
- [`no-unused-expressions`](https://eslint.org/docs/rules/no-unused-expressions)
Expand Down Expand Up @@ -183,37 +183,23 @@ module.exports = {
#### Strict Mode

`"use strict"` directives in every code block would be annoying.
The `plugin:markdown/recommended` config enables the [`impliedStrict` parser option](https://eslint.org/docs/user-guide/configuring#specifying-parser-options) and disables the [`strict` rule](https://eslint.org/docs/rules/strict) in Markdown files.
The `markdown.configs.recommended` config enables the [`impliedStrict` parser option](https://eslint.org/docs/user-guide/configuring#specifying-parser-options) and disables the [`strict` rule](https://eslint.org/docs/rules/strict) in Markdown files.
This opts into strict mode parsing without repeated `"use strict"` directives.

#### Unsatisfiable Rules

Markdown code blocks are not real files, so ESLint's file-format rules do not apply.
The `plugin:markdown/recommended` config disables these rules in Markdown files:
The `markdown.configs.recommended` config disables these rules in Markdown files:

- [`eol-last`](https://eslint.org/docs/rules/eol-last): The Markdown parser trims trailing newlines from code blocks.
- [`unicode-bom`](https://eslint.org/docs/rules/unicode-bom): Markdown code blocks do not have Unicode Byte Order Marks.

### Running

#### ESLint v8+

If you are using an `eslint.config.js` file, then you can run ESLint as usual and it will pick up file patterns in your config file. The `--ext` option is not available when using flat config.

If you are using an `.eslintrc.*` file, then you can run ESLint as usual and it will work as in ESLint v7.x.

#### ESLint v7

You can run ESLint as usual and do not need to use the `--ext` option.
ESLint v7 [automatically lints file extensions specified in `overrides[].files` patterns in config files](https://github.com/eslint/rfcs/blob/0253e3a95511c65d622eaa387eb73f824249b467/designs/2019-additional-lint-targets/README.md).
If you are using an `.eslintrc.*` file, then you can run ESLint as usual and it will pick up file extensions specified in `overrides[].files` patterns in config files.

#### ESLint v6

Use the [`--ext` option](https://eslint.org/docs/user-guide/command-line-interface#ext) to include `.js` and `.md` extensions in ESLint's file search:

```sh
eslint --ext js,md .
```

### Autofixing

Expand Down Expand Up @@ -249,8 +235,8 @@ hello();
```

```jsx
// This can be linted too if you add `.jsx` files to `overrides` in ESLint v7
// or pass `--ext jsx` in ESLint v6.
// This can be linted too if you add `.jsx` files to file patterns in the `eslint.config.js`.
// Or `overrides[].files` in `eslintrc.*`.
var div = <div className="jsx"></div>;
```
````
Expand All @@ -263,14 +249,7 @@ This is plain text and doesn't get linted.
```
````

Unless a fenced code block's syntax appears as a file extension in `overrides[].files` in ESLint v7, it will be ignored.
If using ESLint v6, you must also include the extension with the `--ext` option.

````markdown
```python
print("This doesn't get linted either.")
```
````
Unless a fenced code block's syntax appears as a file extension in file patterns in your config file, it will be ignored.

## Configuration Comments

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
"mdast-util-from-markdown": "^0.8.5"
},
"peerDependencies": {
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0"
"eslint": ">=8"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
}
}

0 comments on commit f14f6a5

Please sign in to comment.