fix prettierignore file and run prettier

This commit is contained in:
Tobias Koppers 2019-02-18 09:09:46 +01:00
부모 75c2784bc5
커밋 75a9a515fd
9개의 변경된 파일236개의 추가작업 그리고 249개의 파일을 삭제

파일 보기

@ -1,8 +1,8 @@
# Ignore test fixtures
test
test/*.*
!test/*.js
!test/**/webpack.config.js
# Ignore example fixtures
examples
examples/*.*
!examples/**/webpack.config.js

파일 보기

@ -279,63 +279,57 @@ describe("BenchmarkTestCases", function() {
describe(`${testName} create benchmarks`, function() {
baselines.forEach(baseline => {
let baselineStats = null;
it(
`should benchmark ${baseline.name} (${baseline.rev})`,
function(done) {
const outputDirectory = path.join(
__dirname,
"js",
"benchmark",
`baseline-${baseline.name}`,
testName
);
const config =
Object.create(
require.requireActual(
path.join(testDirectory, "webpack.config.js")
)
) || {};
config.output = Object.create(config.output || {});
if (!config.context) config.context = testDirectory;
if (!config.output.path) config.output.path = outputDirectory;
runBenchmark(baseline.webpack, config, (err, stats) => {
if (err) return done(err);
process.stderr.write(` ${baseline.name} ${stats.text}`);
if (baseline.name === "HEAD") headStats = stats;
else baselineStats = stats;
done();
});
},
180000
);
it(
`should benchmark ${baseline.name} (${baseline.rev})`,
done => {
const outputDirectory = path.join(
__dirname,
"js",
"benchmark",
`baseline-${baseline.name}`,
testName
);
const config =
it(`should benchmark ${baseline.name} (${
baseline.rev
})`, function(done) {
const outputDirectory = path.join(
__dirname,
"js",
"benchmark",
`baseline-${baseline.name}`,
testName
);
const config =
Object.create(
require.requireActual(
path.join(testDirectory, "webpack.config.js")
) || {};
config.output = config.output || {};
if (!config.context) config.context = testDirectory;
if (!config.output.path) config.output.path = outputDirectory;
runBenchmark(baseline.webpack, config, (err, stats) => {
if (err) return done(err);
process.stderr.write(` ${baseline.name} ${stats.text}`);
if (baseline.name === "HEAD") headStats = stats;
else baselineStats = stats;
done();
});
},
180000
);
)
) || {};
config.output = Object.create(config.output || {});
if (!config.context) config.context = testDirectory;
if (!config.output.path) config.output.path = outputDirectory;
runBenchmark(baseline.webpack, config, (err, stats) => {
if (err) return done(err);
process.stderr.write(` ${baseline.name} ${stats.text}`);
if (baseline.name === "HEAD") headStats = stats;
else baselineStats = stats;
done();
});
}, 180000);
it(`should benchmark ${baseline.name} (${baseline.rev})`, done => {
const outputDirectory = path.join(
__dirname,
"js",
"benchmark",
`baseline-${baseline.name}`,
testName
);
const config =
require.requireActual(
path.join(testDirectory, "webpack.config.js")
) || {};
config.output = config.output || {};
if (!config.context) config.context = testDirectory;
if (!config.output.path) config.output.path = outputDirectory;
runBenchmark(baseline.webpack, config, (err, stats) => {
if (err) return done(err);
process.stderr.write(` ${baseline.name} ${stats.text}`);
if (baseline.name === "HEAD") headStats = stats;
else baselineStats = stats;
done();
});
}, 180000);
if (baseline.name !== "HEAD") {
it(`HEAD should not be slower than ${baseline.name} (${

파일 보기

@ -503,9 +503,9 @@ describe("Compiler", () => {
output: {
path: "/",
filename: "bundle.js"
},
}
});
compiler.hooks.failed.tap('CompilerTest', failedSpy);
compiler.hooks.failed.tap("CompilerTest", failedSpy);
compiler.outputFileSystem = new MemoryFs();
compiler.run((err, stats) => {
expect(err).toBeTruthy();

파일 보기

@ -58,14 +58,16 @@ describe("SourceMapDevToolModuleOptionsPlugin", () => {
});
describe("with line-to-line true", () => {
beforeEach(() =>
(eventBindings = applyPluginWithOptions(
SourceMapDevToolModuleOptionsPlugin,
{
module: false,
lineToLine: true
}
)));
beforeEach(
() =>
(eventBindings = applyPluginWithOptions(
SourceMapDevToolModuleOptionsPlugin,
{
module: false,
lineToLine: true
}
))
);
it("binds one event handler", () => {
expect(eventBindings.length).toBe(1);

파일 보기

@ -4,11 +4,28 @@
const Stats = require("../lib/Stats");
const packageJson = require("../package.json");
describe(
"Stats",
() => {
describe("formatFilePath", () => {
it("emit the file path and request", () => {
describe("Stats", () => {
describe("formatFilePath", () => {
it("emit the file path and request", () => {
const mockStats = new Stats({
children: [],
errors: ["firstError"],
hash: "1234",
compiler: {
context: ""
}
});
const inputPath =
"./node_modules/ts-loader!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/app.vue";
const expectPath = `./src/app.vue (${inputPath})`;
expect(mockStats.formatFilePath(inputPath)).toBe(expectPath);
});
});
describe("Error Handling", () => {
describe("does have", () => {
it("hasErrors", () => {
const mockStats = new Stats({
children: [],
errors: ["firstError"],
@ -17,193 +34,172 @@ describe(
context: ""
}
});
const inputPath =
"./node_modules/ts-loader!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/app.vue";
const expectPath = `./src/app.vue (${inputPath})`;
expect(mockStats.formatFilePath(inputPath)).toBe(expectPath);
expect(mockStats.hasErrors()).toBe(true);
});
});
describe("Error Handling", () => {
describe("does have", () => {
it("hasErrors", () => {
const mockStats = new Stats({
children: [],
errors: ["firstError"],
hash: "1234",
compiler: {
context: ""
}
});
expect(mockStats.hasErrors()).toBe(true);
});
it("hasWarnings", () => {
const mockStats = new Stats({
children: [],
warnings: ["firstError"],
hash: "1234",
compiler: {
context: ""
}
});
expect(mockStats.hasWarnings()).toBe(true);
});
});
describe("does not have", () => {
it("hasErrors", () => {
const mockStats = new Stats({
children: [],
errors: [],
hash: "1234",
compiler: {
context: ""
}
});
expect(mockStats.hasErrors()).toBe(false);
});
it("hasWarnings", () => {
const mockStats = new Stats({
children: [],
warnings: [],
hash: "1234",
compiler: {
context: ""
}
});
expect(mockStats.hasWarnings()).toBe(false);
});
});
describe("children have", () => {
it("hasErrors", () => {
const mockStats = new Stats({
children: [
{
getStats: () =>
new Stats({
errors: ["firstError"],
hash: "5678"
})
}
],
errors: [],
hash: "1234"
});
expect(mockStats.hasErrors()).toBe(true);
});
it("hasWarnings", () => {
const mockStats = new Stats({
children: [
{
getStats: () =>
new Stats({
warnings: ["firstError"],
hash: "5678"
})
}
],
warnings: [],
hash: "1234"
});
expect(mockStats.hasWarnings()).toBe(true);
});
});
it("formatError handles string errors", () => {
it("hasWarnings", () => {
const mockStats = new Stats({
errors: ["firstError"],
warnings: [],
assets: [],
entrypoints: new Map(),
namedChunkGroups: new Map(),
chunks: [],
modules: [],
children: [],
warnings: ["firstError"],
hash: "1234",
mainTemplate: {
outputOptions: {
path: ""
},
getPublicPath: () => "path"
},
compiler: {
context: ""
}
});
const obj = mockStats.toJson();
expect(obj.errors[0]).toEqual("firstError");
expect(mockStats.hasWarnings()).toBe(true);
});
});
describe("toJson", () => {
it("returns plain object representation", () => {
describe("does not have", () => {
it("hasErrors", () => {
const mockStats = new Stats({
errors: [],
warnings: [],
assets: [],
entrypoints: new Map(),
chunks: [],
namedChunkGroups: new Map(),
modules: [],
children: [],
errors: [],
hash: "1234",
mainTemplate: {
outputOptions: {
path: "/"
},
getPublicPath: () => "path"
},
compiler: {
context: ""
}
});
const result = mockStats.toJson();
expect(result).toEqual({
assets: [],
assetsByChunkName: {},
expect(mockStats.hasErrors()).toBe(false);
});
it("hasWarnings", () => {
const mockStats = new Stats({
children: [],
chunks: [],
entrypoints: {},
namedChunkGroups: {},
filteredAssets: 0,
filteredModules: 0,
errors: [],
warnings: [],
hash: "1234",
modules: [],
outputPath: "/",
publicPath: "path",
version: packageJson.version,
warnings: []
compiler: {
context: ""
}
});
expect(mockStats.hasWarnings()).toBe(false);
});
});
describe("Presets", () => {
describe("presetToOptions", () => {
it("returns correct object with 'Normal'", () => {
expect(Stats.presetToOptions("Normal")).toEqual({});
describe("children have", () => {
it("hasErrors", () => {
const mockStats = new Stats({
children: [
{
getStats: () =>
new Stats({
errors: ["firstError"],
hash: "5678"
})
}
],
errors: [],
hash: "1234"
});
it("truthy values behave as 'normal'", () => {
const normalOpts = Stats.presetToOptions("normal");
expect(Stats.presetToOptions("pizza")).toEqual(normalOpts);
expect(Stats.presetToOptions(true)).toEqual(normalOpts);
expect(Stats.presetToOptions(1)).toEqual(normalOpts);
expect(mockStats.hasErrors()).toBe(true);
});
it("hasWarnings", () => {
const mockStats = new Stats({
children: [
{
getStats: () =>
new Stats({
warnings: ["firstError"],
hash: "5678"
})
}
],
warnings: [],
hash: "1234"
});
expect(mockStats.hasWarnings()).toBe(true);
});
});
it("formatError handles string errors", () => {
const mockStats = new Stats({
errors: ["firstError"],
warnings: [],
assets: [],
entrypoints: new Map(),
namedChunkGroups: new Map(),
chunks: [],
modules: [],
children: [],
hash: "1234",
mainTemplate: {
outputOptions: {
path: ""
},
getPublicPath: () => "path"
},
compiler: {
context: ""
}
});
const obj = mockStats.toJson();
expect(obj.errors[0]).toEqual("firstError");
});
});
describe("toJson", () => {
it("returns plain object representation", () => {
const mockStats = new Stats({
errors: [],
warnings: [],
assets: [],
entrypoints: new Map(),
chunks: [],
namedChunkGroups: new Map(),
modules: [],
children: [],
hash: "1234",
mainTemplate: {
outputOptions: {
path: "/"
},
getPublicPath: () => "path"
},
compiler: {
context: ""
}
});
const result = mockStats.toJson();
expect(result).toEqual({
assets: [],
assetsByChunkName: {},
children: [],
chunks: [],
entrypoints: {},
namedChunkGroups: {},
filteredAssets: 0,
filteredModules: 0,
errors: [],
hash: "1234",
modules: [],
outputPath: "/",
publicPath: "path",
version: packageJson.version,
warnings: []
});
});
});
describe("Presets", () => {
describe("presetToOptions", () => {
it("returns correct object with 'Normal'", () => {
expect(Stats.presetToOptions("Normal")).toEqual({});
});
it("truthy values behave as 'normal'", () => {
const normalOpts = Stats.presetToOptions("normal");
expect(Stats.presetToOptions("pizza")).toEqual(normalOpts);
expect(Stats.presetToOptions(true)).toEqual(normalOpts);
expect(Stats.presetToOptions(1)).toEqual(normalOpts);
expect(Stats.presetToOptions("verbose")).not.toEqual(normalOpts);
expect(Stats.presetToOptions(false)).not.toEqual(normalOpts);
});
it("returns correct object with 'none'", () => {
expect(Stats.presetToOptions("none")).toEqual({
all: false
});
});
it("falsy values behave as 'none'", () => {
const noneOpts = Stats.presetToOptions("none");
expect(Stats.presetToOptions("")).toEqual(noneOpts);
expect(Stats.presetToOptions(null)).toEqual(noneOpts);
expect(Stats.presetToOptions()).toEqual(noneOpts);
expect(Stats.presetToOptions(0)).toEqual(noneOpts);
expect(Stats.presetToOptions(false)).toEqual(noneOpts);
expect(Stats.presetToOptions("verbose")).not.toEqual(normalOpts);
expect(Stats.presetToOptions(false)).not.toEqual(normalOpts);
});
it("returns correct object with 'none'", () => {
expect(Stats.presetToOptions("none")).toEqual({
all: false
});
});
it("falsy values behave as 'none'", () => {
const noneOpts = Stats.presetToOptions("none");
expect(Stats.presetToOptions("")).toEqual(noneOpts);
expect(Stats.presetToOptions(null)).toEqual(noneOpts);
expect(Stats.presetToOptions()).toEqual(noneOpts);
expect(Stats.presetToOptions(0)).toEqual(noneOpts);
expect(Stats.presetToOptions(false)).toEqual(noneOpts);
});
});
},
10000
);
});
}, 10000);

파일 보기

@ -7,9 +7,7 @@ module.exports = {
output: {
filename: "[name].js"
},
plugins: [
new IgnorePlugin(/intentionally-missing-module/)
],
plugins: [new IgnorePlugin(/intentionally-missing-module/)],
node: {
__dirname: false
}

파일 보기

@ -1,4 +1,4 @@
const Compiler = require('../../../../lib/Compiler');
const Compiler = require("../../../../lib/Compiler");
module.exports = {
optimization: {
@ -7,12 +7,12 @@ module.exports = {
{
apply(compiler) {
expect(compiler).toBeInstanceOf(Compiler);
},
}
},
function(compiler) {
expect(compiler).toBe(this);
expect(compiler).toBeInstanceOf(Compiler);
}
],
},
]
}
};

파일 보기

@ -103,5 +103,5 @@ module.exports = [
}
},
stats
},
}
];

파일 보기

@ -8,12 +8,9 @@ const valueFile = path.resolve(
module.exports = {
plugins: [
new webpack.DefinePlugin({
TEST_VALUE: webpack.DefinePlugin.runtimeValue(
() => {
return JSON.stringify(fs.readFileSync(valueFile, "utf-8").trim());
},
[valueFile]
),
TEST_VALUE: webpack.DefinePlugin.runtimeValue(() => {
return JSON.stringify(fs.readFileSync(valueFile, "utf-8").trim());
}, [valueFile]),
TEST_VALUE2: webpack.DefinePlugin.runtimeValue(() => {
return JSON.stringify(fs.readFileSync(valueFile, "utf-8").trim());
}, []),