Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: update to ESLint 4.10.0 #16738

Merged
merged 1 commit into from
Nov 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion tools/eslint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ ESLint is a tool for identifying and reporting on patterns found in ECMAScript/J

## Installation and Usage

Prerequisites: [Node.js](https://nodejs.org/en/) (>=4.x), npm version 2+.

There are two ways to install ESLint: globally and locally.

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

## Releases

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

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.


### Is ESLint just linting or does it also check style?

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

### Why can't ESLint find my plugins?

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.

If you are trying to run globally, make sure your plugins are installed globally (use `npm ls -g`).

If you are trying to run locally:

* 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).
* Make sure you have run `npm install` and all your dependencies are installed.

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.

### Does ESLint support JSX?

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.
Expand Down
2 changes: 2 additions & 0 deletions tools/eslint/conf/eslint-recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,15 @@ module.exports = {
"linebreak-style": "off",
"lines-around-comment": "off",
"lines-around-directive": "off",
"lines-between-class-members": "off",
"max-depth": "off",
"max-len": "off",
"max-lines": "off",
"max-nested-callbacks": "off",
"max-params": "off",
"max-statements": "off",
"max-statements-per-line": "off",
"multiline-comment-style": "off",
"multiline-ternary": "off",
"new-cap": "off",
"new-parens": "off",
Expand Down
3 changes: 2 additions & 1 deletion tools/eslint/lib/ast-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,8 @@ module.exports = {
} else if (parent.type === "Property" || parent.type === "MethodDefinition") {
if (parent.kind === "constructor") {
return "constructor";
} else if (parent.kind === "get") {
}
if (parent.kind === "get") {
tokens.push("getter");
} else if (parent.kind === "set") {
tokens.push("setter");
Expand Down
4 changes: 2 additions & 2 deletions tools/eslint/lib/cli-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ function processFile(filename, configHelper, options, linter) {
function createIgnoreResult(filePath, baseDir) {
let message;
const isHidden = /^\./.test(path.basename(filePath));
const isInNodeModules = baseDir && /^node_modules/.test(path.relative(baseDir, filePath));
const isInBowerComponents = baseDir && /^bower_components/.test(path.relative(baseDir, filePath));
const isInNodeModules = baseDir && path.relative(baseDir, filePath).startsWith("node_modules");
const isInBowerComponents = baseDir && path.relative(baseDir, filePath).startsWith("bower_components");

if (isHidden) {
message = "File ignored by default. Use a negated ignore pattern (like \"--ignore-pattern '!<relative/path/to/filename>'\") to override.";
Expand Down
23 changes: 15 additions & 8 deletions tools/eslint/lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function translateOptions(cliOptions) {
cache: cliOptions.cache,
cacheFile: cliOptions.cacheFile,
cacheLocation: cliOptions.cacheLocation,
fix: cliOptions.fix && (cliOptions.quiet ? quietFixPredicate : true),
fix: (cliOptions.fix || cliOptions.fixDryRun) && (cliOptions.quiet ? quietFixPredicate : true),
allowInlineConfig: cliOptions.inlineConfig,
reportUnusedDisableDirectives: cliOptions.reportUnusedDisableDirectives
};
Expand Down Expand Up @@ -144,6 +144,8 @@ const cli = {

const files = currentOptions._;

const useStdin = typeof text === "string";

if (currentOptions.version) { // version from package.json

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

log.info(JSON.stringify(fileConfig, null, " "));
return 0;
} else if (currentOptions.help || (!files.length && !text)) {
} else if (currentOptions.help || (!files.length && !useStdin)) {

log.info(options.generateHelp());

} else {

debug(`Running on ${text ? "text" : "files"}`);
debug(`Running on ${useStdin ? "text" : "files"}`);

if (currentOptions.fix && currentOptions.fixDryRun) {
log.error("The --fix option and the --fix-dry-run option cannot be used together.");
return 1;
}

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

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

const report = text ? engine.executeOnText(text, currentOptions.stdinFilename, true) : engine.executeOnFiles(files);
const report = useStdin ? engine.executeOnText(text, currentOptions.stdinFilename, true) : engine.executeOnFiles(files);

if (currentOptions.fix) {
debug("Fix mode enabled - applying fixes");
Expand Down
3 changes: 2 additions & 1 deletion tools/eslint/lib/formatters/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ function renderSummary(totalErrors, totalWarnings) {
function renderColor(totalErrors, totalWarnings) {
if (totalErrors !== 0) {
return 2;
} else if (totalWarnings !== 0) {
}
if (totalWarnings !== 0) {
return 1;
}
return 0;
Expand Down
2 changes: 1 addition & 1 deletion tools/eslint/lib/ignored-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class IgnoredPaths {
addPattern(this.ig.default, pattern);
});
} else {
throw new Error("Package.json eslintIgnore property requires an array of paths");
throw new TypeError("Package.json eslintIgnore property requires an array of paths");
}
}
}
Expand Down
3 changes: 0 additions & 3 deletions tools/eslint/lib/internal-rules/.eslintrc.yml

This file was deleted.

This file was deleted.

Loading