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
feat: no production assert tslint rule #894
Conversation
We should strip asserts when compiling the framework code for production environment. For that the assertion code should be wrapped in: if (process.env.NODE_ENV === 'production') {}. This is the simple, but good enough implemetation for the code we have.
26d9407
to
f20c59a
Compare
Cause they are checked before calling.
f20c59a
to
972feba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small style detail. But except that LGTM
Another approach to tackle this issue would be to lint the generated production code instead of the dev code. It would alleviate the need to add tslint inline comments for the functions that we know will be stripped in PROD (very fragile). @jodarove Thoughts? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'm fine with this as it is!
@pmdartus i agree that we should add a check (some how) in the generated production code to verify no asserts are leaking before it actually gets to prod, which is a late. That being said, this pr addresses a different issue, is meant to give an early feedback to devs that they might be leaking asserts to prod, trusting that the ci lint phase will fail and the build process of the prod scripts will do the work stripping what is wrapped in the if condition. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious where the tests went? Were they difficult to put into place after moving the rules inside engine?
@ekashida you dont miss one eh? :) I was having an issue with jest generating the coverage (without coverage is fine), in order to run the tests in the |
All lint rules are defaulted to error.
Details
We should strip asserts when compiling the framework code for production environment.
For that the assertion code should be wrapped in: if (process.env.NODE_ENV === 'production') {}.
This pr adds a tslint rule to ensure this.
Does this PR introduce a breaking change?