Merge pull request #344 from toasted-nutbread/eslint-strengthening

Eslint strengthening
This commit is contained in:
toasted-nutbread 2020-02-12 19:06:36 -05:00 committed by GitHub
commit af89659751
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 130 additions and 4 deletions

View File

@ -1,7 +1,14 @@
{ {
"root": true,
"extends": "eslint:recommended", "extends": "eslint:recommended",
"parserOptions": { "parserOptions": {
"ecmaVersion": 8 "ecmaVersion": 8,
"sourceType": "script"
},
"env": {
"browser": true,
"es2017": true,
"webextensions": true
}, },
"ignorePatterns": [ "ignorePatterns": [
"/ext/mixed/lib/", "/ext/mixed/lib/",
@ -16,13 +23,57 @@
"no-case-declarations": "error", "no-case-declarations": "error",
"no-const-assign": "error", "no-const-assign": "error",
"no-constant-condition": "off", "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-vars": ["error", {"vars": "local", "args": "after-used", "argsIgnorePattern": "^_", "caughtErrors": "none"}],
"no-unused-expressions": "error",
"no-var": "error", "no-var": "error",
"prefer-const": ["error", {"destructuring": "all"}], "prefer-const": ["error", {"destructuring": "all"}],
"quote-props": ["error", "consistent"], "quote-props": ["error", "consistent"],
"quotes": ["error", "single", "avoid-escape"], "quotes": ["error", "single", "avoid-escape"],
"require-atomic-updates": "off", "require-atomic-updates": "off",
"semi": "error" "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
}
}
]
} }

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global requestJson*/
/* /*
* AnkiConnect * AnkiConnect

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global jpIsStringEntirelyKana, audioGetFromSources*/
const audioUrlBuilders = new Map([ const audioUrlBuilders = new Map([
['jpod101', async (definition) => { ['jpod101', async (definition) => {

View File

@ -16,6 +16,14 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * 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 { class Backend {
constructor() { constructor() {

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global apiClipboardGet, jpIsStringPartiallyJapanese*/
class ClipboardMonitor { class ClipboardMonitor {
constructor() { constructor() {

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global apiCommandExec, apiGetEnvironmentInfo, apiOptionsGet*/
function showExtensionInfo() { function showExtensionInfo() {
const node = document.getElementById('extension-info'); const node = document.getElementById('extension-info');

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global dictFieldSplit, dictTagSanitize, JSZip*/
class Database { class Database {
constructor() { constructor() {

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global utilSetEqual, utilSetIntersection, apiTemplateRender*/
function dictEnabledSet(options) { function dictEnabledSet(options) {
const dictionaries = {}; const dictionaries = {};

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global jpIsCharCodeKanji, jpDistributeFurigana, Handlebars*/
function handlebarsEscape(text) { function handlebarsEscape(text) {
return Handlebars.Utils.escapeExpression(text); return Handlebars.Utils.escapeExpression(text);

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global wanakana*/
const JP_HALFWIDTH_KATAKANA_MAPPING = new Map([ const JP_HALFWIDTH_KATAKANA_MAPPING = new Map([
['ヲ', 'ヲヺ-'], ['ヲ', 'ヲヺ-'],

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global utilStringHashCode*/
/* /*
* Generic options functions * Generic options functions

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global apiOptionsGet*/
async function searchFrontendSetup() { async function searchFrontendSetup() {
const optionsContext = { const optionsContext = {

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global apiGetQueryParserTemplatesHtml, TemplateHandler*/
class QueryParserGenerator { class QueryParserGenerator {
constructor() { constructor() {

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global apiTermsFind, apiOptionsSet, apiTextParse, apiTextParseMecab, TextScanner, QueryParserGenerator*/
class QueryParser extends TextScanner { class QueryParser extends TextScanner {
constructor(search) { constructor(search) {

View File

@ -16,6 +16,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global apiOptionsSet, apiTermsFind, Display, QueryParser, ClipboardMonitor*/
class DisplaySearch extends Display { class DisplaySearch extends Display {
constructor() { constructor() {
super(document.querySelector('#spinner'), document.querySelector('#content')); super(document.querySelector('#spinner'), document.querySelector('#content'));

View File

@ -16,6 +16,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * 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) { function onAnkiFieldTemplatesReset(e) {
e.preventDefault(); e.preventDefault();

View File

@ -16,6 +16,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global getOptionsContext, getOptionsMutable, settingsSaveOptions
utilBackgroundIsolate, utilAnkiGetDeckNames, utilAnkiGetModelNames, utilAnkiGetModelFieldNames
onFormOptionsChanged*/
// Private // Private

View File

@ -16,7 +16,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
class AudioSourceUI { class AudioSourceUI {
static instantiateTemplate(templateSelector) { static instantiateTemplate(templateSelector) {
const template = document.querySelector(templateSelector); const template = document.querySelector(templateSelector);

View File

@ -16,6 +16,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global getOptionsContext, getOptionsMutable, settingsSaveOptions
AudioSourceUI, audioGetTextToSpeechVoice*/
let audioSourceUI = null; let audioSourceUI = null;

View File

@ -16,6 +16,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global apiOptionsGetFull, apiGetEnvironmentInfo
utilBackend, utilIsolate, utilBackgroundIsolate, utilReadFileArrayBuffer
optionsGetDefault, optionsUpdateVersion
profileOptionsGetDefaultFieldTemplates*/
// Exporting // Exporting

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global conditionsNormalizeOptionValue*/
class ConditionsUI { class ConditionsUI {
static instantiateTemplate(templateSelector) { static instantiateTemplate(templateSelector) {

View File

@ -16,6 +16,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * 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; let dictionaryUI = null;

View File

@ -16,6 +16,14 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * 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) { function getOptionsMutable(optionsContext) {
return utilBackend().getOptions( return utilBackend().getOptions(
utilBackgroundIsolate(optionsContext) utilBackgroundIsolate(optionsContext)

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global apiOptionsGet, Popup, PopupProxyHost, Frontend, TextSourceRange*/
class SettingsPopupPreview { class SettingsPopupPreview {
constructor() { constructor() {

View File

@ -16,6 +16,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * 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 currentProfileIndex = 0;
let profileConditionsContainer = null; let profileConditionsContainer = null;

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global apiGetEnvironmentInfo*/
function storageBytesToLabeledString(size) { function storageBytesToLabeledString(size) {
const base = 1000; const base = 1000;

View File

@ -16,6 +16,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * 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 { class Translator {
constructor() { constructor() {

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * 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*\)/; const REGEX_TRANSPARENT_COLOR = /rgba\s*\([^)]*,\s*0(?:\.0+)?\s*\)/;

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global popupNestedInitialize, Display*/
class DisplayFloat extends Display { class DisplayFloat extends Display {
constructor() { constructor() {

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global PopupProxyHost, PopupProxy, Frontend*/
async function main() { async function main() {
const data = window.frontendInitializationData || {}; const data = window.frontendInitializationData || {};

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global apiGetZoom, apiOptionsGet, apiTermsFind, apiKanjiFind, docSentenceExtract, TextScanner*/
class Frontend extends TextScanner { class Frontend extends TextScanner {
constructor(popup, ignoreNodes) { constructor(popup, ignoreNodes) {

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global apiOptionsGet*/
let popupNestedInitialized = false; let popupNestedInitialized = false;

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global apiFrameInformationGet, FrontendApiReceiver, Popup*/
class PopupProxyHost { class PopupProxyHost {
constructor() { constructor() {

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global FrontendApiSender*/
class PopupProxy { class PopupProxy {
constructor(depth, parentId, parentFrameId, url) { constructor(depth, parentId, parentFrameId, url) {

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global apiInjectStylesheet*/
class Popup { class Popup {
constructor(id, depth, frameIdPromise) { constructor(id, depth, frameIdPromise) {

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global apiAudioGetUrl*/
class TextToSpeechAudio { class TextToSpeechAudio {
constructor(text, voice) { constructor(text, voice) {

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/*global apiGetDisplayTemplatesHtml*/
class DisplayGenerator { class DisplayGenerator {
constructor() { constructor() {

View File

@ -16,6 +16,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * 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 { class Display {
constructor(spinner, container) { constructor(spinner, container) {

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/*global docRangeFromPoint, TextSourceRange, DOM*/
class TextScanner { class TextScanner {
constructor(node, ignoreNodes, ignoreElements, ignorePoints) { constructor(node, ignoreNodes, ignoreElements, ignorePoints) {