Skip to content

Commit

Permalink
tools: update ESLint, fix unused vars bug
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Trott authored and MylesBorins committed Jul 12, 2016
1 parent e3aabdb commit 09c8ec7
Show file tree
Hide file tree
Showing 546 changed files with 9,689 additions and 10,543 deletions.
2,984 changes: 0 additions & 2,984 deletions tools/eslint/CHANGELOG.md

This file was deleted.

133 changes: 97 additions & 36 deletions tools/eslint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,53 @@ ESLint is a tool for identifying and reporting on patterns found in ECMAScript/J
* ESLint uses an AST to evaluate patterns in code.
* ESLint is completely pluggable, every single rule is a plugin and you can add more at runtime.

## Installation
## Installation and Usage

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

npm install -g eslint
### Local Installation and Usage

## Usage
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:

If it's your first time using ESLint, you should set up a config file using `--init`:
```
$ npm install eslint --save-dev
```

You should then setup a configuration file:

```
$ ./node_modules/.bin/eslint --init
```

After that, you can run ESLint on any file or directory like this:

```
$ ./node_modules/.bin/eslint yourfile.js
```

Any plugins or shareable configs that you use must also be installed locally to work with a locally-installed ESLint.

### Global Installation and Usage

eslint --init
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:

After that, you can run ESLint on any JavaScript file:
```
$ npm install -g eslint
```

eslint test.js test2.js
You should then setup a configuration file:

```
$ eslint --init
```

After that, you can run ESLint on any file or directory like this:

```
$ eslint yourfile.js
```

Any plugins or shareable configs that you use must also be installed globally to work with a globally-installed ESLint.

**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.

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

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:
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:

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

## Sponsors

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

## Team

These folks keep the project moving and are resources for help:

* Nicholas C. Zakas ([@nzakas](https://github.com/nzakas)) - project lead
* Ilya Volodin ([@ilyavolodin](https://github.com/ilyavolodin)) - reviewer
* Brandon Mills ([@btmills](https://github.com/btmills)) - reviewer
* Gyandeep Singh ([@gyandeeps](https://github.com/gyandeeps)) - reviewer
* Toru Nagashima ([@mysticatea](https://github.com/mysticatea)) - reviewer
* Alberto Rodríguez ([@alberto](https://github.com/alberto)) - reviewer
* Mathias Schreck ([@lo1tuma](https://github.com/lo1tuma)) - committer
* Jamund Ferguson ([@xjamundx](https://github.com/xjamundx)) - committer
* Ian VanSchooten ([@ianvs](https://github.com/ianvs)) - committer
* Burak Yiğit Kaya ([@byk](https://github.com/byk)) - committer
* Kai Cataldo ([@kaicataldo](https://github.com/kaicataldo)) - committer
* Michael Ficarra ([@michaelficarra](https://github.com/michaelficarra)) - committer
* Mark Pedrotti ([@pedrottimark](https://github.com/pedrottimark)) - committer
* Oleg Gaidarenko ([@markelog](https://github.com/markelog)) - committer
* Mike Sherov [@mikesherov](https://github.com/mikesherov)) - committer
* Henry Zhu ([@hzoo](https://github.com/hzoo)) - committer
* Marat Dulin ([@mdevils](https://github.com/mdevils)) - committer
* Alexej Yaroshevich ([@zxqfox](https://github.com/zxqfox)) - committer
These folks keep the project moving and are resources for help.

### Technical Steering Committee (TSC)

* Nicholas C. Zakas ([@nzakas](https://github.com/nzakas))
* Ilya Volodin ([@ilyavolodin](https://github.com/ilyavolodin))
* Brandon Mills ([@btmills](https://github.com/btmills))
* Gyandeep Singh ([@gyandeeps](https://github.com/gyandeeps))
* Toru Nagashima ([@mysticatea](https://github.com/mysticatea))
* Alberto Rodríguez ([@alberto](https://github.com/alberto))

### Development Team

* Mathias Schreck ([@lo1tuma](https://github.com/lo1tuma))
* Jamund Ferguson ([@xjamundx](https://github.com/xjamundx))
* Ian VanSchooten ([@ianvs](https://github.com/ianvs))
* Burak Yiğit Kaya ([@byk](https://github.com/byk))
* Kai Cataldo ([@kaicataldo](https://github.com/kaicataldo))
* Michael Ficarra ([@michaelficarra](https://github.com/michaelficarra))
* Mark Pedrotti ([@pedrottimark](https://github.com/pedrottimark))
* Oleg Gaidarenko ([@markelog](https://github.com/markelog))
* Mike Sherov [@mikesherov](https://github.com/mikesherov))
* Henry Zhu ([@hzoo](https://github.com/hzoo))
* Marat Dulin ([@mdevils](https://github.com/mdevils))
* Alexej Yaroshevich ([@zxqfox](https://github.com/zxqfox))

### Issues Team

* Kevin Partington ([@platinumazure](https://github.com/platinumazure))
* Vitor Balocco ([@vitorbal](https://github.com/vitorbal))

## Releases

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

## Frequently Asked Questions

### Why don't you like JSHint???
## Semantic Versioning Policy

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:

* Patch release (intended to not break your lint build)
* A bug fix in a rule that results in ESLint reporting fewer errors.
* A bug fix to the CLI or core (including formatters).
* Improvements to documentation.
* Non-user-facing changes such as refactoring code, adding, deleting, or modifying tests, and increasing test coverage.
* Re-releasing after a failed release (i.e., publishing a release that doesn't work for anyone).
* Minor release (might break your lint build)
* A bug fix in a rule that results in ESLint reporting more errors.
* A new rule is created.
* A new option to an existing rule is created.
* An existing rule is deprecated.
* A new CLI capability is created.
* New capabilities to the public API are added (new classes, new methods, new arguments to existing methods, etc.).
* A new formatter is created.
* Major release (likely to break your lint build)
* `eslint:recommended` is updated.
* An existing rule is removed.
* An existing formatter is removed.
* Part of the public API is removed or changed in an incompatible way.

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.
## Frequently Asked Questions

### I'm not giving up JSHint for this!
### How is ESLint different from JSHint?

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.
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!

### How does ESLint performance compare to JSHint?

Expand Down
14 changes: 1 addition & 13 deletions tools/eslint/bin/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,4 @@ if (useStdIn) {
exitCode = cli.execute(process.argv);
}

// https://github.com/eslint/eslint/issues/4691
// In Node.js >= 0.12, you can use a cleaner way
if ("exitCode" in process) {
process.exitCode = exitCode;
} else {
/*
* Wait for the stdout buffer to drain.
* See https://github.com/eslint/eslint/issues/317
*/
process.on("exit", function() {
process.exit(exitCode);
});
}
process.exitCode = exitCode;
5 changes: 2 additions & 3 deletions tools/eslint/conf/cli-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

"use strict";

var DEFAULT_PARSER = require("../conf/eslint.json").parser;

module.exports = {
configFile: null,
baseConfig: false,
Expand All @@ -18,8 +16,9 @@ module.exports = {
extensions: [".js"],
ignore: true,
ignorePath: null,
parser: DEFAULT_PARSER,
parser: "", // must be empty
cache: false,

// in order to honor the cacheFile option if specified
// this option should not have a default value otherwise
// it will always be used
Expand Down
29 changes: 29 additions & 0 deletions tools/eslint/conf/eslint-all.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* @fileoverview Config to enable all rules.
* @author Robert Fletcher
*/

"use strict";

//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------

var fs = require("fs"),
path = require("path");

//------------------------------------------------------------------------------
// Helpers
//------------------------------------------------------------------------------

var ruleFiles = fs.readdirSync(path.resolve(__dirname, "../lib/rules"));
var enabledRules = ruleFiles.reduce(function(result, filename) {
result[path.basename(filename, ".js")] = "error";
return result;
}, {});

//------------------------------------------------------------------------------
// Public Interface
//------------------------------------------------------------------------------

module.exports = { rules: enabledRules };
30 changes: 19 additions & 11 deletions tools/eslint/conf/eslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
"no-debugger": "error",
"no-delete-var": "error",
"no-div-regex": "off",
"no-dupe-args": "error",
"no-dupe-class-members": "error",
"no-dupe-keys": "error",
"no-dupe-args": "error",
"no-duplicate-case": "error",
"no-duplicate-imports": "off",
"no-else-return": "off",
Expand Down Expand Up @@ -55,13 +55,14 @@
"no-lone-blocks": "off",
"no-lonely-if": "off",
"no-loop-func": "off",
"no-magic-numbers": "off",
"no-mixed-operators": "off",
"no-mixed-requires": "off",
"no-mixed-spaces-and-tabs": "error",
"linebreak-style": "off",
"no-multi-spaces": "off",
"no-multi-str": "off",
"no-multiple-empty-lines": "off",
"no-native-reassign": "off",
"no-native-reassign": "error",
"no-negated-condition": "off",
"no-negated-in-lhs": "error",
"no-nested-ternary": "off",
Expand All @@ -80,6 +81,7 @@
"no-process-env": "off",
"no-process-exit": "off",
"no-proto": "off",
"no-prototype-builtins": "off",
"no-redeclare": "error",
"no-regex-spaces": "error",
"no-restricted-globals": "off",
Expand Down Expand Up @@ -109,7 +111,7 @@
"no-unmodified-loop-condition": "off",
"no-unneeded-ternary": "off",
"no-unreachable": "error",
"no-unsafe-finally": "off",
"no-unsafe-finally": "error",
"no-unused-expressions": "off",
"no-unused-labels": "error",
"no-unused-vars": "error",
Expand All @@ -119,11 +121,11 @@
"no-useless-concat": "off",
"no-useless-constructor": "off",
"no-useless-escape": "off",
"no-useless-rename": "off",
"no-void": "off",
"no-var": "off",
"no-warning-comments": "off",
"no-with": "off",
"no-magic-numbers": "off",
"array-bracket-spacing": "off",
"array-callback-return": "off",
"arrow-body-style": "off",
Expand All @@ -135,10 +137,10 @@
"brace-style": "off",
"callback-return": "off",
"camelcase": "off",
"comma-dangle": "error",
"comma-dangle": "off",
"comma-spacing": "off",
"comma-style": "off",
"complexity": ["off", 11],
"complexity": "off",
"computed-property-spacing": "off",
"consistent-return": "off",
"consistent-this": "off",
Expand All @@ -155,15 +157,19 @@
"global-require": "off",
"guard-for-in": "off",
"handle-callback-err": "off",
"id-blacklist": "off",
"id-length": "off",
"id-match": "off",
"indent": "off",
"init-declarations": "off",
"jsx-quotes": "off",
"key-spacing": "off",
"keyword-spacing": "off",
"linebreak-style": "off",
"lines-around-comment": "off",
"max-depth": "off",
"max-len": "off",
"max-lines": "off",
"max-nested-callbacks": "off",
"max-params": "off",
"max-statements": "off",
Expand All @@ -173,7 +179,9 @@
"newline-after-var": "off",
"newline-before-return": "off",
"newline-per-chained-call": "off",
"object-curly-newline": "off",
"object-curly-spacing": ["off", "never"],
"object-property-newline": "off",
"object-shorthand": "off",
"one-var": "off",
"one-var-declaration-per-line": "off",
Expand All @@ -189,14 +197,13 @@
"quote-props": "off",
"quotes": "off",
"radix": "off",
"id-match": "off",
"id-blacklist": "off",
"require-jsdoc": "off",
"require-yield": "off",
"require-yield": "error",
"rest-spread-spacing": "off",
"semi": "off",
"semi-spacing": "off",
"sort-vars": "off",
"sort-imports": "off",
"sort-vars": "off",
"space-before-blocks": "off",
"space-before-function-paren": "off",
"space-in-parens": "off",
Expand All @@ -205,6 +212,7 @@
"spaced-comment": "off",
"strict": "off",
"template-curly-spacing": "off",
"unicode-bom": "off",
"use-isnan": "error",
"valid-jsdoc": "off",
"valid-typeof": "error",
Expand Down
Loading

0 comments on commit 09c8ec7

Please sign in to comment.