Merge pull request #16185 from Snuffleupagus/prefer-negative-index

Enable the `unicorn/prefer-negative-index` ESLint plugin rule
This commit is contained in:
Jonas Jenwald 2023-03-24 12:12:11 +01:00 committed by GitHub
commit c706c6c34f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 6 deletions

View File

@ -59,6 +59,7 @@
"unicorn/prefer-dom-node-remove": "error",
"unicorn/prefer-logical-operator-over-ternary": "error",
"unicorn/prefer-modern-dom-apis": "error",
"unicorn/prefer-negative-index": "error",
"unicorn/prefer-regexp-test": "error",
"unicorn/prefer-string-replace-all": "error",
"unicorn/prefer-string-starts-ends-with": "error",

View File

@ -471,12 +471,12 @@ function validateCSSFont(cssFontInfo) {
// See https://developer.mozilla.org/en-US/docs/Web/CSS/string.
if (/^".*"$/.test(fontFamily)) {
if (/[^\\]"/.test(fontFamily.slice(1, fontFamily.length - 1))) {
if (/[^\\]"/.test(fontFamily.slice(1, -1))) {
warn(`XFA - FontFamily contains some unescaped ": ${fontFamily}.`);
return false;
}
} else if (/^'.*'$/.test(fontFamily)) {
if (/[^\\]'/.test(fontFamily.slice(1, fontFamily.length - 1))) {
if (/[^\\]'/.test(fontFamily.slice(1, -1))) {
warn(`XFA - FontFamily contains some unescaped ': ${fontFamily}.`);
return false;
}

View File

@ -265,7 +265,7 @@ class Type1CharString {
subrNumber = this.stack.pop();
const numArgs = this.stack.pop();
if (subrNumber === 0 && numArgs === 3) {
const flexArgs = this.stack.splice(this.stack.length - 17, 17);
const flexArgs = this.stack.splice(-17, 17);
this.stack.push(
flexArgs[2] + flexArgs[0], // bcp1x + rpx
flexArgs[3] + flexArgs[1], // bcp1y + rpy

View File

@ -26,7 +26,7 @@ const measurementPattern = /([+-]?\d+\.?\d*)(.*)/;
function stripQuotes(str) {
if (str.startsWith("'") || str.startsWith('"')) {
return str.slice(1, str.length - 1);
return str.slice(1, -1);
}
return str;
}

View File

@ -481,9 +481,9 @@ class XFAObject {
// - URI
// For now we don't handle URI other than "." (current document).
if (usehref.startsWith("#som(") && usehref.endsWith(")")) {
somExpression = usehref.slice("#som(".length, usehref.length - 1);
somExpression = usehref.slice("#som(".length, -1);
} else if (usehref.startsWith(".#som(") && usehref.endsWith(")")) {
somExpression = usehref.slice(".#som(".length, usehref.length - 1);
somExpression = usehref.slice(".#som(".length, -1);
} else if (usehref.startsWith("#")) {
id = usehref.slice(1);
} else if (usehref.startsWith(".#")) {