UNPKG

@quintaaa/eslint-plugin-starlims

Version:

Eslint plugin to parse and lint starlims form code successfully

37 lines (36 loc) 1.27 kB
module.exports = { meta: { type: 'problem', docs: { description: 'Detects ammbiguous variables (e.g. `navigator` instead of `Starlims.navigator` or `window.navigator`)', recommended: true, }, }, create(context) { const ammbiguousVariables = { navigator: ['Starlims.navigator', 'window.navigator'], }; return { Identifier(node) { if ( node.parent.type === 'MemberExpression' && node.parent.range[0] !== node.range[0] ) return; // Ignore if already prefixed if (ammbiguousVariables[node.name]) { context.report({ node, message: 'Ambiguous variable "{{ variable }}" should be replaced by {{ replacements }}', data: { variable: node.name, replacements: ammbiguousVariables[node.name].join(' or '), }, }); } }, }; }, };