Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Spec compliancy of check-es2015-constants plugin #5930
I started working on the proposed change to the check-es2015-constants plugin: Instead of throwing a compile time error when
I am not sure if this covers all possible violations besides modules. Is there a list of all possible violation types somewhere? Variable declarations via module import statements are not yet covered by this PR. Let me know if this is going into the right direction or if I should take a different route.
Agreed, finding a parent statement seems more reasonable. Do you have an example where my current implementation fails? I tried using
const a = "foo"; if (false) a = "false";
const a = "foo"; throw new Error("\"a\" is read-only"); if (false) a = "false";
I checked and indeed,
The same happens with all loop constructs that can either have a single expression or a block as body. Do I have to manually work around these or is there a better way than
EDIT: Found more cases where the statement parent is not the right place:
const a = 3 const b = () => a = 4
In the original issue, #5728, I tried to say we should split this up into the two plugins that actually need it (block-scoping and modules), but that doesn't appear to have happened in this PR. Would anyone mind if I file a new issue about that?
As it is, if you turn this on for block scoping for instance, you also get it for modules, e.g.
will still inject the logic to throw, even though you turned off processing of modules, and