Skip to content

Commit

Permalink
Fix .eslintignore and lint errors (mde#207)
Browse files Browse the repository at this point in the history
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
RyanZim authored Sep 29, 2016
1 parent 699b953 commit 54bb18e
Show file tree
Hide file tree
Showing 3 changed files with 180 additions and 182 deletions.
4 changes: 2 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
coverage
out
ejs.js
ejs.min.js
/ejs.js
/ejs.min.js
122 changes: 61 additions & 61 deletions lib/ejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 54bb18e

Please sign in to comment.