Merge pull request #344 from toasted-nutbread/eslint-strengthening
Eslint strengthening
This commit is contained in:
commit
af89659751
@ -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/",
|
||||
@ -16,13 +23,57 @@
|
||||
"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",
|
||||
"prefer-const": ["error", {"destructuring": "all"}],
|
||||
"quote-props": ["error", "consistent"],
|
||||
"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",
|
||||
"parseUrl": "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
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": ["test/**/*.js"],
|
||||
"env": {
|
||||
"browser": false,
|
||||
"es2017": false,
|
||||
"webextensions": false,
|
||||
"node": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global requestJson*/
|
||||
|
||||
/*
|
||||
* AnkiConnect
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global jpIsStringEntirelyKana, audioGetFromSources*/
|
||||
|
||||
const audioUrlBuilders = new Map([
|
||||
['jpod101', async (definition) => {
|
||||
|
@ -16,6 +16,14 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*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, ClipboardMonitor*/
|
||||
|
||||
class Backend {
|
||||
constructor() {
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global apiClipboardGet, jpIsStringPartiallyJapanese*/
|
||||
|
||||
class ClipboardMonitor {
|
||||
constructor() {
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global apiCommandExec, apiGetEnvironmentInfo, apiOptionsGet*/
|
||||
|
||||
function showExtensionInfo() {
|
||||
const node = document.getElementById('extension-info');
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global dictFieldSplit, dictTagSanitize, JSZip*/
|
||||
|
||||
class Database {
|
||||
constructor() {
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global utilSetEqual, utilSetIntersection, apiTemplateRender*/
|
||||
|
||||
function dictEnabledSet(options) {
|
||||
const dictionaries = {};
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global jpIsCharCodeKanji, jpDistributeFurigana, Handlebars*/
|
||||
|
||||
function handlebarsEscape(text) {
|
||||
return Handlebars.Utils.escapeExpression(text);
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global wanakana*/
|
||||
|
||||
const JP_HALFWIDTH_KATAKANA_MAPPING = new Map([
|
||||
['ヲ', 'ヲヺ-'],
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global utilStringHashCode*/
|
||||
|
||||
/*
|
||||
* Generic options functions
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global apiOptionsGet*/
|
||||
|
||||
async function searchFrontendSetup() {
|
||||
const optionsContext = {
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global apiGetQueryParserTemplatesHtml, TemplateHandler*/
|
||||
|
||||
class QueryParserGenerator {
|
||||
constructor() {
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global apiTermsFind, apiOptionsSet, apiTextParse, apiTextParseMecab, TextScanner, QueryParserGenerator*/
|
||||
|
||||
class QueryParser extends TextScanner {
|
||||
constructor(search) {
|
||||
|
@ -16,6 +16,8 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global apiOptionsSet, apiTermsFind, Display, QueryParser, ClipboardMonitor*/
|
||||
|
||||
class DisplaySearch extends Display {
|
||||
constructor() {
|
||||
super(document.querySelector('#spinner'), document.querySelector('#content'));
|
||||
|
@ -16,6 +16,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global getOptionsContext, getOptionsMutable, settingsSaveOptions
|
||||
profileOptionsGetDefaultFieldTemplates, ankiGetFieldMarkers, ankiGetFieldMarkersHtml, dictFieldFormat
|
||||
apiOptionsGet, apiTermsFind*/
|
||||
|
||||
function onAnkiFieldTemplatesReset(e) {
|
||||
e.preventDefault();
|
||||
|
@ -16,6 +16,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global getOptionsContext, getOptionsMutable, settingsSaveOptions
|
||||
utilBackgroundIsolate, utilAnkiGetDeckNames, utilAnkiGetModelNames, utilAnkiGetModelFieldNames
|
||||
onFormOptionsChanged*/
|
||||
|
||||
// Private
|
||||
|
||||
|
@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
class AudioSourceUI {
|
||||
static instantiateTemplate(templateSelector) {
|
||||
const template = document.querySelector(templateSelector);
|
||||
|
@ -16,6 +16,8 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global getOptionsContext, getOptionsMutable, settingsSaveOptions
|
||||
AudioSourceUI, audioGetTextToSpeechVoice*/
|
||||
|
||||
let audioSourceUI = null;
|
||||
|
||||
|
@ -16,6 +16,10 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global apiOptionsGetFull, apiGetEnvironmentInfo
|
||||
utilBackend, utilIsolate, utilBackgroundIsolate, utilReadFileArrayBuffer
|
||||
optionsGetDefault, optionsUpdateVersion
|
||||
profileOptionsGetDefaultFieldTemplates*/
|
||||
|
||||
// Exporting
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global conditionsNormalizeOptionValue*/
|
||||
|
||||
class ConditionsUI {
|
||||
static instantiateTemplate(templateSelector) {
|
||||
|
@ -16,6 +16,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global getOptionsContext, getOptionsMutable, getOptionsFullMutable, settingsSaveOptions, apiOptionsGetFull, apiOptionsGet
|
||||
utilBackgroundIsolate, utilDatabaseDeleteDictionary, utilDatabaseGetDictionaryInfo, utilDatabaseGetDictionaryCounts
|
||||
utilDatabasePurge, utilDatabaseImport
|
||||
storageUpdateStats, storageEstimate
|
||||
PageExitPrevention*/
|
||||
|
||||
let dictionaryUI = null;
|
||||
|
||||
|
@ -16,6 +16,14 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*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)
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global apiOptionsGet, Popup, PopupProxyHost, Frontend, TextSourceRange*/
|
||||
|
||||
class SettingsPopupPreview {
|
||||
constructor() {
|
||||
|
@ -16,6 +16,10 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global getOptionsMutable, getOptionsFullMutable, settingsSaveOptions, apiOptionsGetFull
|
||||
utilBackgroundIsolate, formWrite
|
||||
conditionsClearCaches, ConditionsUI, profileConditionsDescriptor*/
|
||||
|
||||
let currentProfileIndex = 0;
|
||||
let profileConditionsContainer = null;
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global apiGetEnvironmentInfo*/
|
||||
|
||||
function storageBytesToLabeledString(size) {
|
||||
const base = 1000;
|
||||
|
@ -16,6 +16,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global requestJson
|
||||
dictTermsMergeBySequence, dictTagBuildSource, dictTermsMergeByGloss, dictTermsSort, dictTagsSort
|
||||
dictEnabledSet, dictTermsGroup, dictTermsCompressTags, dictTermsUndupe, dictTagSanitize
|
||||
jpDistributeFurigana, jpConvertHalfWidthKanaToFullWidth, jpConvertNumericTofullWidth
|
||||
jpConvertAlphabeticToKana, jpHiraganaToKatakana, jpKatakanaToHiragana, jpIsCharCodeJapanese
|
||||
Database, Deinflector*/
|
||||
|
||||
class Translator {
|
||||
constructor() {
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global TextSourceElement, TextSourceRange, DOM*/
|
||||
|
||||
const REGEX_TRANSPARENT_COLOR = /rgba\s*\([^)]*,\s*0(?:\.0+)?\s*\)/;
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global popupNestedInitialize, Display*/
|
||||
|
||||
class DisplayFloat extends Display {
|
||||
constructor() {
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global PopupProxyHost, PopupProxy, Frontend*/
|
||||
|
||||
async function main() {
|
||||
const data = window.frontendInitializationData || {};
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global apiGetZoom, apiOptionsGet, apiTermsFind, apiKanjiFind, docSentenceExtract, TextScanner*/
|
||||
|
||||
class Frontend extends TextScanner {
|
||||
constructor(popup, ignoreNodes) {
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global apiOptionsGet*/
|
||||
|
||||
let popupNestedInitialized = false;
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global apiFrameInformationGet, FrontendApiReceiver, Popup*/
|
||||
|
||||
class PopupProxyHost {
|
||||
constructor() {
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global FrontendApiSender*/
|
||||
|
||||
class PopupProxy {
|
||||
constructor(depth, parentId, parentFrameId, url) {
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global apiInjectStylesheet*/
|
||||
|
||||
class Popup {
|
||||
constructor(id, depth, frameIdPromise) {
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global apiAudioGetUrl*/
|
||||
|
||||
class TextToSpeechAudio {
|
||||
constructor(text, voice) {
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global apiGetDisplayTemplatesHtml*/
|
||||
|
||||
class DisplayGenerator {
|
||||
constructor() {
|
||||
|
@ -16,6 +16,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global docRangeFromPoint, docSentenceExtract
|
||||
apiKanjiFind, apiTermsFind, apiNoteView, apiOptionsGet, apiDefinitionsAddable, apiDefinitionAdd
|
||||
apiScreenshotGet, apiForward
|
||||
audioPrepareTextToSpeech, audioGetFromSources
|
||||
DisplayGenerator, WindowScroll, DisplayContext, DOM*/
|
||||
|
||||
class Display {
|
||||
constructor(spinner, container) {
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*global docRangeFromPoint, TextSourceRange, DOM*/
|
||||
|
||||
class TextScanner {
|
||||
constructor(node, ignoreNodes, ignoreElements, ignorePoints) {
|
||||
|
Loading…
Reference in New Issue
Block a user