detect-non-literal-regexp.js 444 B

123456789101112131415161718
  1. 'use strict';
  2. const RuleTester = require('eslint').RuleTester;
  3. const tester = new RuleTester();
  4. const ruleName = 'detect-non-literal-regexp';
  5. const invalid = 'var a = new RegExp(c, \'i\')';
  6. tester.run(ruleName, require(`../rules/${ruleName}`), {
  7. valid: [{ code: 'var a = new RegExp(\'ab+c\', \'i\')' }],
  8. invalid: [
  9. {
  10. code: invalid,
  11. errors: [{ message: 'Found non-literal argument to RegExp Constructor' }]
  12. }
  13. ]
  14. });