Skip to content

Commit 61eb441

Browse files
committed
jshint errything
1 parent ae9d54c commit 61eb441

File tree

6 files changed

+94
-4
lines changed

6 files changed

+94
-4
lines changed

.jshintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.jshintrc

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{
2+
// JSHint Default Configuration File (as on JSHint website)
3+
// See http://jshint.com/docs/ for more details
4+
5+
"maxerr" : 50, // {int} Maximum error before stopping
6+
7+
// Enforcing
8+
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
9+
"camelcase" : false, // true: Identifiers must be in camelCase
10+
"curly" : true, // true: Require {} for every new block or scope
11+
"eqeqeq" : true, // true: Require triple equals (===) for comparison
12+
"forin" : false, // true: Require filtering for..in loops with obj.hasOwnProperty()
13+
"immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
14+
"indent" : 4, // {int} Number of spaces to use for indentation
15+
"latedef" : false, // true: Require variables/functions to be defined before being used
16+
"newcap" : false, // true: Require capitalization of all constructor functions e.g. `new F()`
17+
"noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee`
18+
"noempty" : true, // true: Prohibit use of empty blocks
19+
"nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment)
20+
"plusplus" : false, // true: Prohibit use of `++` & `--`
21+
"quotmark" : false, // Quotation mark consistency:
22+
// false : do nothing (default)
23+
// true : ensure whatever is used is consistent
24+
// "single" : require single quotes
25+
// "double" : require double quotes
26+
"undef" : true, // true: Require all non-global variables to be declared (prevents global leaks)
27+
"unused" : true, // true: Require all defined variables be used
28+
"strict" : false, // true: Requires all functions run in ES5 Strict Mode
29+
"maxparams" : false, // {int} Max number of formal params allowed per function
30+
"maxdepth" : false, // {int} Max depth of nested blocks (within functions)
31+
"maxstatements" : false, // {int} Max number statements per function
32+
"maxcomplexity" : false, // {int} Max cyclomatic complexity per function
33+
"maxlen" : 80, // {int} Max number of characters per line
34+
35+
// Relaxing
36+
"asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
37+
"boss" : true, // true: Tolerate assignments where comparisons would be expected
38+
"debug" : false, // true: Allow debugger statements e.g. browser breakpoints.
39+
"eqnull" : false, // true: Tolerate use of `== null`
40+
"es5" : false, // true: Allow ES5 syntax (ex: getters and setters)
41+
"esnext" : false, // true: Allow ES.next (ES6) syntax (ex: `const`)
42+
"moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features)
43+
// (ex: `for each`, multiple try/catch, function expression…)
44+
"evil" : false, // true: Tolerate use of `eval` and `new Function()`
45+
"expr" : false, // true: Tolerate `ExpressionStatement` as Programs
46+
"funcscope" : false, // true: Tolerate defining variables inside control statements
47+
"globalstrict" : false, // true: Allow global "use strict" (also enables 'strict')
48+
"iterator" : false, // true: Tolerate using the `__iterator__` property
49+
"lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block
50+
"laxbreak" : true, // true: Tolerate possibly unsafe line breakings
51+
"laxcomma" : false, // true: Tolerate comma-first style coding
52+
"loopfunc" : false, // true: Tolerate functions being defined in loops
53+
"multistr" : false, // true: Tolerate multi-line strings
54+
"proto" : true, // true: Tolerate using the `__proto__` property
55+
"scripturl" : false, // true: Tolerate script-targeted URLs
56+
"shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;`
57+
"sub" : true, // true: Tolerate using `[]` notation when it can still be expressed in dot notation
58+
"supernew" : true, // true: Tolerate `new function () { ... };` and `new Object;`
59+
"validthis" : false, // true: Tolerate using this in a non-constructor function
60+
61+
// Environments
62+
"browser" : false, // Web Browser (window, document, etc)
63+
"browserify" : false, // Browserify (node.js code in the browser)
64+
"couch" : false, // CouchDB
65+
"devel" : false, // Development/debugging (alert, confirm, etc)
66+
"dojo" : false, // Dojo Toolkit
67+
"jquery" : false, // jQuery
68+
"mootools" : false, // MooTools
69+
"node" : true, // Node.js
70+
"nonstandard" : false, // Widely adopted globals (escape, unescape, etc)
71+
"prototypejs" : false, // Prototype and Scriptaculous
72+
"rhino" : false, // Rhino
73+
"worker" : false, // Web Workers
74+
"wsh" : false, // Windows Scripting Host
75+
"yui" : false, // Yahoo User Interface
76+
77+
// Custom Globals
78+
"globals" : {} // additional predefined global variables
79+
}

hook.sh

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
set -ex
44

5+
npm run lint
56
npm run test
67

78
node package.json

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ exports = module.exports = function vmplate(string, locals, filename) {
2222
var output = 'var str = ""\n';
2323
var token = SCRIPT;
2424
var start = 0;
25-
var previous;
25+
var input;
2626
var match;
2727

2828
function push(str, raw) {

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"description": "Simple templates for node programs",
55
"main": "index.js",
66
"scripts": {
7-
"test": "mocha test.js"
7+
"test": "mocha test.js",
8+
"lint": "jshint ."
89
},
910
"keywords": [
1011
"template",
@@ -17,6 +18,7 @@
1718
"author": "Jeremy Ruppel",
1819
"license": "ISC",
1920
"devDependencies": {
21+
"jshint": "^2.8.0",
2022
"mocha": "^2.3.3"
2123
},
2224
"dependencies": {

test.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
var subject = require(__dirname);
22
var assert = require('assert');
33

4+
/* jshint mocha:true */
5+
46
describe('vmplate', function() {
57
it('throws on an unclosed code section', function() {
68
assert.throws(function() { subject('<%= oops'); }, /SyntaxError/);
@@ -15,8 +17,9 @@ describe('vmplate', function() {
1517
});
1618
it('interpolates multiple values', function() {
1719
var render = subject('<%= one %> <%= two %> and <%= three %>');
20+
var output = render({ one: 'me', two: 'myself', three: 'I' });
1821

19-
assert.equal(render({ one: 'me', two: 'myself', three: 'I' }), 'me myself and I');
22+
assert.equal(output, 'me myself and I');
2023
});
2124
it('evaluates code without output', function() {
2225
var render = subject('<% var who = "george"; %>by <%= who %>!');
@@ -34,7 +37,11 @@ describe('vmplate', function() {
3437
assert.equal(render(), 'ohai');
3538
});
3639
it('iterates over an array in the locals context', function() {
37-
var render = subject('<% for(var i = 0; i < arr.length; i++){ %><%= arr[i] %><% } %>');
40+
var render = subject(
41+
'<% for(var i = 0; i < arr.length; i++){ %>' +
42+
'<%= arr[i] %>' +
43+
'<% } %>'
44+
);
3845

3946
assert.equal(render({ arr: [1, 2, 3] }), '123');
4047
});

0 commit comments

Comments
 (0)