Skip to content

Commit

Permalink
tools: update ESLint to v4.0.0
Browse files Browse the repository at this point in the history
Update ESLint and configuration to version 4.0.0.

PR-URL: #13645
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Trott authored and addaleax committed Jun 21, 2017
1 parent 2ce236e commit ff568d4
Show file tree
Hide file tree
Showing 1,093 changed files with 39,420 additions and 36,822 deletions.
27 changes: 19 additions & 8 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ rules:
eqeqeq: [2, smart]
no-fallthrough: 2
no-global-assign: 2
no-multi-spaces: 2
no-multi-spaces: [2, {ignoreEOLComments: true}]
no-octal: 2
no-proto: 2
no-redeclare: 2
Expand Down Expand Up @@ -98,11 +98,18 @@ rules:
func-call-spacing: 2
func-name-matching: 2
func-style: [2, declaration, {allowArrowFunctions: true}]
indent: [2, 2, {ArrayExpression: first,
CallExpression: {arguments: first},
MemberExpression: 1,
ObjectExpression: first,
SwitchCase: 1}]
# indent: [2, 2, {ArrayExpression: first,
# CallExpression: {arguments: first},
# FunctionDeclaration: {parameters: first},
# FunctionExpression: {parameters: first},
# MemberExpression: off,
# ObjectExpression: first,
# SwitchCase: 1}]
indent-legacy: [2, 2, {ArrayExpression: first,
CallExpression: {arguments: first},
MemberExpression: 1,
ObjectExpression: first,
SwitchCase: 1}]
key-spacing: [2, {mode: minimum}]
keyword-spacing: 2
linebreak-style: [2, unix]
Expand All @@ -122,7 +129,7 @@ rules:
}, {
selector: "ThrowStatement > CallExpression[callee.name=/Error$/]",
message: "Use new keyword when throwing an Error."
}]
}]
no-tabs: 2
no-trailing-spaces: 2
one-var-declaration-per-line: 2
Expand All @@ -131,7 +138,11 @@ rules:
semi: 2
semi-spacing: 2
space-before-blocks: [2, always]
space-before-function-paren: [2, never]
space-before-function-paren: [2, {
"anonymous": "never",
"named": "never",
"asyncArrow": "always"
}]
space-in-parens: [2, never]
space-infix-ops: 2
space-unary-ops: 2
Expand Down
2 changes: 1 addition & 1 deletion test/message/throw_in_line_with_tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

/* eslint-disable indent, no-tabs */
/* eslint-disable indent-legacy, no-tabs */
'use strict';
require('../common');

Expand Down
3,939 changes: 0 additions & 3,939 deletions tools/eslint/CHANGELOG.md

This file was deleted.

1 change: 0 additions & 1 deletion tools/eslint/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
ESLint
Copyright JS Foundation and other contributors, https://js.foundation

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
11 changes: 8 additions & 3 deletions tools/eslint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[![Downloads][downloads-image]][downloads-url]
[![Bountysource](https://www.bountysource.com/badge/tracker?tracker_id=282608)](https://www.bountysource.com/trackers/282608-eslint?utm_source=282608&utm_medium=shield&utm_campaign=TRACKER_BADGE)
[![Join the chat at https://gitter.im/eslint/eslint](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/eslint/eslint?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Feslint%2Feslint.svg?type=shield)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Feslint%2Feslint?ref=badge_shield)

# ESLint

Expand All @@ -13,7 +14,7 @@
[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) |
[Code of Conduct](https://js.foundation/conduct/) |
[Code of Conduct](https://js.foundation/community/code-of-conduct) |
[Twitter](https://twitter.com/geteslint) |
[Mailing List](https://groups.google.com/group/eslint) |
[Chat Room](https://gitter.im/eslint/eslint)
Expand Down Expand Up @@ -123,7 +124,7 @@ These folks keep the project moving and are resources for help.
* 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))
* 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))
Expand Down Expand Up @@ -172,6 +173,10 @@ ESLint follows [semantic versioning](http://semver.org). However, due to the nat

According to our policy, any minor update may report more errors than the previous release (ex: from a bug fix). As such, we recommend using the tilde (`~`) in `package.json` e.g. `"eslint": "~3.1.0"` to guarantee the results of your builds.

## License

[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Feslint%2Feslint.svg?type=large)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Feslint%2Feslint?ref=badge_large)

## Frequently Asked Questions

### How is ESLint different from JSHint?
Expand Down Expand Up @@ -205,7 +210,7 @@ Yes, ESLint natively supports parsing JSX syntax (this must be enabled in [confi

### What about ECMAScript 6 support?

ESLint has full support for ECMAScript 6. By default, this support is off. You can enable ECMAScript 6 support 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](http://eslint.org/docs/user-guide/configuring).

### What about experimental features?

Expand Down
14 changes: 6 additions & 8 deletions tools/eslint/bin/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,12 @@ if (useStdIn) {
} else if (init) {
const configInit = require("../lib/config/config-initializer");

configInit.initializeConfig(err => {
if (err) {
process.exitCode = 1;
console.error(err.message);
console.error(err.stack);
} else {
process.exitCode = 0;
}
configInit.initializeConfig().then(() => {
process.exitCode = 0;
}).catch(err => {
process.exitCode = 1;
console.error(err.message);
console.error(err.stack);
});
} else {
process.exitCode = cli.execute(process.argv);
Expand Down
15 changes: 15 additions & 0 deletions tools/eslint/conf/config-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"type": "object",
"properties": {
"root": { "type": "boolean" },
"globals": { "type": ["object"] },
"parser": { "type": ["string", "null"] },
"env": { "type": "object" },
"plugins": { "type": ["array"] },
"settings": { "type": "object" },
"extends": { "type": ["string", "array"] },
"rules": { "type": "object" },
"parserOptions": { "type": "object" }
},
"additionalProperties": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ module.exports = {
useEslintrc: true,
envs: [],
globals: [],
rules: {},
extensions: [".js"],
ignore: true,
ignorePath: null,
parser: "", // must be empty
cache: false,

// in order to honor the cacheFile option if specified
Expand Down
33 changes: 33 additions & 0 deletions tools/eslint/conf/default-config-options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* @fileoverview Default config options
* @author Teddy Katz
*/

"use strict";

/**
* Freezes an object and all its nested properties
* @param {Object} obj The object to deeply freeze
* @returns {Object} `obj` after freezing it
*/
function deepFreeze(obj) {
if (obj === null || typeof obj !== "object") {
return obj;
}

Object.keys(obj).map(key => obj[key]).forEach(deepFreeze);
return Object.freeze(obj);
}

module.exports = deepFreeze({
env: {},
globals: {},
rules: {},
settings: {},
parser: "espree",
parserOptions: {
ecmaVersion: 5,
sourceType: "script",
ecmaFeatures: {}
}
});
3 changes: 2 additions & 1 deletion tools/eslint/conf/eslint-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
//------------------------------------------------------------------------------

const load = require("../lib/load-rules"),
rules = require("../lib/rules");
Rules = require("../lib/rules");
const rules = new Rules();

//------------------------------------------------------------------------------
// Helpers
Expand Down
17 changes: 11 additions & 6 deletions tools/eslint/conf/eslint-recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
/* eslint-disable sort-keys */

module.exports = {
parser: "espree",
ecmaFeatures: {},

rules: {

/* eslint-enable sort-keys */
"accessor-pairs": "off",
"array-bracket-newline": "off",
"array-bracket-spacing": "off",
"array-callback-return": "off",
"array-element-newline": "off",
"arrow-body-style": "off",
"arrow-parens": "off",
"arrow-spacing": "off",
Expand All @@ -43,6 +42,7 @@ module.exports = {
"dot-notation": "off",
"eol-last": "off",
"eqeqeq": "off",
"for-direction": "off",
"func-call-spacing": "off",
"func-name-matching": "off",
"func-names": "off",
Expand All @@ -55,6 +55,7 @@ module.exports = {
"id-length": "off",
"id-match": "off",
"indent": "off",
"indent-legacy": "off",
"init-declarations": "off",
"jsx-quotes": "off",
"key-spacing": "off",
Expand All @@ -80,11 +81,12 @@ module.exports = {
"no-array-constructor": "off",
"no-await-in-loop": "off",
"no-bitwise": "off",
"no-buffer-constructor": "off",
"no-caller": "off",
"no-case-declarations": "error",
"no-catch-shadow": "off",
"no-class-assign": "error",
"no-compare-neg-zero": "off",
"no-compare-neg-zero": "error",
"no-cond-assign": "error",
"no-confusing-arrow": "off",
"no-console": "error",
Expand Down Expand Up @@ -202,7 +204,7 @@ module.exports = {
"no-useless-computed-key": "off",
"no-useless-concat": "off",
"no-useless-constructor": "off",
"no-useless-escape": "off",
"no-useless-escape": "error",
"no-useless-rename": "off",
"no-useless-return": "off",
"no-var": "off",
Expand All @@ -212,14 +214,15 @@ module.exports = {
"no-with": "off",
"nonblock-statement-body-position": "off",
"object-curly-newline": "off",
"object-curly-spacing": ["off", "never"],
"object-curly-spacing": "off",
"object-property-newline": "off",
"object-shorthand": "off",
"one-var": "off",
"one-var-declaration-per-line": "off",
"operator-assignment": "off",
"operator-linebreak": "off",
"padded-blocks": "off",
"padding-line-between-statements": "off",
"prefer-arrow-callback": "off",
"prefer-const": "off",
"prefer-destructuring": "off",
Expand All @@ -238,6 +241,7 @@ module.exports = {
"rest-spread-spacing": "off",
"semi": "off",
"semi-spacing": "off",
"semi-style": "off",
"sort-imports": "off",
"sort-keys": "off",
"sort-vars": "off",
Expand All @@ -248,6 +252,7 @@ module.exports = {
"space-unary-ops": "off",
"spaced-comment": "off",
"strict": "off",
"switch-colon-spacing": "off",
"symbol-description": "off",
"template-curly-spacing": "off",
"template-tag-spacing": "off",
Expand Down
5 changes: 4 additions & 1 deletion tools/eslint/lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@

"use strict";

const Linter = require("./linter");

module.exports = {
linter: require("./eslint"),
linter: new Linter(),
Linter,
CLIEngine: require("./cli-engine"),
RuleTester: require("./testers/rule-tester"),
SourceCode: require("./util/source-code")
Expand Down
Loading

0 comments on commit ff568d4

Please sign in to comment.