Merge pull request #363 from toasted-nutbread/eslint-stylistic-rules
Eslint stylistic rules
This commit is contained in:
commit
897f2360be
@ -21,11 +21,16 @@
|
|||||||
"curly": ["error", "all"],
|
"curly": ["error", "all"],
|
||||||
"dot-notation": "error",
|
"dot-notation": "error",
|
||||||
"eqeqeq": "error",
|
"eqeqeq": "error",
|
||||||
|
"func-names": ["error", "always"],
|
||||||
"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-global-assign": "error",
|
"no-global-assign": "error",
|
||||||
|
"no-param-reassign": "off",
|
||||||
|
"no-prototype-builtins": "error",
|
||||||
|
"no-shadow": ["error", {"builtinGlobals": false}],
|
||||||
"no-undef": "error",
|
"no-undef": "error",
|
||||||
|
"no-unneeded-ternary": "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-unused-expressions": "error",
|
||||||
"no-var": "error",
|
"no-var": "error",
|
||||||
@ -34,6 +39,35 @@
|
|||||||
"quotes": ["error", "single", "avoid-escape"],
|
"quotes": ["error", "single", "avoid-escape"],
|
||||||
"require-atomic-updates": "off",
|
"require-atomic-updates": "off",
|
||||||
"semi": "error",
|
"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/method": "error",
|
||||||
"no-unsanitized/property": "error"
|
"no-unsanitized/property": "error"
|
||||||
},
|
},
|
||||||
|
@ -274,18 +274,18 @@ class Backend {
|
|||||||
const node = nodes.pop();
|
const node = nodes.pop();
|
||||||
for (const key of Object.keys(node.obj)) {
|
for (const key of Object.keys(node.obj)) {
|
||||||
const path = node.path.concat(key);
|
const path = node.path.concat(key);
|
||||||
const obj = node.obj[key];
|
const obj2 = node.obj[key];
|
||||||
if (obj !== null && typeof obj === 'object') {
|
if (obj2 !== null && typeof obj2 === 'object') {
|
||||||
nodes.unshift({obj, path});
|
nodes.unshift({obj: obj2, path});
|
||||||
} else {
|
} else {
|
||||||
valuePaths.push([obj, path]);
|
valuePaths.push([obj2, path]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return valuePaths;
|
return valuePaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
function modifyOption(path, value, options) {
|
function modifyOption(path, value) {
|
||||||
let pivot = options;
|
let pivot = options;
|
||||||
for (const key of path.slice(0, -1)) {
|
for (const key of path.slice(0, -1)) {
|
||||||
if (!hasOwn(pivot, key)) {
|
if (!hasOwn(pivot, key)) {
|
||||||
@ -298,7 +298,7 @@ class Backend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const [value, path] of getValuePaths(changedOptions)) {
|
for (const [value, path] of getValuePaths(changedOptions)) {
|
||||||
modifyOption(path, value, options);
|
modifyOption(path, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this._onApiOptionsSave({source});
|
await this._onApiOptionsSave({source});
|
||||||
@ -340,9 +340,9 @@ class Backend {
|
|||||||
dictTermsSort(definitions);
|
dictTermsSort(definitions);
|
||||||
const {expression, reading} = definitions[0];
|
const {expression, reading} = definitions[0];
|
||||||
const source = text.substring(0, sourceLength);
|
const source = text.substring(0, sourceLength);
|
||||||
for (const {text, furigana} of jpDistributeFuriganaInflected(expression, reading, source)) {
|
for (const {text: text2, furigana} of jpDistributeFuriganaInflected(expression, reading, source)) {
|
||||||
const reading = jpConvertReading(text, furigana, options.parsing.readingMode);
|
const reading2 = jpConvertReading(text2, furigana, options.parsing.readingMode);
|
||||||
term.push({text, reading});
|
term.push({text: text2, reading: reading2});
|
||||||
}
|
}
|
||||||
text = text.substring(source.length);
|
text = text.substring(source.length);
|
||||||
} else {
|
} else {
|
||||||
@ -365,17 +365,17 @@ class Backend {
|
|||||||
for (const {expression, reading, source} of parsedLine) {
|
for (const {expression, reading, source} of parsedLine) {
|
||||||
const term = [];
|
const term = [];
|
||||||
if (expression !== null && reading !== null) {
|
if (expression !== null && reading !== null) {
|
||||||
for (const {text, furigana} of jpDistributeFuriganaInflected(
|
for (const {text: text2, furigana} of jpDistributeFuriganaInflected(
|
||||||
expression,
|
expression,
|
||||||
jpKatakanaToHiragana(reading),
|
jpKatakanaToHiragana(reading),
|
||||||
source
|
source
|
||||||
)) {
|
)) {
|
||||||
const reading = jpConvertReading(text, furigana, options.parsing.readingMode);
|
const reading2 = jpConvertReading(text2, furigana, options.parsing.readingMode);
|
||||||
term.push({text, reading});
|
term.push({text: text2, reading: reading2});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const reading = jpConvertReading(source, null, options.parsing.readingMode);
|
const reading2 = jpConvertReading(source, null, options.parsing.readingMode);
|
||||||
term.push({text: source, reading});
|
term.push({text: source, reading: reading2});
|
||||||
}
|
}
|
||||||
result.push(term);
|
result.push(term);
|
||||||
}
|
}
|
||||||
@ -801,8 +801,11 @@ class Backend {
|
|||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
chrome.tabs.update(tab.id, {active: true}, () => {
|
chrome.tabs.update(tab.id, {active: true}, () => {
|
||||||
const e = chrome.runtime.lastError;
|
const e = chrome.runtime.lastError;
|
||||||
if (e) { reject(e); }
|
if (e) {
|
||||||
else { resolve(); }
|
reject(e);
|
||||||
|
} else {
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -813,18 +816,24 @@ class Backend {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const tabWindow = await new Promise((resolve, reject) => {
|
const tabWindow = await new Promise((resolve, reject) => {
|
||||||
chrome.windows.get(tab.windowId, {}, (tabWindow) => {
|
chrome.windows.get(tab.windowId, {}, (value) => {
|
||||||
const e = chrome.runtime.lastError;
|
const e = chrome.runtime.lastError;
|
||||||
if (e) { reject(e); }
|
if (e) {
|
||||||
else { resolve(tabWindow); }
|
reject(e);
|
||||||
|
} else {
|
||||||
|
resolve(value);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
if (!tabWindow.focused) {
|
if (!tabWindow.focused) {
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
chrome.windows.update(tab.windowId, {focused: true}, () => {
|
chrome.windows.update(tab.windowId, {focused: true}, () => {
|
||||||
const e = chrome.runtime.lastError;
|
const e = chrome.runtime.lastError;
|
||||||
if (e) { reject(e); }
|
if (e) {
|
||||||
else { resolve(); }
|
reject(e);
|
||||||
|
} else {
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -809,9 +809,9 @@ class Database {
|
|||||||
for (const objectStoreName of objectStoreNames) {
|
for (const objectStoreName of objectStoreNames) {
|
||||||
const {primaryKey, indices} = stores[objectStoreName];
|
const {primaryKey, indices} = stores[objectStoreName];
|
||||||
|
|
||||||
const objectStoreNames = transaction.objectStoreNames || db.objectStoreNames;
|
const objectStoreNames2 = transaction.objectStoreNames || db.objectStoreNames;
|
||||||
const objectStore = (
|
const objectStore = (
|
||||||
Database._listContains(objectStoreNames, objectStoreName) ?
|
Database._listContains(objectStoreNames2, objectStoreName) ?
|
||||||
transaction.objectStore(objectStoreName) :
|
transaction.objectStore(objectStoreName) :
|
||||||
db.createObjectStore(objectStoreName, primaryKey)
|
db.createObjectStore(objectStoreName, primaryKey)
|
||||||
);
|
);
|
||||||
|
@ -224,15 +224,15 @@ function jpDistributeFurigana(expression, reading) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let isAmbiguous = false;
|
let isAmbiguous = false;
|
||||||
const segmentize = (reading, groups) => {
|
const segmentize = (reading2, groups) => {
|
||||||
if (groups.length === 0 || isAmbiguous) {
|
if (groups.length === 0 || isAmbiguous) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const group = groups[0];
|
const group = groups[0];
|
||||||
if (group.mode === 'kana') {
|
if (group.mode === 'kana') {
|
||||||
if (jpKatakanaToHiragana(reading).startsWith(jpKatakanaToHiragana(group.text))) {
|
if (jpKatakanaToHiragana(reading2).startsWith(jpKatakanaToHiragana(group.text))) {
|
||||||
const readingLeft = reading.substring(group.text.length);
|
const readingLeft = reading2.substring(group.text.length);
|
||||||
const segs = segmentize(readingLeft, groups.splice(1));
|
const segs = segmentize(readingLeft, groups.splice(1));
|
||||||
if (segs) {
|
if (segs) {
|
||||||
return [{text: group.text}].concat(segs);
|
return [{text: group.text}].concat(segs);
|
||||||
@ -240,9 +240,9 @@ function jpDistributeFurigana(expression, reading) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let foundSegments = null;
|
let foundSegments = null;
|
||||||
for (let i = reading.length; i >= group.text.length; --i) {
|
for (let i = reading2.length; i >= group.text.length; --i) {
|
||||||
const readingUsed = reading.substring(0, i);
|
const readingUsed = reading2.substring(0, i);
|
||||||
const readingLeft = reading.substring(i);
|
const readingLeft = reading2.substring(i);
|
||||||
const segs = segmentize(readingLeft, groups.slice(1));
|
const segs = segmentize(readingLeft, groups.slice(1));
|
||||||
if (segs) {
|
if (segs) {
|
||||||
if (foundSegments !== null) {
|
if (foundSegments !== null) {
|
||||||
|
@ -401,7 +401,7 @@ class JsonSchemaProxyHandler {
|
|||||||
info.valuePush(i, propertyValue);
|
info.valuePush(i, propertyValue);
|
||||||
JsonSchemaProxyHandler.validate(propertyValue, propertySchema, info);
|
JsonSchemaProxyHandler.validate(propertyValue, propertySchema, info);
|
||||||
info.valuePop();
|
info.valuePop();
|
||||||
for (let i = 0; i < schemaPath.length; ++i) { info.schemaPop(); }
|
for (let j = 0, jj = schemaPath.length; j < jj; ++j) { info.schemaPop(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,43 +18,43 @@
|
|||||||
|
|
||||||
|
|
||||||
class PageExitPrevention {
|
class PageExitPrevention {
|
||||||
constructor() {
|
constructor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
PageExitPrevention._addInstance(this);
|
PageExitPrevention._addInstance(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
end() {
|
end() {
|
||||||
PageExitPrevention._removeInstance(this);
|
PageExitPrevention._removeInstance(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
static _addInstance(instance) {
|
static _addInstance(instance) {
|
||||||
const size = PageExitPrevention._instances.size;
|
const size = PageExitPrevention._instances.size;
|
||||||
PageExitPrevention._instances.set(instance, true);
|
PageExitPrevention._instances.set(instance, true);
|
||||||
if (size === 0) {
|
if (size === 0) {
|
||||||
window.addEventListener('beforeunload', PageExitPrevention._onBeforeUnload);
|
window.addEventListener('beforeunload', PageExitPrevention._onBeforeUnload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static _removeInstance(instance) {
|
static _removeInstance(instance) {
|
||||||
if (
|
if (
|
||||||
PageExitPrevention._instances.delete(instance) &&
|
PageExitPrevention._instances.delete(instance) &&
|
||||||
PageExitPrevention._instances.size === 0
|
PageExitPrevention._instances.size === 0
|
||||||
) {
|
) {
|
||||||
window.removeEventListener('beforeunload', PageExitPrevention._onBeforeUnload);
|
window.removeEventListener('beforeunload', PageExitPrevention._onBeforeUnload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static _onBeforeUnload(e) {
|
static _onBeforeUnload(e) {
|
||||||
if (PageExitPrevention._instances.size === 0) {
|
if (PageExitPrevention._instances.size === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.returnValue = '';
|
e.returnValue = '';
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PageExitPrevention._instances = new Map();
|
PageExitPrevention._instances = new Map();
|
||||||
|
@ -59,7 +59,7 @@ class QueryParser extends TextScanner {
|
|||||||
|
|
||||||
this.search.setContent('terms', {definitions, context: {
|
this.search.setContent('terms', {definitions, context: {
|
||||||
focus: false,
|
focus: false,
|
||||||
disableHistory: cause === 'mouse' ? true : false,
|
disableHistory: cause === 'mouse',
|
||||||
sentence: {text: searchText, offset: 0},
|
sentence: {text: searchText, offset: 0},
|
||||||
url: window.location.href
|
url: window.location.href
|
||||||
}});
|
}});
|
||||||
|
@ -70,7 +70,7 @@ class DisplaySearch extends Display {
|
|||||||
this.wanakanaEnable.checked = false;
|
this.wanakanaEnable.checked = false;
|
||||||
}
|
}
|
||||||
this.wanakanaEnable.addEventListener('change', (e) => {
|
this.wanakanaEnable.addEventListener('change', (e) => {
|
||||||
const {queryParams: {query=''}} = parseUrl(window.location.href);
|
const {queryParams: {query: query2=''}} = parseUrl(window.location.href);
|
||||||
if (e.target.checked) {
|
if (e.target.checked) {
|
||||||
window.wanakana.bind(this.query);
|
window.wanakana.bind(this.query);
|
||||||
apiOptionsSet({general: {enableWanakana: true}}, this.getOptionsContext());
|
apiOptionsSet({general: {enableWanakana: true}}, this.getOptionsContext());
|
||||||
@ -78,7 +78,7 @@ class DisplaySearch extends Display {
|
|||||||
window.wanakana.unbind(this.query);
|
window.wanakana.unbind(this.query);
|
||||||
apiOptionsSet({general: {enableWanakana: false}}, this.getOptionsContext());
|
apiOptionsSet({general: {enableWanakana: false}}, this.getOptionsContext());
|
||||||
}
|
}
|
||||||
this.setQuery(query);
|
this.setQuery(query2);
|
||||||
this.onSearchQueryUpdated(this.query.value, false);
|
this.onSearchQueryUpdated(this.query.value, false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,6 @@ async function _showSettingsImportWarnings(warnings) {
|
|||||||
sanitize: e.currentTarget.dataset.importSanitize === 'true'
|
sanitize: e.currentTarget.dataset.importSanitize === 'true'
|
||||||
});
|
});
|
||||||
modalNode.modal('hide');
|
modalNode.modal('hide');
|
||||||
|
|
||||||
};
|
};
|
||||||
const onModalHide = () => {
|
const onModalHide = () => {
|
||||||
complete({result: false});
|
complete({result: false});
|
||||||
|
@ -166,7 +166,7 @@ class SettingsDictionaryListUI {
|
|||||||
delete n.dataset.dict;
|
delete n.dataset.dict;
|
||||||
$(n).modal('hide');
|
$(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) {
|
if (index >= 0) {
|
||||||
this.dictionaryEntries[index].deleteDictionary();
|
this.dictionaryEntries[index].deleteDictionary();
|
||||||
}
|
}
|
||||||
|
@ -60,8 +60,8 @@ class SettingsPopupPreview {
|
|||||||
|
|
||||||
this.frontend = new Frontend(this.popup);
|
this.frontend = new Frontend(this.popup);
|
||||||
|
|
||||||
this.frontend.setEnabled = function () {};
|
this.frontend.setEnabled = () => {};
|
||||||
this.frontend.searchClear = function () {};
|
this.frontend.searchClear = () => {};
|
||||||
|
|
||||||
await this.frontend.prepare();
|
await this.frontend.prepare();
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ function utilIsolate(value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function utilFunctionIsolate(func) {
|
function utilFunctionIsolate(func) {
|
||||||
return function (...args) {
|
return function isolatedFunction(...args) {
|
||||||
try {
|
try {
|
||||||
args = args.map((v) => utilIsolate(v));
|
args = args.map((v) => utilIsolate(v));
|
||||||
return func.call(this, ...args);
|
return func.call(this, ...args);
|
||||||
|
@ -192,8 +192,7 @@ function docSentenceExtract(source, extent) {
|
|||||||
if (terminators.includes(c)) {
|
if (terminators.includes(c)) {
|
||||||
endPos = i + 1;
|
endPos = i + 1;
|
||||||
break;
|
break;
|
||||||
}
|
} else if (c in quotesBwd) {
|
||||||
else if (c in quotesBwd) {
|
|
||||||
endPos = i;
|
endPos = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,6 @@ class TextToSpeechAudio {
|
|||||||
|
|
||||||
speechSynthesis.cancel();
|
speechSynthesis.cancel();
|
||||||
speechSynthesis.speak(this._utterance);
|
speechSynthesis.speak(this._utterance);
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// NOP
|
// NOP
|
||||||
}
|
}
|
||||||
@ -82,7 +81,6 @@ class TextToSpeechAudio {
|
|||||||
|
|
||||||
return new TextToSpeechAudio(text, voice);
|
return new TextToSpeechAudio(text, voice);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function audioGetFromUrl(url, willDownload) {
|
function audioGetFromUrl(url, willDownload) {
|
||||||
|
@ -160,9 +160,9 @@ function promiseTimeout(delay, resolveValue) {
|
|||||||
const resolve = (value) => complete(promiseResolve, value);
|
const resolve = (value) => complete(promiseResolve, value);
|
||||||
const reject = (value) => complete(promiseReject, value);
|
const reject = (value) => complete(promiseReject, value);
|
||||||
|
|
||||||
const promise = new Promise((resolve, reject) => {
|
const promise = new Promise((resolve2, reject2) => {
|
||||||
promiseResolve = resolve;
|
promiseResolve = resolve2;
|
||||||
promiseReject = reject;
|
promiseReject = reject2;
|
||||||
});
|
});
|
||||||
timer = window.setTimeout(() => {
|
timer = window.setTimeout(() => {
|
||||||
timer = null;
|
timer = null;
|
||||||
|
@ -141,18 +141,18 @@ class TextScanner {
|
|||||||
const textSourceCurrentPrevious = this.textSourceCurrent !== null ? this.textSourceCurrent.clone() : null;
|
const textSourceCurrentPrevious = this.textSourceCurrent !== null ? this.textSourceCurrent.clone() : null;
|
||||||
|
|
||||||
this.searchAt(primaryTouch.clientX, primaryTouch.clientY, 'touchStart')
|
this.searchAt(primaryTouch.clientX, primaryTouch.clientY, 'touchStart')
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (
|
if (
|
||||||
this.textSourceCurrent === null ||
|
this.textSourceCurrent === null ||
|
||||||
this.textSourceCurrent.equals(textSourceCurrentPrevious)
|
this.textSourceCurrent.equals(textSourceCurrentPrevious)
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.preventScroll = true;
|
this.preventScroll = true;
|
||||||
this.preventNextContextMenu = true;
|
this.preventNextContextMenu = true;
|
||||||
this.preventNextMouseDown = true;
|
this.preventNextMouseDown = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onTouchEnd(e) {
|
onTouchEnd(e) {
|
||||||
|
@ -36,8 +36,8 @@ class XMLHttpRequest {
|
|||||||
callbacks.push(callback);
|
callbacks.push(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
open(action, url) {
|
open(action, url2) {
|
||||||
this._url = url;
|
this._url = url2;
|
||||||
}
|
}
|
||||||
|
|
||||||
send() {
|
send() {
|
||||||
@ -116,10 +116,10 @@ function clearDatabase(timeout) {
|
|||||||
(async () => {
|
(async () => {
|
||||||
const indexedDB = global.indexedDB;
|
const indexedDB = global.indexedDB;
|
||||||
for (const {name} of await indexedDB.databases()) {
|
for (const {name} of await indexedDB.databases()) {
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve2, reject2) => {
|
||||||
const request = indexedDB.deleteDatabase(name);
|
const request = indexedDB.deleteDatabase(name);
|
||||||
request.onerror = (e) => reject(e);
|
request.onerror = (e) => reject2(e);
|
||||||
request.onsuccess = () => resolve();
|
request.onsuccess = () => resolve2();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
|
@ -30,7 +30,7 @@ function testValidate1() {
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
const schemaValidate = (value, schema) => {
|
const schemaValidate = (value) => {
|
||||||
try {
|
try {
|
||||||
JsonSchema.validate(value, schema);
|
JsonSchema.validate(value, schema);
|
||||||
return true;
|
return true;
|
||||||
@ -48,7 +48,7 @@ function testValidate1() {
|
|||||||
) &&
|
) &&
|
||||||
(
|
(
|
||||||
(
|
(
|
||||||
(value % 3 )=== 0 ||
|
(value % 3) === 0 ||
|
||||||
(value % 5) === 0
|
(value % 5) === 0
|
||||||
) &&
|
) &&
|
||||||
(value % 15) !== 0
|
(value % 15) !== 0
|
||||||
@ -81,7 +81,7 @@ function testGetValidValueOrDefault1() {
|
|||||||
|
|
||||||
const testData = [
|
const testData = [
|
||||||
[
|
[
|
||||||
void(0),
|
void 0,
|
||||||
{test: 'default'}
|
{test: 'default'}
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -210,7 +210,7 @@ function testGetValidValueOrDefault3() {
|
|||||||
{test: 'value', test2: 2, test3: 10}
|
{test: 'value', test2: 2, test3: 10}
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{test: 'value', test2: 2, test3: void(0)},
|
{test: 'value', test2: 2, test3: void 0},
|
||||||
{test: 'value', test2: 2, test3: 10}
|
{test: 'value', test2: 2, test3: 10}
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
Loading…
Reference in New Issue
Block a user