You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/rules/prefer-node-protocol.md
-18
Original file line number
Diff line number
Diff line change
@@ -9,12 +9,6 @@
9
9
10
10
When importing builtin modules, it's better to use the [`node:` protocol](https://nodejs.org/api/esm.html#node-imports) as it makes it perfectly clear that the package is a Node.js builtin module.
11
11
12
-
Note that Node.js support for this feature began in:
13
-
14
-
> v16.0.0, v14.18.0 (`require()`)
15
-
>
16
-
> v14.13.1, v12.20.0 (`import`)
17
-
18
12
## Fail
19
13
20
14
```js
@@ -29,14 +23,6 @@ export {strict as default} from 'assert';
Copy file name to clipboardExpand all lines: docs/write-tests.md
+10-10
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ Tests are in the `/test` directory.
5
5
A rule test file should look like this:
6
6
7
7
```js
8
-
import {getTester} from'./utils/test.mjs';
8
+
import {getTester} from'./utils/test.js';
9
9
10
10
const {test} =getTester(import.meta);
11
11
@@ -21,12 +21,12 @@ test.snapshot({
21
21
22
22
## `test.snapshot()`
23
23
24
-
This runs [`SnapshotRuleTester`](../test/utils/snapshot-rule-tester.mjs), which auto-generates the snapshot for test results, including error messages, error locations, autofix result, and suggestions. All you have to do is check the snapshot and make sure the results are expected before committing.
24
+
This runs [`SnapshotRuleTester`](../test/utils/snapshot-rule-tester.js), which auto-generates the snapshot for test results, including error messages, error locations, autofix result, and suggestions. All you have to do is check the snapshot and make sure the results are expected before committing.
25
25
26
26
It's recommended to use this approach as it simplifies test writing.
27
27
28
28
```js
29
-
import {getTester} from'./utils/test.mjs';
29
+
import {getTester} from'./utils/test.js';
30
30
31
31
const {test} =getTester(import.meta);
32
32
@@ -45,13 +45,13 @@ test.snapshot({
45
45
We use [`AVA`](https://github.com/avajs/ava) to run tests. To focus on a specific rule test, you can:
46
46
47
47
```console
48
-
npx ava test/rule-name.mjs
48
+
npx ava test/rule-name.js
49
49
```
50
50
51
51
To update snapshots, run the command above with [`--update-snapshots` or `-u`](https://github.com/avajs/ava/blob/main/docs/05-command-line.md#cli).
52
52
53
53
```console
54
-
npx ava test/rule-name.mjs-u
54
+
npx ava test/rule-name.js-u
55
55
```
56
56
57
57
## Focus on one test case
@@ -91,7 +91,7 @@ test.snapshot({
91
91
This runs [`eslint-ava-rule-tester`](https://github.com/jfmengels/eslint-ava-rule-tester):
92
92
93
93
```js
94
-
import {getTester} from'./utils/test.mjs';
94
+
import {getTester} from'./utils/test.js';
95
95
96
96
const {test} =getTester(import.meta);
97
97
@@ -141,10 +141,10 @@ test.snapshot({
141
141
142
142
## `parsers`
143
143
144
-
[`utils/test.mjs`](../test/utils/test.mjs) also exposes a `parsers` object, which can be used in `testerOptions` or `parser` for a single test case.
144
+
[`utils/test.js`](../test/utils/test.js) also exposes a `parsers` object, which can be used in `testerOptions` or `parser` for a single test case.
0 commit comments