UNPKG

@quintaaa/eslint-plugin-starlims

Version:

Eslint plugin to parse and lint starlims form code successfully

51 lines (49 loc) 1.67 kB
const RuleTester = require('eslint').RuleTester; const rule = require('../../src/rules/no-ambiguous-vars'); const ruleTester = new RuleTester({ languageOptions: { ecmaVersion: 2022, }, }); ruleTester.run('no-ambiguous-vars', rule, { valid: [ `const foo = Starlims.navigator.Variables.foo`, `Starlims.navigator.Variables.foo = "bar"`, `const lang = window.navigator.language`, ], invalid: [ { name: 'Get from navigator.Variables', code: `const foo = navigator.Variables.foo`, errors: [ { message: 'Ambiguous variable "navigator" should be replaced by Starlims.navigator or window.navigator', type: 'Identifier', }, ], }, { name: 'Set to navigator.Variables', code: `navigator.Variables.foo = "bar"`, errors: [ { message: 'Ambiguous variable "navigator" should be replaced by Starlims.navigator or window.navigator', type: 'Identifier', }, ], }, { name: 'Set to navigator.Variables 2', code: `navigator.Variables['foo'] = "bar"`, errors: [ { message: 'Ambiguous variable "navigator" should be replaced by Starlims.navigator or window.navigator', type: 'Identifier', }, ], }, ], });