Commit 1f27214
tools: add new ESLint rule: prefer-primordials
I added a new custom ESLint rule to fix these problems.
We have a lot of replaceable codes with primordials.
Accessing built-in objects is restricted by existing rule
(no-restricted-globals), but accessing property in the built-in objects
is not restricted right now. We manually review codes that can be
replaced by primordials, but there's a lot of code that actually needs
to be fixed. We have often made pull requests to replace the primordials
with.
Restrict accessing global built-in objects such as `Promise`.
Restrict calling static methods such as `Array.from` or `Symbol.for`.
Don't restrict prototype methods to prevent false-positive.
PR-URL: #35448
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Ben Coe <bencoe@gmail.com>1 parent 6011bfd commit 1f27214Copy full SHA for 1f27214
File tree
Expand file treeCollapse file tree
17 files changed
+477
-128
lines changedOpen diff view settings
Filter options
- lib
- internal
- fs
- main
- per_context
- quic
- readline
- util
- vm
- test/parallel
- tools/eslint-rules
Expand file treeCollapse file tree
17 files changed
+477
-128
lines changedOpen diff view settings
Collapse file
+39-64Lines changed: 39 additions & 64 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
7 | 7 | |
8 | 8 | |
9 | 9 | |
10 | | - |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
11 | 32 | |
12 | 33 | |
13 | | - |
14 | 34 | |
15 | | - |
16 | 35 | |
17 | | - |
18 | 36 | |
19 | | - |
20 | 37 | |
21 | | - |
22 | 38 | |
23 | | - |
| 39 | + |
| 40 | + |
24 | 41 | |
25 | | - |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + |
26 | 47 | |
27 | | - |
28 | 48 | |
29 | | - |
30 | 49 | |
31 | | - |
| 50 | + |
32 | 51 | |
33 | | - |
34 | 52 | |
35 | | - |
36 | 53 | |
37 | | - |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
38 | 58 | |
39 | | - |
40 | 59 | |
41 | | - |
42 | 60 | |
43 | | - |
44 | 61 | |
45 | | - |
46 | 62 | |
47 | | - |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + |
48 | 67 | |
49 | | - |
50 | 68 | |
51 | | - |
52 | 69 | |
53 | | - |
54 | 70 | |
55 | | - |
56 | 71 | |
57 | | - |
58 | 72 | |
59 | | - |
60 | 73 | |
61 | | - |
62 | 74 | |
63 | | - |
64 | 75 | |
65 | | - |
66 | 76 | |
67 | | - |
68 | | - |
69 | | - |
70 | 77 | |
71 | | - |
72 | 78 | |
73 | | - |
74 | 79 | |
75 | | - |
76 | 80 | |
77 | | - |
| 81 | + |
78 | 82 | |
79 | | - |
80 | 83 | |
81 | | - |
82 | | - |
83 | | - |
84 | | - |
85 | | - |
86 | | - |
87 | | - |
88 | | - |
89 | | - |
90 | | - |
91 | | - |
92 | | - |
93 | | - |
94 | | - |
95 | | - |
96 | | - |
97 | | - |
98 | | - |
99 | | - |
100 | | - |
101 | | - |
102 | | - |
103 | | - |
104 | | - |
105 | | - |
106 | | - |
107 | | - |
108 | | - |
109 | 84 | |
110 | 85 | |
111 | 86 | |
|
Collapse file
lib/internal/event_target.js
Copy file name to clipboardExpand all lines: lib/internal/event_target.js+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
36 | 36 | |
37 | 37 | |
38 | 38 | |
39 | | - |
| 39 | + |
40 | 40 | |
41 | 41 | |
42 | 42 | |
|
Collapse file
lib/internal/freeze_intrinsics.js
Copy file name to clipboardExpand all lines: lib/internal/freeze_intrinsics.js+87-43Lines changed: 87 additions & 43 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
20 | 20 | |
21 | 21 | |
22 | 22 | |
23 | | - |
24 | 23 | |
25 | 24 | |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | + |
26 | 77 | |
27 | | - |
28 | | - |
29 | | - |
30 | | - |
31 | | - |
32 | | - |
33 | | - |
34 | | - |
35 | | - |
36 | | - |
37 | | - |
38 | 78 | |
39 | 79 | |
40 | 80 | |
| ||
47 | 87 | |
48 | 88 | |
49 | 89 | |
50 | | - |
51 | | - |
| 90 | + |
| 91 | + |
52 | 92 | |
53 | 93 | |
54 | | - |
| 94 | + |
55 | 95 | |
56 | | - |
| 96 | + |
57 | 97 | |
58 | | - |
| 98 | + |
59 | 99 | |
60 | | - |
| 100 | + |
61 | 101 | |
62 | | - |
| 102 | + |
63 | 103 | |
64 | | - |
| 104 | + |
65 | 105 | |
66 | | - |
| 106 | + |
67 | 107 | |
68 | | - |
| 108 | + |
69 | 109 | |
70 | 110 | |
71 | 111 | |
| ||
129 | 169 | |
130 | 170 | |
131 | 171 | |
132 | | - |
| 172 | + |
133 | 173 | |
134 | | - |
135 | | - |
| 174 | + |
| 175 | + |
136 | 176 | |
137 | 177 | |
138 | | - |
| 178 | + |
139 | 179 | |
140 | | - |
| 180 | + |
141 | 181 | |
142 | | - |
| 182 | + |
143 | 183 | |
144 | | - |
| 184 | + |
145 | 185 | |
146 | | - |
| 186 | + |
147 | 187 | |
148 | | - |
| 188 | + |
149 | 189 | |
150 | | - |
| 190 | + |
151 | 191 | |
152 | | - |
| 192 | + |
153 | 193 | |
154 | 194 | |
155 | 195 | |
| 196 | + |
156 | 197 | |
| 198 | + |
157 | 199 | |
| 200 | + |
158 | 201 | |
| 202 | + |
159 | 203 | |
160 | 204 | |
161 | 205 | |
| ||
289 | 333 | |
290 | 334 | |
291 | 335 | |
292 | | - |
| 336 | + |
293 | 337 | |
294 | 338 | |
295 | 339 | |
296 | 340 | |
297 | 341 | |
298 | | - |
299 | | - |
| 342 | + |
| 343 | + |
300 | 344 | |
301 | | - |
| 345 | + |
302 | 346 | |
303 | 347 | |
304 | 348 | |
| ||
378 | 422 | |
379 | 423 | |
380 | 424 | |
381 | | - |
| 425 | + |
382 | 426 | |
383 | 427 | |
384 | | - |
| 428 | + |
385 | 429 | |
386 | 430 | |
387 | 431 | |
| ||
390 | 434 | |
391 | 435 | |
392 | 436 | |
393 | | - |
| 437 | + |
394 | 438 | |
395 | 439 | |
396 | 440 | |
| ||
403 | 447 | |
404 | 448 | |
405 | 449 | |
406 | | - |
| 450 | + |
407 | 451 | |
408 | 452 | |
409 | 453 | |
410 | | - |
| 454 | + |
411 | 455 | |
412 | 456 | |
413 | | - |
| 457 | + |
414 | 458 | |
415 | 459 | |
416 | 460 | |
|
Collapse file
+3-1Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
3 | 3 | |
4 | 4 | |
5 | 5 | |
| 6 | + |
6 | 7 | |
7 | 8 | |
8 | 9 | |
9 | 10 | |
10 | 11 | |
| 12 | + |
11 | 13 | |
12 | 14 | |
13 | 15 | |
| ||
785 | 787 | |
786 | 788 | |
787 | 789 | |
788 | | - |
| 790 | + |
789 | 791 | |
790 | 792 | |
791 | 793 | |
|
0 commit comments