UNPKG

coffeelint-no-chai-getters

Version:

Coffeelint rule that detects code using a chai getter without function invocation

40 lines (35 loc) 995 B
regexps = [ /\bexpect\(.*\)\.ok$/ /\bexpect\(.*\)\.false$/ /\bexpect\(.*\)\.true$/ /\bexpect\(.*\)\.null$/ /\bexpect\(.*\)\.undefined$/ /\bexpect\(.*\)\.NaN$/ /\bexpect\(.*\)\.exist$/ /\bexpect\(.*\)\.empty$/ /\bexpect\(.*\)\.arguments$/ /\bexpect\(.*\)\.extensible$/ /\bexpect\(.*\)\.sealed$/ /\bexpect\(.*\)\.frozen$/ /\bexpect\(.*\)\.called$/ /\bexpect\(.*\)\.calledOnce$/ /\bexpect\(.*\)\.calledTwice$/ /\bexpect\(.*\)\.calledThrice$/ /\bexpect\(.*\)\.calledWithNew$/ /\bexpect\(.*\)\.alwaysCalledWithNew$/ /\bexpect\(.*\)\.notCalled$/ ] module.exports = class NoChaiGetters rule: name: 'no_chai_getters' level: 'error' message: 'Chai getters are forbidden, use function invocation instead.' description: ''' This linter errors when a user types a chai getter without function invocation. ''' lintLine: (line, lineApi)-> for regexp in regexps if line.match(regexp)? return true return false