Skip to content

[WIP] lib: rename functions named value #57901

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

LiviaMedeiros
Copy link
Member

Refs: #57899
This requires adjusting linter rules. Or slapping // eslint-disable-line func-name-matching and regression tests as temporal solution.

If anyone is willing to make this into linter rule, feel free to takeover this.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/startup
  • @nodejs/streams
  • @nodejs/test_runner
  • @nodejs/web-standards

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Apr 16, 2025
@LiviaMedeiros LiviaMedeiros added help wanted Issues that need assistance from volunteers or PRs that need help to proceed. wip Issues and PRs that are still a work in progress. labels Apr 16, 2025
@ljharb
Copy link
Member

ljharb commented Apr 16, 2025

it'd be great to get a PR that just fixes the value-named functions and disables the lint rule so that it can be released and maximally backported.

Copy link

codecov bot commented Apr 16, 2025

Codecov Report

Attention: Patch coverage is 97.01493% with 2 lines in your changes missing coverage. Please review.

Project coverage is 90.25%. Comparing base (af85f3f) to head (8345a46).
Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/per_context/domexception.js 0.00% 1 Missing ⚠️
lib/internal/util.js 95.83% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #57901      +/-   ##
==========================================
- Coverage   90.25%   90.25%   -0.01%     
==========================================
  Files         630      630              
  Lines      185697   185957     +260     
  Branches    36409    36447      +38     
==========================================
+ Hits       167603   167834     +231     
- Misses      10998    11003       +5     
- Partials     7096     7120      +24     
Files with missing lines Coverage Δ
lib/fs.js 98.26% <100.00%> (ø)
...internal/bootstrap/web/exposed-window-or-worker.js 93.79% <100.00%> (ø)
lib/internal/console/constructor.js 99.41% <100.00%> (+0.87%) ⬆️
lib/internal/streams/writable.js 96.64% <100.00%> (+<0.01%) ⬆️
lib/internal/util/types.js 100.00% <100.00%> (ø)
lib/internal/worker/io.js 99.19% <100.00%> (+<0.01%) ⬆️
lib/zlib.js 98.22% <100.00%> (+<0.01%) ⬆️
lib/internal/per_context/domexception.js 75.81% <0.00%> (ø)
lib/internal/util.js 95.74% <95.83%> (+<0.01%) ⬆️

... and 47 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines 436 to 450
function hasInstanceFn(instance) {
if (FunctionPrototypeSymbolHasInstance(this, instance)) return true;
if (this !== Writable) return false;

return instance && instance._writableState instanceof WritableState;
};
ObjectDefineProperty(hasInstanceFn, 'name', {
__proto__: null,
value: '[Symbol.hasInstance]',
writable: false,
enumerable: false,
configurable: true,
});
ObjectDefineProperty(Writable, SymbolHasInstance, {
__proto__: null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's set up a util to simplify that

Suggested change
function hasInstanceFn(instance) {
if (FunctionPrototypeSymbolHasInstance(this, instance)) return true;
if (this !== Writable) return false;
return instance && instance._writableState instanceof WritableState;
};
ObjectDefineProperty(hasInstanceFn, 'name', {
__proto__: null,
value: '[Symbol.hasInstance]',
writable: false,
enumerable: false,
configurable: true,
});
ObjectDefineProperty(Writable, SymbolHasInstance, {
__proto__: null,
ObjectDefineProperty(Writable, SymbolHasInstance, {
__proto__: null,
value: setName(function(object) {
if (FunctionPrototypeSymbolHasInstance(this, object)) return true;
if (this !== Writable) return false;
return object && object._writableState instanceof WritableState;
}, '[Symbol.hasInstance]'),

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. I'm thinking of util that would take the symbol directly and [${kPrivateProperty.toString()}]-fy it.
Fixing something like

for (const prop of Object.getOwnPropertySymbols(require('console').Console.prototype))
  console.log(prop, '-->', require('console').Console.prototype[prop]);

will definitely require a helper function. 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issues that need assistance from volunteers or PRs that need help to proceed. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. wip Issues and PRs that are still a work in progress.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants