Skip to content

Commit df697c4

Browse files
Trottevanlucas
authored andcommitted
tools: update ESLint, fix unused vars bug
Update ESLint to 3.0.0. This includes an enhancement to `no-unused-vars` such that it finds a few instances in our code base that it did not find previously (fixed in previous commits readying this for landing). PR-URL: #7601 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Roman Reiss <[email protected]>
1 parent a81ff70 commit df697c4

File tree

546 files changed

+9689
-10546
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

546 files changed

+9689
-10546
lines changed

tools/eslint/CHANGELOG.md

-2,984
This file was deleted.

tools/eslint/README.md

+97-36
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,53 @@ ESLint is a tool for identifying and reporting on patterns found in ECMAScript/J
2424
* ESLint uses an AST to evaluate patterns in code.
2525
* ESLint is completely pluggable, every single rule is a plugin and you can add more at runtime.
2626

27-
## Installation
27+
## Installation and Usage
2828

29-
You can install ESLint using npm:
29+
There are two ways to install ESLint: globally and locally.
3030

31-
npm install -g eslint
31+
### Local Installation and Usage
3232

33-
## Usage
33+
If you want to include ESLint as part of your project's build system, we recommend installing it locally. You can do so using npm:
3434

35-
If it's your first time using ESLint, you should set up a config file using `--init`:
35+
```
36+
$ npm install eslint --save-dev
37+
```
38+
39+
You should then setup a configuration file:
40+
41+
```
42+
$ ./node_modules/.bin/eslint --init
43+
```
44+
45+
After that, you can run ESLint on any file or directory like this:
46+
47+
```
48+
$ ./node_modules/.bin/eslint yourfile.js
49+
```
50+
51+
Any plugins or shareable configs that you use must also be installed locally to work with a locally-installed ESLint.
52+
53+
### Global Installation and Usage
3654

37-
eslint --init
55+
If you want to make ESLint available to tools that run across all of your projects, we recommend installing ESLint globally. You can do so using npm:
3856

39-
After that, you can run ESLint on any JavaScript file:
57+
```
58+
$ npm install -g eslint
59+
```
4060

41-
eslint test.js test2.js
61+
You should then setup a configuration file:
62+
63+
```
64+
$ eslint --init
65+
```
66+
67+
After that, you can run ESLint on any file or directory like this:
68+
69+
```
70+
$ eslint yourfile.js
71+
```
72+
73+
Any plugins or shareable configs that you use must also be installed globally to work with a globally-installed ESLint.
4274

4375
**Note:** `eslint --init` is intended for setting up and configuring ESLint on a per-project basis and will perform a local installation of ESLint and its plugins in the directory in which it is run. If you prefer using a global installation of ESLint, any plugins used in your configuration must also be installed globally.
4476

@@ -55,7 +87,7 @@ After running `eslint --init`, you'll have a `.eslintrc` file in your directory.
5587
}
5688
```
5789

58-
The names `"semi"` and `"quotes"` are the names of [rules](http://eslint.org/docs/rules) in ESLint. The number is the error level of the rule and can be one of the three values:
90+
The names `"semi"` and `"quotes"` are the names of [rules](http://eslint.org/docs/rules) in ESLint. The first value is the error level of the rule and can be one of these values:
5991

6092
* `"off"` or `0` - turn the rule off
6193
* `"warn"` or `1` - turn the rule on as a warning (doesn't affect exit code)
@@ -65,31 +97,40 @@ The three error levels allow you fine-grained control over how ESLint applies ru
6597

6698
## Sponsors
6799

68-
* Development is sponsored by [Box](https://box.com)
69100
* Site search ([eslint.org](http://eslint.org)) is sponsored by [Algolia](https://www.algolia.com)
70101

71102
## Team
72103

73-
These folks keep the project moving and are resources for help:
74-
75-
* Nicholas C. Zakas ([@nzakas](https://github.com/nzakas)) - project lead
76-
* Ilya Volodin ([@ilyavolodin](https://github.com/ilyavolodin)) - reviewer
77-
* Brandon Mills ([@btmills](https://github.com/btmills)) - reviewer
78-
* Gyandeep Singh ([@gyandeeps](https://github.com/gyandeeps)) - reviewer
79-
* Toru Nagashima ([@mysticatea](https://github.com/mysticatea)) - reviewer
80-
* Alberto Rodríguez ([@alberto](https://github.com/alberto)) - reviewer
81-
* Mathias Schreck ([@lo1tuma](https://github.com/lo1tuma)) - committer
82-
* Jamund Ferguson ([@xjamundx](https://github.com/xjamundx)) - committer
83-
* Ian VanSchooten ([@ianvs](https://github.com/ianvs)) - committer
84-
* Burak Yiğit Kaya ([@byk](https://github.com/byk)) - committer
85-
* Kai Cataldo ([@kaicataldo](https://github.com/kaicataldo)) - committer
86-
* Michael Ficarra ([@michaelficarra](https://github.com/michaelficarra)) - committer
87-
* Mark Pedrotti ([@pedrottimark](https://github.com/pedrottimark)) - committer
88-
* Oleg Gaidarenko ([@markelog](https://github.com/markelog)) - committer
89-
* Mike Sherov [@mikesherov](https://github.com/mikesherov)) - committer
90-
* Henry Zhu ([@hzoo](https://github.com/hzoo)) - committer
91-
* Marat Dulin ([@mdevils](https://github.com/mdevils)) - committer
92-
* Alexej Yaroshevich ([@zxqfox](https://github.com/zxqfox)) - committer
104+
These folks keep the project moving and are resources for help.
105+
106+
### Technical Steering Committee (TSC)
107+
108+
* Nicholas C. Zakas ([@nzakas](https://github.com/nzakas))
109+
* Ilya Volodin ([@ilyavolodin](https://github.com/ilyavolodin))
110+
* Brandon Mills ([@btmills](https://github.com/btmills))
111+
* Gyandeep Singh ([@gyandeeps](https://github.com/gyandeeps))
112+
* Toru Nagashima ([@mysticatea](https://github.com/mysticatea))
113+
* Alberto Rodríguez ([@alberto](https://github.com/alberto))
114+
115+
### Development Team
116+
117+
* Mathias Schreck ([@lo1tuma](https://github.com/lo1tuma))
118+
* Jamund Ferguson ([@xjamundx](https://github.com/xjamundx))
119+
* Ian VanSchooten ([@ianvs](https://github.com/ianvs))
120+
* Burak Yiğit Kaya ([@byk](https://github.com/byk))
121+
* Kai Cataldo ([@kaicataldo](https://github.com/kaicataldo))
122+
* Michael Ficarra ([@michaelficarra](https://github.com/michaelficarra))
123+
* Mark Pedrotti ([@pedrottimark](https://github.com/pedrottimark))
124+
* Oleg Gaidarenko ([@markelog](https://github.com/markelog))
125+
* Mike Sherov [@mikesherov](https://github.com/mikesherov))
126+
* Henry Zhu ([@hzoo](https://github.com/hzoo))
127+
* Marat Dulin ([@mdevils](https://github.com/mdevils))
128+
* Alexej Yaroshevich ([@zxqfox](https://github.com/zxqfox))
129+
130+
### Issues Team
131+
132+
* Kevin Partington ([@platinumazure](https://github.com/platinumazure))
133+
* Vitor Balocco ([@vitorbal](https://github.com/vitorbal))
93134

94135
## Releases
95136

@@ -104,15 +145,35 @@ Before filing an issue, please be sure to read the guidelines for what you're re
104145
* [Proposing a Rule Change](http://eslint.org/docs/developer-guide/contributing/rule-changes)
105146
* [Request a Change](http://eslint.org/docs/developer-guide/contributing/changes)
106147

107-
## Frequently Asked Questions
108-
109-
### Why don't you like JSHint???
148+
## Semantic Versioning Policy
149+
150+
ESLint follows [semantic versioning](http://semver.org). However, due to the nature of ESLint as a code quality tool, it's not always clear when a minor or major version bump occurs. To help clarify this for everyone, we've defined the following semantic versioning policy for ESLint:
151+
152+
* Patch release (intended to not break your lint build)
153+
* A bug fix in a rule that results in ESLint reporting fewer errors.
154+
* A bug fix to the CLI or core (including formatters).
155+
* Improvements to documentation.
156+
* Non-user-facing changes such as refactoring code, adding, deleting, or modifying tests, and increasing test coverage.
157+
* Re-releasing after a failed release (i.e., publishing a release that doesn't work for anyone).
158+
* Minor release (might break your lint build)
159+
* A bug fix in a rule that results in ESLint reporting more errors.
160+
* A new rule is created.
161+
* A new option to an existing rule is created.
162+
* An existing rule is deprecated.
163+
* A new CLI capability is created.
164+
* New capabilities to the public API are added (new classes, new methods, new arguments to existing methods, etc.).
165+
* A new formatter is created.
166+
* Major release (likely to break your lint build)
167+
* `eslint:recommended` is updated.
168+
* An existing rule is removed.
169+
* An existing formatter is removed.
170+
* Part of the public API is removed or changed in an incompatible way.
110171

111-
I do like JSHint. And I like Anton and Rick. Neither of those were deciding factors in creating this tool. The fact is that I've had a dire need for a JavaScript tool with pluggable linting rules. I had hoped JSHint would be able to do this, however after chatting with Anton, I found that the planned plugin infrastructure wasn't going to suit my purpose.
172+
## Frequently Asked Questions
112173

113-
### I'm not giving up JSHint for this!
174+
### How is ESLint different from JSHint?
114175

115-
That's not really a question, but I got it. I'm not trying to convince you that ESLint is better than JSHint. The only thing I know is that ESLint is better than JSHint for what I'm doing. In the off chance you're doing something similar, it might be better for you. Otherwise, keep using JSHint, I'm certainly not going to tell you to stop using it.
176+
The most significant difference is that ESlint has pluggable linting rules. That means you can use the rules it comes with, or you can extend it with rules created by others or by yourself!
116177

117178
### How does ESLint performance compare to JSHint?
118179

tools/eslint/bin/eslint.js

+1-13
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,4 @@ if (useStdIn) {
7777
exitCode = cli.execute(process.argv);
7878
}
7979

80-
// https://github.com/eslint/eslint/issues/4691
81-
// In Node.js >= 0.12, you can use a cleaner way
82-
if ("exitCode" in process) {
83-
process.exitCode = exitCode;
84-
} else {
85-
/*
86-
* Wait for the stdout buffer to drain.
87-
* See https://github.com/eslint/eslint/issues/317
88-
*/
89-
process.on("exit", function() {
90-
process.exit(exitCode);
91-
});
92-
}
80+
process.exitCode = exitCode;

tools/eslint/conf/cli-options.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
"use strict";
77

8-
var DEFAULT_PARSER = require("../conf/eslint.json").parser;
9-
108
module.exports = {
119
configFile: null,
1210
baseConfig: false,
@@ -18,8 +16,9 @@ module.exports = {
1816
extensions: [".js"],
1917
ignore: true,
2018
ignorePath: null,
21-
parser: DEFAULT_PARSER,
19+
parser: "", // must be empty
2220
cache: false,
21+
2322
// in order to honor the cacheFile option if specified
2423
// this option should not have a default value otherwise
2524
// it will always be used

tools/eslint/conf/eslint-all.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* @fileoverview Config to enable all rules.
3+
* @author Robert Fletcher
4+
*/
5+
6+
"use strict";
7+
8+
//------------------------------------------------------------------------------
9+
// Requirements
10+
//------------------------------------------------------------------------------
11+
12+
var fs = require("fs"),
13+
path = require("path");
14+
15+
//------------------------------------------------------------------------------
16+
// Helpers
17+
//------------------------------------------------------------------------------
18+
19+
var ruleFiles = fs.readdirSync(path.resolve(__dirname, "../lib/rules"));
20+
var enabledRules = ruleFiles.reduce(function(result, filename) {
21+
result[path.basename(filename, ".js")] = "error";
22+
return result;
23+
}, {});
24+
25+
//------------------------------------------------------------------------------
26+
// Public Interface
27+
//------------------------------------------------------------------------------
28+
29+
module.exports = { rules: enabledRules };

tools/eslint/conf/eslint.json

+19-11
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
"no-debugger": "error",
2020
"no-delete-var": "error",
2121
"no-div-regex": "off",
22+
"no-dupe-args": "error",
2223
"no-dupe-class-members": "error",
2324
"no-dupe-keys": "error",
24-
"no-dupe-args": "error",
2525
"no-duplicate-case": "error",
2626
"no-duplicate-imports": "off",
2727
"no-else-return": "off",
@@ -55,13 +55,14 @@
5555
"no-lone-blocks": "off",
5656
"no-lonely-if": "off",
5757
"no-loop-func": "off",
58+
"no-magic-numbers": "off",
59+
"no-mixed-operators": "off",
5860
"no-mixed-requires": "off",
5961
"no-mixed-spaces-and-tabs": "error",
60-
"linebreak-style": "off",
6162
"no-multi-spaces": "off",
6263
"no-multi-str": "off",
6364
"no-multiple-empty-lines": "off",
64-
"no-native-reassign": "off",
65+
"no-native-reassign": "error",
6566
"no-negated-condition": "off",
6667
"no-negated-in-lhs": "error",
6768
"no-nested-ternary": "off",
@@ -80,6 +81,7 @@
8081
"no-process-env": "off",
8182
"no-process-exit": "off",
8283
"no-proto": "off",
84+
"no-prototype-builtins": "off",
8385
"no-redeclare": "error",
8486
"no-regex-spaces": "error",
8587
"no-restricted-globals": "off",
@@ -109,7 +111,7 @@
109111
"no-unmodified-loop-condition": "off",
110112
"no-unneeded-ternary": "off",
111113
"no-unreachable": "error",
112-
"no-unsafe-finally": "off",
114+
"no-unsafe-finally": "error",
113115
"no-unused-expressions": "off",
114116
"no-unused-labels": "error",
115117
"no-unused-vars": "error",
@@ -119,11 +121,11 @@
119121
"no-useless-concat": "off",
120122
"no-useless-constructor": "off",
121123
"no-useless-escape": "off",
124+
"no-useless-rename": "off",
122125
"no-void": "off",
123126
"no-var": "off",
124127
"no-warning-comments": "off",
125128
"no-with": "off",
126-
"no-magic-numbers": "off",
127129
"array-bracket-spacing": "off",
128130
"array-callback-return": "off",
129131
"arrow-body-style": "off",
@@ -135,10 +137,10 @@
135137
"brace-style": "off",
136138
"callback-return": "off",
137139
"camelcase": "off",
138-
"comma-dangle": "error",
140+
"comma-dangle": "off",
139141
"comma-spacing": "off",
140142
"comma-style": "off",
141-
"complexity": ["off", 11],
143+
"complexity": "off",
142144
"computed-property-spacing": "off",
143145
"consistent-return": "off",
144146
"consistent-this": "off",
@@ -155,15 +157,19 @@
155157
"global-require": "off",
156158
"guard-for-in": "off",
157159
"handle-callback-err": "off",
160+
"id-blacklist": "off",
158161
"id-length": "off",
162+
"id-match": "off",
159163
"indent": "off",
160164
"init-declarations": "off",
161165
"jsx-quotes": "off",
162166
"key-spacing": "off",
163167
"keyword-spacing": "off",
168+
"linebreak-style": "off",
164169
"lines-around-comment": "off",
165170
"max-depth": "off",
166171
"max-len": "off",
172+
"max-lines": "off",
167173
"max-nested-callbacks": "off",
168174
"max-params": "off",
169175
"max-statements": "off",
@@ -173,7 +179,9 @@
173179
"newline-after-var": "off",
174180
"newline-before-return": "off",
175181
"newline-per-chained-call": "off",
182+
"object-curly-newline": "off",
176183
"object-curly-spacing": ["off", "never"],
184+
"object-property-newline": "off",
177185
"object-shorthand": "off",
178186
"one-var": "off",
179187
"one-var-declaration-per-line": "off",
@@ -189,14 +197,13 @@
189197
"quote-props": "off",
190198
"quotes": "off",
191199
"radix": "off",
192-
"id-match": "off",
193-
"id-blacklist": "off",
194200
"require-jsdoc": "off",
195-
"require-yield": "off",
201+
"require-yield": "error",
202+
"rest-spread-spacing": "off",
196203
"semi": "off",
197204
"semi-spacing": "off",
198-
"sort-vars": "off",
199205
"sort-imports": "off",
206+
"sort-vars": "off",
200207
"space-before-blocks": "off",
201208
"space-before-function-paren": "off",
202209
"space-in-parens": "off",
@@ -205,6 +212,7 @@
205212
"spaced-comment": "off",
206213
"strict": "off",
207214
"template-curly-spacing": "off",
215+
"unicode-bom": "off",
208216
"use-isnan": "error",
209217
"valid-jsdoc": "off",
210218
"valid-typeof": "error",

0 commit comments

Comments
 (0)