Skip to content
Permalink
Browse files

Allow unused "detectImport" (zotero#1916)

  • Loading branch information...
retorquere authored and dstillman committed Apr 1, 2019
1 parent e87fc64 commit a6a842687f6b379a4e39346c76ac3d11fa1665d2
Showing with 9 additions and 12 deletions.
  1. +8 −11 .ci/eslint-plugin-zotero-translator/lib/rules/translator-type.js
  2. +1 −1 .eslintrc
@@ -53,20 +53,17 @@ module.exports = {
}
}

const doWeb = getFunction(node, 'doWeb');
const doDetect = getFunction(node, 'doDetect');
const doImport = getFunction(node, 'doImport');
const doExport = getFunction(node, 'doExport');

if (browserSupportNode && !(translatorType & type.web)) context.report(browserSupportNode, `browserSupport set, but translatorType (${translatorType}) does not include web (${type.web})`);

for (const [f, mode] of [[doWeb, 'Web'], [doDetect, 'Import'], [doImport, 'Import'], [doExport, 'Export']]) {
const bit = type[mode.toLowerCase()];
if (f && !(translatorType & bit)) {
context.report(f, `do${mode} present, but translatorType (${translatorType}) does not specify ${mode.toLowerCase()} (${bit})`);
for (const name of ['detectWeb', 'doWeb', 'detectImport', 'doImport', 'doExport']) {
const handler = getFunction(node, name);
const mode = name.replace(/^(detect|do)/, '').toLowerCase();
const bit = type[mode];
if (handler && !(translatorType & bit)) {
context.report(handler, `${name} present, but translatorType (${translatorType}) does not specify ${mode} (${bit})`);
}
if (!f && (translatorType & bit)) {
context.report(translatorTypeNode, `translatorType specifies ${mode.toLowerCase()} (${bit}), but no do${mode} present`);
if (!handler && (translatorType & bit)) {
context.report(translatorTypeNode, `translatorType specifies ${mode} (${bit}), but no ${name} present`);
}
}
}
@@ -23,7 +23,7 @@
"error",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^doWeb$|^detectWeb$|^doImport$|^doExport$"
"varsIgnorePattern": "^detectWeb$|^doWeb$|^detectImport$|^doImport$|^doExport$"
}
],

0 comments on commit a6a8426

Please sign in to comment.
You can’t perform that action at this time.