UNPKG

@coffeelint/cli

Version:
64 lines (55 loc) 1.82 kB
(function() { var NoImplicitParens; module.exports = NoImplicitParens = (function() { class NoImplicitParens { lintToken(token, tokenApi) { var genCallStart, i, sameLine, t; if (token.generated) { if (tokenApi.config[this.rule.name].strict !== false) { return {token}; } else { // If strict mode is turned off it allows implicit parens when // the expression is spread over multiple lines. i = -1; while (true) { t = tokenApi.peek(i); sameLine = t[2].first_line === token[2].first_line; genCallStart = t[0] === 'CALL_START' && t.generated; if ((t == null) || genCallStart && sameLine) { return { token: t || token }; } // If we have not found a CALL_START token that is generated, // and we've moved into a new line, this is fine and should // just return. if (!sameLine) { return null; } i -= 1; } } } } }; NoImplicitParens.prototype.rule = { type: 'style', name: 'no_implicit_parens', level: 'ignore', message: 'Implicit parens are forbidden', strict: true, description: `This rule prohibits implicit parens on function calls. <pre> <code># Some folks don't like this style of coding. myFunction a, b, c # And would rather it always be written like this: myFunction(a, b, c) </code> </pre> Implicit parens are permitted by default, since their use is idiomatic CoffeeScript.` }; NoImplicitParens.prototype.tokens = ['CALL_END']; return NoImplicitParens; }).call(this); }).call(this);