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);
|
||||
});
|
||||
|
||||
@@ -29,48 +29,48 @@ describe("buildConfigChain", function () {
|
||||
|
||||
it("dir1", function () {
|
||||
const chain = buildConfigChain({
|
||||
filename: fixture("dir1", "src.js")
|
||||
filename: fixture("dir1", "src.js"),
|
||||
});
|
||||
|
||||
const expected = [
|
||||
{
|
||||
options: {
|
||||
plugins: [
|
||||
"extended"
|
||||
]
|
||||
"extended",
|
||||
],
|
||||
},
|
||||
alias: fixture("extended.babelrc.json"),
|
||||
loc: fixture("extended.babelrc.json"),
|
||||
dirname: fixture()
|
||||
dirname: fixture(),
|
||||
},
|
||||
{
|
||||
options: {
|
||||
plugins: [
|
||||
"root"
|
||||
]
|
||||
"root",
|
||||
],
|
||||
},
|
||||
alias: fixture(".babelrc"),
|
||||
loc: fixture(".babelrc"),
|
||||
dirname: fixture()
|
||||
dirname: fixture(),
|
||||
},
|
||||
{
|
||||
options: {
|
||||
ignore: [
|
||||
"root-ignore"
|
||||
]
|
||||
"root-ignore",
|
||||
],
|
||||
},
|
||||
alias: fixture(".babelignore"),
|
||||
loc: fixture(".babelignore"),
|
||||
dirname: fixture()
|
||||
dirname: fixture(),
|
||||
},
|
||||
{
|
||||
options: {
|
||||
filename: fixture("dir1", "src.js")
|
||||
filename: fixture("dir1", "src.js"),
|
||||
},
|
||||
alias: "base",
|
||||
loc: "base",
|
||||
dirname: fixture("dir1")
|
||||
}
|
||||
dirname: fixture("dir1"),
|
||||
},
|
||||
];
|
||||
|
||||
assert.deepEqual(chain, expected);
|
||||
@@ -78,38 +78,38 @@ describe("buildConfigChain", function () {
|
||||
|
||||
it("dir2", function () {
|
||||
const chain = buildConfigChain({
|
||||
filename: fixture("dir2", "src.js")
|
||||
filename: fixture("dir2", "src.js"),
|
||||
});
|
||||
|
||||
const expected = [
|
||||
{
|
||||
options: {
|
||||
plugins: [
|
||||
"dir2"
|
||||
]
|
||||
"dir2",
|
||||
],
|
||||
},
|
||||
alias: fixture("dir2", ".babelrc"),
|
||||
loc: fixture("dir2", ".babelrc"),
|
||||
dirname: fixture("dir2")
|
||||
dirname: fixture("dir2"),
|
||||
},
|
||||
{
|
||||
options: {
|
||||
ignore: [
|
||||
"root-ignore"
|
||||
]
|
||||
"root-ignore",
|
||||
],
|
||||
},
|
||||
alias: fixture(".babelignore"),
|
||||
loc: fixture(".babelignore"),
|
||||
dirname: fixture()
|
||||
dirname: fixture(),
|
||||
},
|
||||
{
|
||||
options: {
|
||||
filename: fixture("dir2", "src.js")
|
||||
filename: fixture("dir2", "src.js"),
|
||||
},
|
||||
alias: "base",
|
||||
loc: "base",
|
||||
dirname: fixture("dir2")
|
||||
}
|
||||
dirname: fixture("dir2"),
|
||||
},
|
||||
];
|
||||
|
||||
assert.deepEqual(chain, expected);
|
||||
@@ -117,38 +117,38 @@ describe("buildConfigChain", function () {
|
||||
|
||||
it("env - base", function () {
|
||||
const chain = buildConfigChain({
|
||||
filename: fixture("env", "src.js")
|
||||
filename: fixture("env", "src.js"),
|
||||
});
|
||||
|
||||
const expected = [
|
||||
{
|
||||
options: {
|
||||
plugins: [
|
||||
"env-base"
|
||||
]
|
||||
"env-base",
|
||||
],
|
||||
},
|
||||
alias: fixture("env", ".babelrc"),
|
||||
loc: fixture("env", ".babelrc"),
|
||||
dirname: fixture("env")
|
||||
dirname: fixture("env"),
|
||||
},
|
||||
{
|
||||
options: {
|
||||
ignore: [
|
||||
"root-ignore"
|
||||
]
|
||||
"root-ignore",
|
||||
],
|
||||
},
|
||||
alias: fixture(".babelignore"),
|
||||
loc: fixture(".babelignore"),
|
||||
dirname: fixture()
|
||||
dirname: fixture(),
|
||||
},
|
||||
{
|
||||
options: {
|
||||
filename: fixture("env", "src.js")
|
||||
filename: fixture("env", "src.js"),
|
||||
},
|
||||
alias: "base",
|
||||
loc: "base",
|
||||
dirname: fixture("env")
|
||||
}
|
||||
dirname: fixture("env"),
|
||||
},
|
||||
];
|
||||
|
||||
assert.deepEqual(chain, expected);
|
||||
@@ -158,48 +158,48 @@ describe("buildConfigChain", function () {
|
||||
process.env.NODE_ENV = "foo";
|
||||
|
||||
const chain = buildConfigChain({
|
||||
filename: fixture("env", "src.js")
|
||||
filename: fixture("env", "src.js"),
|
||||
});
|
||||
|
||||
const expected = [
|
||||
{
|
||||
options: {
|
||||
plugins: [
|
||||
"env-base"
|
||||
]
|
||||
"env-base",
|
||||
],
|
||||
},
|
||||
alias: fixture("env", ".babelrc"),
|
||||
loc: fixture("env", ".babelrc"),
|
||||
dirname: fixture("env")
|
||||
dirname: fixture("env"),
|
||||
},
|
||||
{
|
||||
options: {
|
||||
plugins: [
|
||||
"env-foo"
|
||||
]
|
||||
"env-foo",
|
||||
],
|
||||
},
|
||||
alias: fixture("env", ".babelrc.env.foo"),
|
||||
loc: fixture("env", ".babelrc.env.foo"),
|
||||
dirname: fixture("env")
|
||||
dirname: fixture("env"),
|
||||
},
|
||||
{
|
||||
options: {
|
||||
ignore: [
|
||||
"root-ignore"
|
||||
]
|
||||
"root-ignore",
|
||||
],
|
||||
},
|
||||
alias: fixture(".babelignore"),
|
||||
loc: fixture(".babelignore"),
|
||||
dirname: fixture()
|
||||
dirname: fixture(),
|
||||
},
|
||||
{
|
||||
options: {
|
||||
filename: fixture("env", "src.js")
|
||||
filename: fixture("env", "src.js"),
|
||||
},
|
||||
alias: "base",
|
||||
loc: "base",
|
||||
dirname: fixture("env")
|
||||
}
|
||||
dirname: fixture("env"),
|
||||
},
|
||||
];
|
||||
|
||||
assert.deepEqual(chain, expected);
|
||||
@@ -210,48 +210,48 @@ describe("buildConfigChain", function () {
|
||||
process.env.NODE_ENV = "bar";
|
||||
|
||||
const chain = buildConfigChain({
|
||||
filename: fixture("env", "src.js")
|
||||
filename: fixture("env", "src.js"),
|
||||
});
|
||||
|
||||
const expected = [
|
||||
{
|
||||
options: {
|
||||
plugins: [
|
||||
"env-base"
|
||||
]
|
||||
"env-base",
|
||||
],
|
||||
},
|
||||
alias: fixture("env", ".babelrc"),
|
||||
loc: fixture("env", ".babelrc"),
|
||||
dirname: fixture("env")
|
||||
dirname: fixture("env"),
|
||||
},
|
||||
{
|
||||
options: {
|
||||
plugins: [
|
||||
"env-bar"
|
||||
]
|
||||
"env-bar",
|
||||
],
|
||||
},
|
||||
alias: fixture("env", ".babelrc.env.bar"),
|
||||
loc: fixture("env", ".babelrc.env.bar"),
|
||||
dirname: fixture("env")
|
||||
dirname: fixture("env"),
|
||||
},
|
||||
{
|
||||
options: {
|
||||
ignore: [
|
||||
"root-ignore"
|
||||
]
|
||||
"root-ignore",
|
||||
],
|
||||
},
|
||||
alias: fixture(".babelignore"),
|
||||
loc: fixture(".babelignore"),
|
||||
dirname: fixture()
|
||||
dirname: fixture(),
|
||||
},
|
||||
{
|
||||
options: {
|
||||
filename: fixture("env", "src.js")
|
||||
filename: fixture("env", "src.js"),
|
||||
},
|
||||
alias: "base",
|
||||
loc: "base",
|
||||
dirname: fixture("env")
|
||||
}
|
||||
dirname: fixture("env"),
|
||||
},
|
||||
];
|
||||
|
||||
assert.deepEqual(chain, expected);
|
||||
@@ -262,34 +262,34 @@ describe("buildConfigChain", function () {
|
||||
process.env.NODE_ENV = "foo";
|
||||
|
||||
const chain = buildConfigChain({
|
||||
filename: fixture("pkg", "src.js")
|
||||
filename: fixture("pkg", "src.js"),
|
||||
});
|
||||
|
||||
const expected = [
|
||||
{
|
||||
options: {
|
||||
plugins: ["pkg-plugin"]
|
||||
plugins: ["pkg-plugin"],
|
||||
},
|
||||
alias: fixture("pkg", "package.json"),
|
||||
loc: fixture("pkg", "package.json"),
|
||||
dirname: fixture("pkg")
|
||||
dirname: fixture("pkg"),
|
||||
},
|
||||
{
|
||||
options: {
|
||||
ignore: ["pkg-ignore"]
|
||||
ignore: ["pkg-ignore"],
|
||||
},
|
||||
alias: fixture("pkg", ".babelignore"),
|
||||
loc: fixture("pkg", ".babelignore"),
|
||||
dirname: fixture("pkg")
|
||||
dirname: fixture("pkg"),
|
||||
},
|
||||
{
|
||||
options: {
|
||||
filename: fixture("pkg", "src.js")
|
||||
filename: fixture("pkg", "src.js"),
|
||||
},
|
||||
alias: "base",
|
||||
loc: "base",
|
||||
dirname: fixture("pkg")
|
||||
}
|
||||
dirname: fixture("pkg"),
|
||||
},
|
||||
];
|
||||
|
||||
assert.deepEqual(chain, expected);
|
||||
|
||||
@@ -14,7 +14,7 @@ describe("evaluation", function () {
|
||||
};
|
||||
|
||||
traverse(parse(code, {
|
||||
plugins: ["*"]
|
||||
plugins: ["*"],
|
||||
}), visitor);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,13 +10,13 @@ describe("getPossiblePresetNames", function () {
|
||||
assert.deepEqual(getPossiblePresetNames("@babel/es2015"), [
|
||||
"babel-preset-@babel/es2015",
|
||||
"@babel/es2015",
|
||||
"@babel/babel-preset-es2015"
|
||||
"@babel/babel-preset-es2015",
|
||||
]);
|
||||
|
||||
assert.deepEqual(getPossiblePresetNames("@babel/react/optimizations"), [
|
||||
"babel-preset-@babel/react/optimizations",
|
||||
"@babel/react/optimizations",
|
||||
"@babel/babel-preset-react/optimizations"
|
||||
"@babel/babel-preset-react/optimizations",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -19,7 +19,7 @@ describe("option-manager", () => {
|
||||
() => {
|
||||
const opt = new OptionManager(new Logger(null, "unknown"));
|
||||
opt.init({
|
||||
"randomOption": true
|
||||
"randomOption": true,
|
||||
});
|
||||
},
|
||||
/Unknown option: base.randomOption/
|
||||
@@ -32,7 +32,7 @@ describe("option-manager", () => {
|
||||
const opt = new OptionManager(new Logger(null, "unknown"));
|
||||
opt.init({
|
||||
"auxiliaryComment": true,
|
||||
"blacklist": true
|
||||
"blacklist": true,
|
||||
});
|
||||
},
|
||||
// eslint-disable-next-line max-len
|
||||
@@ -45,7 +45,7 @@ describe("option-manager", () => {
|
||||
() => {
|
||||
const opt = new OptionManager(new Logger(null, "unknown"));
|
||||
opt.init({
|
||||
"presets": [path.join(__dirname, "fixtures/option-manager/not-a-preset")]
|
||||
"presets": [path.join(__dirname, "fixtures/option-manager/not-a-preset")],
|
||||
});
|
||||
},
|
||||
/While processing preset: .*option-manager(?:\/|\\\\)not-a-preset\.js/
|
||||
@@ -58,7 +58,7 @@ describe("option-manager", () => {
|
||||
it(name, function () {
|
||||
const opt = new OptionManager(new Logger(null, "unknown"));
|
||||
const options = opt.init({
|
||||
"presets": [path.join(__dirname, "fixtures/option-manager/presets", name)]
|
||||
"presets": [path.join(__dirname, "fixtures/option-manager/presets", name)],
|
||||
});
|
||||
|
||||
assert.equal(true, Array.isArray(options.plugins));
|
||||
@@ -70,7 +70,7 @@ describe("option-manager", () => {
|
||||
it(name, function () {
|
||||
const opt = new OptionManager(new Logger(null, "unknown"));
|
||||
assert.throws(() => opt.init({
|
||||
"presets": [path.join(__dirname, "fixtures/option-manager/presets", name)]
|
||||
"presets": [path.join(__dirname, "fixtures/option-manager/presets", name)],
|
||||
}), msg);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ describe("traversal path", function () {
|
||||
visitor: {
|
||||
FunctionDeclaration: function (path) {
|
||||
path.replaceWithSourceString("console.whatever()");
|
||||
}
|
||||
}
|
||||
})]
|
||||
},
|
||||
},
|
||||
})],
|
||||
}).code;
|
||||
|
||||
chai.expect(actualCode).to.be.equal("console.whatever();");
|
||||
@@ -32,13 +32,13 @@ describe("traversal path", function () {
|
||||
type: "ReturnStatement",
|
||||
argument: {
|
||||
type: "BooleanLiteral",
|
||||
value: true
|
||||
}
|
||||
}]
|
||||
value: true,
|
||||
},
|
||||
}],
|
||||
});
|
||||
}
|
||||
}
|
||||
})]
|
||||
},
|
||||
},
|
||||
})],
|
||||
}).code;
|
||||
|
||||
chai.expect(actualCode).to.be.equal("var fn = () => {\n return true;\n};");
|
||||
@@ -53,11 +53,11 @@ describe("traversal path", function () {
|
||||
ArrowFunctionExpression: function (path) {
|
||||
path.get("body").replaceWith({
|
||||
type: "BooleanLiteral",
|
||||
value: true
|
||||
value: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
})]
|
||||
},
|
||||
},
|
||||
})],
|
||||
}).code;
|
||||
|
||||
chai.expect(actualCode).to.be.equal("var fn = () => true;");
|
||||
@@ -77,13 +77,13 @@ describe("traversal path", function () {
|
||||
type: "VariableDeclarator",
|
||||
id: {
|
||||
type: "Identifier",
|
||||
name: "KEY"
|
||||
}
|
||||
}]
|
||||
name: "KEY",
|
||||
},
|
||||
}],
|
||||
});
|
||||
}
|
||||
}
|
||||
})]
|
||||
},
|
||||
},
|
||||
})],
|
||||
}).code;
|
||||
|
||||
chai.expect(actualCode).to.be.equal("for (var KEY in right);");
|
||||
@@ -98,11 +98,11 @@ describe("traversal path", function () {
|
||||
ForInStatement: function (path) {
|
||||
path.get("left").replaceWith({
|
||||
type: "Identifier",
|
||||
name: "KEY"
|
||||
name: "KEY",
|
||||
});
|
||||
}
|
||||
}
|
||||
})]
|
||||
},
|
||||
},
|
||||
})],
|
||||
}).code;
|
||||
|
||||
chai.expect(actualCode).to.be.equal("for (KEY in right);");
|
||||
@@ -122,13 +122,13 @@ describe("traversal path", function () {
|
||||
type: "VariableDeclarator",
|
||||
id: {
|
||||
type: "Identifier",
|
||||
name: "KEY"
|
||||
}
|
||||
}]
|
||||
name: "KEY",
|
||||
},
|
||||
}],
|
||||
});
|
||||
}
|
||||
}
|
||||
})]
|
||||
},
|
||||
},
|
||||
})],
|
||||
}).code;
|
||||
|
||||
chai.expect(actualCode).to.be.equal("for (var KEY;;);");
|
||||
@@ -143,11 +143,11 @@ describe("traversal path", function () {
|
||||
ForStatement: function (path) {
|
||||
path.get("init").replaceWith({
|
||||
type: "Identifier",
|
||||
name: "KEY"
|
||||
name: "KEY",
|
||||
});
|
||||
}
|
||||
}
|
||||
})]
|
||||
},
|
||||
},
|
||||
})],
|
||||
}).code;
|
||||
|
||||
chai.expect(actualCode).to.be.equal("for (KEY;;);");
|
||||
|
||||
Reference in New Issue
Block a user