Skip to content
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

[REFACTOR]: Warn instead of quitting when invalid options specified #3290

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

caitp
Copy link
Member

@caitp caitp commented Jun 12, 2018

When the options "es3", "es5" or "esnext" are use, emit a warning that
the option is deprecated, and that you should use "esversion: "
instead.

Previously, if you used "esnext" (or other deprecated options) in
addition to "esversion", jshint would refuse to valiate your code, and
quit instantly after reporting a weird error message that doesn't really
explain the change. The new error message, and warning-rather-than-quit
behaviour, should hopefully be easier for users to digest.

(Related to discussion on #2991)

When the options "es3", "es5" or "esnext" are use, emit a warning that
the option is deprecated, and that you should use "esversion: <X>"
instead.

Previously, if you used "esnext" (or other deprecated options) in
addition to "esversion", jshint would refuse to valiate your code, and
quit instantly after reporting a weird error message that doesn't really
explain the change. The new error message, and warning-rather-than-quit
behaviour, should hopefully be easier for users to digest.
@coveralls
Copy link

coveralls commented Jun 12, 2018

Coverage Status

Coverage increased (+0.002%) to 98.756% when pulling 04a0356 on caitp:DEPRECATE-DEPRECATE-DEPRECATE! into 578575d on jshint:master.

@jugglinmike
Copy link
Member

Quitting immediately is definitely more severe than issuing a warning, but we
had good reason for implementing that behavior. This is more than just a bad
practice that we want to discourage: it's a fundamentally ambiguous state.
Under these conditions, it's not clear which edition of ECMAscript the user
intended to specify. Because the options control basic parsing behavior (as
opposed to more cosmetic linting warnings), making the wrong guess can cause
further confusion. This is especially true if the problem is described in terms
of a warning because the user may ignore the warning and from there have no
indication of the misconfiguration.

While I'd be more receptive to implementing this as an error instead of a
warning, I would still need convincing that there is value in proceeding in the
face of ambiguity.

It seems as though your primary concern is with the error message itself.
Judging from what you've written here and in gh-2991, I'm wondering if you
think we could address the problem by making the text more descriptive.

@caitp
Copy link
Member Author

caitp commented Jun 15, 2018

Well, no, I don’t think insta-quitting is that great with deprecation.

App isn’t in ambiguous state, you always favour the non-ambiguous version if they’re both used, but the current case doesn’t even tell the user the feauture is deprecated, or inconsistent unless both flags are used.

There are alternatives, but I don’t think insta-quitting is the way to do this.

@jugglinmike
Copy link
Member

App isn’t in ambiguous state, you always favour the non-ambiguous version if
they’re both used

Trying to take the perspective of a user, I don't see a clear difference in
ambiguity between (for example) es5: true and esversion: 6. They both seem
equally descriptive.

There are alternatives, but I don’t think insta-quitting is the way to do
this.

My argument about parsing according to an assumption about the user's intent
didn't convince you, then. We should discuss those alternatives. Could you also
say more about why you are opposed to halting the parse?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants