Skip to content
This repository has been archived by the owner on Aug 31, 2018. It is now read-only.

Commit

Permalink
tools: update to ESLint 4.8.0
Browse files Browse the repository at this point in the history
PR-URL: nodejs/node#16199
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
apapirovski authored and addaleax committed Oct 26, 2017
1 parent 40eaf17 commit ced86c8
Show file tree
Hide file tree
Showing 476 changed files with 5,601 additions and 23,834 deletions.
35 changes: 17 additions & 18 deletions tools/eslint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

# ESLint

[Website](http://eslint.org) |
[Configuring](http://eslint.org/docs/user-guide/configuring) |
[Rules](http://eslint.org/docs/rules/) |
[Contributing](http://eslint.org/docs/developer-guide/contributing) |
[Reporting Bugs](http://eslint.org/docs/developer-guide/contributing/reporting-bugs) |
[Website](https://eslint.org) |
[Configuring](https://eslint.org/docs/user-guide/configuring) |
[Rules](https://eslint.org/docs/rules/) |
[Contributing](https://eslint.org/docs/developer-guide/contributing) |
[Reporting Bugs](https://eslint.org/docs/developer-guide/contributing/reporting-bugs) |
[Code of Conduct](https://js.foundation/community/code-of-conduct) |
[Twitter](https://twitter.com/geteslint) |
[Mailing List](https://groups.google.com/group/eslint) |
Expand Down Expand Up @@ -88,17 +88,17 @@ 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 first value is the error level of the rule and can be one of these values:
The names `"semi"` and `"quotes"` are the names of [rules](https://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)
* `"error"` or `2` - turn the rule on as an error (exit code will be 1)

The three error levels allow you fine-grained control over how ESLint applies rules (for more configuration options and details, see the [configuration docs](http://eslint.org/docs/user-guide/configuring)).
The three error levels allow you fine-grained control over how ESLint applies rules (for more configuration options and details, see the [configuration docs](https://eslint.org/docs/user-guide/configuring)).

## Sponsors

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

## Team

Expand Down Expand Up @@ -145,10 +145,10 @@ ESLint adheres to the [JS Foundation Code of Conduct](https://js.foundation/comm

Before filing an issue, please be sure to read the guidelines for what you're reporting:

* [Bug Report](http://eslint.org/docs/developer-guide/contributing/reporting-bugs)
* [Propose a New Rule](http://eslint.org/docs/developer-guide/contributing/new-rules)
* [Proposing a Rule Change](http://eslint.org/docs/developer-guide/contributing/rule-changes)
* [Request a Change](http://eslint.org/docs/developer-guide/contributing/changes)
* [Bug Report](https://eslint.org/docs/developer-guide/contributing/reporting-bugs)
* [Propose a New Rule](https://eslint.org/docs/developer-guide/contributing/new-rules)
* [Proposing a Rule Change](https://eslint.org/docs/developer-guide/contributing/rule-changes)
* [Request a Change](https://eslint.org/docs/developer-guide/contributing/changes)

## Semantic Versioning Policy

Expand All @@ -171,7 +171,6 @@ ESLint follows [semantic versioning](http://semver.org). However, due to the nat
* Major release (likely to break your lint build)
* `eslint:recommended` is updated.
* A new option to an existing rule that results in ESLint reporting more errors by default.
* An existing rule is removed.
* An existing formatter is removed.
* Part of the public API is removed or changed in an incompatible way.

Expand All @@ -195,11 +194,11 @@ Despite being slower, we believe that ESLint is fast enough to replace JSHint wi

### I heard ESLint is going to replace JSCS?

Yes. Since we are solving the same problems, ESLint and JSCS teams have decided to join forces and work together in the development of ESLint instead of competing with each other. You can read more about this in both [ESLint](http://eslint.org/blog/2016/04/welcoming-jscs-to-eslint) and [JSCS](https://medium.com/@markelog/jscs-end-of-the-line-bc9bf0b3fdb2#.u76sx334n) announcements.
Yes. Since we are solving the same problems, ESLint and JSCS teams have decided to join forces and work together in the development of ESLint instead of competing with each other. You can read more about this in both [ESLint](https://eslint.org/blog/2016/04/welcoming-jscs-to-eslint) and [JSCS](https://medium.com/@markelog/jscs-end-of-the-line-bc9bf0b3fdb2#.u76sx334n) announcements.

### So, should I stop using JSCS and start using ESLint?

Maybe, depending on how much you need it. [JSCS has reached end of life](http://eslint.org/blog/2016/07/jscs-end-of-life), but if it is working for you then there is no reason to move yet. We are still working to smooth the transition. You can see our progress [here](https://github.com/eslint/eslint/milestones/JSCS%20Compatibility). We’ll announce when all of the changes necessary to support JSCS users in ESLint are complete and will start encouraging JSCS users to switch to ESLint at that time.
Maybe, depending on how much you need it. [JSCS has reached end of life](https://eslint.org/blog/2016/07/jscs-end-of-life), but if it is working for you then there is no reason to move yet. We are still working to smooth the transition. You can see our progress [here](https://github.com/eslint/eslint/milestones/JSCS%20Compatibility). We’ll announce when all of the changes necessary to support JSCS users in ESLint are complete and will start encouraging JSCS users to switch to ESLint at that time.

If you are having issues with JSCS, you can try to move to ESLint. We are focusing our time and energy on JSCS compatibility issues.

Expand All @@ -210,17 +209,17 @@ ESLint does both traditional linting (looking for problematic patterns) and styl

### Does ESLint support JSX?

Yes, ESLint natively supports parsing JSX syntax (this must be enabled in [configuration](http://eslint.org/docs/user-guide/configuring).). Please note that supporting JSX syntax *is not* the same as supporting React. React applies specific semantics to JSX syntax that ESLint doesn't recognize. We recommend using [eslint-plugin-react](https://www.npmjs.com/package/eslint-plugin-react) if you are using React and want React semantics.
Yes, ESLint natively supports parsing JSX syntax (this must be enabled in [configuration](https://eslint.org/docs/user-guide/configuring).). Please note that supporting JSX syntax *is not* the same as supporting React. React applies specific semantics to JSX syntax that ESLint doesn't recognize. We recommend using [eslint-plugin-react](https://www.npmjs.com/package/eslint-plugin-react) if you are using React and want React semantics.

### What about ECMAScript 6 support?

ESLint has full support for ECMAScript 6. By default, this support is off. You can enable ECMAScript 6 syntax and global variables through [configuration](http://eslint.org/docs/user-guide/configuring).
ESLint has full support for ECMAScript 6. By default, this support is off. You can enable ECMAScript 6 syntax and global variables through [configuration](https://eslint.org/docs/user-guide/configuring).

### What about experimental features?

ESLint doesn't natively support experimental ECMAScript language features. You can use [babel-eslint](https://github.com/babel/babel-eslint) to use any option available in Babel.

Once a language feature has been adopted into the ECMAScript standard (stage 4 according to the [TC39 process](https://tc39.github.io/process-document/)), we will accept issues and pull requests related to the new feature, subject to our [contributing guidelines](http://eslint.org/docs/developer-guide/contributing). Until then, please use the appropriate parser and plugin(s) for your experimental feature.
Once a language feature has been adopted into the ECMAScript standard (stage 4 according to the [TC39 process](https://tc39.github.io/process-document/)), we will accept issues and pull requests related to the new feature, subject to our [contributing guidelines](https://eslint.org/docs/developer-guide/contributing). Until then, please use the appropriate parser and plugin(s) for your experimental feature.

### Where to ask for help?

Expand Down
5 changes: 4 additions & 1 deletion tools/eslint/bin/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@ process.once("uncaughtException", err => {

if (typeof err.messageTemplate === "string" && err.messageTemplate.length > 0) {
const template = lodash.template(fs.readFileSync(path.resolve(__dirname, `../messages/${err.messageTemplate}.txt`), "utf-8"));
const pkg = require("../package.json");

console.error("\nOops! Something went wrong! :(");
console.error(`\n${template(err.messageData || {})}`);
console.error(`\nESLint: ${pkg.version}.\n${template(err.messageData || {})}`);
} else {

console.error(err.message);
console.error(err.stack);
}

Expand Down
4 changes: 2 additions & 2 deletions tools/eslint/conf/category-list.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
],
"deprecated": {
"name": "Deprecated",
"description": "These rules have been deprecated and replaced by newer rules:",
"description": "These rules have been deprecated in accordance with the [deprecation policy](/docs/user-guide/rule-deprecation), and replaced by newer rules:",
"rules": []
},
"removed": {
"name": "Removed",
"description": "These rules from older versions of ESLint have been replaced by newer rules:",
"description": "These rules from older versions of ESLint (before the [deprecation policy](/docs/user-guide/rule-deprecation) existed) have been replaced by newer rules:",
"rules": [
{ "removed": "generator-star", "replacedBy": ["generator-star-spacing"] },
{ "removed": "global-strict", "replacedBy": ["strict"] },
Expand Down
4 changes: 3 additions & 1 deletion tools/eslint/conf/config-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ const baseConfigProperties = {
parserOptions: { type: "object" },
plugins: { type: "array" },
rules: { type: "object" },
settings: { type: "object" }
settings: { type: "object" },

ecmaFeatures: { type: "object" } // deprecated; logs a warning when used
};

const overrideProperties = Object.assign(
Expand Down
3 changes: 2 additions & 1 deletion tools/eslint/conf/default-cli-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ module.exports = {
cacheLocation: "",
cacheFile: ".eslintcache",
fix: false,
allowInlineConfig: true
allowInlineConfig: true,
reportUnusedDisableDirectives: false
};
26 changes: 12 additions & 14 deletions tools/eslint/conf/eslint-recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@

"use strict";

/* eslint sort-keys: ["error", "asc"], quote-props: ["error", "consistent"] */
/* eslint-disable sort-keys */
/* eslint sort-keys: ["error", "asc"] */

module.exports = {
rules: {

/* eslint-enable sort-keys */
"accessor-pairs": "off",
"array-bracket-newline": "off",
"array-bracket-spacing": "off",
Expand All @@ -25,28 +22,29 @@ module.exports = {
"block-spacing": "off",
"brace-style": "off",
"callback-return": "off",
"camelcase": "off",
camelcase: "off",
"capitalized-comments": "off",
"class-methods-use-this": "off",
"comma-dangle": "off",
"comma-spacing": "off",
"comma-style": "off",
"complexity": "off",
complexity: "off",
"computed-property-spacing": "off",
"consistent-return": "off",
"consistent-this": "off",
"constructor-super": "error",
"curly": "off",
curly: "off",
"default-case": "off",
"dot-location": "off",
"dot-notation": "off",
"eol-last": "off",
"eqeqeq": "off",
eqeqeq: "off",
"for-direction": "off",
"func-call-spacing": "off",
"func-name-matching": "off",
"func-names": "off",
"func-style": "off",
"function-paren-newline": "off",
"generator-star-spacing": "off",
"getter-return": "off",
"global-require": "off",
Expand All @@ -55,7 +53,7 @@ module.exports = {
"id-blacklist": "off",
"id-length": "off",
"id-match": "off",
"indent": "off",
indent: "off",
"indent-legacy": "off",
"init-declarations": "off",
"jsx-quotes": "off",
Expand Down Expand Up @@ -234,13 +232,13 @@ module.exports = {
"prefer-spread": "off",
"prefer-template": "off",
"quote-props": "off",
"quotes": "off",
"radix": "off",
quotes: "off",
radix: "off",
"require-await": "off",
"require-jsdoc": "off",
"require-yield": "error",
"rest-spread-spacing": "off",
"semi": "off",
semi: "off",
"semi-spacing": "off",
"semi-style": "off",
"sort-imports": "off",
Expand All @@ -252,7 +250,7 @@ module.exports = {
"space-infix-ops": "off",
"space-unary-ops": "off",
"spaced-comment": "off",
"strict": "off",
strict: "off",
"switch-colon-spacing": "off",
"symbol-description": "off",
"template-curly-spacing": "off",
Expand All @@ -265,6 +263,6 @@ module.exports = {
"wrap-iife": "off",
"wrap-regex": "off",
"yield-star-spacing": "off",
"yoda": "off"
yoda: "off"
}
};
37 changes: 20 additions & 17 deletions tools/eslint/lib/ast-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,9 @@ module.exports = {
// // setup...
// return function foo() { ... };
// })();
// obj.foo = (() =>
// function foo() { ... }
// )();
case "ReturnStatement": {
const func = getUpperFunction(parent);

Expand All @@ -635,6 +638,12 @@ module.exports = {
node = func.parent;
break;
}
case "ArrowFunctionExpression":
if (node !== parent.body || !isCallee(parent)) {
return true;
}
node = parent.parent;
break;

// e.g.
// var obj = { foo() { ... } };
Expand All @@ -655,16 +664,15 @@ module.exports = {
// [Foo = function() { ... }] = a;
case "AssignmentExpression":
case "AssignmentPattern":
if (parent.right === node) {
if (parent.left.type === "MemberExpression") {
return false;
}
if (isAnonymous &&
parent.left.type === "Identifier" &&
startsWithUpperCase(parent.left.name)
) {
return false;
}
if (parent.left.type === "MemberExpression") {
return false;
}
if (
isAnonymous &&
parent.left.type === "Identifier" &&
startsWithUpperCase(parent.left.name)
) {
return false;
}
return true;

Expand Down Expand Up @@ -809,19 +817,14 @@ module.exports = {
return 17;

case "CallExpression":

// IIFE is allowed to have parens in any position (#655)
if (node.callee.type === "FunctionExpression") {
return -1;
}
return 18;

case "NewExpression":
return 19;

// no default
default:
return 20;
}
return 20;
},

/**
Expand Down
Loading

0 comments on commit ced86c8

Please sign in to comment.