Skip to content

Commit ff568d4

Browse files
Trottaddaleax
authored andcommitted
tools: update ESLint to v4.0.0
Update ESLint and configuration to version 4.0.0. PR-URL: #13645 Reviewed-By: Teddy Katz <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Sam Roberts <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 2ce236e commit ff568d4

File tree

1,093 files changed

+39420
-36822
lines changed

Some content is hidden

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

1,093 files changed

+39420
-36822
lines changed

.eslintrc.yaml

+19-8
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ rules:
4040
eqeqeq: [2, smart]
4141
no-fallthrough: 2
4242
no-global-assign: 2
43-
no-multi-spaces: 2
43+
no-multi-spaces: [2, {ignoreEOLComments: true}]
4444
no-octal: 2
4545
no-proto: 2
4646
no-redeclare: 2
@@ -98,11 +98,18 @@ rules:
9898
func-call-spacing: 2
9999
func-name-matching: 2
100100
func-style: [2, declaration, {allowArrowFunctions: true}]
101-
indent: [2, 2, {ArrayExpression: first,
102-
CallExpression: {arguments: first},
103-
MemberExpression: 1,
104-
ObjectExpression: first,
105-
SwitchCase: 1}]
101+
# indent: [2, 2, {ArrayExpression: first,
102+
# CallExpression: {arguments: first},
103+
# FunctionDeclaration: {parameters: first},
104+
# FunctionExpression: {parameters: first},
105+
# MemberExpression: off,
106+
# ObjectExpression: first,
107+
# SwitchCase: 1}]
108+
indent-legacy: [2, 2, {ArrayExpression: first,
109+
CallExpression: {arguments: first},
110+
MemberExpression: 1,
111+
ObjectExpression: first,
112+
SwitchCase: 1}]
106113
key-spacing: [2, {mode: minimum}]
107114
keyword-spacing: 2
108115
linebreak-style: [2, unix]
@@ -122,7 +129,7 @@ rules:
122129
}, {
123130
selector: "ThrowStatement > CallExpression[callee.name=/Error$/]",
124131
message: "Use new keyword when throwing an Error."
125-
}]
132+
}]
126133
no-tabs: 2
127134
no-trailing-spaces: 2
128135
one-var-declaration-per-line: 2
@@ -131,7 +138,11 @@ rules:
131138
semi: 2
132139
semi-spacing: 2
133140
space-before-blocks: [2, always]
134-
space-before-function-paren: [2, never]
141+
space-before-function-paren: [2, {
142+
"anonymous": "never",
143+
"named": "never",
144+
"asyncArrow": "always"
145+
}]
135146
space-in-parens: [2, never]
136147
space-infix-ops: 2
137148
space-unary-ops: 2

test/message/throw_in_line_with_tabs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

22-
/* eslint-disable indent, no-tabs */
22+
/* eslint-disable indent-legacy, no-tabs */
2323
'use strict';
2424
require('../common');
2525

tools/eslint/CHANGELOG.md

-3,939
This file was deleted.

tools/eslint/LICENSE

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
ESLint
21
Copyright JS Foundation and other contributors, https://js.foundation
32

43
Permission is hereby granted, free of charge, to any person obtaining a copy

tools/eslint/README.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[![Downloads][downloads-image]][downloads-url]
66
[![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)
77
[![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)
8+
[![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)
89

910
# ESLint
1011

@@ -13,7 +14,7 @@
1314
[Rules](http://eslint.org/docs/rules/) |
1415
[Contributing](http://eslint.org/docs/developer-guide/contributing) |
1516
[Reporting Bugs](http://eslint.org/docs/developer-guide/contributing/reporting-bugs) |
16-
[Code of Conduct](https://js.foundation/conduct/) |
17+
[Code of Conduct](https://js.foundation/community/code-of-conduct) |
1718
[Twitter](https://twitter.com/geteslint) |
1819
[Mailing List](https://groups.google.com/group/eslint) |
1920
[Chat Room](https://gitter.im/eslint/eslint)
@@ -123,7 +124,7 @@ These folks keep the project moving and are resources for help.
123124
* Michael Ficarra ([@michaelficarra](https://github.com/michaelficarra))
124125
* Mark Pedrotti ([@pedrottimark](https://github.com/pedrottimark))
125126
* Oleg Gaidarenko ([@markelog](https://github.com/markelog))
126-
* Mike Sherov [@mikesherov](https://github.com/mikesherov))
127+
* Mike Sherov ([@mikesherov](https://github.com/mikesherov))
127128
* Henry Zhu ([@hzoo](https://github.com/hzoo))
128129
* Marat Dulin ([@mdevils](https://github.com/mdevils))
129130
* Alexej Yaroshevich ([@zxqfox](https://github.com/zxqfox))
@@ -172,6 +173,10 @@ ESLint follows [semantic versioning](http://semver.org). However, due to the nat
172173

173174
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.
174175

176+
## License
177+
178+
[![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)
179+
175180
## Frequently Asked Questions
176181

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

206211
### What about ECMAScript 6 support?
207212

208-
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).
213+
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).
209214

210215
### What about experimental features?
211216

tools/eslint/bin/eslint.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,12 @@ if (useStdIn) {
6161
} else if (init) {
6262
const configInit = require("../lib/config/config-initializer");
6363

64-
configInit.initializeConfig(err => {
65-
if (err) {
66-
process.exitCode = 1;
67-
console.error(err.message);
68-
console.error(err.stack);
69-
} else {
70-
process.exitCode = 0;
71-
}
64+
configInit.initializeConfig().then(() => {
65+
process.exitCode = 0;
66+
}).catch(err => {
67+
process.exitCode = 1;
68+
console.error(err.message);
69+
console.error(err.stack);
7270
});
7371
} else {
7472
process.exitCode = cli.execute(process.argv);

tools/eslint/conf/config-schema.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"type": "object",
3+
"properties": {
4+
"root": { "type": "boolean" },
5+
"globals": { "type": ["object"] },
6+
"parser": { "type": ["string", "null"] },
7+
"env": { "type": "object" },
8+
"plugins": { "type": ["array"] },
9+
"settings": { "type": "object" },
10+
"extends": { "type": ["string", "array"] },
11+
"rules": { "type": "object" },
12+
"parserOptions": { "type": "object" }
13+
},
14+
"additionalProperties": false
15+
}

tools/eslint/conf/cli-options.js tools/eslint/conf/default-cli-options.js

-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ module.exports = {
1212
useEslintrc: true,
1313
envs: [],
1414
globals: [],
15-
rules: {},
1615
extensions: [".js"],
1716
ignore: true,
1817
ignorePath: null,
19-
parser: "", // must be empty
2018
cache: false,
2119

2220
// in order to honor the cacheFile option if specified
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* @fileoverview Default config options
3+
* @author Teddy Katz
4+
*/
5+
6+
"use strict";
7+
8+
/**
9+
* Freezes an object and all its nested properties
10+
* @param {Object} obj The object to deeply freeze
11+
* @returns {Object} `obj` after freezing it
12+
*/
13+
function deepFreeze(obj) {
14+
if (obj === null || typeof obj !== "object") {
15+
return obj;
16+
}
17+
18+
Object.keys(obj).map(key => obj[key]).forEach(deepFreeze);
19+
return Object.freeze(obj);
20+
}
21+
22+
module.exports = deepFreeze({
23+
env: {},
24+
globals: {},
25+
rules: {},
26+
settings: {},
27+
parser: "espree",
28+
parserOptions: {
29+
ecmaVersion: 5,
30+
sourceType: "script",
31+
ecmaFeatures: {}
32+
}
33+
});

tools/eslint/conf/eslint-all.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
//------------------------------------------------------------------------------
1111

1212
const load = require("../lib/load-rules"),
13-
rules = require("../lib/rules");
13+
Rules = require("../lib/rules");
14+
const rules = new Rules();
1415

1516
//------------------------------------------------------------------------------
1617
// Helpers

tools/eslint/conf/eslint-recommended.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@
1010
/* eslint-disable sort-keys */
1111

1212
module.exports = {
13-
parser: "espree",
14-
ecmaFeatures: {},
15-
1613
rules: {
1714

1815
/* eslint-enable sort-keys */
1916
"accessor-pairs": "off",
17+
"array-bracket-newline": "off",
2018
"array-bracket-spacing": "off",
2119
"array-callback-return": "off",
20+
"array-element-newline": "off",
2221
"arrow-body-style": "off",
2322
"arrow-parens": "off",
2423
"arrow-spacing": "off",
@@ -43,6 +42,7 @@ module.exports = {
4342
"dot-notation": "off",
4443
"eol-last": "off",
4544
"eqeqeq": "off",
45+
"for-direction": "off",
4646
"func-call-spacing": "off",
4747
"func-name-matching": "off",
4848
"func-names": "off",
@@ -55,6 +55,7 @@ module.exports = {
5555
"id-length": "off",
5656
"id-match": "off",
5757
"indent": "off",
58+
"indent-legacy": "off",
5859
"init-declarations": "off",
5960
"jsx-quotes": "off",
6061
"key-spacing": "off",
@@ -80,11 +81,12 @@ module.exports = {
8081
"no-array-constructor": "off",
8182
"no-await-in-loop": "off",
8283
"no-bitwise": "off",
84+
"no-buffer-constructor": "off",
8385
"no-caller": "off",
8486
"no-case-declarations": "error",
8587
"no-catch-shadow": "off",
8688
"no-class-assign": "error",
87-
"no-compare-neg-zero": "off",
89+
"no-compare-neg-zero": "error",
8890
"no-cond-assign": "error",
8991
"no-confusing-arrow": "off",
9092
"no-console": "error",
@@ -202,7 +204,7 @@ module.exports = {
202204
"no-useless-computed-key": "off",
203205
"no-useless-concat": "off",
204206
"no-useless-constructor": "off",
205-
"no-useless-escape": "off",
207+
"no-useless-escape": "error",
206208
"no-useless-rename": "off",
207209
"no-useless-return": "off",
208210
"no-var": "off",
@@ -212,14 +214,15 @@ module.exports = {
212214
"no-with": "off",
213215
"nonblock-statement-body-position": "off",
214216
"object-curly-newline": "off",
215-
"object-curly-spacing": ["off", "never"],
217+
"object-curly-spacing": "off",
216218
"object-property-newline": "off",
217219
"object-shorthand": "off",
218220
"one-var": "off",
219221
"one-var-declaration-per-line": "off",
220222
"operator-assignment": "off",
221223
"operator-linebreak": "off",
222224
"padded-blocks": "off",
225+
"padding-line-between-statements": "off",
223226
"prefer-arrow-callback": "off",
224227
"prefer-const": "off",
225228
"prefer-destructuring": "off",
@@ -238,6 +241,7 @@ module.exports = {
238241
"rest-spread-spacing": "off",
239242
"semi": "off",
240243
"semi-spacing": "off",
244+
"semi-style": "off",
241245
"sort-imports": "off",
242246
"sort-keys": "off",
243247
"sort-vars": "off",
@@ -248,6 +252,7 @@ module.exports = {
248252
"space-unary-ops": "off",
249253
"spaced-comment": "off",
250254
"strict": "off",
255+
"switch-colon-spacing": "off",
251256
"symbol-description": "off",
252257
"template-curly-spacing": "off",
253258
"template-tag-spacing": "off",

tools/eslint/lib/api.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55

66
"use strict";
77

8+
const Linter = require("./linter");
9+
810
module.exports = {
9-
linter: require("./eslint"),
11+
linter: new Linter(),
12+
Linter,
1013
CLIEngine: require("./cli-engine"),
1114
RuleTester: require("./testers/rule-tester"),
1215
SourceCode: require("./util/source-code")

0 commit comments

Comments
 (0)