Permalink
Browse files

Fix .eslintignore and lint errors (#207)

The .eslintignore was misconfigured. In an attempt not to validate
the browserified bundles, we added `ejs.js` to the .eslintignore.
This not only ignored the bundle, it also ignored `lib/ejs.js` &
`test/ejs.js`. This line was corrected to read `/ejs.js`.

As a result of this, quite a few linting errors needed fixed.
  • Loading branch information...
1 parent 699b953 commit 54bb18e18ecfa407dccf7cd75e84126a90b6609a @RyanZim RyanZim committed on GitHub Sep 29, 2016
Showing with 180 additions and 182 deletions.
  1. +2 −2 .eslintignore
  2. +61 −61 lib/ejs.js
  3. +117 −119 test/ejs.js
View
@@ -1,4 +1,4 @@
coverage
out
-ejs.js
-ejs.min.js
+/ejs.js
+/ejs.min.js
View
@@ -665,77 +665,77 @@ Template.prototype = {
newLineCount = (line.split('\n').length - 1);
switch (line) {
- case '<' + d:
- case '<' + d + '_':
- this.mode = Template.modes.EVAL;
- break;
- case '<' + d + '=':
- this.mode = Template.modes.ESCAPED;
- break;
- case '<' + d + '-':
- this.mode = Template.modes.RAW;
- break;
- case '<' + d + '#':
- this.mode = Template.modes.COMMENT;
- break;
- case '<' + d + d:
- this.mode = Template.modes.LITERAL;
- this.source += ' ; __append("' + line.replace('<' + d + d, '<' + d) + '")' + '\n';
- break;
- case d + d + '>':
- this.mode = Template.modes.LITERAL;
- this.source += ' ; __append("' + line.replace(d + d + '>', d + '>') + '")' + '\n';
- break;
- case d + '>':
- case '-' + d + '>':
- case '_' + d + '>':
- if (this.mode == Template.modes.LITERAL) {
- _addOutput();
- }
+ case '<' + d:
+ case '<' + d + '_':
+ this.mode = Template.modes.EVAL;
+ break;
+ case '<' + d + '=':
+ this.mode = Template.modes.ESCAPED;
+ break;
+ case '<' + d + '-':
+ this.mode = Template.modes.RAW;
+ break;
+ case '<' + d + '#':
+ this.mode = Template.modes.COMMENT;
+ break;
+ case '<' + d + d:
+ this.mode = Template.modes.LITERAL;
+ this.source += ' ; __append("' + line.replace('<' + d + d, '<' + d) + '")' + '\n';
+ break;
+ case d + d + '>':
+ this.mode = Template.modes.LITERAL;
+ this.source += ' ; __append("' + line.replace(d + d + '>', d + '>') + '")' + '\n';
+ break;
+ case d + '>':
+ case '-' + d + '>':
+ case '_' + d + '>':
+ if (this.mode == Template.modes.LITERAL) {
+ _addOutput();
+ }
- this.mode = null;
- this.truncate = line.indexOf('-') === 0 || line.indexOf('_') === 0;
- break;
- default:
+ this.mode = null;
+ this.truncate = line.indexOf('-') === 0 || line.indexOf('_') === 0;
+ break;
+ default:
// In script mode, depends on type of tag
- if (this.mode) {
+ if (this.mode) {
// If '//' is found without a line break, add a line break.
- switch (this.mode) {
- case Template.modes.EVAL:
- case Template.modes.ESCAPED:
- case Template.modes.RAW:
- if (line.lastIndexOf('//') > line.lastIndexOf('\n')) {
- line += '\n';
- }
+ switch (this.mode) {
+ case Template.modes.EVAL:
+ case Template.modes.ESCAPED:
+ case Template.modes.RAW:
+ if (line.lastIndexOf('//') > line.lastIndexOf('\n')) {
+ line += '\n';
}
- switch (this.mode) {
+ }
+ switch (this.mode) {
// Just executing code
- case Template.modes.EVAL:
- this.source += ' ; ' + line + '\n';
- break;
+ case Template.modes.EVAL:
+ this.source += ' ; ' + line + '\n';
+ break;
// Exec, esc, and output
- case Template.modes.ESCAPED:
- this.source += ' ; __append(escape(' +
+ case Template.modes.ESCAPED:
+ this.source += ' ; __append(escape(' +
line.replace(_TRAILING_SEMCOL, '').trim() + '))' + '\n';
- break;
+ break;
// Exec and output
- case Template.modes.RAW:
- this.source += ' ; __append(' +
+ case Template.modes.RAW:
+ this.source += ' ; __append(' +
line.replace(_TRAILING_SEMCOL, '').trim() + ')' + '\n';
- break;
- case Template.modes.COMMENT:
+ break;
+ case Template.modes.COMMENT:
// Do nothing
- break;
+ break;
// Literal <%% mode, append as raw output
- case Template.modes.LITERAL:
- _addOutput();
- break;
- }
- }
- // In string mode, just add the output
- else {
+ case Template.modes.LITERAL:
_addOutput();
+ break;
}
+ }
+ // In string mode, just add the output
+ else {
+ _addOutput();
+ }
}
if (self.opts.compileDebug && newLineCount) {
@@ -776,9 +776,9 @@ if (require.extensions) {
require.extensions['.ejs'] = function (module, flnm) {
var filename = flnm || /* istanbul ignore next */ module.filename;
var options = {
- filename: filename,
- client: true
- };
+ filename: filename,
+ client: true
+ };
var template = fs.readFileSync(filename).toString();
var fn = exports.compile(template, options);
module._compile('module.exports = ' + fn.toString() + ';', filename);
Oops, something went wrong.

0 comments on commit 54bb18e

Please sign in to comment.