diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2023-12-20 00:37:34 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-20 05:37:34 +0000 |
commit | e8b4c488dd5955bafa3fbdbd71cb125f67486415 (patch) | |
tree | f3e5ed3ec5de4d5d33f4c5902eb4d0961cdd42e9 /ext | |
parent | e56f03901f21fa8f44725b6a68d3d0dca1e9cd34 (diff) |
Declare static fields using modern JavaScript syntax (#400)
Diffstat (limited to 'ext')
-rw-r--r-- | ext/js/accessibility/google-docs-util.js | 7 | ||||
-rw-r--r-- | ext/js/data/anki-util.js | 6 | ||||
-rw-r--r-- | ext/js/dom/document-util.js | 16 | ||||
-rw-r--r-- | ext/js/general/regex-util.js | 6 | ||||
-rw-r--r-- | ext/js/language/deinflector.js | 28 |
5 files changed, 29 insertions, 34 deletions
diff --git a/ext/js/accessibility/google-docs-util.js b/ext/js/accessibility/google-docs-util.js index 4321f082..151b6340 100644 --- a/ext/js/accessibility/google-docs-util.js +++ b/ext/js/accessibility/google-docs-util.js @@ -23,6 +23,9 @@ import {TextSourceRange} from '../dom/text-source-range.js'; * This class is a helper for handling Google Docs content in content scripts. */ export class GoogleDocsUtil { + /** @type {HTMLStyleElement|undefined} */ + static _styleNode = void 0; + /** * Scans the document for text or elements with text information at the given coordinate. * Coordinates are provided in [client space](https://developer.mozilla.org/en-US/docs/Web/CSS/CSSOM_View/Coordinate_systems). @@ -148,7 +151,3 @@ export class GoogleDocsUtil { style.setProperty(propertyName, value, 'important'); } } - -/** @type {HTMLStyleElement|undefined} */ -// eslint-disable-next-line no-underscore-dangle -GoogleDocsUtil._styleNode = void 0; diff --git a/ext/js/data/anki-util.js b/ext/js/data/anki-util.js index 1d5272a6..4717d472 100644 --- a/ext/js/data/anki-util.js +++ b/ext/js/data/anki-util.js @@ -22,6 +22,9 @@ import {isObject} from '../core.js'; * This class has some general utility functions for working with Anki data. */ export class AnkiUtil { + /** @type {RegExp} @readonly */ + static _markerPattern = /\{([\w-]+)\}/g; + /** * Gets the root deck name of a full deck name. If the deck is a root deck, * the same name is returned. Nested decks are separated using '::'. @@ -84,6 +87,3 @@ export class AnkiUtil { ); } } - -// eslint-disable-next-line no-underscore-dangle -AnkiUtil._markerPattern = /\{([\w-]+)\}/g; diff --git a/ext/js/dom/document-util.js b/ext/js/dom/document-util.js index d335eba3..df3bd354 100644 --- a/ext/js/dom/document-util.js +++ b/ext/js/dom/document-util.js @@ -24,6 +24,13 @@ import {TextSourceRange} from './text-source-range.js'; * This class contains utility functions related to the HTML document. */ export class DocumentUtil { + /** @type {RegExp} @readonly */ + static _transparentColorPattern = /rgba\s*\([^)]*,\s*0(?:\.0+)?\s*\)/; + /** @type {?boolean} */ + static _cssZoomSupported = null; + /** @type {import('document-util').GetRangeFromPointHandler[]} @readonly */ + static _getRangeFromPointHandlers = []; + /** * Scans the document for text or elements with text information at the given coordinate. * Coordinates are provided in [client space](https://developer.mozilla.org/en-US/docs/Web/CSS/CSSOM_View/Coordinate_systems). @@ -1086,12 +1093,3 @@ export class DocumentUtil { return (typeof style === 'object' && style !== null && typeof style.zoom === 'string'); } } -/** @type {RegExp} */ -// eslint-disable-next-line no-underscore-dangle -DocumentUtil._transparentColorPattern = /rgba\s*\([^)]*,\s*0(?:\.0+)?\s*\)/; -/** @type {?boolean} */ -// eslint-disable-next-line no-underscore-dangle -DocumentUtil._cssZoomSupported = null; -/** @type {import('document-util').GetRangeFromPointHandler[]} */ -// eslint-disable-next-line no-underscore-dangle -DocumentUtil._getRangeFromPointHandlers = []; diff --git a/ext/js/general/regex-util.js b/ext/js/general/regex-util.js index 62248968..6601e463 100644 --- a/ext/js/general/regex-util.js +++ b/ext/js/general/regex-util.js @@ -21,6 +21,9 @@ * This class provides some general utility functions for regular expressions. */ export class RegexUtil { + /** @type {RegExp} @readonly */ + static _matchReplacementPattern = /\$(?:\$|&|`|'|(\d\d?)|<([^>]*)>)/g; + /** * Applies string.replace using a regular expression and replacement string as arguments. * A source map of the changes is also maintained. @@ -92,6 +95,3 @@ export class RegexUtil { }); } } - -// eslint-disable-next-line no-underscore-dangle -RegexUtil._matchReplacementPattern = /\$(?:\$|&|`|'|(\d\d?)|<([^>]*)>)/g; diff --git a/ext/js/language/deinflector.js b/ext/js/language/deinflector.js index 26cc6b18..f0e02f6f 100644 --- a/ext/js/language/deinflector.js +++ b/ext/js/language/deinflector.js @@ -17,6 +17,19 @@ */ export class Deinflector { + /* eslint-disable no-multi-spaces */ + /** @type {Map<string, import('translation-internal').DeinflectionRuleFlags>} @readonly */ + static _ruleTypes = new Map([ + ['v1', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b00000001)], // Verb ichidan + ['v5', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b00000010)], // Verb godan + ['vs', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b00000100)], // Verb suru + ['vk', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b00001000)], // Verb kuru + ['vz', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b00010000)], // Verb zuru + ['adj-i', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b00100000)], // Adjective i + ['iru', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b01000000)] // Intermediate -iru endings for progressive or perfect tense + ]); + /* eslint-enable no-multi-spaces */ + /** * @param {import('deinflector').ReasonsRaw} reasons * @example @@ -112,18 +125,3 @@ export class Deinflector { return value; } } - - -/* eslint-disable no-multi-spaces */ -/** @type {Map<string, import('translation-internal').DeinflectionRuleFlags>} */ -// eslint-disable-next-line no-underscore-dangle -Deinflector._ruleTypes = new Map([ - ['v1', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b00000001)], // Verb ichidan - ['v5', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b00000010)], // Verb godan - ['vs', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b00000100)], // Verb suru - ['vk', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b00001000)], // Verb kuru - ['vz', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b00010000)], // Verb zuru - ['adj-i', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b00100000)], // Adjective i - ['iru', /** @type {import('translation-internal').DeinflectionRuleFlags} */ (0b01000000)] // Intermediate -iru endings for progressive or perfect tense -]); -/* eslint-enable no-multi-spaces */ |