fix: move define-properties to preferred manifest#755
Conversation
|
A package goes to Otherwise it should stay in the |
|
Also please use the PR template |
|
given that you can conditionally define properties natively, too, can you explain why someone should use a package to do it instead? e.g. Object.defineProperties(obj, {
// Always defined
id: {
value: 303
},
// Conditionally defined
...(flags.enableFoo && {
foo: {
value: "foo value"
},
}),
...(flags.enableBar && {
bar: {
value: "bar value"
},
}),
}); |
|
@43081j I might be wrong but this pr honestly looks like it was opened by a bot |
|
I updated this to follow the preferred-entry convention: I’m not trying to argue that Happy to switch direction or close this if you’d rather keep the native classification. |
| ## `Object.defineProperties` (native) | ||
|
|
||
| [`Object.defineProperties`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties) can define multiple properties on an object without an extra dependency. | ||
|
|
There was a problem hiding this comment.
You need to show a diff for migration like in https://github.com/e18e/module-replacements/blob/main/docs/modules/clipboardy.md for example
|
Updated the example to use the migration diff format. |
|
|
||
| ```ts | ||
| const descriptors = { | ||
| enabled: { | ||
| configurable: true, | ||
| enumerable: false, | ||
| value: true, | ||
| writable: false | ||
| } | ||
| } | ||
|
|
||
| if (!Object.hasOwn(obj, 'enabled') || shouldOverrideEnabled()) { | ||
| Object.defineProperties(obj, descriptors) | ||
| } | ||
| ``` |
There was a problem hiding this comment.
Could you add a diff for this too please?
|
Updated the second example to use the migration diff format too. |
If you understand that You say |
|
Thanks for pushing on the distinction here. I rechecked So I think |
🔗 Linked issue
es-tooling/eslint-plugin-depend#35
📚 Description
Moves
define-propertiesfrom the native manifest to the preferred manifest because it is not always a direct native drop-in forObject.defineProperties.This also adds a docs page for the preferred entry, with the distinction that
Object.definePropertiesis enough when callers only need to define descriptors, whiledefine-propertieshas extra behavior around existing properties and predicate-controlled overrides.Checks:
pnpm lint