Commit f007426
tools: add lint fixer for
Adds `require-buffer` lint fixer.
If the buffer module is not required while `Buffer` is used, require the `buffer` module.
If the file has a `'use strict';` line, add the require after it on a separate line.
If the file does not have any (currently impossible with the `strict` rule) add it after the first comment (before the real code starts).
Fixes: #16636
PR-URL: #17144
Reviewed-By: Michaël Zasso <targos@protonmail.com>require-buffer
1 parent da40417 commit f007426Copy full SHA for f007426
File tree
Expand file treeCollapse file tree
2 files changed
+42
-5
lines changedOpen diff view settings
Filter options
- test/parallel
- tools/eslint-rules
Expand file treeCollapse file tree
2 files changed
+42
-5
lines changedOpen diff view settings
Collapse file
test/parallel/test-eslint-require-buffer.js
Copy file name to clipboardExpand all lines: test/parallel/test-eslint-require-buffer.js+25-4Lines changed: 25 additions & 4 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
12 | 12 | |
13 | 13 | |
14 | 14 | |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
15 | 19 | |
16 | 20 | |
17 | 21 | |
18 | | - |
| 22 | + |
| 23 | + |
19 | 24 | |
20 | 25 | |
21 | 26 | |
22 | | - |
23 | | - |
24 | | - |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
25 | 46 | |
26 | 47 | |
Collapse file
tools/eslint-rules/require-buffer.js
Copy file name to clipboardExpand all lines: tools/eslint-rules/require-buffer.js+17-1Lines changed: 17 additions & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1 | 1 | |
| 2 | + |
2 | 3 | |
3 | 4 | |
| 5 | + |
4 | 6 | |
5 | 7 | |
6 | 8 | |
7 | | - |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
8 | 24 | |
9 | 25 | |
10 | 26 | |
|
0 commit comments