Permalink
Browse files

Add lint script and fix lint errors in lib/utils.js & examples/

Add .eslintignore
1 parent f7f8ab0 commit 54d5ab0b3fe1e00998f6000b8caa7fb633512290 @RyanZim RyanZim committed with RyanZim Aug 16, 2016
Showing with 44 additions and 37 deletions.
  1. +4 −0 .eslintignore
  2. +4 −1 .eslintrc.json
  3. +11 −11 Jakefile
  4. +11 −11 examples/functions.js
  5. +4 −4 examples/list.js
  6. +9 −10 lib/utils.js
  7. +1 −0 package.json
View
@@ -0,0 +1,4 @@
+coverage
+out
+ejs.js
+ejs.min.js
View
@@ -12,7 +12,10 @@
],
"quotes": [
"error",
- "single"
+ "single",
+ {
+ "avoidEscape": true
+ }
],
"semi": [
"error",
View
@@ -1,8 +1,8 @@
-var fs = require('fs')
- , buildOpts = {
- printStdout: true
- , printStderr: true
- };
+/* global jake, task, complete, desc, publishTask */
+var buildOpts = {
+ printStdout: true,
+ printStderr: true
+};
task('build', ['browserify', 'minify'], function () {
console.log('Build completed.');
@@ -17,17 +17,17 @@ task('clean', ['clobber'], function () {
task('browserify', {async: true}, function () {
jake.exec('./node_modules/browserify/bin/cmd.js --standalone ejs lib/ejs.js > ejs.js',
buildOpts, function () {
- console.log('Browserification completed.');
- setTimeout(complete, 0);
- });
+ console.log('Browserification completed.');
+ setTimeout(complete, 0);
+ });
});
task('minify', {async: true}, function () {
jake.exec('./node_modules/uglify-js/bin/uglifyjs ejs.js > ejs.min.js',
buildOpts, function () {
- console.log('Minification completed.');
- setTimeout(complete, 0);
- });
+ console.log('Minification completed.');
+ setTimeout(complete, 0);
+ });
});
publishTask('ejs', ['build'], function () {
View
@@ -2,17 +2,17 @@
* Believe it or not, you can declare and use functions in EJS templates too.
*/
-var ejs = require('../')
- , read = require('fs').readFileSync
- , join = require('path').join
- , path = join(__dirname, '/functions.ejs')
- , data = {
- users: [
- { name: 'Tobi', age: 2, species: 'ferret' }
- , { name: 'Loki', age: 2, species: 'ferret' }
- , { name: 'Jane', age: 6, species: 'ferret' }
- ]
- };
+var ejs = require('../');
+var read = require('fs').readFileSync;
+var join = require('path').join;
+var path = join(__dirname, '/functions.ejs');
+var data = {
+ users: [
+ { name: 'Tobi', age: 2, species: 'ferret' },
+ { name: 'Loki', age: 2, species: 'ferret' },
+ { name: 'Jane', age: 6, species: 'ferret' }
+ ]
+};
var ret = ejs.compile(read(path, 'utf8'), {filename: path})(data);
View
@@ -3,10 +3,10 @@
* template.
*/
-var ejs = require('../')
- , read = require('fs').readFileSync
- , join = require('path').join
- , str = read(join(__dirname, '/list.ejs'), 'utf8');
+var ejs = require('../');
+var read = require('fs').readFileSync;
+var join = require('path').join;
+var str = read(join(__dirname, '/list.ejs'), 'utf8');
var ret = ejs.compile(str)({
names: ['foo', 'bar', 'baz']
View
@@ -45,17 +45,17 @@ exports.escapeRegExpChars = function (string) {
};
var _ENCODE_HTML_RULES = {
- '&': '&'
- , '<': '&lt;'
- , '>': '&gt;'
- , '"': '&#34;'
- , "'": '&#39;'
- }
- , _MATCH_HTML = /[&<>\'"]/g;
+ '&': '&amp;',
+ '<': '&lt;',
+ '>': '&gt;',
+ '"': '&#34;',
+ "'": '&#39;'
+};
+var _MATCH_HTML = /[&<>\'"]/g;
function encode_char(c) {
return _ENCODE_HTML_RULES[c] || c;
-};
+}
/**
* Stringified version of constants used by {@link module:utils.escapeXML}.
@@ -98,7 +98,7 @@ exports.escapeXML = function (markup) {
.replace(_MATCH_HTML, encode_char);
};
exports.escapeXML.toString = function () {
- return Function.prototype.toString.call(this) + ';\n' + escapeFuncStr
+ return Function.prototype.toString.call(this) + ';\n' + escapeFuncStr;
};
/**
@@ -138,4 +138,3 @@ exports.cache = {
this._data = {};
}
};
-
View
@@ -36,6 +36,7 @@
},
"scripts": {
"test": "mocha",
+ "lint": "eslint \"**/*.js\"",
"coverage": "istanbul cover node_modules/mocha/bin/_mocha",
"doc": "rimraf out && jsdoc -c jsdoc.json lib/* docs/jsdoc/*",
"devdoc": "rimraf out && jsdoc -p -c jsdoc.json lib/* docs/jsdoc/*"

0 comments on commit 54d5ab0

Please sign in to comment.