Skip to content

Commit d34bc78

Browse files
TrottMylesBorins
authored andcommitted
tools: update to ESLint 4.1.0
Update ESLint to 4.1.0. This fixes a bug that previously prevented us from using the new and stricter indentation checking. Refs: eslint/eslint#8721 Backport-PR-URL: #14830 PR-URL: #13895 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent d5bf137 commit d34bc78

File tree

216 files changed

+10484
-8298
lines changed

Some content is hidden

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

216 files changed

+10484
-8298
lines changed

tools/eslint/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ These folks keep the project moving and are resources for help.
137137

138138
We have scheduled releases every two weeks on Friday or Saturday.
139139

140+
## Code of Conduct
141+
142+
ESLint adheres to the [JS Foundation Code of Conduct](https://js.foundation/community/code-of-conduct).
143+
140144
## Filing Issues
141145

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

tools/eslint/conf/config-schema.js

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/**
2+
* @fileoverview Defines a schema for configs.
3+
* @author Sylvan Mably
4+
*/
5+
6+
"use strict";
7+
8+
const baseConfigProperties = {
9+
env: { type: "object" },
10+
globals: { type: "object" },
11+
parser: { type: ["string", "null"] },
12+
parserOptions: { type: "object" },
13+
plugins: { type: "array" },
14+
rules: { type: "object" },
15+
settings: { type: "object" }
16+
};
17+
18+
const overrideProperties = Object.assign(
19+
{},
20+
baseConfigProperties,
21+
{
22+
files: {
23+
oneOf: [
24+
{ type: "string" },
25+
{
26+
type: "array",
27+
items: { type: "string" },
28+
minItems: 1
29+
}
30+
]
31+
},
32+
excludedFiles: {
33+
oneOf: [
34+
{ type: "string" },
35+
{
36+
type: "array",
37+
items: { type: "string" }
38+
}
39+
]
40+
}
41+
}
42+
);
43+
44+
const topLevelConfigProperties = Object.assign(
45+
{},
46+
baseConfigProperties,
47+
{
48+
extends: { type: ["string", "array"] },
49+
root: { type: "boolean" },
50+
overrides: {
51+
type: "array",
52+
items: {
53+
type: "object",
54+
properties: overrideProperties,
55+
required: ["files"],
56+
additionalProperties: false
57+
}
58+
}
59+
}
60+
);
61+
62+
const configSchema = {
63+
type: "object",
64+
properties: topLevelConfigProperties,
65+
additionalProperties: false
66+
};
67+
68+
module.exports = configSchema;

tools/eslint/conf/config-schema.json

-15
This file was deleted.

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

+1-5
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,5 @@ module.exports = deepFreeze({
2525
rules: {},
2626
settings: {},
2727
parser: "espree",
28-
parserOptions: {
29-
ecmaVersion: 5,
30-
sourceType: "script",
31-
ecmaFeatures: {}
32-
}
28+
parserOptions: {}
3329
});

tools/eslint/lib/cli-engine.js

+19-90
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ const fs = require("fs"),
2323
Config = require("./config"),
2424
fileEntryCache = require("file-entry-cache"),
2525
globUtil = require("./util/glob-util"),
26-
SourceCodeFixer = require("./util/source-code-fixer"),
2726
validator = require("./config/config-validator"),
2827
stringify = require("json-stable-stringify"),
2928
hash = require("./util/hash"),
30-
3129
pkg = require("../package.json");
3230

3331
const debug = require("debug")("eslint:cli-engine");
@@ -132,80 +130,6 @@ function calculateStatsPerRun(results) {
132130
});
133131
}
134132

135-
/**
136-
* Performs multiple autofix passes over the text until as many fixes as possible
137-
* have been applied.
138-
* @param {string} text The source text to apply fixes to.
139-
* @param {Object} config The ESLint config object to use.
140-
* @param {Object} options The ESLint options object to use.
141-
* @param {string} options.filename The filename from which the text was read.
142-
* @param {boolean} options.allowInlineConfig Flag indicating if inline comments
143-
* should be allowed.
144-
* @param {Linter} linter Linter context
145-
* @returns {Object} The result of the fix operation as returned from the
146-
* SourceCodeFixer.
147-
* @private
148-
*/
149-
function multipassFix(text, config, options, linter) {
150-
const MAX_PASSES = 10;
151-
let messages = [],
152-
fixedResult,
153-
fixed = false,
154-
passNumber = 0;
155-
156-
/**
157-
* This loop continues until one of the following is true:
158-
*
159-
* 1. No more fixes have been applied.
160-
* 2. Ten passes have been made.
161-
*
162-
* That means anytime a fix is successfully applied, there will be another pass.
163-
* Essentially, guaranteeing a minimum of two passes.
164-
*/
165-
do {
166-
passNumber++;
167-
168-
debug(`Linting code for ${options.filename} (pass ${passNumber})`);
169-
messages = linter.verify(text, config, options);
170-
171-
debug(`Generating fixed text for ${options.filename} (pass ${passNumber})`);
172-
fixedResult = SourceCodeFixer.applyFixes(linter.getSourceCode(), messages);
173-
174-
// stop if there are any syntax errors.
175-
// 'fixedResult.output' is a empty string.
176-
if (messages.length === 1 && messages[0].fatal) {
177-
break;
178-
}
179-
180-
// keep track if any fixes were ever applied - important for return value
181-
fixed = fixed || fixedResult.fixed;
182-
183-
// update to use the fixed output instead of the original text
184-
text = fixedResult.output;
185-
186-
} while (
187-
fixedResult.fixed &&
188-
passNumber < MAX_PASSES
189-
);
190-
191-
192-
/*
193-
* If the last result had fixes, we need to lint again to be sure we have
194-
* the most up-to-date information.
195-
*/
196-
if (fixedResult.fixed) {
197-
fixedResult.messages = linter.verify(text, config, options);
198-
}
199-
200-
201-
// ensure the last result properly reflects if fixes were done
202-
fixedResult.fixed = fixed;
203-
fixedResult.output = text;
204-
205-
return fixedResult;
206-
207-
}
208-
209133
/**
210134
* Processes an source code using ESLint.
211135
* @param {string} text The source code to check.
@@ -269,10 +193,10 @@ function processText(text, configHelper, filename, fix, allowInlineConfig, linte
269193
} else {
270194

271195
if (fix) {
272-
fixedResult = multipassFix(text, config, {
196+
fixedResult = linter.verifyAndFix(text, config, {
273197
filename,
274198
allowInlineConfig
275-
}, linter);
199+
});
276200
messages = fixedResult.messages;
277201
} else {
278202
messages = linter.verify(text, config, {
@@ -394,7 +318,7 @@ function getCacheFile(cacheFile, cwd) {
394318
cacheFile = path.normalize(cacheFile);
395319

396320
const resolvedCacheFile = path.resolve(cwd, cacheFile);
397-
const looksLikeADirectory = cacheFile[cacheFile.length - 1 ] === path.sep;
321+
const looksLikeADirectory = cacheFile[cacheFile.length - 1] === path.sep;
398322

399323
/**
400324
* return the name for the cache file in case the provided parameter is a directory
@@ -474,15 +398,17 @@ class CLIEngine {
474398
this.options = options;
475399
this.linter = new Linter();
476400

477-
const cacheFile = getCacheFile(this.options.cacheLocation || this.options.cacheFile, this.options.cwd);
478-
479-
/**
480-
* Cache used to avoid operating on files that haven't changed since the
481-
* last successful execution (e.g., file passed linting with no errors and
482-
* no warnings).
483-
* @type {Object}
484-
*/
485-
this._fileCache = fileEntryCache.create(cacheFile);
401+
if (options.cache) {
402+
const cacheFile = getCacheFile(this.options.cacheLocation || this.options.cacheFile, this.options.cwd);
403+
404+
/**
405+
* Cache used to avoid operating on files that haven't changed since the
406+
* last successful execution (e.g., file passed linting with no errors and
407+
* no warnings).
408+
* @type {Object}
409+
*/
410+
this._fileCache = fileEntryCache.create(cacheFile);
411+
}
486412

487413
// load in additional rules
488414
if (this.options.rulePaths) {
@@ -571,6 +497,11 @@ class CLIEngine {
571497
fileCache = this._fileCache,
572498
configHelper = this.config;
573499
let prevConfig; // the previous configuration used
500+
const cacheFile = getCacheFile(this.options.cacheLocation || this.options.cacheFile, this.options.cwd);
501+
502+
if (!options.cache && fs.existsSync(cacheFile)) {
503+
fs.unlinkSync(cacheFile);
504+
}
574505

575506
/**
576507
* Calculates the hash of the config file used to validate a given file
@@ -646,8 +577,6 @@ class CLIEngine {
646577
// move to the next file
647578
return;
648579
}
649-
} else {
650-
fileCache.destroy();
651580
}
652581

653582
debug(`Processing ${filename}`);

tools/eslint/lib/code-path-analysis/code-path-state.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ class CodePathState {
240240
this.breakContext = null;
241241

242242
this.currentSegments = [];
243-
this.initialSegment = this.forkContext.head[ 0 ];
243+
this.initialSegment = this.forkContext.head[0];
244244

245245
// returnedSegments and thrownSegments push elements into finalSegments also.
246246
const final = this.finalSegments = [];

0 commit comments

Comments
 (0)