@coffeelint/cli
Version:
Lint your CoffeeScript
42 lines (33 loc) • 1.09 kB
JavaScript
(function() {
var NoInterpolationInSingleQuotes;
module.exports = NoInterpolationInSingleQuotes = (function() {
class NoInterpolationInSingleQuotes {
lintToken(token, tokenApi) {
var hasInterpolation, tokenValue;
tokenValue = token[1];
hasInterpolation = tokenValue.match(/^.*#\{[^}]+\}.*$/);
if (hasInterpolation) {
return {token};
}
}
};
NoInterpolationInSingleQuotes.prototype.rule = {
type: 'problem',
name: 'no_interpolation_in_single_quotes',
level: 'ignore',
message: 'Interpolation in single quoted strings is forbidden',
description: `This rule prohibits string interpolation in a single quoted string.
<pre>
<code># String interpolation in single quotes is not allowed:
foo = '#{bar}'
# Double quotes is OK of course
foo = "#{bar}"
</code>
</pre>
String interpolation in single quoted strings is permitted by
default.`
};
NoInterpolationInSingleQuotes.prototype.tokens = ['STRING'];
return NoInterpolationInSingleQuotes;
}).call(this);
}).call(this);