eslint-plugin-angular
Version:
ESLint rules for AngularJS projects
31 lines (26 loc) • 1.77 kB
JavaScript
'use strict';
// ------------------------------------------------------------------------------
// Requirements
// ------------------------------------------------------------------------------
var rule = require('../rules/typecheck-regexp');
var RuleTester = require('eslint').RuleTester;
var commonFalsePositives = require('./utils/commonFalsePositives');
// ------------------------------------------------------------------------------
// Tests
// ------------------------------------------------------------------------------
var eslintTester = new RuleTester();
eslintTester.run('typecheck-regexp', rule, {
valid: [
'angular.isRegexp(/^T/)'
].concat(commonFalsePositives),
invalid: [
{code: 'Object.prototype.toString.call(value) === "[object RegExp]"', errors: [{message: 'You should use the angular.isRegexp method'}]},
{code: '"[object RegExp]" === Object.prototype.toString.call(value)', errors: [{message: 'You should use the angular.isRegexp method'}]},
{code: 'variable === "[object RegExp]"', errors: [{message: 'You should use the angular.isRegexp method'}]},
{code: '"[object RegExp]" === variable', errors: [{message: 'You should use the angular.isRegexp method'}]},
{code: 'Object.prototype.toString.call(value) !== "[object RegExp]"', errors: [{message: 'You should use the angular.isRegexp method'}]},
{code: '"[object RegExp]" !== Object.prototype.toString.call(value)', errors: [{message: 'You should use the angular.isRegexp method'}]},
{code: 'variable !== "[object RegExp]"', errors: [{message: 'You should use the angular.isRegexp method'}]},
{code: '"[object RegExp]" !== variable', errors: [{message: 'You should use the angular.isRegexp method'}]}
]
});