tinymusic
Version:
A simple, lightweight music sequencer in JavaScript using the Web Audio API.
37 lines (30 loc) • 830 B
JavaScript
/* jshint -W101 */
var assert = require('assert');
module.exports = function() {};
module.exports.prototype = {
configure: function( mode ) {
var modes = {
all: true
};
assert(
typeof mode === 'string' &&
modes[mode],
'disallowNoVarOnFirstLine option requires string value \'all\''
);
this._mode = mode;
},
getOptionName: function() {
return 'disallowNoVarOnFirstLine';
},
check: function( file, errors ) {
var nextToken;
file.iterateTokensByType('Keyword', function(token, index, tokens) {
nextToken = tokens[index + 1];
if ( token.value === 'var' ) {
if ( token.loc.end.line !== nextToken.loc.start.line ) {
errors.add('First variable must be on the same line as var keyword', token.loc.end);
}
}
});
}
};