You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
add a flag that enforces boolean expressions where booleans are expected #7306
This would be extremely non-idiomatic for JavaScript (as in, I expect almost no codebases to successfully compile under such a flag). I think TSLint would be the place for a rule like this.
Paul Jolly (@myitcv) Thanks for letting me know. We at our project stopped using TsLint for this exact reason, the rules can only validate the syntax, not the semantics. We developed a homemade rule runner that gets a type checker and runs against the a type checked code of the whole application rather than an AST of a single file.
It would not be a problem to put such rule together.
Activity
RyanCavanaugh commentedon Feb 29, 2016
This would be extremely non-idiomatic for JavaScript (as in, I expect almost no codebases to successfully compile under such a flag). I think TSLint would be the place for a rule like this.
basarat commentedon Mar 1, 2016
Agree with ryan. Just today :
It is highly idiomatic to do such checks in JSX/TSX/React 🌹
myitcv commentedon Mar 4, 2016
Aleksey-Bykov palantir/tslint#253 (amongst others)
This is blocked on palantir/tslint#680 however
zpdDG4gta8XKpMCd commentedon Mar 4, 2016
Paul Jolly (@myitcv) Thanks for letting me know. We at our project stopped using TsLint for this exact reason, the rules can only validate the syntax, not the semantics. We developed a homemade rule runner that gets a type checker and runs against the a type checked code of the whole application rather than an AST of a single file.
It would not be a problem to put such rule together.
myitcv commentedon Mar 5, 2016
Aleksey-Bykov in the absence of support for this kind of rule in
tslinthave you shared your custom rule runner?zpdDG4gta8XKpMCd commentedon Mar 5, 2016
I cannot share the real runner, but I can outline how to make one:
zpdDG4gta8XKpMCd commentedon Mar 5, 2016
then comes the simplified rule
zpdDG4gta8XKpMCd commentedon Mar 5, 2016
also take a look at the official example on how to make a linter: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#traversing-the-ast-with-a-little-linter
myitcv commentedon Mar 6, 2016
Aleksey-Bykov thanks for the pointers