Run new lint rules (#5413)
This commit is contained in:
@@ -18,7 +18,7 @@ function transformAsync(code, opts) {
|
||||
return {
|
||||
then: function (resolve) {
|
||||
resolve(babel.transform(code, opts));
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ describe("parser and generator options", function() {
|
||||
},
|
||||
print: function(ast) {
|
||||
return generator(ast);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
function newTransform(string) {
|
||||
@@ -37,11 +37,11 @@ describe("parser and generator options", function() {
|
||||
parserOpts: {
|
||||
parser: recast.parse,
|
||||
plugins: ["flow"],
|
||||
allowImportExportEverywhere: true
|
||||
allowImportExportEverywhere: true,
|
||||
},
|
||||
generatorOpts: {
|
||||
generator: recast.print
|
||||
}
|
||||
generator: recast.print,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -56,8 +56,8 @@ describe("parser and generator options", function() {
|
||||
|
||||
assert.deepEqual(newTransform(experimental).ast, babel.transform(experimental, {
|
||||
parserOpts: {
|
||||
plugins: ["flow"]
|
||||
}
|
||||
plugins: ["flow"],
|
||||
},
|
||||
}).ast);
|
||||
assert.equal(newTransform(experimental).code, experimental);
|
||||
|
||||
@@ -65,18 +65,18 @@ describe("parser and generator options", function() {
|
||||
return babel.transform(string, {
|
||||
plugins: [__dirname + "/../../babel-plugin-syntax-flow"],
|
||||
parserOpts: {
|
||||
parser: recast.parse
|
||||
parser: recast.parse,
|
||||
},
|
||||
generatorOpts: {
|
||||
generator: recast.print
|
||||
}
|
||||
generator: recast.print,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
assert.deepEqual(newTransformWithPlugins(experimental).ast, babel.transform(experimental, {
|
||||
parserOpts: {
|
||||
plugins: ["flow"]
|
||||
}
|
||||
plugins: ["flow"],
|
||||
},
|
||||
}).ast);
|
||||
assert.equal(newTransformWithPlugins(experimental).code, experimental);
|
||||
});
|
||||
@@ -86,8 +86,8 @@ describe("parser and generator options", function() {
|
||||
|
||||
assert.notEqual(newTransform(experimental).ast, babel.transform(experimental, {
|
||||
parserOpts: {
|
||||
allowImportExportEverywhere: true
|
||||
}
|
||||
allowImportExportEverywhere: true,
|
||||
},
|
||||
}).ast);
|
||||
assert.equal(newTransform(experimental).code, experimental);
|
||||
});
|
||||
@@ -102,15 +102,15 @@ describe("api", function () {
|
||||
visitor: {
|
||||
Program: function (path) {
|
||||
path.mark("category", "foobar");
|
||||
}
|
||||
}
|
||||
})]
|
||||
},
|
||||
},
|
||||
})],
|
||||
}).marked[0].message, "foobar");
|
||||
|
||||
assert.equal(babel.analyse("foobar;", {}, {
|
||||
Program: function (path) {
|
||||
path.mark("category", "foobar");
|
||||
}
|
||||
},
|
||||
}).marked[0].message, "foobar");
|
||||
});
|
||||
|
||||
@@ -138,7 +138,7 @@ describe("api", function () {
|
||||
return assert.throws(
|
||||
function () {
|
||||
babel.transform("", {
|
||||
plugins: [__dirname + "/../../babel-plugin-syntax-jsx", false]
|
||||
plugins: [__dirname + "/../../babel-plugin-syntax-jsx", false],
|
||||
});
|
||||
},
|
||||
/TypeError: Falsy value found in plugins/
|
||||
@@ -148,7 +148,7 @@ describe("api", function () {
|
||||
it("options merge backwards", function () {
|
||||
return transformAsync("", {
|
||||
presets: [__dirname + "/../../babel-preset-es2015"],
|
||||
plugins: [__dirname + "/../../babel-plugin-syntax-jsx"]
|
||||
plugins: [__dirname + "/../../babel-plugin-syntax-jsx"],
|
||||
}).then(function (result) {
|
||||
assert.ok(result.options.plugins[0][0].manipulateOptions.toString().indexOf("jsx") >= 0);
|
||||
});
|
||||
@@ -177,9 +177,9 @@ describe("api", function () {
|
||||
visitor: {
|
||||
"Program|Identifier": function () {
|
||||
calledRaw++;
|
||||
}
|
||||
}
|
||||
})]
|
||||
},
|
||||
},
|
||||
})],
|
||||
});
|
||||
|
||||
assert.equal(calledRaw, 4);
|
||||
@@ -212,10 +212,10 @@ describe("api", function () {
|
||||
// In case of `passPerPreset` being `true`, the
|
||||
// alias node should still exist.
|
||||
aliasBaseType = alias.right.type; // NumberTypeAnnotation
|
||||
}
|
||||
}
|
||||
})
|
||||
]
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
};
|
||||
},
|
||||
|
||||
@@ -228,9 +228,9 @@ describe("api", function () {
|
||||
plugins: [
|
||||
require(__dirname + "/../../babel-plugin-syntax-flow"),
|
||||
require(__dirname + "/../../babel-plugin-transform-flow-strip-types"),
|
||||
]
|
||||
],
|
||||
};
|
||||
}
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
@@ -246,7 +246,7 @@ describe("api", function () {
|
||||
"",
|
||||
"var x = function x(y) {",
|
||||
" return y;",
|
||||
"};"
|
||||
"};",
|
||||
].join("\n"), result.code);
|
||||
|
||||
// 2. passPerPreset: false
|
||||
@@ -262,7 +262,7 @@ describe("api", function () {
|
||||
"",
|
||||
"var x = function x(y) {",
|
||||
" return y;",
|
||||
"};"
|
||||
"};",
|
||||
].join("\n"), result.code);
|
||||
|
||||
});
|
||||
@@ -276,10 +276,10 @@ describe("api", function () {
|
||||
" _classCallCheck(this, Foo);",
|
||||
"};",
|
||||
"",
|
||||
"//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0ZG91dCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztJQUFNLEdBQUcsWUFBSCxHQUFHO3dCQUFILEdBQUciLCJmaWxlIjoidW5kZWZpbmVkIiwic291cmNlc0NvbnRlbnQiOlsiY2xhc3MgRm9vIHt9XG4iXX0="
|
||||
"//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0ZG91dCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztJQUFNLEdBQUcsWUFBSCxHQUFHO3dCQUFILEdBQUciLCJmaWxlIjoidW5kZWZpbmVkIiwic291cmNlc0NvbnRlbnQiOlsiY2xhc3MgRm9vIHt9XG4iXX0=",
|
||||
/* eslint-enable max-len */
|
||||
].join("\n"), {
|
||||
sourceMap: true
|
||||
sourceMap: true,
|
||||
});
|
||||
|
||||
assert.deepEqual([
|
||||
@@ -291,19 +291,19 @@ describe("api", function () {
|
||||
"",
|
||||
"let Foo = function Foo() {",
|
||||
" _classCallCheck(this, Foo);",
|
||||
"};"
|
||||
"};",
|
||||
].join("\n"), result.code);
|
||||
|
||||
const consumer = new sourceMap.SourceMapConsumer(result.map);
|
||||
|
||||
assert.deepEqual(consumer.originalPositionFor({
|
||||
line: 7,
|
||||
column: 4
|
||||
column: 4,
|
||||
}), {
|
||||
name: null,
|
||||
source: "stdout",
|
||||
line: 1,
|
||||
column: 6
|
||||
column: 6,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -330,10 +330,10 @@ describe("api", function () {
|
||||
Program: function (path) {
|
||||
path.unshiftContainer("body", t.expressionStatement(t.identifier("start")));
|
||||
path.pushContainer("body", t.expressionStatement(t.identifier("end")));
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
}]
|
||||
}],
|
||||
}).then(function (result) {
|
||||
assert.equal(result.code,
|
||||
"/*before*/start;\n/*after*/class Foo {}\n/*before*/end;\n/*after*/");
|
||||
@@ -350,8 +350,8 @@ describe("api", function () {
|
||||
specifiers: [{
|
||||
kind: "named",
|
||||
imported: "externalName",
|
||||
local: "localName"
|
||||
}]
|
||||
local: "localName",
|
||||
}],
|
||||
});
|
||||
}),
|
||||
|
||||
@@ -361,8 +361,8 @@ describe("api", function () {
|
||||
imported: ["*"],
|
||||
specifiers: [{
|
||||
kind: "namespace",
|
||||
local: "localName2"
|
||||
}]
|
||||
local: "localName2",
|
||||
}],
|
||||
});
|
||||
}),
|
||||
|
||||
@@ -373,15 +373,15 @@ describe("api", function () {
|
||||
specifiers: [{
|
||||
kind: "named",
|
||||
imported: "default",
|
||||
local: "localName3"
|
||||
}]
|
||||
local: "localName3",
|
||||
}],
|
||||
});
|
||||
}),
|
||||
|
||||
transformAsync("import localName from \"./array\";", {
|
||||
resolveModuleSource: function() {
|
||||
return "override-source";
|
||||
}
|
||||
},
|
||||
}).then(function (result) {
|
||||
assert.deepEqual(result.metadata.modules.imports, [
|
||||
{
|
||||
@@ -391,15 +391,15 @@ describe("api", function () {
|
||||
{
|
||||
"kind": "named",
|
||||
"imported": "default",
|
||||
"local": "localName"
|
||||
}
|
||||
]
|
||||
}
|
||||
"local": "localName",
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
}),
|
||||
|
||||
transformAsync("export * as externalName1 from \"external\";", {
|
||||
plugins: [require("../../babel-plugin-syntax-export-extensions")]
|
||||
plugins: [require("../../babel-plugin-syntax-export-extensions")],
|
||||
}).then(function (result) {
|
||||
assert.deepEqual(result.metadata.modules.exports, {
|
||||
exported: ["externalName1"],
|
||||
@@ -407,12 +407,12 @@ describe("api", function () {
|
||||
kind: "external-namespace",
|
||||
exported: "externalName1",
|
||||
source: "external",
|
||||
}]
|
||||
}],
|
||||
});
|
||||
}),
|
||||
|
||||
transformAsync("export externalName2 from \"external\";", {
|
||||
plugins: [require("../../babel-plugin-syntax-export-extensions")]
|
||||
plugins: [require("../../babel-plugin-syntax-export-extensions")],
|
||||
}).then(function (result) {
|
||||
assert.deepEqual(result.metadata.modules.exports, {
|
||||
exported: ["externalName2"],
|
||||
@@ -420,8 +420,8 @@ describe("api", function () {
|
||||
kind: "external",
|
||||
local: "externalName2",
|
||||
exported: "externalName2",
|
||||
source: "external"
|
||||
}]
|
||||
source: "external",
|
||||
}],
|
||||
});
|
||||
}),
|
||||
|
||||
@@ -431,8 +431,8 @@ describe("api", function () {
|
||||
specifiers: [{
|
||||
kind: "local",
|
||||
local: "namedFunction",
|
||||
exported: "namedFunction"
|
||||
}]
|
||||
exported: "namedFunction",
|
||||
}],
|
||||
});
|
||||
}),
|
||||
|
||||
@@ -442,8 +442,8 @@ describe("api", function () {
|
||||
specifiers: [{
|
||||
kind: "local",
|
||||
local: "foo",
|
||||
exported: "foo"
|
||||
}]
|
||||
exported: "foo",
|
||||
}],
|
||||
});
|
||||
}),
|
||||
|
||||
@@ -453,8 +453,8 @@ describe("api", function () {
|
||||
specifiers: [{
|
||||
kind: "local",
|
||||
local: "localName",
|
||||
exported: "externalName3"
|
||||
}]
|
||||
exported: "externalName3",
|
||||
}],
|
||||
});
|
||||
}),
|
||||
|
||||
@@ -465,8 +465,8 @@ describe("api", function () {
|
||||
kind: "external",
|
||||
local: "externalName4",
|
||||
exported: "externalName4",
|
||||
source: "external"
|
||||
}]
|
||||
source: "external",
|
||||
}],
|
||||
});
|
||||
}),
|
||||
|
||||
@@ -475,8 +475,8 @@ describe("api", function () {
|
||||
exported: [],
|
||||
specifiers: [{
|
||||
kind: "external-all",
|
||||
source: "external"
|
||||
}]
|
||||
source: "external",
|
||||
}],
|
||||
});
|
||||
}),
|
||||
|
||||
@@ -486,10 +486,10 @@ describe("api", function () {
|
||||
specifiers: [{
|
||||
kind: "local",
|
||||
local: "defaultFunction",
|
||||
exported: "default"
|
||||
}]
|
||||
exported: "default",
|
||||
}],
|
||||
});
|
||||
})
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -497,18 +497,18 @@ describe("api", function () {
|
||||
return Promise.all([
|
||||
transformAsync("", {
|
||||
ignore: "node_modules",
|
||||
filename: "/foo/node_modules/bar"
|
||||
filename: "/foo/node_modules/bar",
|
||||
}).then(assertIgnored),
|
||||
|
||||
transformAsync("", {
|
||||
ignore: "foo/node_modules",
|
||||
filename: "/foo/node_modules/bar"
|
||||
filename: "/foo/node_modules/bar",
|
||||
}).then(assertIgnored),
|
||||
|
||||
transformAsync("", {
|
||||
ignore: "foo/node_modules/*.bar",
|
||||
filename: "/foo/node_modules/foo.bar"
|
||||
}).then(assertIgnored)
|
||||
filename: "/foo/node_modules/foo.bar",
|
||||
}).then(assertIgnored),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -516,33 +516,33 @@ describe("api", function () {
|
||||
return Promise.all([
|
||||
transformAsync("", {
|
||||
only: "node_modules",
|
||||
filename: "/foo/node_modules/bar"
|
||||
filename: "/foo/node_modules/bar",
|
||||
}).then(assertNotIgnored),
|
||||
|
||||
transformAsync("", {
|
||||
only: "foo/node_modules",
|
||||
filename: "/foo/node_modules/bar"
|
||||
filename: "/foo/node_modules/bar",
|
||||
}).then(assertNotIgnored),
|
||||
|
||||
transformAsync("", {
|
||||
only: "foo/node_modules/*.bar",
|
||||
filename: "/foo/node_modules/foo.bar"
|
||||
filename: "/foo/node_modules/foo.bar",
|
||||
}).then(assertNotIgnored),
|
||||
|
||||
transformAsync("", {
|
||||
only: "node_modules",
|
||||
filename: "/foo/node_module/bar"
|
||||
filename: "/foo/node_module/bar",
|
||||
}).then(assertIgnored),
|
||||
|
||||
transformAsync("", {
|
||||
only: "foo/node_modules",
|
||||
filename: "/bar/node_modules/foo"
|
||||
filename: "/bar/node_modules/foo",
|
||||
}).then(assertIgnored),
|
||||
|
||||
transformAsync("", {
|
||||
only: "foo/node_modules/*.bar",
|
||||
filename: "/foo/node_modules/bar.foo"
|
||||
}).then(assertIgnored)
|
||||
filename: "/foo/node_modules/bar.foo",
|
||||
}).then(assertIgnored),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -565,8 +565,8 @@ describe("api", function () {
|
||||
it("default", function () {
|
||||
const result = babel.transform("foo;", {
|
||||
env: {
|
||||
development: { code: false }
|
||||
}
|
||||
development: { code: false },
|
||||
},
|
||||
});
|
||||
|
||||
assert.equal(result.code, undefined);
|
||||
@@ -576,8 +576,8 @@ describe("api", function () {
|
||||
process.env.BABEL_ENV = "foo";
|
||||
const result = babel.transform("foo;", {
|
||||
env: {
|
||||
foo: { code: false }
|
||||
}
|
||||
foo: { code: false },
|
||||
},
|
||||
});
|
||||
assert.equal(result.code, undefined);
|
||||
});
|
||||
@@ -586,8 +586,8 @@ describe("api", function () {
|
||||
process.env.NODE_ENV = "foo";
|
||||
const result = babel.transform("foo;", {
|
||||
env: {
|
||||
foo: { code: false }
|
||||
}
|
||||
foo: { code: false },
|
||||
},
|
||||
});
|
||||
assert.equal(result.code, undefined);
|
||||
});
|
||||
@@ -602,7 +602,7 @@ describe("api", function () {
|
||||
return transformAsync(actual, {
|
||||
resolveModuleSource: function (originalSource) {
|
||||
return "resolved/" + originalSource;
|
||||
}
|
||||
},
|
||||
}).then(function (result) {
|
||||
assert.equal(result.code.trim(), expected);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user