Remove obsolete max-len eslint rule and reformat some stuff to fit (#7602)
This commit is contained in:
parent
6d6fe844fd
commit
f0d681a238
@ -32,7 +32,6 @@ function collect(value, previousValue): Array<string> {
|
||||
return previousValue ? previousValue.concat(values) : values;
|
||||
}
|
||||
|
||||
/* eslint-disable max-len */
|
||||
// Standard Babel input configs.
|
||||
commander.option(
|
||||
"-f, --filename [filename]",
|
||||
@ -168,7 +167,6 @@ commander.option(
|
||||
"--delete-dir-on-start",
|
||||
"Delete the out directory before compilation",
|
||||
);
|
||||
/* eslint-enable max-len */
|
||||
|
||||
commander.version(pkg.version + " (@babel/core " + version + ")");
|
||||
commander.usage("[options] <files ...>");
|
||||
|
||||
@ -105,7 +105,6 @@ function resolveStandardizedName(
|
||||
} catch (e2) {}
|
||||
|
||||
if (resolvedOriginal) {
|
||||
// eslint-disable-next-line max-len
|
||||
e.message += `\n- If you want to resolve "${name}", use "module:${name}"`;
|
||||
}
|
||||
}
|
||||
@ -119,7 +118,6 @@ function resolveStandardizedName(
|
||||
} catch (e2) {}
|
||||
|
||||
if (resolvedBabel) {
|
||||
// eslint-disable-next-line max-len
|
||||
e.message += `\n- Did you mean "@babel/${name}"?`;
|
||||
}
|
||||
|
||||
@ -131,7 +129,6 @@ function resolveStandardizedName(
|
||||
} catch (e2) {}
|
||||
|
||||
if (resolvedOppositeType) {
|
||||
// eslint-disable-next-line max-len
|
||||
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 {
|
||||
if (LOADING_MODULES.has(name)) {
|
||||
throw new Error(
|
||||
// eslint-disable-next-line max-len
|
||||
`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.`,
|
||||
`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.',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
// @flow
|
||||
/* eslint max-len: "off" */
|
||||
|
||||
export default {
|
||||
auxiliaryComment: {
|
||||
@ -16,36 +15,42 @@ export default {
|
||||
},
|
||||
externalHelpers: {
|
||||
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: {
|
||||
message: "",
|
||||
},
|
||||
jsxPragma: {
|
||||
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: {
|
||||
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: {
|
||||
message: "Not required anymore as this is enabled by default",
|
||||
},
|
||||
modules: {
|
||||
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: {
|
||||
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: {
|
||||
message: "Put the specific transforms you want in the `plugins` option",
|
||||
},
|
||||
sourceMapName: {
|
||||
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: {
|
||||
message:
|
||||
@ -69,6 +74,7 @@ export default {
|
||||
sourceMapTarget: {
|
||||
version: 6,
|
||||
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.",
|
||||
},
|
||||
};
|
||||
|
||||
@ -243,7 +243,6 @@ describe("addon resolution", function() {
|
||||
babelrc: false,
|
||||
presets: ["foo"],
|
||||
});
|
||||
// eslint-disable-next-line max-len
|
||||
}).toThrow(
|
||||
/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,
|
||||
plugins: ["foo"],
|
||||
});
|
||||
// eslint-disable-next-line max-len
|
||||
}).toThrow(
|
||||
/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,
|
||||
presets: ["foo"],
|
||||
});
|
||||
// eslint-disable-next-line max-len
|
||||
}).toThrow(
|
||||
/Cannot find module 'babel-preset-foo'.*\n- Did you mean "@babel\/foo"\?/,
|
||||
);
|
||||
@ -288,7 +285,6 @@ describe("addon resolution", function() {
|
||||
babelrc: false,
|
||||
plugins: ["foo"],
|
||||
});
|
||||
// eslint-disable-next-line max-len
|
||||
}).toThrow(
|
||||
/Cannot find module 'babel-plugin-foo'.*\n- Did you mean "@babel\/foo"\?/,
|
||||
);
|
||||
@ -303,7 +299,6 @@ describe("addon resolution", function() {
|
||||
babelrc: false,
|
||||
presets: ["testplugin"],
|
||||
});
|
||||
// eslint-disable-next-line max-len
|
||||
}).toThrow(
|
||||
/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,
|
||||
plugins: ["testpreset"],
|
||||
});
|
||||
// eslint-disable-next-line max-len
|
||||
}).toThrow(
|
||||
/Cannot find module 'babel-plugin-testpreset'.*\n- Did you accidentally pass a plugin as a preset\?/,
|
||||
);
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
/* eslint max-len: "off" */
|
||||
|
||||
import template from "@babel/template";
|
||||
|
||||
const helpers = {};
|
||||
@ -26,7 +24,9 @@ helpers.jsx = () => template.program.ast`
|
||||
|
||||
export default function _createRawReactElement(type, props, key, children) {
|
||||
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;
|
||||
@ -431,7 +431,8 @@ helpers.inherits = () => template.program.ast`
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
|
||||
if (superClass)
|
||||
Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
|
||||
}
|
||||
`;
|
||||
|
||||
|
||||
@ -21,7 +21,6 @@ function collect(value, previousValue): Array<string> {
|
||||
return previousValue ? previousValue.concat(values) : values;
|
||||
}
|
||||
|
||||
/* eslint-disable max-len */
|
||||
program.option("-e, --eval [script]", "Evaluate script");
|
||||
program.option("-p, --print [code]", "Evaluate script and print result");
|
||||
program.option(
|
||||
@ -41,7 +40,6 @@ program.option(
|
||||
);
|
||||
program.option("-w, --plugins [string]", "", collect);
|
||||
program.option("-b, --presets [string]", "", collect);
|
||||
/* eslint-enable max-len */
|
||||
|
||||
program.version(pkg.version);
|
||||
program.usage("[options] [ -e script | script.js ] [arguments]");
|
||||
|
||||
@ -88,14 +88,16 @@ export default declare((api, options) => {
|
||||
}
|
||||
`);
|
||||
|
||||
/* eslint-disable max-len */
|
||||
const buildForOf = template(`
|
||||
var ITERATOR_COMPLETION = true;
|
||||
var ITERATOR_HAD_ERROR_KEY = false;
|
||||
var ITERATOR_ERROR_KEY = undefined;
|
||||
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) {
|
||||
ITERATOR_HAD_ERROR_KEY = true;
|
||||
ITERATOR_ERROR_KEY = err;
|
||||
@ -111,7 +113,6 @@ export default declare((api, options) => {
|
||||
}
|
||||
}
|
||||
`);
|
||||
/* eslint-enable max-len */
|
||||
|
||||
function _ForOfStatementArray(path) {
|
||||
const { node, scope } = path;
|
||||
|
||||
@ -79,8 +79,8 @@ export const isPluginRequired = (
|
||||
|
||||
if (!semver.valid(lowestTargetedVersion)) {
|
||||
throw new Error(
|
||||
// eslint-disable-next-line max-len
|
||||
`Invalid version passed for target "${environment}": "${lowestTargetedVersion}". Versions must be in semver format (major.minor.patch)`,
|
||||
`Invalid version passed for target "${environment}": "${lowestTargetedVersion}". ` +
|
||||
"Versions must be in semver format (major.minor.patch)",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
/* eslint max-len: 0 */
|
||||
|
||||
// @flow
|
||||
|
||||
/**
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
/* eslint max-len: 0 */
|
||||
|
||||
// @flow
|
||||
|
||||
// A recursive descent parser operates by defining functions for all
|
||||
@ -436,7 +434,10 @@ export default class ExpressionParser extends LValParser {
|
||||
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(
|
||||
base: N.Expression,
|
||||
startPos: number,
|
||||
@ -625,7 +626,8 @@ export default class ExpressionParser extends LValParser {
|
||||
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) {
|
||||
innerParenStart = this.state.start;
|
||||
}
|
||||
@ -710,7 +712,8 @@ export default class ExpressionParser extends LValParser {
|
||||
) {
|
||||
this.raise(
|
||||
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");
|
||||
@ -913,7 +916,7 @@ export default class ExpressionParser extends LValParser {
|
||||
if (this.isContextual(propertyName)) {
|
||||
this.expectPlugin("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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
/* eslint max-len: 0 */
|
||||
|
||||
// @flow
|
||||
|
||||
import * as N from "../types";
|
||||
@ -246,7 +244,8 @@ export default class StatementParser extends ExpressionParser {
|
||||
} else {
|
||||
this.raise(
|
||||
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 &&
|
||||
!(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")) {
|
||||
this.unexpected();
|
||||
}
|
||||
@ -1708,7 +1708,8 @@ export default class StatementParser extends ExpressionParser {
|
||||
if (this.eat(tt.colon)) {
|
||||
this.unexpected(
|
||||
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.",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
/* eslint max-len: 0 */
|
||||
|
||||
// @flow
|
||||
|
||||
import type Parser from "../parser";
|
||||
@ -261,7 +259,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
let kind = null;
|
||||
let hasModuleExport = false;
|
||||
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 => {
|
||||
if (isEsModuleType(bodyElement)) {
|
||||
if (kind === "CommonJS") {
|
||||
@ -1902,7 +1901,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
) {
|
||||
this.raise(
|
||||
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) {
|
||||
this.raise(
|
||||
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",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
/* eslint max-len: 0 */
|
||||
|
||||
// @flow
|
||||
|
||||
import type { Options } from "../options";
|
||||
|
||||
@ -20,8 +20,18 @@ export default class State {
|
||||
this.noArrowAt = [];
|
||||
this.noArrowParamsConversionAt = [];
|
||||
|
||||
// eslint-disable-next-line max-len
|
||||
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.inMethod = 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;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user