mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-06-22 16:05:56 +02:00
Upgrade eslint-plugin-unicorn to version 66.0.0
This is a major version bump, but the changelog at https://github.com/sindresorhus/eslint-plugin-unicorn/releases/tag/v66.0.0 doesn't indicate any breaking changes that should impact us. However, improved rules do require a small number of changes here: - The `prefer-array-some` rule no longer reports a false positive after https://github.com/sindresorhus/eslint-plugin-unicorn/issues/3198 got fixed, so the ignore line that was added in commit 68a5ec1 is removed. - The `prefer-ternary` rule triggers on more cases now, in particular `let` declarations with `if` reassignments, so a number of changes are made to make it pass again. - The `prefer-at` rule triggers on more cases now, in particular `substring` calls that just extract a single character, so one change is made to make it pass again.
This commit is contained in:
parent
92bd2dbb38
commit
0ea67ed96f
@ -1030,10 +1030,7 @@ function createBuildNumber(done) {
|
|||||||
const version = config.versionPrefix + buildNumber;
|
const version = config.versionPrefix + buildNumber;
|
||||||
|
|
||||||
exec('git log --format="%h" -n 1', function (err2, stdout2, stderr2) {
|
exec('git log --format="%h" -n 1', function (err2, stdout2, stderr2) {
|
||||||
let buildCommit = "";
|
const buildCommit = !err2 ? stdout2.replace("\n", "") : "";
|
||||||
if (!err2) {
|
|
||||||
buildCommit = stdout2.replace("\n", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
createStringSource(
|
createStringSource(
|
||||||
"version.json",
|
"version.json",
|
||||||
|
|||||||
33
package-lock.json
generated
33
package-lock.json
generated
@ -32,7 +32,7 @@
|
|||||||
"eslint-plugin-perfectionist": "^5.9.0",
|
"eslint-plugin-perfectionist": "^5.9.0",
|
||||||
"eslint-plugin-prettier": "^5.5.6",
|
"eslint-plugin-prettier": "^5.5.6",
|
||||||
"eslint-plugin-regexp": "^3.1.0",
|
"eslint-plugin-regexp": "^3.1.0",
|
||||||
"eslint-plugin-unicorn": "^65.0.1",
|
"eslint-plugin-unicorn": "^66.0.0",
|
||||||
"globals": "^17.6.0",
|
"globals": "^17.6.0",
|
||||||
"gulp": "^5.0.1",
|
"gulp": "^5.0.1",
|
||||||
"gulp-cli": "^3.1.0",
|
"gulp-cli": "^3.1.0",
|
||||||
@ -5282,42 +5282,43 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/eslint-plugin-unicorn": {
|
"node_modules/eslint-plugin-unicorn": {
|
||||||
"version": "65.0.1",
|
"version": "66.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-65.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-66.0.0.tgz",
|
||||||
"integrity": "sha512-daCrQrgxOoOz2uMPWB3Y3vvv/5q+ncwICI8IjoebiwtW87CaY4tAN5EEiRXTYVnf7qi1v1BGBdHOSnZLV0rx6A==",
|
"integrity": "sha512-+ywdy8T3foyZ2t3nRBujGa3vfOVMobHIi5iLB0L+fogdVO3EiUJ4BAyIacogWytnweLw3hgT70LQL9KoKTY/kA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/helper-validator-identifier": "^7.28.5",
|
"@babel/helper-validator-identifier": "^7.29.7",
|
||||||
"@eslint-community/eslint-utils": "^4.9.1",
|
"@eslint-community/eslint-utils": "^4.9.1",
|
||||||
|
"browserslist": "^4.28.2",
|
||||||
"change-case": "^5.4.4",
|
"change-case": "^5.4.4",
|
||||||
"ci-info": "^4.4.0",
|
"ci-info": "^4.4.0",
|
||||||
"core-js-compat": "^3.49.0",
|
"core-js-compat": "^3.49.0",
|
||||||
"detect-indent": "^7.0.2",
|
"detect-indent": "^7.0.2",
|
||||||
"find-up-simple": "^1.0.1",
|
"find-up-simple": "^1.0.1",
|
||||||
"globals": "^17.4.0",
|
"globals": "^17.6.0",
|
||||||
"indent-string": "^5.0.0",
|
"indent-string": "^5.0.0",
|
||||||
"is-builtin-module": "^5.0.0",
|
"is-builtin-module": "^5.0.0",
|
||||||
"jsesc": "^3.1.0",
|
"jsesc": "^3.1.0",
|
||||||
"pluralize": "^8.0.0",
|
"pluralize": "^8.0.0",
|
||||||
"regjsparser": "^0.13.0",
|
"regjsparser": "^0.13.1",
|
||||||
"semver": "^7.7.4",
|
"semver": "^7.8.4",
|
||||||
"strip-indent": "^4.1.1"
|
"strip-indent": "^4.1.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^20.10.0 || >=21.0.0"
|
"node": ">=22"
|
||||||
},
|
},
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sindresorhus/eslint-plugin-unicorn?sponsor=1"
|
"url": "https://github.com/sindresorhus/eslint-plugin-unicorn?sponsor=1"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"eslint": ">=9.38.0"
|
"eslint": ">=10.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/eslint-plugin-unicorn/node_modules/semver": {
|
"node_modules/eslint-plugin-unicorn/node_modules/semver": {
|
||||||
"version": "7.7.4",
|
"version": "7.8.4",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.4.tgz",
|
||||||
"integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==",
|
"integrity": "sha512-rUCObTnP32Q08R2uuIrt7r9PlEonuTmtuXYcW6s5kjdlj3xbnwe+21yXptAUYcMAABLkYYTtnmzb3w3EDZfueA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"bin": {
|
"bin": {
|
||||||
@ -8779,9 +8780,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/regjsparser": {
|
"node_modules/regjsparser": {
|
||||||
"version": "0.13.0",
|
"version": "0.13.2",
|
||||||
"resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.13.0.tgz",
|
"resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.13.2.tgz",
|
||||||
"integrity": "sha512-NZQZdC5wOE/H3UT28fVGL+ikOZcEzfMGk/c3iN9UGxzWHMa1op7274oyiUVrAG4B2EuFhus8SvkaYnhvW92p9Q==",
|
"integrity": "sha512-NgRBy2Nx/bE+9F27nVHnqcN5HjyLmecqsqx2PJHu3/IEtADD4WuxuXIVExD5PoSDFVrl78dOonfcOe5O+5nbzQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "BSD-2-Clause",
|
"license": "BSD-2-Clause",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
"eslint-plugin-perfectionist": "^5.9.0",
|
"eslint-plugin-perfectionist": "^5.9.0",
|
||||||
"eslint-plugin-prettier": "^5.5.6",
|
"eslint-plugin-prettier": "^5.5.6",
|
||||||
"eslint-plugin-regexp": "^3.1.0",
|
"eslint-plugin-regexp": "^3.1.0",
|
||||||
"eslint-plugin-unicorn": "^65.0.1",
|
"eslint-plugin-unicorn": "^66.0.0",
|
||||||
"globals": "^17.6.0",
|
"globals": "^17.6.0",
|
||||||
"gulp": "^5.0.1",
|
"gulp": "^5.0.1",
|
||||||
"gulp-cli": "^3.1.0",
|
"gulp-cli": "^3.1.0",
|
||||||
|
|||||||
@ -4265,10 +4265,7 @@ class FreeTextAnnotation extends MarkupAnnotation {
|
|||||||
totalWidth = Math.max(totalWidth, lineWidth);
|
totalWidth = Math.max(totalWidth, lineWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
let hscale = 1;
|
const hscale = totalWidth > w ? w / totalWidth : 1;
|
||||||
if (totalWidth > w) {
|
|
||||||
hscale = w / totalWidth;
|
|
||||||
}
|
|
||||||
let vscale = 1;
|
let vscale = 1;
|
||||||
const lineHeight = LINE_FACTOR * fontSize;
|
const lineHeight = LINE_FACTOR * fontSize;
|
||||||
const lineAscent = (LINE_FACTOR - LINE_DESCENT_FACTOR) * fontSize;
|
const lineAscent = (LINE_FACTOR - LINE_DESCENT_FACTOR) * fontSize;
|
||||||
|
|||||||
@ -418,10 +418,7 @@ class FakeUnicodeFont {
|
|||||||
[w, h] = [h, w];
|
[w, h] = [h, w];
|
||||||
}
|
}
|
||||||
|
|
||||||
let hscale = 1;
|
const hscale = maxWidth > w ? w / maxWidth : 1;
|
||||||
if (maxWidth > w) {
|
|
||||||
hscale = w / maxWidth;
|
|
||||||
}
|
|
||||||
let vscale = 1;
|
let vscale = 1;
|
||||||
const lineHeight = LINE_FACTOR * fontSize;
|
const lineHeight = LINE_FACTOR * fontSize;
|
||||||
const lineDescent = LINE_DESCENT_FACTOR * fontSize;
|
const lineDescent = LINE_DESCENT_FACTOR * fontSize;
|
||||||
|
|||||||
@ -3535,10 +3535,7 @@ class PartialEvaluator {
|
|||||||
if (includeMarkedContent) {
|
if (includeMarkedContent) {
|
||||||
markedContentData.level++;
|
markedContentData.level++;
|
||||||
|
|
||||||
let mcid = null;
|
const mcid = args[1] instanceof Dict ? args[1].get("MCID") : null;
|
||||||
if (args[1] instanceof Dict) {
|
|
||||||
mcid = args[1].get("MCID");
|
|
||||||
}
|
|
||||||
textContent.items.push({
|
textContent.items.push({
|
||||||
type: "beginMarkedContentProps",
|
type: "beginMarkedContentProps",
|
||||||
id: Number.isInteger(mcid)
|
id: Number.isInteger(mcid)
|
||||||
|
|||||||
@ -3171,10 +3171,7 @@ class Font {
|
|||||||
// there isn't enough room to duplicate, the glyph id is left the same. In
|
// there isn't enough room to duplicate, the glyph id is left the same. In
|
||||||
// this case, glyph 0 may not work correctly, but that is better than
|
// this case, glyph 0 may not work correctly, but that is better than
|
||||||
// having the whole font fail.
|
// having the whole font fail.
|
||||||
let glyphZeroId = numGlyphsOut - 1;
|
const glyphZeroId = dupFirstEntry ? numGlyphsOut - 1 : 0;
|
||||||
if (!dupFirstEntry) {
|
|
||||||
glyphZeroId = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// When `cssFontInfo` is set, the font is used to render text in the HTML
|
// When `cssFontInfo` is set, the font is used to render text in the HTML
|
||||||
// view (e.g. with Xfa) so nothing must be moved in the private use area.
|
// view (e.g. with Xfa) so nothing must be moved in the private use area.
|
||||||
@ -3248,10 +3245,7 @@ class Font {
|
|||||||
// Type 1 fonts have a notdef inserted at the beginning, so glyph 0
|
// Type 1 fonts have a notdef inserted at the beginning, so glyph 0
|
||||||
// becomes glyph 1. In a CFF font glyph 0 is appended to the end of the
|
// becomes glyph 1. In a CFF font glyph 0 is appended to the end of the
|
||||||
// char strings.
|
// char strings.
|
||||||
let glyphZeroId = 1;
|
const glyphZeroId = font instanceof CFFFont ? font.numGlyphs - 1 : 1;
|
||||||
if (font instanceof CFFFont) {
|
|
||||||
glyphZeroId = font.numGlyphs - 1;
|
|
||||||
}
|
|
||||||
const mapping = font.getGlyphMapping(properties);
|
const mapping = font.getGlyphMapping(properties);
|
||||||
let newMapping = null;
|
let newMapping = null;
|
||||||
let newCharCodeToGlyphId = mapping;
|
let newCharCodeToGlyphId = mapping;
|
||||||
|
|||||||
@ -285,10 +285,9 @@ class RadialAxialShading extends BaseShading {
|
|||||||
}
|
}
|
||||||
colorStops.push([1, Util.makeHexColor(rPrev, gPrev, bPrev)]);
|
colorStops.push([1, Util.makeHexColor(rPrev, gPrev, bPrev)]);
|
||||||
|
|
||||||
let background = "transparent";
|
const background = dict.has("Background")
|
||||||
if (dict.has("Background")) {
|
? cs.getRgbHex(dict.get("Background"), 0)
|
||||||
background = cs.getRgbHex(dict.get("Background"), 0);
|
: "transparent";
|
||||||
}
|
|
||||||
|
|
||||||
if (!extendStart) {
|
if (!extendStart) {
|
||||||
// Insert a color stop at the front and offset the first real color stop
|
// Insert a color stop at the front and offset the first real color stop
|
||||||
|
|||||||
@ -691,13 +691,10 @@ class Type1Parser {
|
|||||||
subrs,
|
subrs,
|
||||||
this.seacAnalysisEnabled
|
this.seacAnalysisEnabled
|
||||||
);
|
);
|
||||||
let output = charString.output;
|
// It seems when FreeType encounters an error while evaluating a glyph
|
||||||
if (error) {
|
// that it completely ignores the glyph so we'll mimic that behaviour
|
||||||
// It seems when FreeType encounters an error while evaluating a glyph
|
// here and put an endchar to make the validator happy.
|
||||||
// that it completely ignores the glyph so we'll mimic that behaviour
|
const output = !error ? charString.output : [14];
|
||||||
// here and put an endchar to make the validator happy.
|
|
||||||
output = [14];
|
|
||||||
}
|
|
||||||
const charStringObject = {
|
const charStringObject = {
|
||||||
glyphName: glyph,
|
glyphName: glyph,
|
||||||
charstring: output,
|
charstring: output,
|
||||||
|
|||||||
@ -101,7 +101,6 @@ class XFAFactory {
|
|||||||
const missingFonts = [];
|
const missingFonts = [];
|
||||||
for (let typeface of this.form[$globalData].usedTypefaces) {
|
for (let typeface of this.form[$globalData].usedTypefaces) {
|
||||||
typeface = stripQuotes(typeface);
|
typeface = stripQuotes(typeface);
|
||||||
// eslint-disable-next-line unicorn/prefer-array-some
|
|
||||||
const font = this.form[$globalData].fontFinder.find(typeface);
|
const font = this.form[$globalData].fontFinder.find(typeface);
|
||||||
if (!font) {
|
if (!font) {
|
||||||
missingFonts.push(typeface);
|
missingFonts.push(typeface);
|
||||||
|
|||||||
@ -51,7 +51,7 @@ class XMLParserBase {
|
|||||||
return s.replaceAll(/&([^;]+);/g, (all, entity) => {
|
return s.replaceAll(/&([^;]+);/g, (all, entity) => {
|
||||||
if (entity.substring(0, 2) === "#x") {
|
if (entity.substring(0, 2) === "#x") {
|
||||||
return String.fromCodePoint(parseInt(entity.substring(2), 16));
|
return String.fromCodePoint(parseInt(entity.substring(2), 16));
|
||||||
} else if (entity.substring(0, 1) === "#") {
|
} else if (entity.at(0) === "#") {
|
||||||
return String.fromCodePoint(parseInt(entity.substring(1), 10));
|
return String.fromCodePoint(parseInt(entity.substring(1), 10));
|
||||||
}
|
}
|
||||||
switch (entity) {
|
switch (entity) {
|
||||||
|
|||||||
@ -255,11 +255,9 @@ class EventDispatcher {
|
|||||||
this.runCalculate(source, event);
|
this.runCalculate(source, event);
|
||||||
|
|
||||||
const savedValue = (event.value = source.obj._getValue());
|
const savedValue = (event.value = source.obj._getValue());
|
||||||
let formattedValue = null;
|
const formattedValue = this.runActions(source, source, event, "Format")
|
||||||
|
? event.value?.toString?.()
|
||||||
if (this.runActions(source, source, event, "Format")) {
|
: null;
|
||||||
formattedValue = event.value?.toString?.();
|
|
||||||
}
|
|
||||||
|
|
||||||
source.obj._send({
|
source.obj._send({
|
||||||
id: source.obj._id,
|
id: source.obj._id,
|
||||||
@ -365,10 +363,9 @@ class EventDispatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
savedValue = target.obj._getValue();
|
savedValue = target.obj._getValue();
|
||||||
let formattedValue = null;
|
const formattedValue = this.runActions(target, target, event, "Format")
|
||||||
if (this.runActions(target, target, event, "Format")) {
|
? event.value?.toString?.()
|
||||||
formattedValue = event.value?.toString?.();
|
: null;
|
||||||
}
|
|
||||||
|
|
||||||
target.obj._send({
|
target.obj._send({
|
||||||
id: target.obj._id,
|
id: target.obj._id,
|
||||||
|
|||||||
@ -555,10 +555,11 @@ window.onload = function () {
|
|||||||
window.addEventListener("keydown", function keydown(event) {
|
window.addEventListener("keydown", function keydown(event) {
|
||||||
if (event.which === 84) {
|
if (event.which === 84) {
|
||||||
// 't' switch test/ref images
|
// 't' switch test/ref images
|
||||||
let val = 0;
|
const val = document.querySelector(
|
||||||
if (document.querySelector('input[name="which"][value="0"]:checked')) {
|
'input[name="which"][value="0"]:checked'
|
||||||
val = 1;
|
)
|
||||||
}
|
? 1
|
||||||
|
: 0;
|
||||||
document
|
document
|
||||||
.querySelector('input[name="which"][value="' + val + '"]')
|
.querySelector('input[name="which"][value="' + val + '"]')
|
||||||
.click();
|
.click();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user