From cb6e8d07d02e77389e3d395517863a2c9ff8e170 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 1 Feb 2020 15:00:11 -0500 Subject: Add more settings to eslintrc --- .eslintrc.json | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to '.eslintrc.json') diff --git a/.eslintrc.json b/.eslintrc.json index 0e3b939a..81fe517f 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,7 +1,14 @@ { + "root": true, "extends": "eslint:recommended", "parserOptions": { - "ecmaVersion": 8 + "ecmaVersion": 8, + "sourceType": "script" + }, + "env": { + "browser": true, + "es2017": true, + "webextensions": true }, "ignorePatterns": [ "/ext/mixed/lib/", @@ -18,6 +25,7 @@ "no-constant-condition": "off", "no-undef": "off", "no-unused-vars": ["error", {"vars": "local", "args": "after-used", "argsIgnorePattern": "^_", "caughtErrors": "none"}], + "no-unused-expressions": "error", "no-var": "error", "prefer-const": ["error", {"destructuring": "all"}], "quote-props": ["error", "consistent"], -- cgit v1.2.3 From 4629fb3639ec28e6c514b4a364b71e4192575b9b Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 1 Feb 2020 15:00:34 -0500 Subject: Change no-undef from off to error --- .eslintrc.json | 37 +++++++++++++++++++++++++++++-- ext/bg/js/anki.js | 1 + ext/bg/js/audio.js | 1 + ext/bg/js/backend.js | 8 +++++++ ext/bg/js/context.js | 1 + ext/bg/js/database.js | 1 + ext/bg/js/dictionary.js | 1 + ext/bg/js/handlebars.js | 1 + ext/bg/js/japanese.js | 1 + ext/bg/js/options.js | 1 + ext/bg/js/search-frontend.js | 1 + ext/bg/js/search-query-parser.js | 1 + ext/bg/js/search.js | 3 +++ ext/bg/js/settings/anki-templates.js | 3 +++ ext/bg/js/settings/anki.js | 3 +++ ext/bg/js/settings/audio-ui.js | 1 + ext/bg/js/settings/audio.js | 2 ++ ext/bg/js/settings/backup.js | 4 ++++ ext/bg/js/settings/conditions-ui.js | 1 + ext/bg/js/settings/dictionaries.js | 5 +++++ ext/bg/js/settings/main.js | 8 +++++++ ext/bg/js/settings/popup-preview-frame.js | 1 + ext/bg/js/settings/profiles.js | 4 ++++ ext/bg/js/settings/storage.js | 1 + ext/bg/js/translator.js | 6 +++++ ext/mixed/js/audio.js | 1 + ext/mixed/js/display-generator.js | 1 + ext/mixed/js/display.js | 5 +++++ ext/mixed/js/text-scanner.js | 1 + 29 files changed, 103 insertions(+), 2 deletions(-) (limited to '.eslintrc.json') diff --git a/.eslintrc.json b/.eslintrc.json index 81fe517f..9b1a19b3 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -23,7 +23,8 @@ "no-case-declarations": "error", "no-const-assign": "error", "no-constant-condition": "off", - "no-undef": "off", + "no-global-assign": "error", + "no-undef": "error", "no-unused-vars": ["error", {"vars": "local", "args": "after-used", "argsIgnorePattern": "^_", "caughtErrors": "none"}], "no-unused-expressions": "error", "no-var": "error", @@ -32,5 +33,37 @@ "quotes": ["error", "single", "avoid-escape"], "require-atomic-updates": "off", "semi": "error" - } + }, + "overrides": [ + { + "files": ["*.js"], + "excludedFiles": ["ext/mixed/js/core.js"], + "globals": { + "yomichan": "readonly", + "errorToJson": "readonly", + "jsonToError": "readonly", + "logError": "readonly", + "isObject": "readonly", + "hasOwn": "readonly", + "toIterable": "readonly", + "stringReverse": "readonly", + "promiseTimeout": "readonly", + "stringReplaceAsync": "readonly", + "EventDispatcher": "readonly", + "EXTENSION_IS_BROWSER_EDGE": "readonly" + } + }, + { + "files": ["ext/mixed/js/core.js"], + "globals": { + "chrome": "writable" + } + }, + { + "files": ["ext/bg/js/settings/*.js"], + "env": { + "jquery": true + } + } + ] } diff --git a/ext/bg/js/anki.js b/ext/bg/js/anki.js index 10a07061..39c6ad51 100644 --- a/ext/bg/js/anki.js +++ b/ext/bg/js/anki.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global requestJson*/ /* * AnkiConnect diff --git a/ext/bg/js/audio.js b/ext/bg/js/audio.js index d1e4af9e..6389528b 100644 --- a/ext/bg/js/audio.js +++ b/ext/bg/js/audio.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global jpIsStringEntirelyKana, audioGetFromSources*/ const audioUrlBuilders = new Map([ ['jpod101', async (definition) => { diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 529055d2..1a1dc735 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -16,6 +16,14 @@ * along with this program. If not, see . */ +/*global optionsSave, utilIsolate +conditionsTestValue, profileConditionsDescriptor, profileOptionsGetDefaultFieldTemplates +handlebarsRenderDynamic, handlebarsRenderStatic +requestText, requestJson, optionsLoad +dictConfigured, dictTermsSort, dictEnabledSet, dictNoteFormat +audioGetUrl, audioInject +jpConvertReading, jpDistributeFuriganaInflected, jpKatakanaToHiragana +Translator, AnkiConnect, AnkiNull, Mecab, BackendApiForwarder, JsonSchema*/ class Backend { constructor() { diff --git a/ext/bg/js/context.js b/ext/bg/js/context.js index 37adb6b7..bec964fb 100644 --- a/ext/bg/js/context.js +++ b/ext/bg/js/context.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global apiCommandExec, apiGetEnvironmentInfo, apiOptionsGet*/ function showExtensionInfo() { const node = document.getElementById('extension-info'); diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js index e87cc64b..b54d832c 100644 --- a/ext/bg/js/database.js +++ b/ext/bg/js/database.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global dictFieldSplit, dictTagSanitize, JSZip*/ class Database { constructor() { diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js index 48f65d6c..e03dece0 100644 --- a/ext/bg/js/dictionary.js +++ b/ext/bg/js/dictionary.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global utilSetEqual, utilSetIntersection, apiTemplateRender*/ function dictEnabledSet(options) { const dictionaries = {}; diff --git a/ext/bg/js/handlebars.js b/ext/bg/js/handlebars.js index 62f89ee4..e8cb67eb 100644 --- a/ext/bg/js/handlebars.js +++ b/ext/bg/js/handlebars.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global jpIsCharCodeKanji, jpDistributeFurigana, Handlebars*/ function handlebarsEscape(text) { return Handlebars.Utils.escapeExpression(text); diff --git a/ext/bg/js/japanese.js b/ext/bg/js/japanese.js index c45c0958..e8a6fa08 100644 --- a/ext/bg/js/japanese.js +++ b/ext/bg/js/japanese.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global wanakana*/ const JP_HALFWIDTH_KATAKANA_MAPPING = new Map([ ['ヲ', 'ヲヺ-'], diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js index 97032660..f9db99a2 100644 --- a/ext/bg/js/options.js +++ b/ext/bg/js/options.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global utilStringHashCode*/ /* * Generic options functions diff --git a/ext/bg/js/search-frontend.js b/ext/bg/js/search-frontend.js index e453ccef..509c4009 100644 --- a/ext/bg/js/search-frontend.js +++ b/ext/bg/js/search-frontend.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global apiOptionsGet*/ async function searchFrontendSetup() { const optionsContext = { diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js index f648fdd4..ff0dbaef 100644 --- a/ext/bg/js/search-query-parser.js +++ b/ext/bg/js/search-query-parser.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global apiTermsFind, apiOptionsSet, apiTextParse, apiTextParseMecab, apiTemplateRender, TextScanner*/ class QueryParser extends TextScanner { constructor(search) { diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index 6641255f..312d1de4 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -16,6 +16,9 @@ * along with this program. If not, see . */ +/*global jpIsStringPartiallyJapanese, apiOptionsSet, apiTermsFind, apiClipboardGet, apiGetEnvironmentInfo +Display, QueryParser*/ + class DisplaySearch extends Display { constructor() { super(document.querySelector('#spinner'), document.querySelector('#content')); diff --git a/ext/bg/js/settings/anki-templates.js b/ext/bg/js/settings/anki-templates.js index 5e74358f..2e80e334 100644 --- a/ext/bg/js/settings/anki-templates.js +++ b/ext/bg/js/settings/anki-templates.js @@ -16,6 +16,9 @@ * along with this program. If not, see . */ +/*global getOptionsContext, getOptionsMutable, settingsSaveOptions +profileOptionsGetDefaultFieldTemplates, ankiGetFieldMarkers, ankiGetFieldMarkersHtml, dictFieldFormat +apiOptionsGet, apiTermsFind*/ function onAnkiFieldTemplatesReset(e) { e.preventDefault(); diff --git a/ext/bg/js/settings/anki.js b/ext/bg/js/settings/anki.js index f55989fc..4263fc51 100644 --- a/ext/bg/js/settings/anki.js +++ b/ext/bg/js/settings/anki.js @@ -16,6 +16,9 @@ * along with this program. If not, see . */ +/*global getOptionsContext, getOptionsMutable, settingsSaveOptions +utilBackgroundIsolate, utilAnkiGetDeckNames, utilAnkiGetModelNames, utilAnkiGetModelFieldNames +onFormOptionsChanged*/ // Private diff --git a/ext/bg/js/settings/audio-ui.js b/ext/bg/js/settings/audio-ui.js index 711c2291..e918609e 100644 --- a/ext/bg/js/settings/audio-ui.js +++ b/ext/bg/js/settings/audio-ui.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global toIterable*/ class AudioSourceUI { static instantiateTemplate(templateSelector) { diff --git a/ext/bg/js/settings/audio.js b/ext/bg/js/settings/audio.js index cff3f521..588d9a11 100644 --- a/ext/bg/js/settings/audio.js +++ b/ext/bg/js/settings/audio.js @@ -16,6 +16,8 @@ * along with this program. If not, see . */ +/*global getOptionsContext, getOptionsMutable, settingsSaveOptions +AudioSourceUI, audioGetTextToSpeechVoice*/ let audioSourceUI = null; diff --git a/ext/bg/js/settings/backup.js b/ext/bg/js/settings/backup.js index becdc568..6d1f28e9 100644 --- a/ext/bg/js/settings/backup.js +++ b/ext/bg/js/settings/backup.js @@ -16,6 +16,10 @@ * along with this program. If not, see . */ +/*global apiOptionsGetFull, apiGetEnvironmentInfo +utilBackend, utilIsolate, utilBackgroundIsolate, utilReadFileArrayBuffer +optionsGetDefault, optionsUpdateVersion +profileOptionsGetDefaultFieldTemplates*/ // Exporting diff --git a/ext/bg/js/settings/conditions-ui.js b/ext/bg/js/settings/conditions-ui.js index 4d041451..5a271321 100644 --- a/ext/bg/js/settings/conditions-ui.js +++ b/ext/bg/js/settings/conditions-ui.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global conditionsNormalizeOptionValue*/ class ConditionsUI { static instantiateTemplate(templateSelector) { diff --git a/ext/bg/js/settings/dictionaries.js b/ext/bg/js/settings/dictionaries.js index 0d827f49..c80aac73 100644 --- a/ext/bg/js/settings/dictionaries.js +++ b/ext/bg/js/settings/dictionaries.js @@ -16,6 +16,11 @@ * along with this program. If not, see . */ +/*global getOptionsContext, getOptionsMutable, getOptionsFullMutable, settingsSaveOptions, apiOptionsGetFull +utilBackgroundIsolate, utilDatabaseDeleteDictionary, utilDatabaseGetDictionaryInfo, utilDatabaseGetDictionaryCounts +utilDatabasePurge, utilDatabaseImport +storageUpdateStats, storageEstimate +PageExitPrevention*/ let dictionaryUI = null; diff --git a/ext/bg/js/settings/main.js b/ext/bg/js/settings/main.js index cf0f08db..1ba4a7ef 100644 --- a/ext/bg/js/settings/main.js +++ b/ext/bg/js/settings/main.js @@ -16,6 +16,14 @@ * along with this program. If not, see . */ +/*global getOptionsContext, apiOptionsSave +utilBackend, utilIsolate, utilBackgroundIsolate +ankiErrorShown, ankiFieldsToDict +ankiTemplatesUpdateValue, onAnkiOptionsChanged, onDictionaryOptionsChanged +appearanceInitialize, audioSettingsInitialize, profileOptionsSetup, dictSettingsInitialize +ankiInitialize, ankiTemplatesInitialize, storageInfoInitialize +*/ + function getOptionsMutable(optionsContext) { return utilBackend().getOptions( utilBackgroundIsolate(optionsContext) diff --git a/ext/bg/js/settings/popup-preview-frame.js b/ext/bg/js/settings/popup-preview-frame.js index 37a4b416..042f335f 100644 --- a/ext/bg/js/settings/popup-preview-frame.js +++ b/ext/bg/js/settings/popup-preview-frame.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global apiOptionsGet, Popup, PopupProxyHost, Frontend, TextSourceRange*/ class SettingsPopupPreview { constructor() { diff --git a/ext/bg/js/settings/profiles.js b/ext/bg/js/settings/profiles.js index c4e68b53..3e589809 100644 --- a/ext/bg/js/settings/profiles.js +++ b/ext/bg/js/settings/profiles.js @@ -16,6 +16,10 @@ * along with this program. If not, see . */ +/*global getOptionsMutable, getOptionsFullMutable, settingsSaveOptions, apiOptionsGetFull +utilBackgroundIsolate, formWrite +conditionsClearCaches, ConditionsUI, profileConditionsDescriptor*/ + let currentProfileIndex = 0; let profileConditionsContainer = null; diff --git a/ext/bg/js/settings/storage.js b/ext/bg/js/settings/storage.js index 6c10f665..cbe1bb4d 100644 --- a/ext/bg/js/settings/storage.js +++ b/ext/bg/js/settings/storage.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global apiGetEnvironmentInfo*/ function storageBytesToLabeledString(size) { const base = 1000; diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js index d32f8c67..81c2464b 100644 --- a/ext/bg/js/translator.js +++ b/ext/bg/js/translator.js @@ -16,6 +16,12 @@ * along with this program. If not, see . */ +/*global requestJson +dictTermsMergeBySequence, dictTagBuildSource, dictTermsMergeByGloss, dictTermsSort, dictTagsSort +dictEnabledSet, dictTermsGroup, dictTermsCompressTags, dictTermsUndupe, dictTagSanitize +jpDistributeFurigana, jpConvertHalfWidthKanaToFullWidth, jpConvertNumericTofullWidth +jpConvertAlphabeticToKana, jpHiraganaToKatakana, jpKatakanaToHiragana, jpIsCharCodeJapanese +Database, Deinflector*/ class Translator { constructor() { diff --git a/ext/mixed/js/audio.js b/ext/mixed/js/audio.js index b0c5fa82..76a3e7da 100644 --- a/ext/mixed/js/audio.js +++ b/ext/mixed/js/audio.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global apiAudioGetUrl*/ class TextToSpeechAudio { constructor(text, voice) { diff --git a/ext/mixed/js/display-generator.js b/ext/mixed/js/display-generator.js index d5ab9dbc..3617e546 100644 --- a/ext/mixed/js/display-generator.js +++ b/ext/mixed/js/display-generator.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global apiGetDisplayTemplatesHtml*/ class DisplayGenerator { constructor() { diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index a6cfe848..b18e275d 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -16,6 +16,11 @@ * along with this program. If not, see . */ +/*global docRangeFromPoint, docSentenceExtract +apiKanjiFind, apiTermsFind, apiNoteView, apiOptionsGet, apiDefinitionsAddable, apiDefinitionAdd +apiScreenshotGet, apiForward +audioPrepareTextToSpeech, audioGetFromSources +DisplayGenerator, WindowScroll, DisplayContext, DOM*/ class Display { constructor(spinner, container) { diff --git a/ext/mixed/js/text-scanner.js b/ext/mixed/js/text-scanner.js index 88f1e27a..e6da1e5e 100644 --- a/ext/mixed/js/text-scanner.js +++ b/ext/mixed/js/text-scanner.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global docRangeFromPoint, TextSourceRange, DOM*/ class TextScanner { constructor(node, ignoreNodes, ignoreElements, ignorePoints) { -- cgit v1.2.3 From e2ac478cb7635cbd15d0033bd2c486689a7b4e67 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 11 Feb 2020 22:19:47 -0500 Subject: Define more globals --- .eslintrc.json | 1 + ext/bg/js/backend.js | 2 +- ext/bg/js/clipboard-monitor.js | 1 + ext/bg/js/search-query-parser-generator.js | 1 + ext/bg/js/search-query-parser.js | 2 +- ext/bg/js/search.js | 2 +- ext/bg/js/settings/dictionaries.js | 2 +- ext/fg/js/document.js | 1 + ext/fg/js/float.js | 1 + ext/fg/js/frontend-initialize.js | 1 + ext/fg/js/frontend.js | 1 + ext/fg/js/popup-nested.js | 1 + ext/fg/js/popup-proxy-host.js | 1 + ext/fg/js/popup-proxy.js | 1 + ext/fg/js/popup.js | 1 + 15 files changed, 15 insertions(+), 4 deletions(-) (limited to '.eslintrc.json') diff --git a/.eslintrc.json b/.eslintrc.json index 9b1a19b3..f502479d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -49,6 +49,7 @@ "stringReverse": "readonly", "promiseTimeout": "readonly", "stringReplaceAsync": "readonly", + "parseUrl": "readonly", "EventDispatcher": "readonly", "EXTENSION_IS_BROWSER_EDGE": "readonly" } diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 1a1dc735..7b2ec46d 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -23,7 +23,7 @@ requestText, requestJson, optionsLoad dictConfigured, dictTermsSort, dictEnabledSet, dictNoteFormat audioGetUrl, audioInject jpConvertReading, jpDistributeFuriganaInflected, jpKatakanaToHiragana -Translator, AnkiConnect, AnkiNull, Mecab, BackendApiForwarder, JsonSchema*/ +Translator, AnkiConnect, AnkiNull, Mecab, BackendApiForwarder, JsonSchema, ClipboardMonitor*/ class Backend { constructor() { diff --git a/ext/bg/js/clipboard-monitor.js b/ext/bg/js/clipboard-monitor.js index b4a27fa2..c2f41385 100644 --- a/ext/bg/js/clipboard-monitor.js +++ b/ext/bg/js/clipboard-monitor.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global apiClipboardGet, jpIsStringPartiallyJapanese*/ class ClipboardMonitor { constructor() { diff --git a/ext/bg/js/search-query-parser-generator.js b/ext/bg/js/search-query-parser-generator.js index 8d71890b..f842644e 100644 --- a/ext/bg/js/search-query-parser-generator.js +++ b/ext/bg/js/search-query-parser-generator.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global apiGetQueryParserTemplatesHtml, TemplateHandler*/ class QueryParserGenerator { constructor() { diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js index ff0dbaef..49c0bb34 100644 --- a/ext/bg/js/search-query-parser.js +++ b/ext/bg/js/search-query-parser.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -/*global apiTermsFind, apiOptionsSet, apiTextParse, apiTextParseMecab, apiTemplateRender, TextScanner*/ +/*global apiTermsFind, apiOptionsSet, apiTextParse, apiTextParseMecab, apiTemplateRender, TextScanner, QueryParserGenerator*/ class QueryParser extends TextScanner { constructor(search) { diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index 312d1de4..50ec146f 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -17,7 +17,7 @@ */ /*global jpIsStringPartiallyJapanese, apiOptionsSet, apiTermsFind, apiClipboardGet, apiGetEnvironmentInfo -Display, QueryParser*/ +Display, QueryParser, ClipboardMonitor*/ class DisplaySearch extends Display { constructor() { diff --git a/ext/bg/js/settings/dictionaries.js b/ext/bg/js/settings/dictionaries.js index c80aac73..fb459404 100644 --- a/ext/bg/js/settings/dictionaries.js +++ b/ext/bg/js/settings/dictionaries.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -/*global getOptionsContext, getOptionsMutable, getOptionsFullMutable, settingsSaveOptions, apiOptionsGetFull +/*global getOptionsContext, getOptionsMutable, getOptionsFullMutable, settingsSaveOptions, apiOptionsGetFull, apiOptionsGet utilBackgroundIsolate, utilDatabaseDeleteDictionary, utilDatabaseGetDictionaryInfo, utilDatabaseGetDictionaryCounts utilDatabasePurge, utilDatabaseImport storageUpdateStats, storageEstimate diff --git a/ext/fg/js/document.js b/ext/fg/js/document.js index 71654b29..7284cdd1 100644 --- a/ext/fg/js/document.js +++ b/ext/fg/js/document.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global TextSourceElement, TextSourceRange, DOM*/ const REGEX_TRANSPARENT_COLOR = /rgba\s*\([^)]*,\s*0(?:\.0+)?\s*\)/; diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js index 8d61d8f6..d31b8336 100644 --- a/ext/fg/js/float.js +++ b/ext/fg/js/float.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global popupNestedInitialize, Display*/ class DisplayFloat extends Display { constructor() { diff --git a/ext/fg/js/frontend-initialize.js b/ext/fg/js/frontend-initialize.js index 9c923fea..c32e97d4 100644 --- a/ext/fg/js/frontend-initialize.js +++ b/ext/fg/js/frontend-initialize.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global PopupProxyHost, PopupProxy, Frontend*/ async function main() { const data = window.frontendInitializationData || {}; diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 2286bf19..3611d44e 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global apiGetZoom, apiOptionsGet, apiTermsFind, apiKanjiFind, docSentenceExtract, TextScanner*/ class Frontend extends TextScanner { constructor(popup, ignoreNodes) { diff --git a/ext/fg/js/popup-nested.js b/ext/fg/js/popup-nested.js index 3f3c945e..3e5f5b80 100644 --- a/ext/fg/js/popup-nested.js +++ b/ext/fg/js/popup-nested.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global apiOptionsGet*/ let popupNestedInitialized = false; diff --git a/ext/fg/js/popup-proxy-host.js b/ext/fg/js/popup-proxy-host.js index 427172c6..98729796 100644 --- a/ext/fg/js/popup-proxy-host.js +++ b/ext/fg/js/popup-proxy-host.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global apiFrameInformationGet, FrontendApiReceiver, Popup*/ class PopupProxyHost { constructor() { diff --git a/ext/fg/js/popup-proxy.js b/ext/fg/js/popup-proxy.js index 63aa6bbe..db6dffb1 100644 --- a/ext/fg/js/popup-proxy.js +++ b/ext/fg/js/popup-proxy.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global FrontendApiSender*/ class PopupProxy { constructor(depth, parentId, parentFrameId, url) { diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js index e7dae93e..0b142dda 100644 --- a/ext/fg/js/popup.js +++ b/ext/fg/js/popup.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global apiInjectStylesheet*/ class Popup { constructor(id, depth, frameIdPromise) { -- cgit v1.2.3 From 571a1fdbeb47b7557a77ed36291f9d4a604c7653 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 11 Feb 2020 22:21:30 -0500 Subject: Update rules for test files --- .eslintrc.json | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to '.eslintrc.json') diff --git a/.eslintrc.json b/.eslintrc.json index f502479d..d4ae215b 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -65,6 +65,15 @@ "env": { "jquery": true } + }, + { + "files": ["test/**/*.js"], + "env": { + "browser": false, + "es2017": false, + "webextensions": false, + "node": true + } } ] } -- cgit v1.2.3 From e83167dcd1f40ed8c9fd0f2f1039717b61175e9e Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 11 Feb 2020 22:11:28 -0500 Subject: Add eslint-plugin-no-unsanitized --- .eslintrc.json | 5 ++++- package-lock.json | 6 ++++++ package.json | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) (limited to '.eslintrc.json') diff --git a/.eslintrc.json b/.eslintrc.json index d4ae215b..39c5e964 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -10,6 +10,7 @@ "es2017": true, "webextensions": true }, + "plugins": ["no-unsanitized"], "ignorePatterns": [ "/ext/mixed/lib/", "/ext/bg/js/templates.js" @@ -32,7 +33,9 @@ "quote-props": ["error", "consistent"], "quotes": ["error", "single", "avoid-escape"], "require-atomic-updates": "off", - "semi": "error" + "semi": "error", + "no-unsanitized/method": "error", + "no-unsanitized/property": "error" }, "overrides": [ { diff --git a/package-lock.json b/package-lock.json index 0d8eb27f..11cf28bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -264,6 +264,12 @@ "v8-compile-cache": "^2.0.3" } }, + "eslint-plugin-no-unsanitized": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-no-unsanitized/-/eslint-plugin-no-unsanitized-3.0.2.tgz", + "integrity": "sha512-JnwpoH8Sv4QOjrTDutENBHzSnyYtspdjtglYtqUtAHe6f6LLKqykJle+UwFPg23GGwt5hI3amS9CRDezW8GAww==", + "dev": true + }, "eslint-scope": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz", diff --git a/package.json b/package.json index eb1fb25c..8e71de59 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ }, "homepage": "https://foosoft.net/projects/yomichan/", "devDependencies": { - "eslint": "^6.8.0" + "eslint": "^6.8.0", + "eslint-plugin-no-unsanitized": "^3.0.2" } } -- cgit v1.2.3 From 070ae70f7cd635f2b8742a6c406d1ef7b09ccc51 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 16 Feb 2020 16:33:48 -0500 Subject: Create EventListenerCollection class --- .eslintrc.json | 1 + ext/bg/js/settings/dictionaries.js | 24 ++++------------ ext/mixed/js/core.js | 23 +++++++++++++++ ext/mixed/js/display.js | 59 ++++++++++++++++++-------------------- ext/mixed/js/text-scanner.js | 24 ++++------------ 5 files changed, 64 insertions(+), 67 deletions(-) (limited to '.eslintrc.json') diff --git a/.eslintrc.json b/.eslintrc.json index d4ae215b..bda308e2 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -51,6 +51,7 @@ "stringReplaceAsync": "readonly", "parseUrl": "readonly", "EventDispatcher": "readonly", + "EventListenerCollection": "readonly", "EXTENSION_IS_BROWSER_EDGE": "readonly" } }, diff --git a/ext/bg/js/settings/dictionaries.js b/ext/bg/js/settings/dictionaries.js index fb459404..adad76fb 100644 --- a/ext/bg/js/settings/dictionaries.js +++ b/ext/bg/js/settings/dictionaries.js @@ -179,7 +179,7 @@ class SettingsDictionaryEntryUI { this.dictionaryInfo = dictionaryInfo; this.optionsDictionary = optionsDictionary; this.counts = null; - this.eventListeners = []; + this.eventListeners = new EventListenerCollection(); this.isDeleting = false; this.content = content; @@ -198,10 +198,10 @@ class SettingsDictionaryEntryUI { this.applyValues(); - this.addEventListener(this.enabledCheckbox, 'change', (e) => this.onEnabledChanged(e), false); - this.addEventListener(this.allowSecondarySearchesCheckbox, 'change', (e) => this.onAllowSecondarySearchesChanged(e), false); - this.addEventListener(this.priorityInput, 'change', (e) => this.onPriorityChanged(e), false); - this.addEventListener(this.deleteButton, 'click', (e) => this.onDeleteButtonClicked(e), false); + this.eventListeners.addEventListener(this.enabledCheckbox, 'change', (e) => this.onEnabledChanged(e), false); + this.eventListeners.addEventListener(this.allowSecondarySearchesCheckbox, 'change', (e) => this.onAllowSecondarySearchesChanged(e), false); + this.eventListeners.addEventListener(this.priorityInput, 'change', (e) => this.onPriorityChanged(e), false); + this.eventListeners.addEventListener(this.deleteButton, 'click', (e) => this.onDeleteButtonClicked(e), false); } cleanup() { @@ -212,7 +212,7 @@ class SettingsDictionaryEntryUI { this.content = null; } this.dictionaryInfo = null; - this.clearEventListeners(); + this.eventListeners.removeAllEventListeners(); } setCounts(counts) { @@ -229,18 +229,6 @@ class SettingsDictionaryEntryUI { this.parent.save(); } - addEventListener(node, type, listener, options) { - node.addEventListener(type, listener, options); - this.eventListeners.push([node, type, listener, options]); - } - - clearEventListeners() { - for (const [node, type, listener, options] of this.eventListeners) { - node.removeEventListener(type, listener, options); - } - this.eventListeners = []; - } - applyValues() { this.enabledCheckbox.checked = this.optionsDictionary.enabled; this.allowSecondarySearchesCheckbox.checked = this.optionsDictionary.allowSecondarySearches; diff --git a/ext/mixed/js/core.js b/ext/mixed/js/core.js index b6ecb48b..330a30fb 100644 --- a/ext/mixed/js/core.js +++ b/ext/mixed/js/core.js @@ -236,6 +236,29 @@ class EventDispatcher { } } +class EventListenerCollection { + constructor() { + this._eventListeners = []; + } + + get size() { + return this._eventListeners.length; + } + + addEventListener(node, type, listener, options) { + node.addEventListener(type, listener, options); + this._eventListeners.push([node, type, listener, options]); + } + + removeAllEventListeners() { + if (this._eventListeners.length === 0) { return; } + for (const [node, type, listener, options] of this._eventListeners) { + node.removeEventListener(type, listener, options); + } + this._eventListeners = []; + } +} + /* * Default message handlers diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index e914b082..8113260c 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -35,8 +35,8 @@ class Display { this.audioCache = new Map(); this.styleNode = null; - this.eventListeners = []; - this.persistentEventListeners = []; + this.eventListeners = new EventListenerCollection(); + this.persistentEventListeners = new EventListenerCollection(); this.interactive = false; this.eventListenersActive = false; this.clickScanPrevent = false; @@ -301,13 +301,23 @@ class Display { this.interactive = interactive; if (interactive) { - Display.addEventListener(this.persistentEventListeners, document, 'keydown', this.onKeyDown.bind(this), false); - Display.addEventListener(this.persistentEventListeners, document, 'wheel', this.onWheel.bind(this), {passive: false}); - Display.addEventListener(this.persistentEventListeners, document.querySelector('.action-previous'), 'click', this.onSourceTermView.bind(this)); - Display.addEventListener(this.persistentEventListeners, document.querySelector('.action-next'), 'click', this.onNextTermView.bind(this)); - Display.addEventListener(this.persistentEventListeners, document.querySelector('.navigation-header'), 'wheel', this.onHistoryWheel.bind(this), {passive: false}); + const actionPrevious = document.querySelector('.action-previous'); + const actionNext = document.querySelector('.action-next'); + const navigationHeader = document.querySelector('.navigation-header'); + + this.persistentEventListeners.addEventListener(document, 'keydown', this.onKeyDown.bind(this), false); + this.persistentEventListeners.addEventListener(document, 'wheel', this.onWheel.bind(this), {passive: false}); + if (actionPrevious !== null) { + this.persistentEventListeners.addEventListener(actionPrevious, 'click', this.onSourceTermView.bind(this)); + } + if (actionNext !== null) { + this.persistentEventListeners.addEventListener(actionNext, 'click', this.onNextTermView.bind(this)); + } + if (navigationHeader !== null) { + this.persistentEventListeners.addEventListener(navigationHeader, 'wheel', this.onHistoryWheel.bind(this), {passive: false}); + } } else { - Display.clearEventListeners(this.persistentEventListeners); + this.persistentEventListeners.removeAllEventListeners(); } this.setEventListenersActive(this.eventListenersActive); } @@ -318,23 +328,23 @@ class Display { this.eventListenersActive = active; if (active) { - this.addEventListeners('.action-add-note', 'click', this.onNoteAdd.bind(this)); - this.addEventListeners('.action-view-note', 'click', this.onNoteView.bind(this)); - this.addEventListeners('.action-play-audio', 'click', this.onAudioPlay.bind(this)); - this.addEventListeners('.kanji-link', 'click', this.onKanjiLookup.bind(this)); + this.addMultipleEventListeners('.action-add-note', 'click', this.onNoteAdd.bind(this)); + this.addMultipleEventListeners('.action-view-note', 'click', this.onNoteView.bind(this)); + this.addMultipleEventListeners('.action-play-audio', 'click', this.onAudioPlay.bind(this)); + this.addMultipleEventListeners('.kanji-link', 'click', this.onKanjiLookup.bind(this)); if (this.options.scanning.enablePopupSearch) { - this.addEventListeners('.term-glossary-item, .tag', 'mouseup', this.onGlossaryMouseUp.bind(this)); - this.addEventListeners('.term-glossary-item, .tag', 'mousedown', this.onGlossaryMouseDown.bind(this)); - this.addEventListeners('.term-glossary-item, .tag', 'mousemove', this.onGlossaryMouseMove.bind(this)); + this.addMultipleEventListeners('.term-glossary-item, .tag', 'mouseup', this.onGlossaryMouseUp.bind(this)); + this.addMultipleEventListeners('.term-glossary-item, .tag', 'mousedown', this.onGlossaryMouseDown.bind(this)); + this.addMultipleEventListeners('.term-glossary-item, .tag', 'mousemove', this.onGlossaryMouseMove.bind(this)); } } else { - Display.clearEventListeners(this.eventListeners); + this.eventListeners.removeAllEventListeners(); } } - addEventListeners(selector, type, listener, options) { + addMultipleEventListeners(selector, type, listener, options) { for (const node of this.container.querySelectorAll(selector)) { - Display.addEventListener(this.eventListeners, node, type, listener, options); + this.eventListeners.addEventListener(node, type, listener, options); } } @@ -793,19 +803,6 @@ class Display { return -1; } - static addEventListener(eventListeners, object, type, listener, options) { - if (object === null) { return; } - object.addEventListener(type, listener, options); - eventListeners.push([object, type, listener, options]); - } - - static clearEventListeners(eventListeners) { - for (const [object, type, listener, options] of eventListeners) { - object.removeEventListener(type, listener, options); - } - eventListeners.length = 0; - } - static getElementTop(element) { const elementRect = element.getBoundingClientRect(); const documentRect = document.documentElement.getBoundingClientRect(); diff --git a/ext/mixed/js/text-scanner.js b/ext/mixed/js/text-scanner.js index e6da1e5e..aa10bbaf 100644 --- a/ext/mixed/js/text-scanner.js +++ b/ext/mixed/js/text-scanner.js @@ -31,7 +31,7 @@ class TextScanner { this.options = null; this.enabled = false; - this.eventListeners = []; + this.eventListeners = new EventListenerCollection(); this.primaryTouchIdentifier = null; this.preventNextContextMenu = false; @@ -229,7 +229,7 @@ class TextScanner { } } else { if (this.enabled) { - this.clearEventListeners(); + this.eventListeners.removeAllEventListeners(); this.enabled = false; } this.onSearchClear(false); @@ -237,13 +237,13 @@ class TextScanner { } hookEvents() { - let eventListeners = this.getMouseEventListeners(); + let eventListenerInfos = this.getMouseEventListeners(); if (this.options.scanning.touchInputEnabled) { - eventListeners = eventListeners.concat(this.getTouchEventListeners()); + eventListenerInfos = eventListenerInfos.concat(this.getTouchEventListeners()); } - for (const [node, type, listener, options] of eventListeners) { - this.addEventListener(node, type, listener, options); + for (const [node, type, listener, options] of eventListenerInfos) { + this.eventListeners.addEventListener(node, type, listener, options); } } @@ -268,18 +268,6 @@ class TextScanner { ]; } - addEventListener(node, type, listener, options) { - node.addEventListener(type, listener, options); - this.eventListeners.push([node, type, listener, options]); - } - - clearEventListeners() { - for (const [node, type, listener, options] of this.eventListeners) { - node.removeEventListener(type, listener, options); - } - this.eventListeners = []; - } - setOptions(options) { this.options = options; this.setEnabled(this.options.general.enable); -- cgit v1.2.3 From 4f39ac207917c6f4cd1f840ccf338137785e99cc Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 19 Feb 2020 20:00:27 -0500 Subject: Upadte eslintrc --- .eslintrc.json | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to '.eslintrc.json') diff --git a/.eslintrc.json b/.eslintrc.json index a350bce4..9b0754fc 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -72,11 +72,15 @@ }, { "files": ["test/**/*.js"], + "parserOptions": { + "ecmaVersion": 8, + "sourceType": "module" + }, "env": { "browser": false, - "es2017": false, - "webextensions": false, - "node": true + "es2017": true, + "node": true, + "webextensions": false } } ] -- cgit v1.2.3 From b3212d776e3f6d735bc9d67acbebc28b7f061ba8 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 15 Feb 2020 20:11:29 -0500 Subject: Stylistic rules --- .eslintrc.json | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to '.eslintrc.json') diff --git a/.eslintrc.json b/.eslintrc.json index 9b0754fc..b21c00f4 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -21,11 +21,13 @@ "curly": ["error", "all"], "dot-notation": "error", "eqeqeq": "error", + "func-names": ["error", "always"], "no-case-declarations": "error", "no-const-assign": "error", "no-constant-condition": "off", "no-global-assign": "error", "no-undef": "error", + "no-unneeded-ternary": "error", "no-unused-vars": ["error", {"vars": "local", "args": "after-used", "argsIgnorePattern": "^_", "caughtErrors": "none"}], "no-unused-expressions": "error", "no-var": "error", @@ -34,6 +36,35 @@ "quotes": ["error", "single", "avoid-escape"], "require-atomic-updates": "off", "semi": "error", + + // Whitespace rules + "brace-style": ["error", "1tbs", {"allowSingleLine": true}], + "indent": ["error", 4, {"SwitchCase": 1, "MemberExpression": 1, "flatTernaryExpressions": true, "ignoredNodes": ["ConditionalExpression"]}], + "object-curly-newline": "error", + "padded-blocks": ["error", "never"], + + "array-bracket-spacing": ["error", "never"], + "arrow-spacing": ["error", {"before": true, "after": true}], + "block-spacing": ["error", "always"], + "comma-spacing": ["error", { "before": false, "after": true }], + "computed-property-spacing": ["error", "never"], + "func-call-spacing": ["error", "never"], + "generator-star-spacing": ["error", "before"], + "key-spacing": ["error", {"beforeColon": false, "afterColon": true, "mode": "strict"}], + "keyword-spacing": ["error", {"before": true, "after": true}], + "no-trailing-spaces": "error", + "no-whitespace-before-property": "error", + "object-curly-spacing": ["error", "never"], + "rest-spread-spacing": ["error", "never"], + "semi-spacing": ["error", {"before": false, "after": true}], + "space-in-parens": ["error", "never"], + "space-unary-ops": "error", + "spaced-comment": ["error", "always", {"markers": ["global"]}], + "switch-colon-spacing": ["error", {"after": true, "before": false}], + "template-curly-spacing": ["error", "never"], + "template-tag-spacing": ["error", "never"], + + // Extensions "no-unsanitized/method": "error", "no-unsanitized/property": "error" }, -- cgit v1.2.3 From c0d91bffc461c61af9d35aecb7c92e15648382b2 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Mon, 17 Feb 2020 15:21:30 -0500 Subject: Add no-shadow --- .eslintrc.json | 1 + ext/bg/js/backend.js | 32 ++++++++++++++++---------------- ext/bg/js/database.js | 4 ++-- ext/bg/js/japanese.js | 12 ++++++------ ext/bg/js/json-schema.js | 2 +- ext/bg/js/search.js | 4 ++-- ext/bg/js/settings/dictionaries.js | 2 +- ext/mixed/js/core.js | 6 +++--- 8 files changed, 32 insertions(+), 31 deletions(-) (limited to '.eslintrc.json') diff --git a/.eslintrc.json b/.eslintrc.json index b21c00f4..cfee7be8 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -26,6 +26,7 @@ "no-const-assign": "error", "no-constant-condition": "off", "no-global-assign": "error", + "no-shadow": ["error", {"builtinGlobals": false}], "no-undef": "error", "no-unneeded-ternary": "error", "no-unused-vars": ["error", {"vars": "local", "args": "after-used", "argsIgnorePattern": "^_", "caughtErrors": "none"}], diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 7c71f82c..2691b7d9 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -274,18 +274,18 @@ class Backend { const node = nodes.pop(); for (const key of Object.keys(node.obj)) { const path = node.path.concat(key); - const obj = node.obj[key]; - if (obj !== null && typeof obj === 'object') { - nodes.unshift({obj, path}); + const obj2 = node.obj[key]; + if (obj2 !== null && typeof obj2 === 'object') { + nodes.unshift({obj: obj2, path}); } else { - valuePaths.push([obj, path]); + valuePaths.push([obj2, path]); } } } return valuePaths; } - function modifyOption(path, value, options) { + function modifyOption(path, value) { let pivot = options; for (const key of path.slice(0, -1)) { if (!hasOwn(pivot, key)) { @@ -298,7 +298,7 @@ class Backend { } for (const [value, path] of getValuePaths(changedOptions)) { - modifyOption(path, value, options); + modifyOption(path, value); } await this._onApiOptionsSave({source}); @@ -340,9 +340,9 @@ class Backend { dictTermsSort(definitions); const {expression, reading} = definitions[0]; const source = text.substring(0, sourceLength); - for (const {text, furigana} of jpDistributeFuriganaInflected(expression, reading, source)) { - const reading = jpConvertReading(text, furigana, options.parsing.readingMode); - term.push({text, reading}); + for (const {text: text2, furigana} of jpDistributeFuriganaInflected(expression, reading, source)) { + const reading2 = jpConvertReading(text2, furigana, options.parsing.readingMode); + term.push({text: text2, reading: reading2}); } text = text.substring(source.length); } else { @@ -365,17 +365,17 @@ class Backend { for (const {expression, reading, source} of parsedLine) { const term = []; if (expression !== null && reading !== null) { - for (const {text, furigana} of jpDistributeFuriganaInflected( + for (const {text: text2, furigana} of jpDistributeFuriganaInflected( expression, jpKatakanaToHiragana(reading), source )) { - const reading = jpConvertReading(text, furigana, options.parsing.readingMode); - term.push({text, reading}); + const reading2 = jpConvertReading(text2, furigana, options.parsing.readingMode); + term.push({text: text2, reading: reading2}); } } else { - const reading = jpConvertReading(source, null, options.parsing.readingMode); - term.push({text: source, reading}); + const reading2 = jpConvertReading(source, null, options.parsing.readingMode); + term.push({text: source, reading: reading2}); } result.push(term); } @@ -816,12 +816,12 @@ class Backend { try { const tabWindow = await new Promise((resolve, reject) => { - chrome.windows.get(tab.windowId, {}, (tabWindow) => { + chrome.windows.get(tab.windowId, {}, (value) => { const e = chrome.runtime.lastError; if (e) { reject(e); } else { - resolve(tabWindow); + resolve(value); } }); }); diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js index 1f6810cf..558f3ceb 100644 --- a/ext/bg/js/database.js +++ b/ext/bg/js/database.js @@ -809,9 +809,9 @@ class Database { for (const objectStoreName of objectStoreNames) { const {primaryKey, indices} = stores[objectStoreName]; - const objectStoreNames = transaction.objectStoreNames || db.objectStoreNames; + const objectStoreNames2 = transaction.objectStoreNames || db.objectStoreNames; const objectStore = ( - Database._listContains(objectStoreNames, objectStoreName) ? + Database._listContains(objectStoreNames2, objectStoreName) ? transaction.objectStore(objectStoreName) : db.createObjectStore(objectStoreName, primaryKey) ); diff --git a/ext/bg/js/japanese.js b/ext/bg/js/japanese.js index e8a6fa08..abb32da4 100644 --- a/ext/bg/js/japanese.js +++ b/ext/bg/js/japanese.js @@ -224,15 +224,15 @@ function jpDistributeFurigana(expression, reading) { } let isAmbiguous = false; - const segmentize = (reading, groups) => { + const segmentize = (reading2, groups) => { if (groups.length === 0 || isAmbiguous) { return []; } const group = groups[0]; if (group.mode === 'kana') { - if (jpKatakanaToHiragana(reading).startsWith(jpKatakanaToHiragana(group.text))) { - const readingLeft = reading.substring(group.text.length); + if (jpKatakanaToHiragana(reading2).startsWith(jpKatakanaToHiragana(group.text))) { + const readingLeft = reading2.substring(group.text.length); const segs = segmentize(readingLeft, groups.splice(1)); if (segs) { return [{text: group.text}].concat(segs); @@ -240,9 +240,9 @@ function jpDistributeFurigana(expression, reading) { } } else { let foundSegments = null; - for (let i = reading.length; i >= group.text.length; --i) { - const readingUsed = reading.substring(0, i); - const readingLeft = reading.substring(i); + for (let i = reading2.length; i >= group.text.length; --i) { + const readingUsed = reading2.substring(0, i); + const readingLeft = reading2.substring(i); const segs = segmentize(readingLeft, groups.slice(1)); if (segs) { if (foundSegments !== null) { diff --git a/ext/bg/js/json-schema.js b/ext/bg/js/json-schema.js index 3cf24c35..58f804fd 100644 --- a/ext/bg/js/json-schema.js +++ b/ext/bg/js/json-schema.js @@ -401,7 +401,7 @@ class JsonSchemaProxyHandler { info.valuePush(i, propertyValue); JsonSchemaProxyHandler.validate(propertyValue, propertySchema, info); info.valuePop(); - for (let i = 0; i < schemaPath.length; ++i) { info.schemaPop(); } + for (let j = 0, jj = schemaPath.length; j < jj; ++j) { info.schemaPop(); } } } diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index 76a62b97..98e167ad 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -70,7 +70,7 @@ class DisplaySearch extends Display { this.wanakanaEnable.checked = false; } this.wanakanaEnable.addEventListener('change', (e) => { - const {queryParams: {query=''}} = parseUrl(window.location.href); + const {queryParams: {query: query2=''}} = parseUrl(window.location.href); if (e.target.checked) { window.wanakana.bind(this.query); apiOptionsSet({general: {enableWanakana: true}}, this.getOptionsContext()); @@ -78,7 +78,7 @@ class DisplaySearch extends Display { window.wanakana.unbind(this.query); apiOptionsSet({general: {enableWanakana: false}}, this.getOptionsContext()); } - this.setQuery(query); + this.setQuery(query2); this.onSearchQueryUpdated(this.query.value, false); }); } diff --git a/ext/bg/js/settings/dictionaries.js b/ext/bg/js/settings/dictionaries.js index 427f47f0..70a22a16 100644 --- a/ext/bg/js/settings/dictionaries.js +++ b/ext/bg/js/settings/dictionaries.js @@ -166,7 +166,7 @@ class SettingsDictionaryListUI { delete n.dataset.dict; $(n).modal('hide'); - const index = this.dictionaryEntries.findIndex((e) => e.dictionaryInfo.title === title); + const index = this.dictionaryEntries.findIndex((entry) => entry.dictionaryInfo.title === title); if (index >= 0) { this.dictionaryEntries[index].deleteDictionary(); } diff --git a/ext/mixed/js/core.js b/ext/mixed/js/core.js index 330a30fb..83813796 100644 --- a/ext/mixed/js/core.js +++ b/ext/mixed/js/core.js @@ -160,9 +160,9 @@ function promiseTimeout(delay, resolveValue) { const resolve = (value) => complete(promiseResolve, value); const reject = (value) => complete(promiseReject, value); - const promise = new Promise((resolve, reject) => { - promiseResolve = resolve; - promiseReject = reject; + const promise = new Promise((resolve2, reject2) => { + promiseResolve = resolve2; + promiseReject = reject2; }); timer = window.setTimeout(() => { timer = null; -- cgit v1.2.3 From f1ccd5280635f9528b2cfe4629222c627065781c Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Mon, 17 Feb 2020 15:28:10 -0500 Subject: Explicitly indicate that "no-param-reassign" is allowed --- .eslintrc.json | 1 + 1 file changed, 1 insertion(+) (limited to '.eslintrc.json') diff --git a/.eslintrc.json b/.eslintrc.json index cfee7be8..2dc63e80 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -26,6 +26,7 @@ "no-const-assign": "error", "no-constant-condition": "off", "no-global-assign": "error", + "no-param-reassign": "off", "no-shadow": ["error", {"builtinGlobals": false}], "no-undef": "error", "no-unneeded-ternary": "error", -- cgit v1.2.3 From 9dd779836c34c6877c9736d937c3c4109b173b18 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Mon, 17 Feb 2020 15:30:41 -0500 Subject: Add "no-prototype-builtins" --- .eslintrc.json | 1 + 1 file changed, 1 insertion(+) (limited to '.eslintrc.json') diff --git a/.eslintrc.json b/.eslintrc.json index 2dc63e80..fcc6995b 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -27,6 +27,7 @@ "no-constant-condition": "off", "no-global-assign": "error", "no-param-reassign": "off", + "no-prototype-builtins": "error", "no-shadow": ["error", {"builtinGlobals": false}], "no-undef": "error", "no-unneeded-ternary": "error", -- cgit v1.2.3