Commit Graph

10 Commits

Author SHA1 Message Date
Antoine du Hamel
5e5af2947f
tools: add polyfilled option to prefer-primordials rule
PR-URL: https://github.com/nodejs/node/pull/55318
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2024-10-17 10:37:54 +00:00
Michaël Zasso
3c1069bb06
tools: prepare custom rules for ESLint v9
Refs: https://eslint.org/docs/latest/use/migrate-to-9.0.0
PR-URL: https://github.com/nodejs/node/pull/52889
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
2024-05-09 15:27:39 +00:00
Antoine du Hamel
0084fc7994
tools: fix bug in prefer-primordials lint rule
PR-URL: https://github.com/nodejs/node/pull/46659
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2023-02-17 18:29:42 +00:00
Antoine du Hamel
3ce4cef4e6
tools: enforce use of trailing commas in tools/
PR-URL: https://github.com/nodejs/node/pull/45889
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2022-12-18 16:39:39 +00:00
Antoine du Hamel
6700b5c9e1
tools: fix bugs in prefer-primordials linter rule
The ESLint rule would repport false positive if code is using an
identifier that happens to have the same name as a primordials member.

PR-URL: https://github.com/nodejs/node/pull/42010
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2022-02-18 18:42:02 +00:00
Ikko Ashimine
0dce87e279
tools: fix typo in prefer-primordials.js
replacable -> replaceable

PR-URL: https://github.com/nodejs/node/pull/41891
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Qingyu Deng <i@ayase-lab.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2022-02-08 16:41:40 +00:00
Antoine du Hamel
8fce09e2a5
tools: fix bug in prefer-primordials ESLint rule
Refs: https://github.com/nodejs/node/pull/40622

PR-URL: https://github.com/nodejs/node/pull/40628
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Voltrex <mohammadkeyvanzade94@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-11-04 18:04:27 +01:00
Antoine du Hamel
7fd6c2036d tools: refactor prefer-primordials
Use optional chaining to improve code readability and remove use of
`Array.prototype.reduce`.

PR-URL: https://github.com/nodejs/node/pull/36018
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
2021-02-16 17:58:31 +01:00
Antoine du Hamel
5c3944fa20 lib,tools: enforce access to prototype from primordials
PR-URL: https://github.com/nodejs/node/pull/36025
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-11-14 05:56:39 -08:00
Leko
cef144421c 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: https://github.com/nodejs/node/pull/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>
2020-11-07 18:28:14 +08:00