Enable the arrow-body-style
ESLint rule
This manually ignores some cases where the resulting auto-formatting would not, as far as I'm concerned, constitute a readability improvement or where we'd just end up with more overall indentation. Please see https://eslint.org/docs/latest/rules/arrow-body-style
This commit is contained in:
parent
998184a00e
commit
f9a384d711
@ -242,6 +242,7 @@
|
|||||||
}],
|
}],
|
||||||
|
|
||||||
// ECMAScript 6
|
// ECMAScript 6
|
||||||
|
"arrow-body-style": ["error", "as-needed"],
|
||||||
"constructor-super": "error",
|
"constructor-super": "error",
|
||||||
"no-class-assign": "error",
|
"no-class-assign": "error",
|
||||||
"no-const-assign": "error",
|
"no-const-assign": "error",
|
||||||
|
@ -79,6 +79,7 @@ class AnnotationFactory {
|
|||||||
// with "GoToE" actions, from throwing and thus breaking parsing:
|
// with "GoToE" actions, from throwing and thus breaking parsing:
|
||||||
pdfManager.ensureCatalog("attachments"),
|
pdfManager.ensureCatalog("attachments"),
|
||||||
]).then(
|
]).then(
|
||||||
|
// eslint-disable-next-line arrow-body-style
|
||||||
([acroForm, xfaDatasets, structTreeRoot, baseUrl, attachments]) => {
|
([acroForm, xfaDatasets, structTreeRoot, baseUrl, attachments]) => {
|
||||||
return {
|
return {
|
||||||
pdfManager,
|
pdfManager,
|
||||||
@ -2133,11 +2134,8 @@ class WidgetAnnotation extends Annotation {
|
|||||||
value,
|
value,
|
||||||
};
|
};
|
||||||
|
|
||||||
const encoder = val => {
|
const encoder = val =>
|
||||||
return isAscii(val)
|
isAscii(val) ? val : stringToUTF16String(val, /* bigEndian = */ true);
|
||||||
? val
|
|
||||||
: stringToUTF16String(val, /* bigEndian = */ true);
|
|
||||||
};
|
|
||||||
dict.set("V", Array.isArray(value) ? value.map(encoder) : encoder(value));
|
dict.set("V", Array.isArray(value) ? value.map(encoder) : encoder(value));
|
||||||
this.amendSavedDict(annotationStorage, dict);
|
this.amendSavedDict(annotationStorage, dict);
|
||||||
|
|
||||||
|
@ -893,14 +893,13 @@ class Catalog {
|
|||||||
case "PrintPageRange":
|
case "PrintPageRange":
|
||||||
// The number of elements must be even.
|
// The number of elements must be even.
|
||||||
if (Array.isArray(value) && value.length % 2 === 0) {
|
if (Array.isArray(value) && value.length % 2 === 0) {
|
||||||
const isValid = value.every((page, i, arr) => {
|
const isValid = value.every(
|
||||||
return (
|
(page, i, arr) =>
|
||||||
Number.isInteger(page) &&
|
Number.isInteger(page) &&
|
||||||
page > 0 &&
|
page > 0 &&
|
||||||
(i === 0 || page >= arr[i - 1]) &&
|
(i === 0 || page >= arr[i - 1]) &&
|
||||||
page <= this.numPages
|
page <= this.numPages
|
||||||
);
|
);
|
||||||
});
|
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
prefValue = value;
|
prefValue = value;
|
||||||
}
|
}
|
||||||
|
@ -1577,6 +1577,7 @@ class PDFDocument {
|
|||||||
} else {
|
} else {
|
||||||
promise = catalog.getPageDict(pageIndex);
|
promise = catalog.getPageDict(pageIndex);
|
||||||
}
|
}
|
||||||
|
// eslint-disable-next-line arrow-body-style
|
||||||
promise = promise.then(([pageDict, ref]) => {
|
promise = promise.then(([pageDict, ref]) => {
|
||||||
return new Page({
|
return new Page({
|
||||||
pdfManager: this.pdfManager,
|
pdfManager: this.pdfManager,
|
||||||
|
@ -1039,14 +1039,15 @@ class PartialEvaluator {
|
|||||||
|
|
||||||
return translated;
|
return translated;
|
||||||
})
|
})
|
||||||
.catch(reason => {
|
.catch(
|
||||||
return new TranslatedFont({
|
reason =>
|
||||||
|
new TranslatedFont({
|
||||||
loadedName: "g_font_error",
|
loadedName: "g_font_error",
|
||||||
font: new ErrorFont(`Type3 font load error: ${reason}`),
|
font: new ErrorFont(`Type3 font load error: ${reason}`),
|
||||||
dict: translated.font,
|
dict: translated.font,
|
||||||
evaluatorOptions: this.options,
|
evaluatorOptions: this.options,
|
||||||
});
|
})
|
||||||
});
|
);
|
||||||
})
|
})
|
||||||
.then(translated => {
|
.then(translated => {
|
||||||
state.font = translated.font;
|
state.font = translated.font;
|
||||||
@ -1129,6 +1130,7 @@ class PartialEvaluator {
|
|||||||
case "Font":
|
case "Font":
|
||||||
isSimpleGState = false;
|
isSimpleGState = false;
|
||||||
|
|
||||||
|
// eslint-disable-next-line arrow-body-style
|
||||||
promise = promise.then(() => {
|
promise = promise.then(() => {
|
||||||
return this.handleSetFont(
|
return this.handleSetFont(
|
||||||
resources,
|
resources,
|
||||||
@ -1154,6 +1156,7 @@ class PartialEvaluator {
|
|||||||
if (value instanceof Dict) {
|
if (value instanceof Dict) {
|
||||||
isSimpleGState = false;
|
isSimpleGState = false;
|
||||||
|
|
||||||
|
// eslint-disable-next-line arrow-body-style
|
||||||
promise = promise.then(() => {
|
promise = promise.then(() => {
|
||||||
return this.handleSMask(
|
return this.handleSMask(
|
||||||
value,
|
value,
|
||||||
@ -1214,6 +1217,7 @@ class PartialEvaluator {
|
|||||||
fallbackFontDict = null,
|
fallbackFontDict = null,
|
||||||
cssFontInfo = null
|
cssFontInfo = null
|
||||||
) {
|
) {
|
||||||
|
// eslint-disable-next-line arrow-body-style
|
||||||
const errorFont = async () => {
|
const errorFont = async () => {
|
||||||
return new TranslatedFont({
|
return new TranslatedFont({
|
||||||
loadedName: "g_font_error",
|
loadedName: "g_font_error",
|
||||||
|
@ -129,12 +129,10 @@ function getRelevant(data) {
|
|||||||
return data
|
return data
|
||||||
.trim()
|
.trim()
|
||||||
.split(/\s+/)
|
.split(/\s+/)
|
||||||
.map(e => {
|
.map(e => ({
|
||||||
return {
|
|
||||||
excluded: e[0] === "-",
|
excluded: e[0] === "-",
|
||||||
viewname: e.substring(1),
|
viewname: e.substring(1),
|
||||||
};
|
}));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getColor(data, def = [0, 0, 0]) {
|
function getColor(data, def = [0, 0, 0]) {
|
||||||
|
@ -1838,9 +1838,10 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
|
|||||||
|
|
||||||
const getItems = event => {
|
const getItems = event => {
|
||||||
const options = event.target.options;
|
const options = event.target.options;
|
||||||
return Array.prototype.map.call(options, option => {
|
return Array.prototype.map.call(options, option => ({
|
||||||
return { displayValue: option.textContent, exportValue: option.value };
|
displayValue: option.textContent,
|
||||||
});
|
exportValue: option.value,
|
||||||
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.enableScripting && this.hasJSActions) {
|
if (this.enableScripting && this.hasJSActions) {
|
||||||
|
@ -3013,14 +3013,12 @@ class WorkerTransport {
|
|||||||
}
|
}
|
||||||
const promise = this.messageHandler
|
const promise = this.messageHandler
|
||||||
.sendWithPromise(name, null)
|
.sendWithPromise(name, null)
|
||||||
.then(results => {
|
.then(results => ({
|
||||||
return {
|
|
||||||
info: results[0],
|
info: results[0],
|
||||||
metadata: results[1] ? new Metadata(results[1]) : null,
|
metadata: results[1] ? new Metadata(results[1]) : null,
|
||||||
contentDispositionFilename: this._fullReader?.filename ?? null,
|
contentDispositionFilename: this._fullReader?.filename ?? null,
|
||||||
contentLength: this._fullReader?.contentLength ?? null,
|
contentLength: this._fullReader?.contentLength ?? null,
|
||||||
};
|
}));
|
||||||
});
|
|
||||||
this.#methodPromises.set(name, promise);
|
this.#methodPromises.set(name, promise);
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
@ -2359,8 +2359,8 @@ class CanvasGraphics {
|
|||||||
const color = IR[1];
|
const color = IR[1];
|
||||||
const baseTransform = this.baseTransform || getCurrentTransform(this.ctx);
|
const baseTransform = this.baseTransform || getCurrentTransform(this.ctx);
|
||||||
const canvasGraphicsFactory = {
|
const canvasGraphicsFactory = {
|
||||||
createCanvasGraphics: ctx => {
|
createCanvasGraphics: ctx =>
|
||||||
return new CanvasGraphics(
|
new CanvasGraphics(
|
||||||
ctx,
|
ctx,
|
||||||
this.commonObjs,
|
this.commonObjs,
|
||||||
this.objs,
|
this.objs,
|
||||||
@ -2370,8 +2370,7 @@ class CanvasGraphics {
|
|||||||
optionalContentConfig: this.optionalContentConfig,
|
optionalContentConfig: this.optionalContentConfig,
|
||||||
markedContentStack: this.markedContentStack,
|
markedContentStack: this.markedContentStack,
|
||||||
}
|
}
|
||||||
);
|
),
|
||||||
},
|
|
||||||
};
|
};
|
||||||
pattern = new TilingPattern(
|
pattern = new TilingPattern(
|
||||||
IR,
|
IR,
|
||||||
|
@ -466,15 +466,13 @@ class DOMCMapReaderFactory extends BaseCMapReaderFactory {
|
|||||||
return fetchData(
|
return fetchData(
|
||||||
url,
|
url,
|
||||||
/* type = */ this.isCompressed ? "arraybuffer" : "text"
|
/* type = */ this.isCompressed ? "arraybuffer" : "text"
|
||||||
).then(data => {
|
).then(data => ({
|
||||||
return {
|
|
||||||
cMapData:
|
cMapData:
|
||||||
data instanceof ArrayBuffer
|
data instanceof ArrayBuffer
|
||||||
? new Uint8Array(data)
|
? new Uint8Array(data)
|
||||||
: stringToBytes(data),
|
: stringToBytes(data),
|
||||||
compressionType,
|
compressionType,
|
||||||
};
|
}));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -606,15 +606,14 @@ class AnnotationEditorUIManager {
|
|||||||
static get _keyboardManager() {
|
static get _keyboardManager() {
|
||||||
const proto = AnnotationEditorUIManager.prototype;
|
const proto = AnnotationEditorUIManager.prototype;
|
||||||
|
|
||||||
const arrowChecker = self => {
|
/**
|
||||||
// If the focused element is an input, we don't want to handle the arrow.
|
* If the focused element is an input, we don't want to handle the arrow.
|
||||||
// For example, sliders can be controlled with the arrow keys.
|
* For example, sliders can be controlled with the arrow keys.
|
||||||
return (
|
*/
|
||||||
|
const arrowChecker = self =>
|
||||||
self.#container.contains(document.activeElement) &&
|
self.#container.contains(document.activeElement) &&
|
||||||
document.activeElement.tagName !== "BUTTON" &&
|
document.activeElement.tagName !== "BUTTON" &&
|
||||||
self.hasSomethingToControl()
|
self.hasSomethingToControl();
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const textInputChecker = (_self, { target: el }) => {
|
const textInputChecker = (_self, { target: el }) => {
|
||||||
if (el instanceof HTMLInputElement) {
|
if (el instanceof HTMLInputElement) {
|
||||||
|
@ -98,9 +98,7 @@ class NodeCMapReaderFactory extends BaseCMapReaderFactory {
|
|||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
_fetchData(url, compressionType) {
|
_fetchData(url, compressionType) {
|
||||||
return fetchData(url).then(data => {
|
return fetchData(url).then(data => ({ cMapData: data, compressionType }));
|
||||||
return { cMapData: data, compressionType };
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1039,9 +1039,9 @@ function normalizeUnicode(str) {
|
|||||||
/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu;
|
/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu;
|
||||||
NormalizationMap = new Map([["ſt", "ſt"]]);
|
NormalizationMap = new Map([["ſt", "ſt"]]);
|
||||||
}
|
}
|
||||||
return str.replaceAll(NormalizeRegex, (_, p1, p2) => {
|
return str.replaceAll(NormalizeRegex, (_, p1, p2) =>
|
||||||
return p1 ? p1.normalize("NFKC") : NormalizationMap.get(p2);
|
p1 ? p1.normalize("NFKC") : NormalizationMap.get(p2)
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUuid() {
|
function getUuid() {
|
||||||
|
@ -106,6 +106,7 @@ async function inlineImages(node, silentErrors = false) {
|
|||||||
}
|
}
|
||||||
return response.blob();
|
return response.blob();
|
||||||
})
|
})
|
||||||
|
// eslint-disable-next-line arrow-body-style
|
||||||
.then(blob => {
|
.then(blob => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
@ -117,6 +118,7 @@ async function inlineImages(node, silentErrors = false) {
|
|||||||
reader.readAsDataURL(blob);
|
reader.readAsDataURL(blob);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
// eslint-disable-next-line arrow-body-style
|
||||||
.then(dataUrl => {
|
.then(dataUrl => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
image.onload = resolve;
|
image.onload = resolve;
|
||||||
|
@ -38,8 +38,8 @@ const getXY = (page, selector) =>
|
|||||||
return `${bbox.x}::${bbox.y}`;
|
return `${bbox.x}::${bbox.y}`;
|
||||||
}, selector);
|
}, selector);
|
||||||
|
|
||||||
const getSpanRectFromText = (page, pageNumber, text) => {
|
const getSpanRectFromText = (page, pageNumber, text) =>
|
||||||
return page.evaluate(
|
page.evaluate(
|
||||||
(number, content) => {
|
(number, content) => {
|
||||||
for (const el of document.querySelectorAll(
|
for (const el of document.querySelectorAll(
|
||||||
`.page[data-page-number="${number}"] > .textLayer > span`
|
`.page[data-page-number="${number}"] > .textLayer > span`
|
||||||
@ -54,7 +54,6 @@ const getSpanRectFromText = (page, pageNumber, text) => {
|
|||||||
pageNumber,
|
pageNumber,
|
||||||
text
|
text
|
||||||
);
|
);
|
||||||
};
|
|
||||||
|
|
||||||
describe("Highlight Editor", () => {
|
describe("Highlight Editor", () => {
|
||||||
describe("Editor must be removed without exception", () => {
|
describe("Editor must be removed without exception", () => {
|
||||||
|
@ -265,9 +265,10 @@ async function serializeBitmapDimensions(page) {
|
|||||||
const { map } =
|
const { map } =
|
||||||
window.PDFViewerApplication.pdfDocument.annotationStorage.serializable;
|
window.PDFViewerApplication.pdfDocument.annotationStorage.serializable;
|
||||||
return map
|
return map
|
||||||
? Array.from(map.values(), x => {
|
? Array.from(map.values(), x => ({
|
||||||
return { width: x.bitmap.width, height: x.bitmap.height };
|
width: x.bitmap.width,
|
||||||
})
|
height: x.bitmap.height,
|
||||||
|
}))
|
||||||
: [];
|
: [];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2689,9 +2689,7 @@ describe("api", function () {
|
|||||||
|
|
||||||
const viewPromises = [];
|
const viewPromises = [];
|
||||||
for (let i = 0; i < numPages; i++) {
|
for (let i = 0; i < numPages; i++) {
|
||||||
viewPromises[i] = pdfDoc.getPage(i + 1).then(pdfPage => {
|
viewPromises[i] = pdfDoc.getPage(i + 1).then(pdfPage => pdfPage.view);
|
||||||
return pdfPage.view;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const [page1, page2, page3] = await Promise.all(viewPromises);
|
const [page1, page2, page3] = await Promise.all(viewPromises);
|
||||||
@ -3412,7 +3410,9 @@ Caron Broadcasting, Inc., an Ohio corporation (“Lessee”).`)
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// eslint-disable-next-line arrow-body-style
|
||||||
const result1 = loadingTask1.promise.then(pdfDoc => {
|
const result1 = loadingTask1.promise.then(pdfDoc => {
|
||||||
|
// eslint-disable-next-line arrow-body-style
|
||||||
return pdfDoc.getPage(1).then(pdfPage => {
|
return pdfDoc.getPage(1).then(pdfPage => {
|
||||||
return pdfPage.getOperatorList().then(opList => {
|
return pdfPage.getOperatorList().then(opList => {
|
||||||
expect(opList.fnArray.length).toBeGreaterThan(100);
|
expect(opList.fnArray.length).toBeGreaterThan(100);
|
||||||
@ -3425,7 +3425,9 @@ Caron Broadcasting, Inc., an Ohio corporation (“Lessee”).`)
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// eslint-disable-next-line arrow-body-style
|
||||||
const result2 = loadingTask2.promise.then(pdfDoc => {
|
const result2 = loadingTask2.promise.then(pdfDoc => {
|
||||||
|
// eslint-disable-next-line arrow-body-style
|
||||||
return pdfDoc.getPage(1).then(pdfPage => {
|
return pdfDoc.getPage(1).then(pdfPage => {
|
||||||
return pdfPage.getOperatorList().then(opList => {
|
return pdfPage.getOperatorList().then(opList => {
|
||||||
expect(opList.fnArray.length).toEqual(0);
|
expect(opList.fnArray.length).toEqual(0);
|
||||||
|
@ -152,14 +152,12 @@ describe("Scripting", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should get field using a path", async () => {
|
it("should get field using a path", async () => {
|
||||||
const base = value => {
|
const base = value => ({
|
||||||
return {
|
|
||||||
id: getId(),
|
id: getId(),
|
||||||
value,
|
value,
|
||||||
actions: {},
|
actions: {},
|
||||||
type: "text",
|
type: "text",
|
||||||
};
|
});
|
||||||
};
|
|
||||||
const data = {
|
const data = {
|
||||||
objects: {
|
objects: {
|
||||||
A: [base(1)],
|
A: [base(1)],
|
||||||
|
@ -129,6 +129,7 @@ class PDFDocumentProperties {
|
|||||||
this.#parseFileSize(contentLength),
|
this.#parseFileSize(contentLength),
|
||||||
this.#parseDate(info.CreationDate),
|
this.#parseDate(info.CreationDate),
|
||||||
this.#parseDate(info.ModDate),
|
this.#parseDate(info.ModDate),
|
||||||
|
// eslint-disable-next-line arrow-body-style
|
||||||
this.pdfDocument.getPage(currentPageNumber).then(pdfPage => {
|
this.pdfDocument.getPage(currentPageNumber).then(pdfPage => {
|
||||||
return this.#parsePageSize(getPageSizeInches(pdfPage), pagesRotation);
|
return this.#parsePageSize(getPageSizeInches(pdfPage), pagesRotation);
|
||||||
}),
|
}),
|
||||||
|
@ -842,12 +842,11 @@ class PDFFindController {
|
|||||||
const extractTextCapability = new PromiseCapability();
|
const extractTextCapability = new PromiseCapability();
|
||||||
this._extractTextPromises[i] = extractTextCapability.promise;
|
this._extractTextPromises[i] = extractTextCapability.promise;
|
||||||
|
|
||||||
|
// eslint-disable-next-line arrow-body-style
|
||||||
promise = promise.then(() => {
|
promise = promise.then(() => {
|
||||||
return this._pdfDocument
|
return this._pdfDocument
|
||||||
.getPage(i + 1)
|
.getPage(i + 1)
|
||||||
.then(pdfPage => {
|
.then(pdfPage => pdfPage.getTextContent(textOptions))
|
||||||
return pdfPage.getTextContent(textOptions);
|
|
||||||
})
|
|
||||||
.then(
|
.then(
|
||||||
textContent => {
|
textContent => {
|
||||||
const strBuf = [];
|
const strBuf = [];
|
||||||
|
Loading…
Reference in New Issue
Block a user