-
Notifications
You must be signed in to change notification settings - Fork 663
refactor(rome_js_analyze): improve noDelete
#4272
Conversation
✅ Deploy Preview for docs-rometools ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
noDelete
noDelete
TypeScript ESLint has a rule in its strict preset that disallows delete on computed keys: no-dynamic-delete. This conflicts with the proposal I made of relaxing the rule. Another possibility could be to keep the rule strict by rejecting |
@ematipico What do you think about the second option: keeping the rule strict and removing the rule from the recommended preset? In the meantime, I can remove the relaxing in order to ship the other improvements of the rule. |
Personally, I would keep it recommended but relax the logic. ESLint rule is very relaxed: https://eslint.org/docs/latest/rules/no-delete-var |
In fact |
IMHO, we could relax the rule. It seems users are bothered by its strictness, not by having it in the recommended set. |
Summary
This improves
noDelete
in several ways:Better documentation and diagnostics
Add comments to understand implementation decisions
Avoid recursion
Avoid the introduction of a new enum type
Relax the rule like discussed here
This no longer rejects the following code:
Following code is still rejected:
Report
delete
on optional chainsPreviously the rule didn't report the following code:
There are no explanation why it is not rejected.
I think it is not rejected because
delete
can be without effect when the property is missing.The rule now reports
delete
on optional chains.Test Plan
Updated and extended.
Documentation
Updated and improved.