tools: add buffer-constructor eslint rule#5740
Conversation
|
This custom rule isn't working for me, but maybe I'm misunderstanding what it is supposed to capture. Can you provide a code sample that this should flag? I've been assuming something like this is what you're trying to avoid: |
There was a problem hiding this comment.
I don't think it's possible for node.type === which to be false in this situation. I don't think you need the which variable at all.
|
@Trott .. thank you for that, I'm afraid I'm not that familiar with eslint yet so those comments were very helpful. As for the rule itself, yes, it should catch uses of The rule appears to be working just fine for me on this end. If I add a Changing that to |
|
Updated to address that feedback :-) |
|
LGTM |
Now that the Buffer.alloc, allocUnsafe, and from methods have landed, add a linting rule that requires their use within lib. Tests and benchmarks are explicitly excluded by the rule.
|
CI is green. |
|
LGTM, but perhaps you should try getting this upstreamed to help the community. |
|
That's a possibility. I'd want to get this landed here first tho. If it did hit upstream we could revert and use that later. |
|
Opened an issue to get this upstreamed. Will land this now. If/When it lands up stream we can update to use that version |
Now that the Buffer.alloc, allocUnsafe, and from methods have landed, add a linting rule that requires their use within lib. Tests and benchmarks are explicitly excluded by the rule. PR-URL: #5740 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
|
Landed in 9e30129 |
Pull Request check-list
make -j8 test(UNIX) orvcbuild test nosign(Windows) pass withthis change (including linting)?
test (or a benchmark) included?
existing APIs, or introduces new ones)?
Affected core subsystem(s)
tools (eslint)
Description of change
Now that the Buffer.alloc, allocUnsafe, and from methods have landed,
add a linting rule that requires their use within lib. Tests and
benchmarks are explicitly excluded by the rule.
Requires: #4682
/cc @Trott @ChALkeR @nodejs/testing