-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Switch to using ESLint, instead of JSHint, for linting #7897
Conversation
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.
Looks good! r=me with the comments fixed.
@@ -2392,6 +2393,8 @@ if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('MOZCENTRAL')) { | |||
} | |||
|
|||
scope.URL = JURL; | |||
|
|||
/* eslint-disable yoda */ |
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.
This should probably use eslint-enable
.
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.
Whoops, this is embarrassing. Fixed now, thanks for noticing!
beforeAll, afterAll, AnnotationFieldFlag, stringToUTF8String, | ||
StringStream, Lexer, Parser */ | ||
/* globals isRef, AnnotationFactory, Dict, Name, Ref, AnnotationType, | ||
AnnotationType, AnnotationFlag, Annotation, AnnotationBorderStyle, |
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.
AnnotationType
is listed twice 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.
Good eye, fixed now!
PostScriptParser, PostScriptLexer, PostScriptEvaluator, | ||
PostScriptCompiler*/ | ||
/* globals isArray, StringStream, PostScriptParser, PostScriptLexer, | ||
StringStream, PostScriptEvaluator, PostScriptCompiler */ |
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.
StringStream
is listed twice 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.
Fixed now, thanks.
*Please note that most of the necessary code adjustments were made in PR 7890.* ESLint has a number of advantageous properties, compared to JSHint. Among those are: - The ability to find subtle bugs, thanks to more rules (e.g. PR 7881). - Much more customizable in general, and many rules allow fine-tuned behaviour rather than the just the on/off rules in JSHint. - Many more rules that can help developers avoid bugs, and a lot of rules that can be used to enforce a consistent coding style. The latter should be particularily useful for new contributors (and reduce the amount of stylistic review comments necessary). - The ability to easily specify exactly what rules to use/not to use, as opposed to JSHint which has a default set. *Note:* in future JSHint version some of the rules we depend on will be removed, according to warnings in http://jshint.com/docs/options/, so we wouldn't be able to update without losing lint coverage. - More easily disable one, or more, rules temporarily. In JSHint this requires using a numeric code, which isn't very user friendly, whereas in ESLint the rule name is simply used instead. By default there's no rules enabled in ESLint, but there are some default rule sets available. However, to prevent linting failures if we update ESLint in the future, it seemed easier to just explicitly specify what rules we want. Obviously this makes the ESLint config file somewhat bigger than the old JSHint config file, but given how rarely that one has been updated over the years I don't think that matters too much. I've tried, to the best of my ability, to ensure that we enable the same rules for ESLint that we had for JSHint. Furthermore, I've also enabled a number of rules that seemed to make sense, both to catch possible errors *and* various style guide violations. Despite the ESLint README claiming that it's slower that JSHint, https://github.com/eslint/eslint#how-does-eslint-performance-compare-to-jshint, locally this patch actually reduces the runtime for `gulp` lint (by approximately 20-25%). A couple of stylistic rules that would have been nice to enable, but where our code currently differs to much to make it feasible: - `comma-dangle`, controls trailing commas in Objects and Arrays (among others). - `object-curly-spacing`, controls spacing inside of Objects. - `spaced-comment`, used to enforce spaces after `//` and `/*. (This is made difficult by the fact that there's still some usage of the old preprocessor left.) Rules that I indend to look into possibly enabling in follow-ups, if it seems to make sense: `no-else-return`, `no-lonely-if`, `brace-style` with the `allowSingleLine` parameter removed. Useful links: - http://eslint.org/docs/user-guide/configuring - http://eslint.org/docs/rules/
…s ESLint environments (e.g. Node, ShellJS, Jasmine)
/botio lint |
From: Bot.io (Linux)ReceivedCommand cmd_lint from @Snuffleupagus received. Current queue size: 0 Live output at: http://107.21.233.14:8877/916a368676c6dea/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_lint from @Snuffleupagus received. Current queue size: 0 Live output at: http://107.22.172.223:8877/01b2d65ab42ffc2/output.txt |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/916a368676c6dea/output.txt Total script time: 1.50 mins
|
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/01b2d65ab42ffc2/output.txt Total script time: 2.71 mins
|
/botio unittest |
From: Bot.io (Windows)ReceivedCommand cmd_unittest from @Snuffleupagus received. Current queue size: 0 Live output at: http://107.22.172.223:8877/2f64eb7a6e0e3c5/output.txt |
From: Bot.io (Linux)ReceivedCommand cmd_unittest from @Snuffleupagus received. Current queue size: 0 Live output at: http://107.21.233.14:8877/0b856228ba901ab/output.txt |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/0b856228ba901ab/output.txt Total script time: 2.06 mins
|
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/2f64eb7a6e0e3c5/output.txt Total script time: 2.67 mins
|
/botio-linux preview |
From: Bot.io (Linux)ReceivedCommand cmd_preview from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/3e06de983ef5649/output.txt |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/3e06de983ef5649/output.txt Total script time: 2.21 mins Published |
/botio test |
From: Bot.io (Linux)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/65fe0e3d6ae09d4/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://107.22.172.223:8877/f7c3dc2c7847be8/output.txt |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/65fe0e3d6ae09d4/output.txt Total script time: 25.74 mins
|
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/f7c3dc2c7847be8/output.txt Total script time: 25.96 mins
|
Thank you for the patch! |
Switch to using ESLint, instead of JSHint, for linting
Please note that most of the necessary code adjustments were made in PR #7890.
ESLint has a number of advantageous properties, compared to JSHint. Among those are:
By default there's no rules enabled in ESLint, but there are some default rule sets available. However, to prevent linting failures if we update ESLint in the future, it seemed easier to just explicitly specify what rules we want.
Obviously this makes the ESLint config file somewhat bigger than the old JSHint config file, but given how rarely that one has been updated over the years I don't think that matters too much.
I've tried, to the best of my ability, to ensure that we enable the same rules for ESLint that we had for JSHint. Furthermore, I've also enabled a number of rules that seemed to make sense, both to catch possible errors and various style guide violations.
Despite the ESLint README claiming that it's slower that JSHint, https://github.com/eslint/eslint#how-does-eslint-performance-compare-to-jshint, locally this patch actually reduces the runtime for
gulp
lint (by approximately 20-25%).A couple of stylistic rules that would have been nice to enable, but where our code currently differs to much to make it feasible:
comma-dangle
, controls trailing commas in Objects and Arrays (among others).object-curly-spacing
, controls spacing inside of Objects.spaced-comment
, used to enforce spaces after//
and `/*. (This is made difficult by the fact that there's still some usage of the old preprocessor left.)Rules that I indend to look into possibly enabling in follow-ups, if it seems to make sense:
no-else-return
,no-lonely-if
,brace-style
with theallowSingleLine
parameter removed.Useful links:
@timvandermeij I'm hoping that you are willing to review this as well. Unfortunately I don't think that it's possible to make this that much smaller, but hopefully it's at least manageable!