Run gulp lint --fix, to account for changes in Prettier version 2.2.1

Please refer to https://github.com/prettier/prettier/blob/master/CHANGELOG.md#221 for additional details.
This commit is contained in:
Jonas Jenwald 2020-11-29 09:59:03 +01:00
parent cd2e6d803a
commit c42029489e
7 changed files with 358 additions and 345 deletions

View File

@ -202,14 +202,14 @@ function preprocessCSS(mode, source, destination) {
} }
function expandImports(content, baseUrl) { function expandImports(content, baseUrl) {
return content.replace(/^\s*@import\s+url\(([^)]+)\);\s*$/gm, function ( return content.replace(
all, /^\s*@import\s+url\(([^)]+)\);\s*$/gm,
url function (all, url) {
) {
var file = path.join(path.dirname(baseUrl), url); var file = path.join(path.dirname(baseUrl), url);
var imported = fs.readFileSync(file, "utf8").toString(); var imported = fs.readFileSync(file, "utf8").toString();
return expandImports(imported, file); return expandImports(imported, file);
}); }
);
} }
function removePrefixed(content, hasPrefixedFilter) { function removePrefixed(content, hasPrefixedFilter) {

View File

@ -577,17 +577,17 @@ gulp.task("buildnumber", function (done) {
console.log(); console.log();
console.log("### Getting extension build number"); console.log("### Getting extension build number");
exec("git log --format=oneline " + config.baseVersion + "..", function ( exec(
err, "git log --format=oneline " + config.baseVersion + "..",
stdout, function (err, stdout, stderr) {
stderr
) {
var buildNumber = 0; var buildNumber = 0;
if (!err) { if (!err) {
// Build number is the number of commits since base version // Build number is the number of commits since base version
buildNumber = stdout ? stdout.match(/\n/g).length : 0; buildNumber = stdout ? stdout.match(/\n/g).length : 0;
} else { } else {
console.log("This is not a Git repository; using default build number."); console.log(
"This is not a Git repository; using default build number."
);
} }
console.log("Extension build number: " + buildNumber); console.log("Extension build number: " + buildNumber);
@ -615,7 +615,8 @@ gulp.task("buildnumber", function (done) {
.pipe(gulp.dest(BUILD_DIR)) .pipe(gulp.dest(BUILD_DIR))
.on("end", done); .on("end", done);
}); });
}); }
);
}); });
gulp.task("default_preferences-pre", function () { gulp.task("default_preferences-pre", function () {
@ -1619,9 +1620,10 @@ gulp.task("baseline", function (done) {
return; return;
} }
exec("git checkout " + baselineCommit, { cwd: workingDirectory }, function ( exec(
error2 "git checkout " + baselineCommit,
) { { cwd: workingDirectory },
function (error2) {
if (error2) { if (error2) {
done(new Error("Baseline commit checkout failed.")); done(new Error("Baseline commit checkout failed."));
return; return;
@ -1629,7 +1631,8 @@ gulp.task("baseline", function (done) {
console.log('Baseline commit "' + baselineCommit + '" checked out.'); console.log('Baseline commit "' + baselineCommit + '" checked out.');
done(); done();
}); }
);
}); });
}); });

View File

@ -994,11 +994,13 @@ var CMapFactory = (function CMapFactoryClosure() {
var cMap = new CMap(true); var cMap = new CMap(true);
if (compressionType === CMapCompressionType.BINARY) { if (compressionType === CMapCompressionType.BINARY) {
return new BinaryCMapReader().process(cMapData, cMap, function ( return new BinaryCMapReader().process(
useCMap cMapData,
) { cMap,
function (useCMap) {
return extendCMap(cMap, fetchBuiltInCMap, useCMap); return extendCMap(cMap, fetchBuiltInCMap, useCMap);
}); }
);
} }
if (compressionType === CMapCompressionType.NONE) { if (compressionType === CMapCompressionType.NONE) {
var lexer = new Lexer(new Stream(cMapData)); var lexer = new Lexer(new Stream(cMapData));

View File

@ -533,11 +533,9 @@ class WorkerMessageHandler {
return pdfManager.ensureDoc("calculationOrderIds"); return pdfManager.ensureDoc("calculationOrderIds");
}); });
handler.on("SaveDocument", function ({ handler.on(
numPages, "SaveDocument",
annotationStorage, function ({ numPages, annotationStorage, filename }) {
filename,
}) {
pdfManager.requestLoadedStream(); pdfManager.requestLoadedStream();
const promises = [ const promises = [
pdfManager.onLoadedStream(), pdfManager.onLoadedStream(),
@ -627,7 +625,8 @@ class WorkerMessageHandler {
datasetsRef: xfaDatasets, datasetsRef: xfaDatasets,
}); });
}); });
}); }
);
handler.on("GetOperatorList", function wphSetupRenderPage(data, sink) { handler.on("GetOperatorList", function wphSetupRenderPage(data, sink) {
var pageIndex = data.pageIndex; var pageIndex = data.pageIndex;

View File

@ -70,14 +70,9 @@ class Util extends PDFObject {
const ZERO = 4; const ZERO = 4;
const HASH = 8; const HASH = 8;
let i = 0; let i = 0;
return args[0].replace(pattern, function ( return args[0].replace(
match, pattern,
nDecSep, function (match, nDecSep, cFlags, nWidth, nPrecision, cConvChar) {
cFlags,
nWidth,
nPrecision,
cConvChar
) {
// cConvChar must be one of d, f, s, x // cConvChar must be one of d, f, s, x
if ( if (
cConvChar !== "d" && cConvChar !== "d" &&
@ -203,7 +198,8 @@ class Util extends PDFObject {
} }
return `${sign}${n}`; return `${sign}${n}`;
}); }
);
} }
iconStreamFromIcon() { iconStreamFromIcon() {
@ -525,14 +521,14 @@ class Util extends PDFObject {
const patterns = /(mmmm|mmm|mm|m|dddd|ddd|dd|d|yyyy|yy|HH|H|hh|h|MM|M|ss|s|tt|t)/g; const patterns = /(mmmm|mmm|mm|m|dddd|ddd|dd|d|yyyy|yy|HH|H|hh|h|MM|M|ss|s|tt|t)/g;
const actions = []; const actions = [];
const re = escapedFormat.replace(patterns, function ( const re = escapedFormat.replace(
match, patterns,
patternElement function (match, patternElement) {
) {
const { pattern, action } = handlers[patternElement]; const { pattern, action } = handlers[patternElement];
actions.push(action); actions.push(action);
return pattern; return pattern;
}); }
);
this._scandCache.set(cFormat, [new RegExp(re, "g"), actions]); this._scandCache.set(cFormat, [new RegExp(re, "g"), actions]);
} }

View File

@ -121,9 +121,11 @@ describe("evaluator", function () {
resources.XObject = xObject; resources.XObject = xObject;
const stream = new StringStream("/Res1 DoQ"); const stream = new StringStream("/Res1 DoQ");
runOperatorListCheck(partialEvaluator, stream, resources, function ( runOperatorListCheck(
result partialEvaluator,
) { stream,
resources,
function (result) {
expect(result.fnArray.length).toEqual(3); expect(result.fnArray.length).toEqual(3);
expect(result.fnArray[0]).toEqual(OPS.dependency); expect(result.fnArray[0]).toEqual(OPS.dependency);
expect(result.fnArray[1]).toEqual(OPS.paintImageXObject); expect(result.fnArray[1]).toEqual(OPS.paintImageXObject);
@ -133,7 +135,8 @@ describe("evaluator", function () {
expect(result.argsArray[1]).toEqual(["img_p0_1", 1, 1]); expect(result.argsArray[1]).toEqual(["img_p0_1", 1, 1]);
expect(result.argsArray[2]).toEqual(null); expect(result.argsArray[2]).toEqual(null);
done(); done();
}); }
);
}); });
it("should handle three glued operations", function (done) { it("should handle three glued operations", function (done) {
@ -157,16 +160,19 @@ describe("evaluator", function () {
const resources = new ResourcesMock(); const resources = new ResourcesMock();
resources.Res1 = {}; resources.Res1 = {};
const stream = new StringStream("B*Bf*"); const stream = new StringStream("B*Bf*");
runOperatorListCheck(partialEvaluator, stream, resources, function ( runOperatorListCheck(
result partialEvaluator,
) { stream,
resources,
function (result) {
expect(!!result.fnArray && !!result.argsArray).toEqual(true); expect(!!result.fnArray && !!result.argsArray).toEqual(true);
expect(result.fnArray.length).toEqual(3); expect(result.fnArray.length).toEqual(3);
expect(result.fnArray[0]).toEqual(OPS.eoFillStroke); expect(result.fnArray[0]).toEqual(OPS.eoFillStroke);
expect(result.fnArray[1]).toEqual(OPS.fillStroke); expect(result.fnArray[1]).toEqual(OPS.fillStroke);
expect(result.fnArray[2]).toEqual(OPS.eoFill); expect(result.fnArray[2]).toEqual(OPS.eoFill);
done(); done();
}); }
);
}); });
it("should handle glued operations and operands", function (done) { it("should handle glued operations and operands", function (done) {
@ -253,9 +259,11 @@ describe("evaluator", function () {
resources.ExtGState = extGState; resources.ExtGState = extGState;
const stream = new StringStream("/F2 /GS2 gs 5.711 Tf"); const stream = new StringStream("/F2 /GS2 gs 5.711 Tf");
runOperatorListCheck(partialEvaluator, stream, resources, function ( runOperatorListCheck(
result partialEvaluator,
) { stream,
resources,
function (result) {
expect(result.fnArray.length).toEqual(3); expect(result.fnArray.length).toEqual(3);
expect(result.fnArray[0]).toEqual(OPS.setGState); expect(result.fnArray[0]).toEqual(OPS.setGState);
expect(result.fnArray[1]).toEqual(OPS.dependency); expect(result.fnArray[1]).toEqual(OPS.dependency);
@ -270,7 +278,8 @@ describe("evaluator", function () {
expect(result.argsArray[1]).toEqual(["g_font_error"]); expect(result.argsArray[1]).toEqual(["g_font_error"]);
expect(result.argsArray[2]).toEqual(["g_font_error", 5.711]); expect(result.argsArray[2]).toEqual(["g_font_error", 5.711]);
done(); done();
}); }
);
}); });
it("should skip if too few arguments", function (done) { it("should skip if too few arguments", function (done) {
const stream = new StringStream("5 d0"); const stream = new StringStream("5 d0");
@ -369,13 +378,16 @@ describe("evaluator", function () {
resources.set("XObject", xobjs); resources.set("XObject", xobjs);
const stream = new StringStream("/Res1 Do"); const stream = new StringStream("/Res1 Do");
runOperatorListCheck(partialEvaluator, stream, resources, function ( runOperatorListCheck(
result partialEvaluator,
) { stream,
resources,
function (result) {
expect(result.argsArray).toEqual([]); expect(result.argsArray).toEqual([]);
expect(result.fnArray).toEqual([]); expect(result.fnArray).toEqual([]);
done(); done();
}); }
);
}); });
}); });

View File

@ -98,9 +98,9 @@ describe("pdf_find_controller", function () {
return a + b; return a + b;
}); });
eventBus.on("updatefindmatchescount", function onUpdateFindMatchesCount( eventBus.on(
evt "updatefindmatchescount",
) { function onUpdateFindMatchesCount(evt) {
if (pdfFindController.pageMatches.length !== totalPages) { if (pdfFindController.pageMatches.length !== totalPages) {
return; return;
} }
@ -120,7 +120,8 @@ describe("pdf_find_controller", function () {
); );
resolve(); resolve();
}); }
);
}); });
} }