Skip to content

Commit ba73a67

Browse files
cjihriggibfahn
authored andcommitted
tools: update to ESLint 4.10.0
PR-URL: #16738 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
1 parent 9ec35c5 commit ba73a67

File tree

263 files changed

+9333
-8838
lines changed

Some content is hidden

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

263 files changed

+9333
-8838
lines changed

tools/eslint/README.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ ESLint is a tool for identifying and reporting on patterns found in ECMAScript/J
2727

2828
## Installation and Usage
2929

30+
Prerequisites: [Node.js](https://nodejs.org/en/) (>=4.x), npm version 2+.
31+
3032
There are two ways to install ESLint: globally and locally.
3133

3234
### Local Installation and Usage
@@ -132,6 +134,8 @@ These folks keep the project moving and are resources for help.
132134
* Vitor Balocco ([@vitorbal](https://github.com/vitorbal))
133135
* James Henry ([@JamesHenry](https://github.com/JamesHenry))
134136
* Reyad Attiyat ([@soda0289](https://github.com/soda0289))
137+
* 薛定谔的猫 ([@Aladdin-ADD](https://github.com/Aladdin-ADD))
138+
* Victor Hom ([@VictorHom](https://github.com/VictorHom))
135139

136140
## Releases
137141

@@ -202,11 +206,23 @@ Maybe, depending on how much you need it. [JSCS has reached end of life](https:/
202206

203207
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.
204208

205-
206209
### Is ESLint just linting or does it also check style?
207210

208211
ESLint does both traditional linting (looking for problematic patterns) and style checking (enforcement of conventions). You can use it for both.
209212

213+
### Why can't ESLint find my plugins?
214+
215+
ESLint can be [globally or locally installed](#installation-and-usage). If you install ESLint globally, your plugins must also be installed globally; if you install ESLint locally, your plugins must also be installed locally.
216+
217+
If you are trying to run globally, make sure your plugins are installed globally (use `npm ls -g`).
218+
219+
If you are trying to run locally:
220+
221+
* Make sure your plugins (and ESLint) are both in your project's `package.json` as devDependencies (or dependencies, if your project uses ESLint at runtime).
222+
* Make sure you have run `npm install` and all your dependencies are installed.
223+
224+
In all cases, make sure your plugins' peerDependencies have been installed as well. You can use `npm view eslint-plugin-myplugin peerDepencies` to see what peer dependencies `eslint-plugin-myplugin` has.
225+
210226
### Does ESLint support JSX?
211227

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

tools/eslint/conf/eslint-recommended.js

+2
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,15 @@ module.exports = {
6363
"linebreak-style": "off",
6464
"lines-around-comment": "off",
6565
"lines-around-directive": "off",
66+
"lines-between-class-members": "off",
6667
"max-depth": "off",
6768
"max-len": "off",
6869
"max-lines": "off",
6970
"max-nested-callbacks": "off",
7071
"max-params": "off",
7172
"max-statements": "off",
7273
"max-statements-per-line": "off",
74+
"multiline-comment-style": "off",
7375
"multiline-ternary": "off",
7476
"new-cap": "off",
7577
"new-parens": "off",

tools/eslint/lib/ast-utils.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,8 @@ module.exports = {
10411041
} else if (parent.type === "Property" || parent.type === "MethodDefinition") {
10421042
if (parent.kind === "constructor") {
10431043
return "constructor";
1044-
} else if (parent.kind === "get") {
1044+
}
1045+
if (parent.kind === "get") {
10451046
tokens.push("getter");
10461047
} else if (parent.kind === "set") {
10471048
tokens.push("setter");

tools/eslint/lib/cli-engine.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ function processFile(filename, configHelper, options, linter) {
240240
function createIgnoreResult(filePath, baseDir) {
241241
let message;
242242
const isHidden = /^\./.test(path.basename(filePath));
243-
const isInNodeModules = baseDir && /^node_modules/.test(path.relative(baseDir, filePath));
244-
const isInBowerComponents = baseDir && /^bower_components/.test(path.relative(baseDir, filePath));
243+
const isInNodeModules = baseDir && path.relative(baseDir, filePath).startsWith("node_modules");
244+
const isInBowerComponents = baseDir && path.relative(baseDir, filePath).startsWith("bower_components");
245245

246246
if (isHidden) {
247247
message = "File ignored by default. Use a negated ignore pattern (like \"--ignore-pattern '!<relative/path/to/filename>'\") to override.";

tools/eslint/lib/cli.js

+15-8
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function translateOptions(cliOptions) {
6363
cache: cliOptions.cache,
6464
cacheFile: cliOptions.cacheFile,
6565
cacheLocation: cliOptions.cacheLocation,
66-
fix: cliOptions.fix && (cliOptions.quiet ? quietFixPredicate : true),
66+
fix: (cliOptions.fix || cliOptions.fixDryRun) && (cliOptions.quiet ? quietFixPredicate : true),
6767
allowInlineConfig: cliOptions.inlineConfig,
6868
reportUnusedDisableDirectives: cliOptions.reportUnusedDisableDirectives
6969
};
@@ -144,6 +144,8 @@ const cli = {
144144

145145
const files = currentOptions._;
146146

147+
const useStdin = typeof text === "string";
148+
147149
if (currentOptions.version) { // version from package.json
148150

149151
log.info(`v${require("../package.json").version}`);
@@ -152,7 +154,8 @@ const cli = {
152154
if (files.length) {
153155
log.error("The --print-config option must be used with exactly one file name.");
154156
return 1;
155-
} else if (text) {
157+
}
158+
if (useStdin) {
156159
log.error("The --print-config option is not available for piped-in code.");
157160
return 1;
158161
}
@@ -163,23 +166,27 @@ const cli = {
163166

164167
log.info(JSON.stringify(fileConfig, null, " "));
165168
return 0;
166-
} else if (currentOptions.help || (!files.length && !text)) {
169+
} else if (currentOptions.help || (!files.length && !useStdin)) {
167170

168171
log.info(options.generateHelp());
169172

170173
} else {
171174

172-
debug(`Running on ${text ? "text" : "files"}`);
175+
debug(`Running on ${useStdin ? "text" : "files"}`);
176+
177+
if (currentOptions.fix && currentOptions.fixDryRun) {
178+
log.error("The --fix option and the --fix-dry-run option cannot be used together.");
179+
return 1;
180+
}
173181

174-
// disable --fix for piped-in code until we know how to do it correctly
175-
if (text && currentOptions.fix) {
176-
log.error("The --fix option is not available for piped-in code.");
182+
if (useStdin && currentOptions.fix) {
183+
log.error("The --fix option is not available for piped-in code; use --fix-dry-run instead.");
177184
return 1;
178185
}
179186

180187
const engine = new CLIEngine(translateOptions(currentOptions));
181188

182-
const report = text ? engine.executeOnText(text, currentOptions.stdinFilename, true) : engine.executeOnFiles(files);
189+
const report = useStdin ? engine.executeOnText(text, currentOptions.stdinFilename, true) : engine.executeOnFiles(files);
183190

184191
if (currentOptions.fix) {
185192
debug("Fix mode enabled - applying fixes");

tools/eslint/lib/formatters/html.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ function renderSummary(totalErrors, totalWarnings) {
5151
function renderColor(totalErrors, totalWarnings) {
5252
if (totalErrors !== 0) {
5353
return 2;
54-
} else if (totalWarnings !== 0) {
54+
}
55+
if (totalWarnings !== 0) {
5556
return 1;
5657
}
5758
return 0;

tools/eslint/lib/ignored-paths.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class IgnoredPaths {
184184
addPattern(this.ig.default, pattern);
185185
});
186186
} else {
187-
throw new Error("Package.json eslintIgnore property requires an array of paths");
187+
throw new TypeError("Package.json eslintIgnore property requires an array of paths");
188188
}
189189
}
190190
}

tools/eslint/lib/internal-rules/.eslintrc.yml

-3
This file was deleted.

tools/eslint/lib/internal-rules/internal-consistent-docs-description.js

-130
This file was deleted.

0 commit comments

Comments
 (0)