Skip to content

Commit

Permalink
Fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDancingCode committed Mar 16, 2018
1 parent 9407382 commit c30d153
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 83 deletions.
4 changes: 4 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"env": {
"node": true,
"mocha": true
},
"extends": "standard",
"rules": {
"padded-blocks": 0,
Expand Down
11 changes: 6 additions & 5 deletions examples/express.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// npm install express

var express = require('../../express')
, cons = require('../')
, app = express();
var express = require('../../express');
var cons = require('../');
var app = express();
var path = require('path');

app.engine('html', cons.swig);
app.set('view engine', 'html');
app.set('views', __dirname + '/views');
app.set('views', path.join(__dirname, 'views'));

var users = [];
users.push({ name: 'tobi' });
Expand All @@ -27,4 +28,4 @@ app.get('/users', function(req, res){
});

app.listen(3000);
console.log('Express server listening on port 3000');
console.log('Express server listening on port 3000');
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./lib/consolidate');
module.exports = require('./lib/consolidate');
24 changes: 11 additions & 13 deletions lib/consolidate.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ exports.liquid.render = function(str, options, fn){
// set up liquid-node engine
try {
Liquid = requires.liquid = require('liquid-node');
engine = new Liquid.Engine;
engine = new Liquid.Engine();
} catch (err) {
throw err;
}
Expand Down Expand Up @@ -376,10 +376,6 @@ exports.liquid.render = function(str, options, fn){
* callback:
*/

var compileOptions = {
customTags: {}
};

if (options.customTags){
var tagFunctions = options.customTags;

Expand Down Expand Up @@ -1178,10 +1174,10 @@ exports.dot.render = function (str, options, fn) {
var engine = requires.dot || (requires.dot = require('dot'));
var extend = (requires.extend || (requires.extend = require('util')._extend));
try {
var settings = {};
settings = extend(settings, engine.templateSettings);
settings = extend(settings, options ? options.dot : {});
var tmpl = cache(options) || cache(options, engine.template(str, settings, options));
var settings = {};
settings = extend(settings, engine.templateSettings);
settings = extend(settings, options ? options.dot : {});
var tmpl = cache(options) || cache(options, engine.template(str, settings, options));
fn(null, tmpl(options));
} catch (err) {
fn(err);
Expand Down Expand Up @@ -1236,7 +1232,8 @@ exports.ractive.render = function(str, options, fn){
options.data = extend({}, options);

// Remove consolidate-specific properties from the clone
var i, length;
var i;
var length;
var properties = ["template", "filename", "cache", "partials"];
for (i = 0, length = properties.length; i < length; i++) {
var property = properties[i];
Expand Down Expand Up @@ -1377,7 +1374,7 @@ function requireReactString(src, filename) {

if (!filename) filename = '';
var m = new module.constructor();
filename = filename || '';
filename = filename || '';

// Compile Using React
var compiled = babel.transform(src, { presets: [ 'react' ] }).code;
Expand Down Expand Up @@ -1594,6 +1591,7 @@ exports.vash.render = function(str, options, fn) {

var tmpl = cache(options) || cache(options, engine.compile(str, options));
tmpl(options, function sealLayout(err, ctx) {
if(err) fn(err);
ctx.finishLayout();
fn(null, ctx.toString().replace(/\n$/, ''));
});
Expand Down Expand Up @@ -1670,7 +1668,7 @@ exports.teacup = function(path, options, fn) {
return promisify(fn, function(fn) {
var engine = requires.teacup || (requires.teacup = require('teacup/lib/express'));
require.extensions['.teacup'] = require.extensions['.coffee'];
if (path[0] != '/') {
if (path[0] !== '/') {
path = join(process.cwd(), path);
}
if (!options.cache) {
Expand Down Expand Up @@ -1704,4 +1702,4 @@ exports.teacup.render = function(str, options, fn){
/**
* expose the instance of the engine
*/
exports.requires = requires;
exports.requires = requires;
2 changes: 1 addition & 1 deletion test/shared/dust.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ exports.test = function(name) {

if (name === 'dust') {
var dust = require('dustjs-helpers');
dust.helpers.templateName = function(chunk, context, bodies, params) {
dust.helpers.templateName = function(chunk, context) {
return chunk.write(context.getTemplateName());
};
cons.requires.dust = dust;
Expand Down
13 changes: 6 additions & 7 deletions test/shared/filters.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
var cons = require('../../')
, fs = require('fs');

var should = require('should');
var cons = require('../../');
var fs = require('fs');

exports.test = function(name) {
var user = { name: 'Tobi' };
Expand All @@ -12,9 +10,10 @@ exports.test = function(name) {
it('should support filters', function(done) {
var str = fs.readFileSync('test/fixtures/' + name + '/filters.' + name).toString();

var locals = { user: user, filters: { toupper: function(object) {
return object.toUpperCase();
}}};
var locals = { user: user,
filters: { toupper: function(object) {
return object.toUpperCase();
}}};

cons[name].render(str, locals, function(err, html){
if (err) return done(err);
Expand Down
67 changes: 35 additions & 32 deletions test/shared/helpers.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

var cons = require('../../')
, handlebars = require('handlebars')
, vash = require('vash')
, fs = require('fs')
, readFile = fs.readFile
, readFileSync = fs.readFileSync;
var cons = require('../../');
var handlebars = require('handlebars');
var fs = require('fs');
var readFile = fs.readFile;
var readFileSync = fs.readFileSync;

exports.test = function(name) {

Expand All @@ -15,43 +14,47 @@ exports.test = function(name) {
fs.readFileSync = readFileSync;
});

var user;

if (name === 'handlebars') {
var user = { name: '<strong>Tobi</strong>' };
user = { name: '<strong>Tobi</strong>' };

// Use case: return safe HTML that won’t be escaped in the final render.
it('should support helpers', function(done) {
var str = fs.readFileSync('test/fixtures/' + name + '/helpers.' + name).toString();

var locals = { user: user, helpers: { safe: function(object) {
return new handlebars.SafeString(object);
}}};

cons[name].render(str, locals, function(err, html){
if (err) return done(err);
html.should.equal('<strong>Tobi</strong>');
done();
});
it('should support helpers', function(done) {
var str = fs.readFileSync('test/fixtures/' + name + '/helpers.' + name).toString();

var locals = { user: user,
helpers: { safe: function(object) {
return new handlebars.SafeString(object);
}}};

cons[name].render(str, locals, function(err, html){
if (err) return done(err);
html.should.equal('<strong>Tobi</strong>');
done();
});
});
}

if (name === 'vash') {
var user = { name: 'Tobi' };
user = { name: 'Tobi' };

// See this for Vash helper system : https://github.com/kirbysayshi/vash#helper-system
// Use case: return as as lower case
it('should support helpers', function(done) {
var str = fs.readFileSync('test/fixtures/' + name + '/helpers.' + name).toString();

var locals = { user: user, helpers: { lowerCase: function(text) {
return text.toLowerCase();
}}};

cons[name].render(str, locals, function(err, html){
if (err) return done(err);
html.should.equal('<strong>tobi</strong>');
done();
});
it('should support helpers', function(done) {
var str = fs.readFileSync('test/fixtures/' + name + '/helpers.' + name).toString();

var locals = { user: user,
helpers: { lowerCase: function(text) {
return text.toLowerCase();
}}};

cons[name].render(str, locals, function(err, html){
if (err) return done(err);
html.should.equal('<strong>tobi</strong>');
done();
});
});
}
});
};
8 changes: 3 additions & 5 deletions test/shared/includes.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
var cons = require('../../')
, fs = require('fs');

var should = require('should');
var cons = require('../../');
var fs = require('fs');

exports.test = function(name) {
var user = { name: 'Tobi' };
Expand Down Expand Up @@ -33,7 +31,7 @@ exports.test = function(name) {
});
});

if (name == 'nunjucks') {
if (name === 'nunjucks') {
it('should support extending views', function (done) {
var str = fs.readFileSync('test/fixtures/' + name + '/layouts.' + name).toString();

Expand Down
12 changes: 6 additions & 6 deletions test/shared/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

var cons = require('../../')
, fs = require('fs')
, readFile = fs.readFile
, readFileSync = fs.readFileSync;
var cons = require('../../');
var fs = require('fs');
var readFile = fs.readFile;
var readFileSync = fs.readFileSync;

exports.test = function(name) {
var user = { name: 'Tobi' };
Expand Down Expand Up @@ -109,8 +109,8 @@ exports.test = function(name) {
});

it('should be exposed in the requires object', function(){
var should = require('should'),
requiredName = name;
var should = require('should');
var requiredName = name;
should.exist(cons.requires[requiredName]);
});
});
Expand Down
13 changes: 7 additions & 6 deletions test/shared/partials.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@

var cons = require('../../')
, fs = require('fs')
, readFile = fs.readFile
, readFileSync = fs.readFileSync;
var cons = require('../../');
var join = require('path').join;
var fs = require('fs');
var readFile = fs.readFile;
var readFileSync = fs.readFileSync;

exports.test = function(name) {
var user = { name: 'Tobi' };
Expand All @@ -13,7 +14,7 @@ exports.test = function(name) {
fs.readFileSync = readFileSync;
});

if (name == 'hogan' || name == 'mustache' || name == 'handlebars' || name == 'ractive') {
if (name === 'hogan' || name === 'mustache' || name === 'handlebars' || name === 'ractive') {
it('should support partials', function(done){
var path = 'test/fixtures/' + name + '/partials.' + name;
var locals = { user: user, partials: { partial: 'user' } };
Expand All @@ -25,7 +26,7 @@ exports.test = function(name) {
});
it('should support absolute path partial', function(done){
var path = 'test/fixtures/' + name + '/partials.' + name;
var locals = {user: user, partials: {partial: __dirname + '/../../test/fixtures/' + name + '/user' }};
var locals = {user: user, partials: {partial: join(__dirname, '/../../test/fixtures/' , name, '/user') }};
cons[name](path, locals, function(err, html){
if (err) return done(err);
html.should.equal('<p>Tobi</p>');
Expand Down
14 changes: 7 additions & 7 deletions test/shared/react.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*eslint-env node, mocha */
/*eslint quotes: [2, "single"] */
var consolidate = require('../../'),
fs = require('fs');
var consolidate = require('../../');
var fs = require('fs');

var readFile = fs.readFile,
readFileSync = fs.readFileSync;
var readFile = fs.readFile;
var readFileSync = fs.readFileSync;


exports.test = function(name) {
Expand Down Expand Up @@ -82,9 +82,9 @@ exports.test = function(name) {
it('should support rendering into a base template', function(done){
var path = 'test/fixtures/' + name + '/user.' + name;
var locals = {
user: user,
base: 'test/fixtures/' + name + '/base.html',
title: 'My Title'
user: user,
base: 'test/fixtures/' + name + '/base.html',
title: 'My Title'
};

cons[name](path, locals, function(err, html){
Expand Down

0 comments on commit c30d153

Please sign in to comment.