Re-enable the max-len ESLint rule. (#5265)
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
/* eslint max-len: 0 */
|
||||
|
||||
import * as helpers from "babel-helpers";
|
||||
import generator from "babel-generator";
|
||||
import * as messages from "babel-messages";
|
||||
@@ -23,12 +21,14 @@ const buildUmdWrapper = template(`
|
||||
function buildGlobal(namespace, builder) {
|
||||
const body = [];
|
||||
const container = t.functionExpression(null, [t.identifier("global")], t.blockStatement(body));
|
||||
const tree = t.program([t.expressionStatement(t.callExpression(container, [helpers.get("selfGlobal")]))]);
|
||||
const tree = t.program([
|
||||
t.expressionStatement(t.callExpression(container, [helpers.get("selfGlobal")]))]);
|
||||
|
||||
body.push(t.variableDeclaration("var", [
|
||||
t.variableDeclarator(
|
||||
namespace,
|
||||
t.assignmentExpression("=", t.memberExpression(t.identifier("global"), namespace), t.objectExpression([]))
|
||||
t.assignmentExpression("=", t.memberExpression(t.identifier("global"), namespace),
|
||||
t.objectExpression([]))
|
||||
)
|
||||
]));
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* global BabelFileResult, BabelParserOptions, BabelFileMetadata */
|
||||
/* eslint max-len: 0 */
|
||||
|
||||
import getHelper from "babel-helpers";
|
||||
import * as metadataVisitor from "./metadata";
|
||||
@@ -339,7 +338,7 @@ export default class File extends Store {
|
||||
this.scope.push({
|
||||
id: uid,
|
||||
init: init,
|
||||
_blockHoist: 1.9 // This ensures that we don't fail if not using function expression helpers
|
||||
_blockHoist: 1.9 // This ensures that we don't fail if not using function expression helpers
|
||||
});
|
||||
return uid;
|
||||
}
|
||||
@@ -378,8 +377,8 @@ export default class File extends Store {
|
||||
sourceRoot: inputMapConsumer.sourceRoot
|
||||
});
|
||||
|
||||
// This assumes the output map always has a single source, since Babel always compiles a single source file to a
|
||||
// single output file.
|
||||
// This assumes the output map always has a single source, since Babel always compiles a
|
||||
// single source file to a single output file.
|
||||
const source = outputMapConsumer.sources[0];
|
||||
|
||||
inputMapConsumer.eachMapping(function (mapping) {
|
||||
@@ -424,7 +423,8 @@ export default class File extends Store {
|
||||
if (parser) {
|
||||
parseCode = require(parser).parse;
|
||||
} else {
|
||||
throw new Error(`Couldn't find parser ${parserOpts.parser} with "parse" method relative to directory ${dirname}`);
|
||||
throw new Error(`Couldn't find parser ${parserOpts.parser} with "parse" method ` +
|
||||
`relative to directory ${dirname}`);
|
||||
}
|
||||
} else {
|
||||
parseCode = parserOpts.parser;
|
||||
@@ -472,7 +472,8 @@ export default class File extends Store {
|
||||
this.log.debug("Start transform traverse");
|
||||
|
||||
// merge all plugin visitors into a single visitor
|
||||
const visitor = traverse.visitors.merge(this.pluginVisitors[i], pluginPasses, this.opts.wrapPluginVisitorMethod);
|
||||
const visitor = traverse.visitors.merge(this.pluginVisitors[i], pluginPasses,
|
||||
this.opts.wrapPluginVisitorMethod);
|
||||
traverse(this.ast, visitor, this.scope);
|
||||
|
||||
this.log.debug("End transform traverse");
|
||||
@@ -610,14 +611,16 @@ export default class File extends Store {
|
||||
if (generator) {
|
||||
gen = require(generator).print;
|
||||
} else {
|
||||
throw new Error(`Couldn't find generator ${gen} with "print" method relative to directory ${dirname}`);
|
||||
throw new Error(`Couldn't find generator ${gen} with "print" method relative ` +
|
||||
`to directory ${dirname}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.log.debug("Generation start");
|
||||
|
||||
const _result = gen(ast, opts.generatorOpts ? Object.assign(opts, opts.generatorOpts) : opts, this.code);
|
||||
const _result = gen(ast, opts.generatorOpts ? Object.assign(opts, opts.generatorOpts) : opts,
|
||||
this.code);
|
||||
result.code = _result.code;
|
||||
result.map = _result.map;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* eslint max-len: 0 */
|
||||
/* eslint max-len: "off" */
|
||||
|
||||
module.exports = {
|
||||
filename: {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
/* eslint max-len: 0 */
|
||||
|
||||
import * as context from "../../../api/node";
|
||||
import type Logger from "../logger";
|
||||
import Plugin from "../../plugin";
|
||||
@@ -180,10 +178,13 @@ export default class OptionManager {
|
||||
// check for an unknown option
|
||||
if (!option && this.log) {
|
||||
if (removed[key]) {
|
||||
this.log.error(`Using removed Babel 5 option: ${alias}.${key} - ${removed[key].message}`, ReferenceError);
|
||||
this.log.error(`Using removed Babel 5 option: ${alias}.${key} - ${removed[key].message}`,
|
||||
ReferenceError);
|
||||
} else {
|
||||
/* eslint-disable max-len */
|
||||
const unknownOptErr = `Unknown option: ${alias}.${key}. Check out http://babeljs.io/docs/usage/options/ for more information about options.`;
|
||||
const presetConfigErr = "A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:\n\nInvalid:\n `{ presets: [{option: value}] }`\nValid:\n `{ presets: [['presetName', {option: value}]] }`\n\nFor more detailed information on preset configuration, please see http://babeljs.io/docs/plugins/#pluginpresets-options.";
|
||||
/* eslint-enable max-len */
|
||||
|
||||
this.log.error(`${unknownOptErr}\n\n${presetConfigErr}`, ReferenceError);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* eslint max-len: 0 */
|
||||
/* eslint max-len: "off" */
|
||||
|
||||
module.exports = {
|
||||
"auxiliaryComment": {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
/* eslint max-len: 0 */
|
||||
|
||||
import OptionManager from "./file/options/option-manager";
|
||||
import * as messages from "babel-messages";
|
||||
import Store from "../store";
|
||||
@@ -85,7 +83,8 @@ export default class Plugin extends Store {
|
||||
normaliseVisitor(visitor: Object): Object {
|
||||
for (const key of GLOBAL_VISITOR_PROPS) {
|
||||
if (visitor[key]) {
|
||||
throw new Error("Plugins aren't allowed to specify catch-all enter/exit handlers. Please target individual nodes.");
|
||||
throw new Error("Plugins aren't allowed to specify catch-all enter/exit handlers. " +
|
||||
"Please target individual nodes.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -265,6 +265,7 @@ describe("api", function () {
|
||||
|
||||
it("source map merging", function () {
|
||||
const result = babel.transform([
|
||||
/* eslint-disable max-len */
|
||||
"function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }",
|
||||
"",
|
||||
"let Foo = function Foo() {",
|
||||
@@ -272,6 +273,7 @@ describe("api", function () {
|
||||
"};",
|
||||
"",
|
||||
"//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0ZG91dCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztJQUFNLEdBQUcsWUFBSCxHQUFHO3dCQUFILEdBQUciLCJmaWxlIjoidW5kZWZpbmVkIiwic291cmNlc0NvbnRlbnQiOlsiY2xhc3MgRm9vIHt9XG4iXX0="
|
||||
/* eslint-enable max-len */
|
||||
].join("\n"), {
|
||||
sourceMap: true
|
||||
});
|
||||
@@ -329,12 +331,14 @@ describe("api", function () {
|
||||
};
|
||||
}]
|
||||
}).then(function (result) {
|
||||
assert.equal(result.code, "/*before*/start;\n/*after*/class Foo {}\n/*before*/end;\n/*after*/");
|
||||
assert.equal(result.code,
|
||||
"/*before*/start;\n/*after*/class Foo {}\n/*before*/end;\n/*after*/");
|
||||
});
|
||||
});
|
||||
|
||||
it("modules metadata", function () {
|
||||
return Promise.all([
|
||||
// eslint-disable-next-line max-len
|
||||
transformAsync("import { externalName as localName } from \"external\";").then(function (result) {
|
||||
assert.deepEqual(result.metadata.modules.imports[0], {
|
||||
source: "external",
|
||||
@@ -586,8 +590,10 @@ describe("api", function () {
|
||||
});
|
||||
|
||||
it("resolveModuleSource option", function () {
|
||||
/* eslint-disable max-len */
|
||||
const actual = "import foo from \"foo-import-default\";\nimport \"foo-import-bare\";\nexport { foo } from \"foo-export-named\";";
|
||||
const expected = "import foo from \"resolved/foo-import-default\";\nimport \"resolved/foo-import-bare\";\nexport { foo } from \"resolved/foo-export-named\";";
|
||||
/* eslint-enable max-len */
|
||||
|
||||
return transformAsync(actual, {
|
||||
resolveModuleSource: function (originalSource) {
|
||||
|
||||
@@ -35,6 +35,7 @@ describe("option-manager", () => {
|
||||
"blacklist": true
|
||||
});
|
||||
},
|
||||
// eslint-disable-next-line max-len
|
||||
/Using removed Babel 5 option: base.auxiliaryComment - Use `auxiliaryCommentBefore` or `auxiliaryCommentAfter`/
|
||||
);
|
||||
});
|
||||
@@ -59,6 +60,7 @@ describe("option-manager", () => {
|
||||
"presets": [{ option: "value" }]
|
||||
});
|
||||
},
|
||||
// eslint-disable-next-line max-len
|
||||
/Unknown option: foreign.option\.(?:.|\n)+A common cause of this error is the presence of a configuration options object without the corresponding preset name/
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user