chore(lint): add no-const-enum rule #4677
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
This PR enables the
no-const-enum
rule that's intslint-etc
.ATM,
tslint-etc
is used in the dtslint tests to catch malformed type expectations. This PR bumps thetslint-etc
version and enables the above-mentioned rule in the project'stslint.json
file.The reason const enums cannot be used is outlined in #4556. Basically, using a const enum prohibits isolated module transpilation, as it's necessary to refer to another file to determine the literal that should replace a reference to a const enum member. That means that versions of RxJS that export const enums cannot be used with
create-react-app
-generated projects or any other projects that build using isolated modules.As configured, the rule forbids all use of const enums. The rule does have an
allowLocal
option, but I don't see the use of local (i.e. within a single module) const enums to be a likely use case.The main reason for adding the rule is to prevent the sort of breaking change that happened in 6.4.0 from happening again. In #4556, I mentioned that I tried to include a test that compiled the project using isolated modules, but was unable to do so (the reason is given in the linked PR).
The linting in this PR will fail until #4556 is merged.
Related issue (if exists): #4556