diff options
| -rw-r--r-- | .eslintrc.json | 2 | ||||
| -rw-r--r-- | ext/bg/js/anki.js | 2 | ||||
| -rw-r--r-- | ext/bg/js/api.js | 2 | ||||
| -rw-r--r-- | ext/bg/js/backend-api-forwarder.js | 4 | ||||
| -rw-r--r-- | ext/bg/js/backend.js | 6 | ||||
| -rw-r--r-- | ext/bg/js/context.js | 2 | ||||
| -rw-r--r-- | ext/bg/js/database.js | 22 | ||||
| -rw-r--r-- | ext/bg/js/dictionary.js | 10 | ||||
| -rw-r--r-- | ext/bg/js/options.js | 6 | ||||
| -rw-r--r-- | ext/bg/js/profile-conditions.js | 2 | ||||
| -rw-r--r-- | ext/bg/js/request.js | 2 | ||||
| -rw-r--r-- | ext/bg/js/search-query-parser.js | 4 | ||||
| -rw-r--r-- | ext/bg/js/settings-dictionaries.js | 10 | ||||
| -rw-r--r-- | ext/bg/js/settings-profiles.js | 2 | ||||
| -rw-r--r-- | ext/bg/js/settings.js | 8 | ||||
| -rw-r--r-- | ext/bg/js/translator.js | 8 | ||||
| -rw-r--r-- | ext/bg/js/util.js | 4 | ||||
| -rw-r--r-- | ext/fg/js/frontend-api-receiver.js | 4 | ||||
| -rw-r--r-- | ext/fg/js/popup.js | 4 | ||||
| -rw-r--r-- | ext/mixed/js/core.js | 2 | 
20 files changed, 53 insertions, 53 deletions
| diff --git a/.eslintrc.json b/.eslintrc.json index fce4b884..0e3b939a 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -8,7 +8,7 @@          "/ext/bg/js/templates.js"      ],      "rules": { -        "arrow-parens": ["error", "as-needed"], +        "arrow-parens": ["error", "always"],          "comma-dangle": ["error", "never"],          "curly": ["error", "all"],          "dot-notation": "error", diff --git a/ext/bg/js/anki.js b/ext/bg/js/anki.js index ac45784b..17b93620 100644 --- a/ext/bg/js/anki.js +++ b/ext/bg/js/anki.js @@ -74,7 +74,7 @@ class AnkiConnect {      async findNoteIds(notes) {          await this.checkVersion(); -        const actions = notes.map(note => ({ +        const actions = notes.map((note) => ({              action: 'findNotes',              params: {                  query: `deck:"${AnkiConnect.escapeQuery(note.deckName)}" ${AnkiConnect.fieldsToQuery(note.fields)}` diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js index d5256acb..b489b8d2 100644 --- a/ext/bg/js/api.js +++ b/ext/bg/js/api.js @@ -207,7 +207,7 @@ async function apiDefinitionsAddable(definitions, modes, optionsContext) {          }          if (cannotAdd.length > 0) { -            const noteIdsArray = await anki.findNoteIds(cannotAdd.map(e => e[0])); +            const noteIdsArray = await anki.findNoteIds(cannotAdd.map((e) => e[0]));              for (let i = 0, ii = Math.min(cannotAdd.length, noteIdsArray.length); i < ii; ++i) {                  const noteIds = noteIdsArray[i];                  if (noteIds.length > 0) { diff --git a/ext/bg/js/backend-api-forwarder.js b/ext/bg/js/backend-api-forwarder.js index 979afd16..db4d30b9 100644 --- a/ext/bg/js/backend-api-forwarder.js +++ b/ext/bg/js/backend-api-forwarder.js @@ -37,8 +37,8 @@ class BackendApiForwarder {          const forwardPort = chrome.tabs.connect(tabId, {name: 'frontend-api-receiver'}); -        port.onMessage.addListener(message => forwardPort.postMessage(message)); -        forwardPort.onMessage.addListener(message => port.postMessage(message)); +        port.onMessage.addListener((message) => forwardPort.postMessage(message)); +        forwardPort.onMessage.addListener((message) => port.postMessage(message));          port.onDisconnect.addListener(() => forwardPort.disconnect());          forwardPort.onDisconnect.addListener(() => port.disconnect());      } diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 73df7cf5..d9f9b586 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -60,7 +60,7 @@ class Backend {          this.applyOptions();          const callback = () => this.checkLastError(chrome.runtime.lastError); -        chrome.tabs.query({}, tabs => { +        chrome.tabs.query({}, (tabs) => {              for (const tab of tabs) {                  chrome.tabs.sendMessage(tab.id, {action: 'optionsUpdate', params: {source}}, callback);              } @@ -77,8 +77,8 @@ class Backend {              const handler = handlers[action];              const promise = handler(params, sender);              promise.then( -                result => callback({result}), -                error => callback({error: errorToJson(error)}) +                (result) => callback({result}), +                (error) => callback({error: errorToJson(error)})              );          } diff --git a/ext/bg/js/context.js b/ext/bg/js/context.js index b288a79a..38a82636 100644 --- a/ext/bg/js/context.js +++ b/ext/bg/js/context.js @@ -63,7 +63,7 @@ window.addEventListener('DOMContentLoaded', () => {          depth: 0,          url: window.location.href      }; -    apiOptionsGet(optionsContext).then(options => { +    apiOptionsGet(optionsContext).then((options) => {          const toggle = document.querySelector('#enable-search');          toggle.checked = options.general.enable;          toggle.addEventListener('change', () => apiCommandExec('toggle'), false); diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js index c53c9f77..a20d5f15 100644 --- a/ext/bg/js/database.js +++ b/ext/bg/js/database.js @@ -257,7 +257,7 @@ class Database {          const dbTerms = dbTransaction.objectStore('tagMeta');          const dbIndex = dbTerms.index('name');          const only = IDBKeyRange.only(name); -        await Database.getAll(dbIndex, only, null, row => { +        await Database.getAll(dbIndex, only, null, (row) => {              if (title === row.dictionary) {                  result = row;              } @@ -273,7 +273,7 @@ class Database {          const dbTransaction = this.db.transaction(['dictionaries'], 'readonly');          const dbDictionaries = dbTransaction.objectStore('dictionaries'); -        await Database.getAll(dbDictionaries, null, null, info => results.push(info)); +        await Database.getAll(dbDictionaries, null, null, (info) => results.push(info));          return results;      } @@ -308,7 +308,7 @@ class Database {              counts.push(null);              const index = i;              const query2 = IDBKeyRange.only(dictionaryNames[i]); -            const countPromise = Database.getCounts(targets, query2).then(v => counts[index] = v); +            const countPromise = Database.getCounts(targets, query2).then((v) => counts[index] = v);              countPromises.push(countPromise);          }          await Promise.all(countPromises); @@ -346,7 +346,7 @@ class Database {              }          }; -        const indexDataLoaded = async summary => { +        const indexDataLoaded = async (summary) => {              if (summary.version > 3) {                  throw new Error('Unsupported dictionary version');              } @@ -522,13 +522,13 @@ class Database {          await indexDataLoaded(summary); -        const buildTermBankName      = index => `term_bank_${index + 1}.json`; -        const buildTermMetaBankName  = index => `term_meta_bank_${index + 1}.json`; -        const buildKanjiBankName     = index => `kanji_bank_${index + 1}.json`; -        const buildKanjiMetaBankName = index => `kanji_meta_bank_${index + 1}.json`; -        const buildTagBankName       = index => `tag_bank_${index + 1}.json`; +        const buildTermBankName      = (index) => `term_bank_${index + 1}.json`; +        const buildTermMetaBankName  = (index) => `term_meta_bank_${index + 1}.json`; +        const buildKanjiBankName     = (index) => `kanji_bank_${index + 1}.json`; +        const buildKanjiMetaBankName = (index) => `kanji_meta_bank_${index + 1}.json`; +        const buildTagBankName       = (index) => `tag_bank_${index + 1}.json`; -        const countBanks = namer => { +        const countBanks = (namer) => {              let count = 0;              while (zip.files[namer(count)]) {                  ++count; @@ -657,7 +657,7 @@ class Database {          const counts = {};          for (const [objectStoreName, index] of targets) {              const n = objectStoreName; -            const countPromise = Database.getCount(index, query).then(count => counts[n] = count); +            const countPromise = Database.getCount(index, query).then((count) => counts[n] = count);              countPromises.push(countPromise);          }          return Promise.all(countPromises).then(() => counts); diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js index 409bed85..0b35e32e 100644 --- a/ext/bg/js/dictionary.js +++ b/ext/bg/js/dictionary.js @@ -99,8 +99,8 @@ function dictTermsCompressTags(definitions) {      let lastPartOfSpeech = '';      for (const definition of definitions) { -        const dictionary = JSON.stringify(definition.definitionTags.filter(tag => tag.category === 'dictionary').map(tag => tag.name).sort()); -        const partOfSpeech = JSON.stringify(definition.definitionTags.filter(tag => tag.category === 'partOfSpeech').map(tag => tag.name).sort()); +        const dictionary = JSON.stringify(definition.definitionTags.filter((tag) => tag.category === 'dictionary').map((tag) => tag.name).sort()); +        const partOfSpeech = JSON.stringify(definition.definitionTags.filter((tag) => tag.category === 'partOfSpeech').map((tag) => tag.name).sort());          const filterOutCategories = []; @@ -117,7 +117,7 @@ function dictTermsCompressTags(definitions) {              lastPartOfSpeech = partOfSpeech;          } -        definition.definitionTags = definition.definitionTags.filter(tag => !filterOutCategories.includes(tag.category)); +        definition.definitionTags = definition.definitionTags.filter((tag) => !filterOutCategories.includes(tag.category));      }  } @@ -231,7 +231,7 @@ function dictTermsMergeByGloss(result, definitions, appendTo, mergedIndices) {          result.reading.add(definition.reading);          for (const tag of definition.definitionTags) { -            if (!definitionsByGloss[gloss].definitionTags.find(existingTag => existingTag.name === tag.name)) { +            if (!definitionsByGloss[gloss].definitionTags.find((existingTag) => existingTag.name === tag.name)) {                  definitionsByGloss[gloss].definitionTags.push(tag);              }          } @@ -246,7 +246,7 @@ function dictTermsMergeByGloss(result, definitions, appendTo, mergedIndices) {              }              for (const tag of definition.termTags) { -                if (!result.expressions.get(definition.expression).get(definition.reading).find(existingTag => existingTag.name === tag.name)) { +                if (!result.expressions.get(definition.expression).get(definition.reading).find((existingTag) => existingTag.name === tag.name)) {                      result.expressions.get(definition.expression).get(definition.reading).push(tag);                  }              } diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js index 358a6b45..e53a8a13 100644 --- a/ext/bg/js/options.js +++ b/ext/bg/js/options.js @@ -429,7 +429,7 @@ function optionsUpdateVersion(options, defaultProfileOptions) {  function optionsLoad() {      return new Promise((resolve, reject) => { -        chrome.storage.local.get(['options'], store => { +        chrome.storage.local.get(['options'], (store) => {              const error = chrome.runtime.lastError;              if (error) {                  reject(new Error(error)); @@ -437,7 +437,7 @@ function optionsLoad() {                  resolve(store.options);              }          }); -    }).then(optionsStr => { +    }).then((optionsStr) => {          if (typeof optionsStr === 'string') {              const options = JSON.parse(optionsStr);              if (isObject(options)) { @@ -447,7 +447,7 @@ function optionsLoad() {          return {};      }).catch(() => {          return {}; -    }).then(options => { +    }).then((options) => {          return (              Array.isArray(options.profiles) ?              optionsUpdateVersion(options, {}) : diff --git a/ext/bg/js/profile-conditions.js b/ext/bg/js/profile-conditions.js index 8272e5dd..ebc6680a 100644 --- a/ext/bg/js/profile-conditions.js +++ b/ext/bg/js/profile-conditions.js @@ -86,7 +86,7 @@ const profileConditionsDescriptor = {                  placeholder: 'Comma separated list of domains',                  defaultValue: 'example.com',                  transformCache: {}, -                transform: (optionValue) => optionValue.split(/[,;\s]+/).map(v => v.trim().toLowerCase()).filter(v => v.length > 0), +                transform: (optionValue) => optionValue.split(/[,;\s]+/).map((v) => v.trim().toLowerCase()).filter((v) => v.length > 0),                  transformReverse: (transformedOptionValue) => transformedOptionValue.join(', '),                  validateTransformed: (transformedOptionValue) => (transformedOptionValue.length > 0),                  test: ({url}, transformedOptionValue) => _profileConditionTestDomainList(url, transformedOptionValue) diff --git a/ext/bg/js/request.js b/ext/bg/js/request.js index 3afc1506..7d73d49b 100644 --- a/ext/bg/js/request.js +++ b/ext/bg/js/request.js @@ -29,7 +29,7 @@ function requestJson(url, action, params) {          } else {              xhr.send();          } -    }).then(responseText => { +    }).then((responseText) => {          try {              return JSON.parse(responseText);          } diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js index 74ef32d8..c7222212 100644 --- a/ext/bg/js/search-query-parser.js +++ b/ext/bg/js/search-query-parser.js @@ -107,7 +107,7 @@ class QueryParser {      }      getParseResult() { -        return this.parseResults.find(r => r.id === this.selectedParser); +        return this.parseResults.find((r) => r.id === this.selectedParser);      }      async setText(text) { @@ -216,7 +216,7 @@ class QueryParser {      static processParseResultForDisplay(result) {          return result.map((term) => { -            return term.filter(part => part.text.trim()).map((part) => { +            return term.filter((part) => part.text.trim()).map((part) => {                  return {                      text: Array.from(part.text),                      reading: part.reading, diff --git a/ext/bg/js/settings-dictionaries.js b/ext/bg/js/settings-dictionaries.js index 177379b0..065a8abc 100644 --- a/ext/bg/js/settings-dictionaries.js +++ b/ext/bg/js/settings-dictionaries.js @@ -62,8 +62,8 @@ class SettingsDictionaryListUI {          this.updateDictionaryOrder(); -        const titles = this.dictionaryEntries.map(e => e.dictionaryInfo.title); -        const removeKeys = Object.keys(this.optionsDictionaries).filter(key => titles.indexOf(key) < 0); +        const titles = this.dictionaryEntries.map((e) => e.dictionaryInfo.title); +        const removeKeys = Object.keys(this.optionsDictionaries).filter((key) => titles.indexOf(key) < 0);          if (removeKeys.length > 0) {              for (const key of toIterable(removeKeys)) {                  delete this.optionsDictionaries[key]; @@ -161,7 +161,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((e) => e.dictionaryInfo.title === title);          if (index >= 0) {              this.dictionaryEntries[index].deleteDictionary();          } @@ -377,7 +377,7 @@ async function onDatabaseUpdated(options) {          updateMainDictionarySelect(options, dictionaries); -        const {counts, total} = await utilDatabaseGetDictionaryCounts(dictionaries.map(v => v.title), true); +        const {counts, total} = await utilDatabaseGetDictionaryCounts(dictionaries.map((v) => v.title), true);          dictionaryUI.setCounts(counts, total);      } catch (e) {          dictionaryErrorsShow([e]); @@ -564,7 +564,7 @@ async function onDictionaryImport(e) {          dictionaryErrorsShow(null);          dictionarySpinnerShow(true); -        const setProgress = percent => dictProgress.find('.progress-bar').css('width', `${percent}%`); +        const setProgress = (percent) => dictProgress.find('.progress-bar').css('width', `${percent}%`);          const updateProgress = (total, current) => {              setProgress(current / total * 100.0);              if (storageEstimate.mostRecent !== null && !storageUpdateStats.isUpdating) { diff --git a/ext/bg/js/settings-profiles.js b/ext/bg/js/settings-profiles.js index 9532e3eb..8c218e97 100644 --- a/ext/bg/js/settings-profiles.js +++ b/ext/bg/js/settings-profiles.js @@ -147,7 +147,7 @@ function profileOptionsCreateCopyName(name, profiles, maxUniqueAttempts) {      let i = 0;      while (true) {          const newName = `${prefix}${space}${index}${suffix}`; -        if (i++ >= maxUniqueAttempts || profiles.findIndex(profile => profile.name === newName) < 0) { +        if (i++ >= maxUniqueAttempts || profiles.findIndex((profile) => profile.name === newName) < 0) {              return newName;          }          if (typeof index !== 'number') { diff --git a/ext/bg/js/settings.js b/ext/bg/js/settings.js index 48026794..abe6f389 100644 --- a/ext/bg/js/settings.js +++ b/ext/bg/js/settings.js @@ -18,7 +18,7 @@  async function getOptionsArray() {      const optionsFull = await apiOptionsGetFull(); -    return optionsFull.profiles.map(profile => profile.options); +    return optionsFull.profiles.map((profile) => profile.options);  }  async function formRead(options) { @@ -484,12 +484,12 @@ async function ankiDeckAndModelPopulate(options) {      const deckNames = await utilAnkiGetDeckNames();      const ankiDeck = $('.anki-deck');      ankiDeck.find('option').remove(); -    deckNames.sort().forEach(name => ankiDeck.append($('<option/>', {value: name, text: name}))); +    deckNames.sort().forEach((name) => ankiDeck.append($('<option/>', {value: name, text: name})));      const modelNames = await utilAnkiGetModelNames();      const ankiModel = $('.anki-model');      ankiModel.find('option').remove(); -    modelNames.sort().forEach(name => ankiModel.append($('<option/>', {value: name, text: name}))); +    modelNames.sort().forEach((name) => ankiModel.append($('<option/>', {value: name, text: name})));      $('#anki-terms-deck').val(options.anki.terms.deck);      await ankiFieldsPopulate($('#anki-terms-model').val(options.anki.terms.model), options); @@ -690,7 +690,7 @@ async function ankiTemplatesValidate(infoNode, field, mode, showSuccessResult, i      const hasException = exceptions.length > 0;      infoNode.hidden = !(showSuccessResult || hasException); -    infoNode.textContent = hasException ? exceptions.map(e => `${e}`).join('\n') : (showSuccessResult ? result : ''); +    infoNode.textContent = hasException ? exceptions.map((e) => `${e}`).join('\n') : (showSuccessResult ? result : '');      infoNode.classList.toggle('text-danger', hasException);      if (invalidateInput) {          const input = document.querySelector('#field-templates'); diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js index 0a0ce663..202014c9 100644 --- a/ext/bg/js/translator.js +++ b/ext/bg/js/translator.js @@ -51,7 +51,7 @@ class Translator {          const definitionsBySequence = dictTermsMergeBySequence(definitions, mainDictionary);          const defaultDefinitions = definitionsBySequence['-1']; -        const sequenceList = Object.keys(definitionsBySequence).map(v => Number(v)).filter(v => v >= 0); +        const sequenceList = Object.keys(definitionsBySequence).map((v) => Number(v)).filter((v) => v >= 0);          const sequencedDefinitions = sequenceList.map((key) => ({              definitions: definitionsBySequence[key],              rawDefinitions: [] @@ -124,7 +124,7 @@ class Translator {          for (const expression of result.expressions.keys()) {              for (const reading of result.expressions.get(expression).keys()) {                  const termTags = result.expressions.get(expression).get(reading); -                const score = termTags.map(tag => tag.score).reduce((p, v) => p + v, 0); +                const score = termTags.map((tag) => tag.score).reduce((p, v) => p + v, 0);                  expressions.push({                      expression: expression,                      reading: reading, @@ -173,7 +173,7 @@ class Translator {      async findTermsMerged(text, details, options) {          const dictionaries = dictEnabledSet(options); -        const secondarySearchTitles = Object.keys(options.dictionaries).filter(dict => options.dictionaries[dict].allowSecondarySearches); +        const secondarySearchTitles = Object.keys(options.dictionaries).filter((dict) => options.dictionaries[dict].allowSecondarySearches);          const titles = Object.keys(dictionaries);          const [definitions, length] = await this.findTermsInternal(text, dictionaries, options.scanning.alphanumeric, details);          const {sequencedDefinitions, defaultDefinitions} = await this.getSequencedDefinitions(definitions, options.general.mainDictionary); @@ -320,7 +320,7 @@ class Translator {              }          } -        return deinflections.filter(e => e.definitions.length > 0); +        return deinflections.filter((e) => e.definitions.length > 0);      }      getDeinflections(text) { diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js index c21fd68c..3dd5fd55 100644 --- a/ext/bg/js/util.js +++ b/ext/bg/js/util.js @@ -41,13 +41,13 @@ function utilSetEqual(setA, setB) {  function utilSetIntersection(setA, setB) {      return new Set( -        [...setA].filter(value => setB.has(value)) +        [...setA].filter((value) => setB.has(value))      );  }  function utilSetDifference(setA, setB) {      return new Set( -        [...setA].filter(value => !setB.has(value)) +        [...setA].filter((value) => !setB.has(value))      );  } diff --git a/ext/fg/js/frontend-api-receiver.js b/ext/fg/js/frontend-api-receiver.js index bde14646..7d38ddd5 100644 --- a/ext/fg/js/frontend-api-receiver.js +++ b/ext/fg/js/frontend-api-receiver.js @@ -43,10 +43,10 @@ class FrontendApiReceiver {          const handler = this.handlers[action];          handler(params).then( -            result => { +            (result) => {                  this.sendResult(port, id, senderId, {result});              }, -            error => { +            (error) => {                  this.sendResult(port, id, senderId, {error: errorToJson(error)});              });      } diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js index c40e5d60..42475d96 100644 --- a/ext/fg/js/popup.js +++ b/ext/fg/js/popup.js @@ -28,8 +28,8 @@ class Popup {          this.childrenSupported = true;          this.container = document.createElement('iframe');          this.container.className = 'yomichan-float'; -        this.container.addEventListener('mousedown', e => e.stopPropagation()); -        this.container.addEventListener('scroll', e => e.stopPropagation()); +        this.container.addEventListener('mousedown', (e) => e.stopPropagation()); +        this.container.addEventListener('scroll', (e) => e.stopPropagation());          this.container.setAttribute('src', chrome.runtime.getURL('/fg/float.html'));          this.container.style.width = '0px';          this.container.style.height = '0px'; diff --git a/ext/mixed/js/core.js b/ext/mixed/js/core.js index d82b9b4b..b5911535 100644 --- a/ext/mixed/js/core.js +++ b/ext/mixed/js/core.js @@ -173,5 +173,5 @@ function stringReplaceAsync(str, regex, replacer) {          return Promise.resolve(str);      }      parts.push(str.substring(index)); -    return Promise.all(parts).then(v => v.join('')); +    return Promise.all(parts).then((v) => v.join(''));  } |