Remove obsolete max-len eslint rule and reformat some stuff to fit (#7602)

This commit is contained in:
Daniel Tschinder 2018-03-20 14:51:47 +01:00 committed by Brian Ng
parent 6d6fe844fd
commit f0d681a238
14 changed files with 62 additions and 55 deletions

View File

@ -32,7 +32,6 @@ function collect(value, previousValue): Array<string> {
return previousValue ? previousValue.concat(values) : values; return previousValue ? previousValue.concat(values) : values;
} }
/* eslint-disable max-len */
// Standard Babel input configs. // Standard Babel input configs.
commander.option( commander.option(
"-f, --filename [filename]", "-f, --filename [filename]",
@ -168,7 +167,6 @@ commander.option(
"--delete-dir-on-start", "--delete-dir-on-start",
"Delete the out directory before compilation", "Delete the out directory before compilation",
); );
/* eslint-enable max-len */
commander.version(pkg.version + " (@babel/core " + version + ")"); commander.version(pkg.version + " (@babel/core " + version + ")");
commander.usage("[options] <files ...>"); commander.usage("[options] <files ...>");

View File

@ -105,7 +105,6 @@ function resolveStandardizedName(
} catch (e2) {} } catch (e2) {}
if (resolvedOriginal) { if (resolvedOriginal) {
// eslint-disable-next-line max-len
e.message += `\n- If you want to resolve "${name}", use "module:${name}"`; e.message += `\n- If you want to resolve "${name}", use "module:${name}"`;
} }
} }
@ -119,7 +118,6 @@ function resolveStandardizedName(
} catch (e2) {} } catch (e2) {}
if (resolvedBabel) { if (resolvedBabel) {
// eslint-disable-next-line max-len
e.message += `\n- Did you mean "@babel/${name}"?`; e.message += `\n- Did you mean "@babel/${name}"?`;
} }
@ -131,7 +129,6 @@ function resolveStandardizedName(
} catch (e2) {} } catch (e2) {}
if (resolvedOppositeType) { if (resolvedOppositeType) {
// eslint-disable-next-line max-len
e.message += `\n- Did you accidentally pass a ${type} as a ${oppositeType}?`; e.message += `\n- Did you accidentally pass a ${type} as a ${oppositeType}?`;
} }
@ -143,8 +140,9 @@ const LOADING_MODULES = new Set();
function requireModule(type: string, name: string): mixed { function requireModule(type: string, name: string): mixed {
if (LOADING_MODULES.has(name)) { if (LOADING_MODULES.has(name)) {
throw new Error( throw new Error(
// eslint-disable-next-line max-len `Reentrant ${type} detected trying to load "${name}". This module is not ignored ` +
`Reentrant ${type} detected trying to load "${name}". This module is not ignored and is trying to load itself while compiling itself, leading to a dependency cycle. We recommend adding it to your "ignore" list in your babelrc, or to a .babelignore.`, "and is trying to load itself while compiling itself, leading to a dependency cycle. " +
'We recommend adding it to your "ignore" list in your babelrc, or to a .babelignore.',
); );
} }

View File

@ -1,5 +1,4 @@
// @flow // @flow
/* eslint max-len: "off" */
export default { export default {
auxiliaryComment: { auxiliaryComment: {
@ -16,36 +15,42 @@ export default {
}, },
externalHelpers: { externalHelpers: {
message: message:
"Use the `external-helpers` plugin instead. Check out http://babeljs.io/docs/plugins/external-helpers/", "Use the `external-helpers` plugin instead. " +
"Check out http://babeljs.io/docs/plugins/external-helpers/",
}, },
extra: { extra: {
message: "", message: "",
}, },
jsxPragma: { jsxPragma: {
message: message:
"use the `pragma` option in the `react-jsx` plugin . Check out http://babeljs.io/docs/plugins/transform-react-jsx/", "use the `pragma` option in the `react-jsx` plugin. " +
"Check out http://babeljs.io/docs/plugins/transform-react-jsx/",
}, },
loose: { loose: {
message: message:
"Specify the `loose` option for the relevant plugin you are using or use a preset that sets the option.", "Specify the `loose` option for the relevant plugin you are using " +
"or use a preset that sets the option.",
}, },
metadataUsedHelpers: { metadataUsedHelpers: {
message: "Not required anymore as this is enabled by default", message: "Not required anymore as this is enabled by default",
}, },
modules: { modules: {
message: message:
"Use the corresponding module transform plugin in the `plugins` option. Check out http://babeljs.io/docs/plugins/#modules", "Use the corresponding module transform plugin in the `plugins` option. " +
"Check out http://babeljs.io/docs/plugins/#modules",
}, },
nonStandard: { nonStandard: {
message: message:
"Use the `react-jsx` and `flow-strip-types` plugins to support JSX and Flow. Also check out the react preset http://babeljs.io/docs/plugins/preset-react/", "Use the `react-jsx` and `flow-strip-types` plugins to support JSX and Flow. " +
"Also check out the react preset http://babeljs.io/docs/plugins/preset-react/",
}, },
optional: { optional: {
message: "Put the specific transforms you want in the `plugins` option", message: "Put the specific transforms you want in the `plugins` option",
}, },
sourceMapName: { sourceMapName: {
message: message:
"The `sourceMapName` option has been removed because it makes more sense for the tooling that calls Babel to assign `map.file` themselves.", "The `sourceMapName` option has been removed because it makes more sense for the " +
"tooling that calls Babel to assign `map.file` themselves.",
}, },
stage: { stage: {
message: message:
@ -69,6 +74,7 @@ export default {
sourceMapTarget: { sourceMapTarget: {
version: 6, version: 6,
message: message:
"The `sourceMapTarget` option has been removed because it makes more sense for the tooling that calls Babel to assign `map.file` themselves.", "The `sourceMapTarget` option has been removed because it makes more sense for the tooling " +
"that calls Babel to assign `map.file` themselves.",
}, },
}; };

View File

@ -243,7 +243,6 @@ describe("addon resolution", function() {
babelrc: false, babelrc: false,
presets: ["foo"], presets: ["foo"],
}); });
// eslint-disable-next-line max-len
}).toThrow( }).toThrow(
/Cannot find module 'babel-preset-foo'.*\n- If you want to resolve "foo", use "module:foo"/, /Cannot find module 'babel-preset-foo'.*\n- If you want to resolve "foo", use "module:foo"/,
); );
@ -258,7 +257,6 @@ describe("addon resolution", function() {
babelrc: false, babelrc: false,
plugins: ["foo"], plugins: ["foo"],
}); });
// eslint-disable-next-line max-len
}).toThrow( }).toThrow(
/Cannot find module 'babel-plugin-foo'.*\n- If you want to resolve "foo", use "module:foo"/, /Cannot find module 'babel-plugin-foo'.*\n- If you want to resolve "foo", use "module:foo"/,
); );
@ -273,7 +271,6 @@ describe("addon resolution", function() {
babelrc: false, babelrc: false,
presets: ["foo"], presets: ["foo"],
}); });
// eslint-disable-next-line max-len
}).toThrow( }).toThrow(
/Cannot find module 'babel-preset-foo'.*\n- Did you mean "@babel\/foo"\?/, /Cannot find module 'babel-preset-foo'.*\n- Did you mean "@babel\/foo"\?/,
); );
@ -288,7 +285,6 @@ describe("addon resolution", function() {
babelrc: false, babelrc: false,
plugins: ["foo"], plugins: ["foo"],
}); });
// eslint-disable-next-line max-len
}).toThrow( }).toThrow(
/Cannot find module 'babel-plugin-foo'.*\n- Did you mean "@babel\/foo"\?/, /Cannot find module 'babel-plugin-foo'.*\n- Did you mean "@babel\/foo"\?/,
); );
@ -303,7 +299,6 @@ describe("addon resolution", function() {
babelrc: false, babelrc: false,
presets: ["testplugin"], presets: ["testplugin"],
}); });
// eslint-disable-next-line max-len
}).toThrow( }).toThrow(
/Cannot find module 'babel-preset-testplugin'.*\n- Did you accidentally pass a preset as a plugin\?/, /Cannot find module 'babel-preset-testplugin'.*\n- Did you accidentally pass a preset as a plugin\?/,
); );
@ -318,7 +313,6 @@ describe("addon resolution", function() {
babelrc: false, babelrc: false,
plugins: ["testpreset"], plugins: ["testpreset"],
}); });
// eslint-disable-next-line max-len
}).toThrow( }).toThrow(
/Cannot find module 'babel-plugin-testpreset'.*\n- Did you accidentally pass a plugin as a preset\?/, /Cannot find module 'babel-plugin-testpreset'.*\n- Did you accidentally pass a plugin as a preset\?/,
); );

View File

@ -1,5 +1,3 @@
/* eslint max-len: "off" */
import template from "@babel/template"; import template from "@babel/template";
const helpers = {}; const helpers = {};
@ -26,7 +24,9 @@ helpers.jsx = () => template.program.ast`
export default function _createRawReactElement(type, props, key, children) { export default function _createRawReactElement(type, props, key, children) {
if (!REACT_ELEMENT_TYPE) { if (!REACT_ELEMENT_TYPE) {
REACT_ELEMENT_TYPE = (typeof Symbol === "function" && Symbol.for && Symbol.for("react.element")) || 0xeac7; REACT_ELEMENT_TYPE = (
typeof Symbol === "function" && Symbol.for && Symbol.for("react.element")
) || 0xeac7;
} }
var defaultProps = type && type.defaultProps; var defaultProps = type && type.defaultProps;
@ -431,7 +431,8 @@ helpers.inherits = () => template.program.ast`
configurable: true configurable: true
} }
}); });
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; if (superClass)
Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
} }
`; `;

View File

@ -21,7 +21,6 @@ function collect(value, previousValue): Array<string> {
return previousValue ? previousValue.concat(values) : values; return previousValue ? previousValue.concat(values) : values;
} }
/* eslint-disable max-len */
program.option("-e, --eval [script]", "Evaluate script"); program.option("-e, --eval [script]", "Evaluate script");
program.option("-p, --print [code]", "Evaluate script and print result"); program.option("-p, --print [code]", "Evaluate script and print result");
program.option( program.option(
@ -41,7 +40,6 @@ program.option(
); );
program.option("-w, --plugins [string]", "", collect); program.option("-w, --plugins [string]", "", collect);
program.option("-b, --presets [string]", "", collect); program.option("-b, --presets [string]", "", collect);
/* eslint-enable max-len */
program.version(pkg.version); program.version(pkg.version);
program.usage("[options] [ -e script | script.js ] [arguments]"); program.usage("[options] [ -e script | script.js ] [arguments]");

View File

@ -88,14 +88,16 @@ export default declare((api, options) => {
} }
`); `);
/* eslint-disable max-len */
const buildForOf = template(` const buildForOf = template(`
var ITERATOR_COMPLETION = true; var ITERATOR_COMPLETION = true;
var ITERATOR_HAD_ERROR_KEY = false; var ITERATOR_HAD_ERROR_KEY = false;
var ITERATOR_ERROR_KEY = undefined; var ITERATOR_ERROR_KEY = undefined;
try { try {
for (var ITERATOR_KEY = OBJECT[Symbol.iterator](), STEP_KEY; !(ITERATOR_COMPLETION = (STEP_KEY = ITERATOR_KEY.next()).done); ITERATOR_COMPLETION = true) { for (
} var ITERATOR_KEY = OBJECT[Symbol.iterator](), STEP_KEY;
!(ITERATOR_COMPLETION = (STEP_KEY = ITERATOR_KEY.next()).done);
ITERATOR_COMPLETION = true
) {}
} catch (err) { } catch (err) {
ITERATOR_HAD_ERROR_KEY = true; ITERATOR_HAD_ERROR_KEY = true;
ITERATOR_ERROR_KEY = err; ITERATOR_ERROR_KEY = err;
@ -111,7 +113,6 @@ export default declare((api, options) => {
} }
} }
`); `);
/* eslint-enable max-len */
function _ForOfStatementArray(path) { function _ForOfStatementArray(path) {
const { node, scope } = path; const { node, scope } = path;

View File

@ -79,8 +79,8 @@ export const isPluginRequired = (
if (!semver.valid(lowestTargetedVersion)) { if (!semver.valid(lowestTargetedVersion)) {
throw new Error( throw new Error(
// eslint-disable-next-line max-len `Invalid version passed for target "${environment}": "${lowestTargetedVersion}". ` +
`Invalid version passed for target "${environment}": "${lowestTargetedVersion}". Versions must be in semver format (major.minor.patch)`, "Versions must be in semver format (major.minor.patch)",
); );
} }

View File

@ -1,5 +1,3 @@
/* eslint max-len: 0 */
// @flow // @flow
/** /**

View File

@ -1,5 +1,3 @@
/* eslint max-len: 0 */
// @flow // @flow
// A recursive descent parser operates by defining functions for all // A recursive descent parser operates by defining functions for all
@ -436,7 +434,10 @@ export default class ExpressionParser extends LValParser {
return base; return base;
} }
/** @param state Set 'state.stop = true' to indicate that we should stop parsing subscripts. 'state.optionalChainMember to indicate that the member is currently in OptionalChain'*/ /**
* @param state Set 'state.stop = true' to indicate that we should stop parsing subscripts.
* state.optionalChainMember to indicate that the member is currently in OptionalChain
*/
parseSubscript( parseSubscript(
base: N.Expression, base: N.Expression,
startPos: number, startPos: number,
@ -625,7 +626,8 @@ export default class ExpressionParser extends LValParser {
if (this.eat(close)) break; if (this.eat(close)) break;
} }
// we need to make sure that if this is an async arrow functions, that we don't allow inner parens inside the params // we need to make sure that if this is an async arrow functions,
// that we don't allow inner parens inside the params
if (this.match(tt.parenL) && !innerParenStart) { if (this.match(tt.parenL) && !innerParenStart) {
innerParenStart = this.state.start; innerParenStart = this.state.start;
} }
@ -710,7 +712,8 @@ export default class ExpressionParser extends LValParser {
) { ) {
this.raise( this.raise(
node.start, node.start,
"super() is only valid inside a class constructor. Make sure the method name is spelled exactly as 'constructor'.", "super() is only valid inside a class constructor. " +
"Make sure the method name is spelled exactly as 'constructor'.",
); );
} }
return this.finishNode(node, "Super"); return this.finishNode(node, "Super");
@ -913,7 +916,7 @@ export default class ExpressionParser extends LValParser {
if (this.isContextual(propertyName)) { if (this.isContextual(propertyName)) {
this.expectPlugin("functionSent"); this.expectPlugin("functionSent");
} else if (!this.hasPlugin("functionSent")) { } else if (!this.hasPlugin("functionSent")) {
// They didn't actually say `function.sent`, just `function.`, so a simple error would be less confusing. // The code wasn't `function.sent` but just `function.`, so a simple error is less confusing.
this.unexpected(); this.unexpected();
} }
} }

View File

@ -1,5 +1,3 @@
/* eslint max-len: 0 */
// @flow // @flow
import * as N from "../types"; import * as N from "../types";
@ -246,7 +244,8 @@ export default class StatementParser extends ExpressionParser {
} else { } else {
this.raise( this.raise(
this.state.start, this.state.start,
"Using the export keyword between a decorator and a class is not allowed. Please use `export @dec class` instead", "Using the export keyword between a decorator and a class is not allowed. " +
"Please use `export @dec class` instead",
); );
} }
} }
@ -775,7 +774,8 @@ export default class StatementParser extends ExpressionParser {
kind === tt._const && kind === tt._const &&
!(this.match(tt._in) || this.isContextual("of")) !(this.match(tt._in) || this.isContextual("of"))
) { ) {
// `const` with no initializer is allowed in TypeScript. It could be a declaration `const x: number;`. // `const` with no initializer is allowed in TypeScript.
// It could be a declaration like `const x: number;`.
if (!this.hasPlugin("typescript")) { if (!this.hasPlugin("typescript")) {
this.unexpected(); this.unexpected();
} }
@ -1708,7 +1708,8 @@ export default class StatementParser extends ExpressionParser {
if (this.eat(tt.colon)) { if (this.eat(tt.colon)) {
this.unexpected( this.unexpected(
null, null,
"ES2015 named imports do not destructure. Use another statement for destructuring after the import.", "ES2015 named imports do not destructure. " +
"Use another statement for destructuring after the import.",
); );
} }

View File

@ -1,5 +1,3 @@
/* eslint max-len: 0 */
// @flow // @flow
import type Parser from "../parser"; import type Parser from "../parser";
@ -261,7 +259,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
let kind = null; let kind = null;
let hasModuleExport = false; let hasModuleExport = false;
const errorMessage = const errorMessage =
"Found both `declare module.exports` and `declare export` in the same module. Modules can only have 1 since they are either an ES module or they are a CommonJS module"; "Found both `declare module.exports` and `declare export` in the same module. " +
"Modules can only have 1 since they are either an ES module or they are a CommonJS module";
body.forEach(bodyElement => { body.forEach(bodyElement => {
if (isEsModuleType(bodyElement)) { if (isEsModuleType(bodyElement)) {
if (kind === "CommonJS") { if (kind === "CommonJS") {
@ -1902,7 +1901,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
) { ) {
this.raise( this.raise(
node.typeAnnotation.start, node.typeAnnotation.start,
"Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`", "Type annotations must come before default assignments, " +
"e.g. instead of `age = 25: number` use `age: number = 25`",
); );
} }
@ -2019,7 +2019,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
if (nodeIsTypeImport && specifierIsTypeImport) { if (nodeIsTypeImport && specifierIsTypeImport) {
this.raise( this.raise(
firstIdentLoc, firstIdentLoc,
"The `type` and `typeof` keywords on named imports can only be used on regular `import` statements. It cannot be used with `import type` or `import typeof` statements", "The `type` and `typeof` keywords on named imports can only be used on regular " +
"`import` statements. It cannot be used with `import type` or `import typeof` statements",
); );
} }

View File

@ -1,5 +1,3 @@
/* eslint max-len: 0 */
// @flow // @flow
import type { Options } from "../options"; import type { Options } from "../options";

View File

@ -20,8 +20,18 @@ export default class State {
this.noArrowAt = []; this.noArrowAt = [];
this.noArrowParamsConversionAt = []; this.noArrowParamsConversionAt = [];
// eslint-disable-next-line max-len this.inMethod = false;
this.inMethod = this.inFunction = this.inParameters = this.maybeInArrowParameters = this.inGenerator = this.inAsync = this.inPropertyName = this.inType = this.inClassProperty = this.noAnonFunctionType = this.hasFlowComment = this.isIterator = false; this.inFunction = false;
this.inParameters = false;
this.maybeInArrowParameters = false;
this.inGenerator = false;
this.inAsync = false;
this.inPropertyName = false;
this.inType = false;
this.inClassProperty = false;
this.noAnonFunctionType = false;
this.hasFlowComment = false;
this.isIterator = false;
this.classLevel = 0; this.classLevel = 0;