-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix for gh-3013 #3016
Fix for gh-3013 #3016
Conversation
This method simply proxies `lex.nextLine` to scan a single line of the program. It is currently only used to scan the very first line of input, which is problematic for two reasons: 1. Linting options have not yet been applied via the `assume` function, so linting options that effect the parser's behavior are not honored for this first line (see the unit test corrected in this patch for an example) 2. So-called "checks" for asynchronously-reported warnings on the first line cannot be associated with a token. This makes it impossible to issue warnings asynchronously for the first line. Because the `lex.token` method itself invokes `lex.nextLine`, these problems may be avoided by removing `lex.start` and deferring the invocation of `nextLine` until the first token is requested.
Defer the reporting of warning W100 until parse time (using `triggerAsync`) so that it may be disabled via in-line directives even in contexts where a "lookahead" is taking place.
This needs work--W101 is also suffering the same problem. |
@rwaldron Thanks to gh-3017, I have a better understanding of the scope of this problem. The context that triggers this error is the lookahead operations JSHint
This latest version of the patch addresses all lexer-triggered warnings in all
I've also included the above text as a comment within the test's fixture file. @damyanpetev @batista would either of you mind testing this branch of JSHint |
Sure, I'm unable to do it now, but I'll test it and get back to you |
Thanks! |
I can review tomorrow—please nudge me if I haven't reported by noon |
@jugglinmike can confirm that 72209ba fixes #3017 for me |
Thanks, Sérgio! |
@jugglinmike I'm confused about the relationship to #2741 |
@rwaldron I made that comment when I believed that the bug reported in gh-3013 was limited to W100. From that perspective, another viable fix was to remove W100 altogether--I suggested that as a possibility in gh-2741. While I still don't understand the intent of W100, it's clear that the underlying problem is more far-reaching, so I'm happy to let the conversation about removing W100 proceed separately. |
@jugglinmike A bit late, but I can also verify 72209ba honored the ignore for W100 warning with as initially logged in #3013 (massive IIFE). Also tested with this bit: (function() {
var test;
/*jshint -W100 */
test = "س";
})(); And it worked out okay as well. |
Thanks @damyanpetev and @batista, you're testing and confirmation is helpful here |
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.
Mike,
Thanks for walking me through this changeset, and I apologize for the amount of time that it took for me to fully understand the context.
Create work here, thanks @jugglinmike |
* [[CHORE]] Remove `lex.start` method This method simply proxies `lex.nextLine` to scan a single line of the program. It is currently only used to scan the very first line of input, which is problematic for two reasons: 1. Linting options have not yet been applied via the `assume` function, so linting options that effect the parser's behavior are not honored for this first line (see the unit test corrected in this patch for an example) 2. So-called "checks" for asynchronously-reported warnings on the first line cannot be associated with a token. This makes it impossible to issue warnings asynchronously for the first line. Because the `lex.token` method itself invokes `lex.nextLine`, these problems may be avoided by removing `lex.start` and deferring the invocation of `nextLine` until the first token is requested. * [[FIX]] Allow W100 to be ignored during lookahead Defer the reporting of warning W100 until parse time (using `triggerAsync`) so that it may be disabled via in-line directives even in contexts where a "lookahead" is taking place. * fixup! [[FIX]] Allow W100 to be ignored during lookahead
@rwaldron This is a fix for gh-3013 in two parts. You can see my response to
that issue for more detail about the problem. Please review carefully because
I'm messing with some relatively fundamental behavior here.
One specific question I have for you: I do not think it's possible to test for
this behavior at every call site of
nextLine
. (The situation we're interestedin here is when the lexer is tokenizing input and may pass over a
-W100
directive.) I've still updated the call sites for consistency, and in case some
future change can use
checks
from different call sites. Does that seemright to you?