-
Notifications
You must be signed in to change notification settings - Fork 889
no-unused-expression rule doesn't handle directives #1050
Comments
Thanks for the detailed report @ArturDorochowicz; we should definitely support this. How about a new |
I'm fine with lenient for starters and maybe refining it later. But why not incorporate it into the base rule, i.e. without additional option? Especially that the proposed option suggests something that doesn't exist in the language. After all, a statement consisting of a string literal expression outside of a directive prologue is not a directive. NB ESLint seems to get this rule right [1] |
Ah, ok, that makes sense, I wasn't paying close enough attention to the valid directive prologue positions. We should support it without the additional option. Thanks for the ESLint link. |
@ArturDorochowicz Filed #1094 to fix this. Feel free to give it a look over so we make sure it gets the right behavior |
@jkillian LGTM. Thank you! I initially thought that it will break on comments before or in between directives: function a() {
/* comment */
// comment
'directive1';
// comment
'directive2';
/* comment */
'directive3';
var a = 1;
} But no, things are ok. Probably the comments don't make it into the parsed syntax tree - that's something I did not know about. |
Bug Report
3.6.0
1.8.9
TypeScript code being linted
with tslint.json
Actual behavior
Expected behavior
The no-unused-expression rule does not handle directive prologues at all. It only has a hard coded detection of 'use strict' expression in any position.
'ngInject' directive is just an example. Any directive should work in directive prologue position.
This "reopens" #423 which was valid but maybe not explained well enough.
For reference, the directive prologue definition from ECMAScript 5.1
The text was updated successfully, but these errors were encountered: