Merge pull request #15162 from Snuffleupagus/prefer-logical-operator-over-ternary

Enable the `unicorn/prefer-logical-operator-over-ternary` ESLint plugin rule
This commit is contained in:
Jonas Jenwald 2022-07-13 09:50:04 +02:00 committed by GitHub
commit b4a3fd31c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 15 deletions

View File

@ -46,8 +46,8 @@
}], }],
"unicorn/no-abusive-eslint-disable": "error", "unicorn/no-abusive-eslint-disable": "error",
"unicorn/no-array-push-push": "error", "unicorn/no-array-push-push": "error",
"unicorn/no-new-buffer": "error",
"unicorn/no-instanceof-array": "error", "unicorn/no-instanceof-array": "error",
"unicorn/no-new-buffer": "error",
"unicorn/no-useless-spread": "error", "unicorn/no-useless-spread": "error",
"unicorn/prefer-array-flat": "error", "unicorn/prefer-array-flat": "error",
"unicorn/prefer-array-flat-map": "error", "unicorn/prefer-array-flat-map": "error",
@ -56,6 +56,7 @@
"unicorn/prefer-date-now": "error", "unicorn/prefer-date-now": "error",
"unicorn/prefer-dom-node-append": "error", "unicorn/prefer-dom-node-append": "error",
"unicorn/prefer-dom-node-remove": "error", "unicorn/prefer-dom-node-remove": "error",
"unicorn/prefer-logical-operator-over-ternary": "error",
"unicorn/prefer-modern-dom-apis": "error", "unicorn/prefer-modern-dom-apis": "error",
"unicorn/prefer-string-starts-ends-with": "error", "unicorn/prefer-string-starts-ends-with": "error",

View File

@ -1267,7 +1267,7 @@ class Font {
// Read the table associated data // Read the table associated data
const previousPosition = file.pos; const previousPosition = file.pos;
file.pos = file.start ? file.start : 0; file.pos = file.start || 0;
file.skip(offset); file.skip(offset);
const data = file.getBytes(length); const data = file.getBytes(length);
file.pos = previousPosition; file.pos = previousPosition;
@ -1405,7 +1405,7 @@ class Font {
}; };
} }
let segment; let segment;
let start = (file.start ? file.start : 0) + cmap.offset; let start = (file.start || 0) + cmap.offset;
file.pos = start; file.pos = start;
file.skip(2); // version file.skip(2); // version
@ -1717,7 +1717,7 @@ class Font {
return; return;
} }
file.pos = (file.start ? file.start : 0) + header.offset; file.pos = (file.start || 0) + header.offset;
file.pos += 4; // version file.pos += 4; // version
file.pos += 2; // ascent file.pos += 2; // ascent
file.pos += 2; // descent file.pos += 2; // descent
@ -2081,7 +2081,7 @@ class Font {
} }
function readPostScriptTable(post, propertiesObj, maxpNumGlyphs) { function readPostScriptTable(post, propertiesObj, maxpNumGlyphs) {
const start = (font.start ? font.start : 0) + post.offset; const start = (font.start || 0) + post.offset;
font.pos = start; font.pos = start;
const length = post.length, const length = post.length,
@ -2151,7 +2151,7 @@ class Font {
} }
function readNameTable(nameTable) { function readNameTable(nameTable) {
const start = (font.start ? font.start : 0) + nameTable.offset; const start = (font.start || 0) + nameTable.offset;
font.pos = start; font.pos = start;
const names = [[], []]; const names = [[], []];

View File

@ -35,9 +35,8 @@ const Name = (function NameClosure() {
} }
static get(name) { static get(name) {
const nameValue = nameCache[name];
// eslint-disable-next-line no-restricted-syntax // eslint-disable-next-line no-restricted-syntax
return nameValue ? nameValue : (nameCache[name] = new Name(name)); return nameCache[name] || (nameCache[name] = new Name(name));
} }
static _clearCache() { static _clearCache() {
@ -65,9 +64,8 @@ const Cmd = (function CmdClosure() {
} }
static get(cmd) { static get(cmd) {
const cmdValue = cmdCache[cmd];
// eslint-disable-next-line no-restricted-syntax // eslint-disable-next-line no-restricted-syntax
return cmdValue ? cmdValue : (cmdCache[cmd] = new Cmd(cmd)); return cmdCache[cmd] || (cmdCache[cmd] = new Cmd(cmd));
} }
static _clearCache() { static _clearCache() {
@ -310,9 +308,8 @@ const Ref = (function RefClosure() {
static get(num, gen) { static get(num, gen) {
const key = gen === 0 ? `${num}R` : `${num}R${gen}`; const key = gen === 0 ? `${num}R` : `${num}R${gen}`;
const refValue = refCache[key];
// eslint-disable-next-line no-restricted-syntax // eslint-disable-next-line no-restricted-syntax
return refValue ? refValue : (refCache[key] = new Ref(num, gen)); return refCache[key] || (refCache[key] = new Ref(num, gen));
} }
static _clearCache() { static _clearCache() {

View File

@ -247,7 +247,7 @@ function layoutNode(node, availableSpace) {
} }
} }
const maxWidth = (!node.w ? availableSpace.width : node.w) - marginH; const maxWidth = (node.w || availableSpace.width) - marginH;
const fontFinder = node[$globalData].fontFinder; const fontFinder = node[$globalData].fontFinder;
if ( if (
node.value.exData && node.value.exData &&

View File

@ -457,7 +457,7 @@ class Arc extends XFAObject {
} }
[$toHTML]() { [$toHTML]() {
const edge = this.edge ? this.edge : new Edge({}); const edge = this.edge || new Edge({});
const edgeStyle = edge[$toStyle](); const edgeStyle = edge[$toStyle]();
const style = Object.create(null); const style = Object.create(null);
if (this.fill && this.fill.presence === "visible") { if (this.fill && this.fill.presence === "visible") {
@ -3650,7 +3650,7 @@ class Line extends XFAObject {
[$toHTML]() { [$toHTML]() {
const parent = this[$getParent]()[$getParent](); const parent = this[$getParent]()[$getParent]();
const edge = this.edge ? this.edge : new Edge({}); const edge = this.edge || new Edge({});
const edgeStyle = edge[$toStyle](); const edgeStyle = edge[$toStyle]();
const style = Object.create(null); const style = Object.create(null);
const thickness = edge.presence === "visible" ? edge.thickness : 0; const thickness = edge.presence === "visible" ? edge.thickness : 0;