aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-12-04 18:20:05 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-12-04 18:23:05 -0500
commitdcddbee07e20163ae167dd67fe58f0776f9acb64 (patch)
tree4a55c4bd42859f7bebae9d9cb31c6ae5fa0e3f9a
parent4b80a486181b902f3b1e089b584818ce725a91be (diff)
Update how ts comments are handled
-rw-r--r--.eslintrc.json9
-rw-r--r--dev/translator-vm.js2
-rw-r--r--ext/js/accessibility/google-docs.js6
-rw-r--r--ext/js/app/popup.js2
-rw-r--r--ext/js/background/offscreen-proxy.js8
-rw-r--r--ext/js/comm/frame-ancestry-handler.js4
-rw-r--r--ext/js/dom/document-util.js14
-rw-r--r--ext/js/dom/dom-text-scanner.js5
-rw-r--r--ext/js/dom/simple-dom-parser.js3
-rw-r--r--ext/js/pages/settings/backup-controller.js4
-rw-r--r--ext/js/yomitan.js4
-rw-r--r--test/cache-map.test.js2
-rw-r--r--test/data/html/test-document2-script.js30
-rw-r--r--test/object-property-accessor.test.js6
-rw-r--r--test/profile-conditions-util.test.js32
-rw-r--r--vitest.config.js2
16 files changed, 69 insertions, 64 deletions
diff --git a/.eslintrc.json b/.eslintrc.json
index a46aff4b..83e7ffe6 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -350,7 +350,14 @@
"allowAllPropertiesOnSameLine": true
}
],
- "@typescript-eslint/ban-ts-comment": "off",
+ "@typescript-eslint/ban-ts-comment": [
+ "error",
+ {
+ "ts-expect-error": {
+ "descriptionFormat": "^ - .+$"
+ }
+ }
+ ],
"@typescript-eslint/ban-types": [
"error",
{
diff --git a/dev/translator-vm.js b/dev/translator-vm.js
index 4022d465..7fdda879 100644
--- a/dev/translator-vm.js
+++ b/dev/translator-vm.js
@@ -42,7 +42,7 @@ export class TranslatorVM {
}
}
};
- // @ts-ignore - Overwriting a global
+ // @ts-expect-error - Overwriting a global
global.chrome = chrome;
/** @type {?JapaneseUtil} */
diff --git a/ext/js/accessibility/google-docs.js b/ext/js/accessibility/google-docs.js
index da6ab994..27841b6d 100644
--- a/ext/js/accessibility/google-docs.js
+++ b/ext/js/accessibility/google-docs.js
@@ -18,9 +18,9 @@
(async () => {
// Reentrant check
- // @ts-ignore : Checking a property to the global object
+ // @ts-expect-error - Checking a property to the global object
if (self.googleDocsAccessibilitySetup) { return; }
- // @ts-ignore : Adding a property to the global object
+ // @ts-expect-error - Adding a property to the global object
self.googleDocsAccessibilitySetup = true;
/**
@@ -57,7 +57,7 @@
// The extension ID below is on an allow-list that is used on the Google Docs webpage.
/* eslint-disable */
- // @ts-ignore : Adding a property to the global object
+ // @ts-expect-error : Adding a property to the global object
const inject = () => { window._docs_annotate_canvas_by_ext = 'ogmnaimimemjmbakcfefmnahgdfhfami'; };
/* eslint-enable */
diff --git a/ext/js/app/popup.js b/ext/js/app/popup.js
index 4f201fc3..7419785b 100644
--- a/ext/js/app/popup.js
+++ b/ext/js/app/popup.js
@@ -745,7 +745,7 @@ export class Popup extends EventDispatcher {
if (
fullscreenElement === null ||
fullscreenElement.shadowRoot ||
- // @ts-ignore - openOrClosedShadowRoot is available to Firefox 63+ for WebExtensions
+ // @ts-expect-error - openOrClosedShadowRoot is available to Firefox 63+ for WebExtensions
fullscreenElement.openOrClosedShadowRoot
) {
return defaultParent;
diff --git a/ext/js/background/offscreen-proxy.js b/ext/js/background/offscreen-proxy.js
index 7b504855..63f619fa 100644
--- a/ext/js/background/offscreen-proxy.js
+++ b/ext/js/background/offscreen-proxy.js
@@ -54,16 +54,16 @@ export class OffscreenProxy {
*/
async _hasOffscreenDocument() {
const offscreenUrl = chrome.runtime.getURL('offscreen.html');
- // @ts-ignore - API not defined yet
+ // @ts-expect-error - API not defined yet
if (!chrome.runtime.getContexts) { // chrome version below 116
// Clients: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope/clients
- // @ts-ignore - Types not set up for service workers yet
+ // @ts-expect-error - Types not set up for service workers yet
const matchedClients = await clients.matchAll();
- // @ts-ignore - Types not set up for service workers yet
+ // @ts-expect-error - Types not set up for service workers yet
return await matchedClients.some((client) => client.url === offscreenUrl);
}
- // @ts-ignore - API not defined yet
+ // @ts-expect-error - API not defined yet
const contexts = await chrome.runtime.getContexts({
contextTypes: ['OFFSCREEN_DOCUMENT'],
documentUrls: [offscreenUrl]
diff --git a/ext/js/comm/frame-ancestry-handler.js b/ext/js/comm/frame-ancestry-handler.js
index 687ec368..e4d08f28 100644
--- a/ext/js/comm/frame-ancestry-handler.js
+++ b/ext/js/comm/frame-ancestry-handler.js
@@ -295,7 +295,7 @@ export class FrameAncestryHandler {
while (walker.nextNode()) {
const element = /** @type {Element} */ (walker.currentNode);
- // @ts-ignore - this is more simple to elide any type checks or casting
+ // @ts-expect-error - this is more simple to elide any type checks or casting
if (element.contentWindow === contentWindow) {
return element;
}
@@ -303,7 +303,7 @@ export class FrameAncestryHandler {
/** @type {?ShadowRoot|undefined} */
const shadowRoot = (
element.shadowRoot ||
- // @ts-ignore - openOrClosedShadowRoot is available to Firefox 63+ for WebExtensions
+ // @ts-expect-error - openOrClosedShadowRoot is available to Firefox 63+ for WebExtensions
element.openOrClosedShadowRoot
);
if (shadowRoot) {
diff --git a/ext/js/dom/document-util.js b/ext/js/dom/document-util.js
index 549a8195..b2aa8f81 100644
--- a/ext/js/dom/document-util.js
+++ b/ext/js/dom/document-util.js
@@ -210,7 +210,7 @@ export class DocumentUtil {
*/
static computeZoomScale(node) {
if (this._cssZoomSupported === null) {
- // @ts-ignore - zoom is a non-standard property that exists in Chromium-based browsers
+ // @ts-expect-error - zoom is a non-standard property that exists in Chromium-based browsers
this._cssZoomSupported = (typeof document.createElement('div').style.zoom === 'string');
}
if (!this._cssZoomSupported) { return 1; }
@@ -387,11 +387,11 @@ export class DocumentUtil {
static getFullscreenElement() {
return (
document.fullscreenElement ||
- // @ts-ignore - vendor prefix
+ // @ts-expect-error - vendor prefix
document.msFullscreenElement ||
- // @ts-ignore - vendor prefix
+ // @ts-expect-error - vendor prefix
document.mozFullScreenElement ||
- // @ts-ignore - vendor prefix
+ // @ts-expect-error - vendor prefix
document.webkitFullscreenElement ||
null
);
@@ -808,7 +808,7 @@ export class DocumentUtil {
return document.caretRangeFromPoint(x, y);
}
- // @ts-ignore - caretPositionFromPoint is non-standard
+ // @ts-expect-error - caretPositionFromPoint is non-standard
if (typeof document.caretPositionFromPoint === 'function') {
// Firefox
return this._caretPositionFromPoint(x, y);
@@ -824,7 +824,7 @@ export class DocumentUtil {
* @returns {?Range}
*/
static _caretPositionFromPoint(x, y) {
- // @ts-ignore - caretPositionFromPoint is non-standard
+ // @ts-expect-error - caretPositionFromPoint is non-standard
const position = /** @type {(x: number, y: number) => ?{offsetNode: Node, offset: number}} */ (document.caretPositionFromPoint)(x, y);
if (position === null) {
return null;
@@ -876,7 +876,7 @@ export class DocumentUtil {
nextElement.style.setProperty('user-select', 'text', 'important');
}
- // @ts-ignore - caretPositionFromPoint is non-standard
+ // @ts-expect-error - caretPositionFromPoint is non-standard
const position = /** @type {(x: number, y: number) => ?{offsetNode: Node, offset: number}} */ (document.caretPositionFromPoint)(x, y);
if (position === null) {
return null;
diff --git a/ext/js/dom/dom-text-scanner.js b/ext/js/dom/dom-text-scanner.js
index 3a785680..42e0acc9 100644
--- a/ext/js/dom/dom-text-scanner.js
+++ b/ext/js/dom/dom-text-scanner.js
@@ -520,11 +520,10 @@ export class DOMTextScanner {
static isStyleSelectable(style) {
return !(
style.userSelect === 'none' ||
- // @ts-ignore - vendor prefix
style.webkitUserSelect === 'none' ||
- // @ts-ignore - vendor prefix
+ // @ts-expect-error - vendor prefix
style.MozUserSelect === 'none' ||
- // @ts-ignore - vendor prefix
+ // @ts-expect-error - vendor prefix
style.msUserSelect === 'none'
);
}
diff --git a/ext/js/dom/simple-dom-parser.js b/ext/js/dom/simple-dom-parser.js
index a1f63890..bca1cd88 100644
--- a/ext/js/dom/simple-dom-parser.js
+++ b/ext/js/dom/simple-dom-parser.js
@@ -27,7 +27,7 @@ export class SimpleDOMParser {
*/
constructor(content) {
/** @type {import('parse5')} */
- // @ts-ignore - parse5 global is not defined in typescript declaration
+ // @ts-expect-error - parse5 global is not defined in typescript declaration
this._parse5Lib = /** @type {import('parse5')} */ (parse5);
/** @type {import('parse5').TreeAdapter<import('parse5').DefaultTreeAdapterMap>} */
this._treeAdapter = this._parse5Lib.defaultTreeAdapter;
@@ -131,7 +131,6 @@ export class SimpleDOMParser {
* @returns {boolean}
*/
static isSupported() {
- // @ts-ignore - parse5 global is not defined in typescript declaration
return typeof parse5 !== 'undefined';
}
diff --git a/ext/js/pages/settings/backup-controller.js b/ext/js/pages/settings/backup-controller.js
index 52c5f418..bf44bb90 100644
--- a/ext/js/pages/settings/backup-controller.js
+++ b/ext/js/pages/settings/backup-controller.js
@@ -165,9 +165,9 @@ export class BackupController {
_saveBlob(blob, fileName) {
if (
typeof navigator === 'object' && navigator !== null &&
- // @ts-ignore - call for legacy Edge
+ // @ts-expect-error - call for legacy Edge
typeof navigator.msSaveBlob === 'function' &&
- // @ts-ignore - call for legacy Edge
+ // @ts-expect-error - call for legacy Edge
navigator.msSaveBlob(blob)
) {
return;
diff --git a/ext/js/yomitan.js b/ext/js/yomitan.js
index 3c0f7cb9..7cf67aec 100644
--- a/ext/js/yomitan.js
+++ b/ext/js/yomitan.js
@@ -37,7 +37,7 @@ if ((() => {
}
return (hasBrowser && !hasChrome);
})()) {
- // @ts-ignore - objects should have roughly the same interface
+ // @ts-expect-error - objects should have roughly the same interface
chrome = browser;
}
@@ -182,7 +182,7 @@ export class Yomitan extends EventDispatcher {
*/
sendMessage(...args) {
try {
- // @ts-ignore - issue with type conversion, somewhat difficult to resolve in pure JS
+ // @ts-expect-error - issue with type conversion, somewhat difficult to resolve in pure JS
chrome.runtime.sendMessage(...args);
} catch (e) {
this.triggerExtensionUnloaded();
diff --git a/test/cache-map.test.js b/test/cache-map.test.js
index 3e7def1f..df891188 100644
--- a/test/cache-map.test.js
+++ b/test/cache-map.test.js
@@ -30,7 +30,7 @@ function testConstructor() {
[true, () => new CacheMap(1.5)],
[true, () => new CacheMap(Number.NaN)],
[true, () => new CacheMap(Number.POSITIVE_INFINITY)],
- // @ts-ignore - Ignore because it should throw an error
+ // @ts-expect-error - Ignore because it should throw an error
[true, () => new CacheMap('a')]
];
diff --git a/test/data/html/test-document2-script.js b/test/data/html/test-document2-script.js
index 5a6ad4d1..f6082802 100644
--- a/test/data/html/test-document2-script.js
+++ b/test/data/html/test-document2-script.js
@@ -22,17 +22,17 @@
function requestFullscreen(element) {
if (element.requestFullscreen) {
element.requestFullscreen();
- // @ts-ignore - Browser compatibility
+ // @ts-expect-error - Browser compatibility
} else if (element.mozRequestFullScreen) {
- // @ts-ignore - Browser compatibility
+ // @ts-expect-error - Browser compatibility
element.mozRequestFullScreen();
- // @ts-ignore - Browser compatibility
+ // @ts-expect-error - Browser compatibility
} else if (element.webkitRequestFullscreen) {
- // @ts-ignore - Browser compatibility
+ // @ts-expect-error - Browser compatibility
element.webkitRequestFullscreen();
- // @ts-ignore - Browser compatibility
+ // @ts-expect-error - Browser compatibility
} else if (element.msRequestFullscreen) {
- // @ts-ignore - Browser compatibility
+ // @ts-expect-error - Browser compatibility
element.msRequestFullscreen();
}
}
@@ -41,17 +41,17 @@ function requestFullscreen(element) {
function exitFullscreen() {
if (document.exitFullscreen) {
document.exitFullscreen();
- // @ts-ignore - Browser compatibility
+ // @ts-expect-error - Browser compatibility
} else if (document.mozCancelFullScreen) {
- // @ts-ignore - Browser compatibility
+ // @ts-expect-error - Browser compatibility
document.mozCancelFullScreen();
- // @ts-ignore - Browser compatibility
+ // @ts-expect-error - Browser compatibility
} else if (document.webkitExitFullscreen) {
- // @ts-ignore - Browser compatibility
+ // @ts-expect-error - Browser compatibility
document.webkitExitFullscreen();
- // @ts-ignore - Browser compatibility
+ // @ts-expect-error - Browser compatibility
} else if (document.msExitFullscreen) {
- // @ts-ignore - Browser compatibility
+ // @ts-expect-error - Browser compatibility
document.msExitFullscreen();
}
}
@@ -62,11 +62,11 @@ function exitFullscreen() {
function getFullscreenElement() {
return (
document.fullscreenElement ||
- // @ts-ignore - Browser compatibility
+ // @ts-expect-error - Browser compatibility
document.msFullscreenElement ||
- // @ts-ignore - Browser compatibility
+ // @ts-expect-error - Browser compatibility
document.mozFullScreenElement ||
- // @ts-ignore - Browser compatibility
+ // @ts-expect-error - Browser compatibility
document.webkitFullscreenElement ||
null
);
diff --git a/test/object-property-accessor.test.js b/test/object-property-accessor.test.js
index 4f1fa87b..4d50b1e9 100644
--- a/test/object-property-accessor.test.js
+++ b/test/object-property-accessor.test.js
@@ -334,7 +334,7 @@ function testGetPathString2() {
];
for (const [pathArray, message] of data) {
- // @ts-ignore - Throwing is expected
+ // @ts-expect-error - Throwing is expected
expect(() => ObjectPropertyAccessor.getPathString(pathArray)).toThrow(message);
}
});
@@ -424,7 +424,7 @@ function testHasProperty() {
];
for (const [object, property, expected] of data) {
- // @ts-ignore - Ignore potentially property types
+ // @ts-expect-error - Ignore potentially property types
expect(ObjectPropertyAccessor.hasProperty(object, property)).toStrictEqual(expected);
}
});
@@ -449,7 +449,7 @@ function testIsValidPropertyType() {
];
for (const [object, property, expected] of data) {
- // @ts-ignore - Ignore potentially property types
+ // @ts-expect-error - Ignore potentially property types
expect(ObjectPropertyAccessor.isValidPropertyType(object, property)).toStrictEqual(expected);
}
});
diff --git a/test/profile-conditions-util.test.js b/test/profile-conditions-util.test.js
index 30052b34..62b21555 100644
--- a/test/profile-conditions-util.test.js
+++ b/test/profile-conditions-util.test.js
@@ -637,9 +637,9 @@ function testSchemas() {
{expected: true, context: {depth: 0, url: ''}},
{expected: true, context: {depth: 0, url: '', flags: []}},
{expected: false, context: {depth: 0, url: '', flags: ['clipboard']}},
- // @ts-ignore - Ignore type for string flag for testing purposes
+ // @ts-expect-error - Ignore type for string flag for testing purposes
{expected: false, context: {depth: 0, url: '', flags: ['clipboard', 'test2']}},
- // @ts-ignore - Ignore type for string flag for testing purposes
+ // @ts-expect-error - Ignore type for string flag for testing purposes
{expected: false, context: {depth: 0, url: '', flags: ['clipboard', 'test2', 'test3']}}
]
},
@@ -673,9 +673,9 @@ function testSchemas() {
{expected: false, context: {depth: 0, url: ''}},
{expected: false, context: {depth: 0, url: '', flags: []}},
{expected: false, context: {depth: 0, url: '', flags: ['clipboard']}},
- // @ts-ignore - Ignore type for string flag for testing purposes
+ // @ts-expect-error - Ignore type for string flag for testing purposes
{expected: true, context: {depth: 0, url: '', flags: ['clipboard', 'test2']}},
- // @ts-ignore - Ignore type for string flag for testing purposes
+ // @ts-expect-error - Ignore type for string flag for testing purposes
{expected: false, context: {depth: 0, url: '', flags: ['clipboard', 'test2', 'test3']}}
]
},
@@ -711,9 +711,9 @@ function testSchemas() {
{expected: false, context: {depth: 0, url: ''}},
{expected: false, context: {depth: 0, url: '', flags: []}},
{expected: true, context: {depth: 0, url: '', flags: ['clipboard']}},
- // @ts-ignore - Ignore type for string flag for testing purposes
+ // @ts-expect-error - Ignore type for string flag for testing purposes
{expected: true, context: {depth: 0, url: '', flags: ['clipboard', 'test2']}},
- // @ts-ignore - Ignore type for string flag for testing purposes
+ // @ts-expect-error - Ignore type for string flag for testing purposes
{expected: true, context: {depth: 0, url: '', flags: ['clipboard', 'test2', 'test3']}}
]
},
@@ -753,9 +753,9 @@ function testSchemas() {
{expected: true, context: {depth: 0, url: ''}},
{expected: true, context: {depth: 0, url: '', flags: []}},
{expected: true, context: {depth: 0, url: '', flags: ['clipboard']}},
- // @ts-ignore - Ignore type for string flag for testing purposes
+ // @ts-expect-error - Ignore type for string flag for testing purposes
{expected: false, context: {depth: 0, url: '', flags: ['clipboard', 'test2']}},
- // @ts-ignore - Ignore type for string flag for testing purposes
+ // @ts-expect-error - Ignore type for string flag for testing purposes
{expected: true, context: {depth: 0, url: '', flags: ['clipboard', 'test2', 'test3']}}
]
},
@@ -784,9 +784,9 @@ function testSchemas() {
{expected: true, context: {depth: 0, url: ''}},
{expected: true, context: {depth: 0, url: '', flags: []}},
{expected: true, context: {depth: 0, url: '', flags: ['clipboard']}},
- // @ts-ignore - Ignore type for string flag for testing purposes
+ // @ts-expect-error - Ignore type for string flag for testing purposes
{expected: true, context: {depth: 0, url: '', flags: ['clipboard', 'test2']}},
- // @ts-ignore - Ignore type for string flag for testing purposes
+ // @ts-expect-error - Ignore type for string flag for testing purposes
{expected: true, context: {depth: 0, url: '', flags: ['clipboard', 'test2', 'test3']}}
]
},
@@ -819,9 +819,9 @@ function testSchemas() {
{expected: false, context: {depth: 0, url: ''}},
{expected: false, context: {depth: 0, url: '', flags: []}},
{expected: false, context: {depth: 0, url: '', flags: ['clipboard']}},
- // @ts-ignore - Ignore type for string flag for testing purposes
+ // @ts-expect-error - Ignore type for string flag for testing purposes
{expected: true, context: {depth: 0, url: '', flags: ['clipboard', 'test2']}},
- // @ts-ignore - Ignore type for string flag for testing purposes
+ // @ts-expect-error - Ignore type for string flag for testing purposes
{expected: true, context: {depth: 0, url: '', flags: ['clipboard', 'test2', 'test3']}}
]
},
@@ -849,9 +849,9 @@ function testSchemas() {
{expected: true, context: {depth: 0, url: ''}},
{expected: true, context: {depth: 0, url: '', flags: []}},
{expected: true, context: {depth: 0, url: '', flags: ['clipboard']}},
- // @ts-ignore - Ignore type for string flag for testing purposes
+ // @ts-expect-error - Ignore type for string flag for testing purposes
{expected: true, context: {depth: 0, url: '', flags: ['clipboard', 'test2']}},
- // @ts-ignore - Ignore type for string flag for testing purposes
+ // @ts-expect-error - Ignore type for string flag for testing purposes
{expected: true, context: {depth: 0, url: '', flags: ['clipboard', 'test2', 'test3']}}
]
},
@@ -885,9 +885,9 @@ function testSchemas() {
{expected: true, context: {depth: 0, url: ''}},
{expected: true, context: {depth: 0, url: '', flags: []}},
{expected: false, context: {depth: 0, url: '', flags: ['clipboard']}},
- // @ts-ignore - Ignore type for string flag for testing purposes
+ // @ts-expect-error - Ignore type for string flag for testing purposes
{expected: false, context: {depth: 0, url: '', flags: ['clipboard', 'test2']}},
- // @ts-ignore - Ignore type for string flag for testing purposes
+ // @ts-expect-error - Ignore type for string flag for testing purposes
{expected: false, context: {depth: 0, url: '', flags: ['clipboard', 'test2', 'test3']}}
]
},
diff --git a/vitest.config.js b/vitest.config.js
index 3b6cdde0..025eec17 100644
--- a/vitest.config.js
+++ b/vitest.config.js
@@ -24,7 +24,7 @@ export default defineConfig({
'test/playwright/**'
],
environment: 'jsdom',
- // @ts-ignore - Appears to not be defined in the type definitions (https://vitest.dev/advanced/pool)
+ // @ts-expect-error - Appears to not be defined in the type definitions (https://vitest.dev/advanced/pool)
poolOptions: {
threads: {
useAtomics: true