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

Documentation misleading regarding bitwise option? #3242

Closed
cherdt opened this issue Jan 22, 2018 · 5 comments
Closed

Documentation misleading regarding bitwise option? #3242

cherdt opened this issue Jan 22, 2018 · 5 comments

Comments

@cherdt
Copy link

@cherdt cherdt commented Jan 22, 2018

On http://jshint.com/docs/options/

bitwise is listed as an enforcing option and says "When set to true, these options will make JSHint produce more warnings about your code" (emphasis mine) and "This option prohibits the use of bitwise operators such as ^ (XOR), | (OR) and others."

However, setting:

/* jshint bitwise: true */

suppresses errors about bitwise operators. Based on the description, I expected the opposite, that:

/* jshint bitwise: false*/

would suppress errors about bitwise operators.

@jugglinmike
Copy link
Member

@jugglinmike jugglinmike commented Jan 28, 2018

That's strange. On my system, the option behaves in the way it is documented:

$ echo '0 ^ 0;' | ./bin/jshint -
stdin: line 1, col 5, Expected an assignment or function call and instead saw an expression.

1 error
$ echo '/* jshint bitwise: true */ 0 ^ 0;' | ./bin/jshint -
stdin: line 1, col 30, Unexpected use of '^'.
stdin: line 1, col 32, Expected an assignment or function call and instead saw an expression.

2 errors
$ ./bin/jshint --version
jshint v2.9.5

Before we can help, we'll need some more information. Could you share the other info documented in the project's contribution guidelines?

  • Version of JSHint being used
  • Input source code (simplified to only contain details necessary to
    demonstrate the problem)
  • Configuration values
  • Description of expected behavior
  • Description of actual behavior
@cherdt
Copy link
Author

@cherdt cherdt commented Jan 28, 2018

I get the same result with your example, but the results are swapped if I change out jshint for jslint (which I assumed were synonymous to jshint). Details below:

version of jshint: 2.9.5:

$ jshint --version jshint v2.9.5

Input source code:

echo '/* jslint bitwise: false */ 0 ^ 0;' | jshint -

Configuration values:

default (no custom config other than what is specified in the example)

Description of expected behavior:

No error re: Unexpected use of '^'

Description of actual behavior:

$ echo '/* jslint bitwise: false */ 0 ^ 0;' | jshint -
stdin: line 1, col 31, Unexpected use of '^'.
stdin: line 1, col 33, Expected an assignment or function call and instead saw an expression.

2 errors

Further details:

Comparing the results when jshint is specified versus jslint:

$ echo '/* jshint bitwise: false */ 0 ^ 0;' | jshint -
stdin: line 1, col 33, Expected an assignment or function call and instead saw an expression.

1 error
$ echo '/* jslint bitwise: false */ 0 ^ 0;' | jshint -
stdin: line 1, col 31, Unexpected use of '^'.
stdin: line 1, col 33, Expected an assignment or function call and instead saw an expression.

2 errors
$ echo '/* jshint bitwise: true */ 0 ^ 0;' | jshint -
stdin: line 1, col 30, Unexpected use of '^'.
stdin: line 1, col 32, Expected an assignment or function call and instead saw an expression.

2 errors
$ echo '/* jslint bitwise: true */ 0 ^ 0;' | jshint -
stdin: line 1, col 32, Expected an assignment or function call and instead saw an expression.

1 error

Is this the expected behavior?

@jugglinmike
Copy link
Member

@jugglinmike jugglinmike commented Jan 28, 2018

Yup, that's expected. The jslint directive is exposed for compatibility with the JSLint project, which defines inverse semantics for that option.

@cherdt
Copy link
Author

@cherdt cherdt commented Jan 29, 2018

Got it. Thanks for clearing that up!

@cherdt cherdt closed this Jan 29, 2018
@jugglinmike
Copy link
Member

@jugglinmike jugglinmike commented Jan 30, 2018

No problem!

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.