From 5ba895dff9a375fbba6817a643a31c2514761344 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Thu, 2 Jan 2014 22:53:37 -0500 Subject: [PATCH 01/11] Add EditorConfig for indentation standardization --- .editorconfig | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..833f2619d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +# This file is for unifying the coding style for different editors and IDEs +# editorconfig.org + +root = true + +[*] +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +indent_style = spaces +indent_size = 2 From 956dfe9ea6b9b7ef4949a6379513b8eeb1572465 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Thu, 2 Jan 2014 22:56:00 -0500 Subject: [PATCH 02/11] Don't lint node_modules --- .jshintignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .jshintignore diff --git a/.jshintignore b/.jshintignore new file mode 100644 index 000000000..40b878db5 --- /dev/null +++ b/.jshintignore @@ -0,0 +1 @@ +node_modules/ \ No newline at end of file From c9d9294c1b25f0ffd0a3340f304d9399591e06eb Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Thu, 2 Jan 2014 22:57:51 -0500 Subject: [PATCH 03/11] JSHint Middleware example --- examples/middleware.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/middleware.js b/examples/middleware.js index 20650afd0..4c2d6a2c5 100644 --- a/examples/middleware.js +++ b/examples/middleware.js @@ -3,21 +3,21 @@ * Module dependencies. */ -var connect = require('connect') - , sass = require('../sass'); +var connect = require('connect'), + sass = require('../sass'); // Setup server // $ curl http://localhost:3000/test.css var server = connect.createServer( sass.middleware({ - src: __dirname - , dest: __dirname + '/public' - , debug: true - , outputStyle: 'compressed' + src: __dirname, + dest: __dirname + '/public', + debug: true, + outputStyle: 'compressed' }), connect.static(__dirname + '/public') ); server.listen(3000); -console.log('server listening on port 3000'); \ No newline at end of file +console.log('server listening on port 3000'); From c0fc5dbc42465e396ab2c6c5eac82cbd85bd2119 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Thu, 2 Jan 2014 22:58:21 -0500 Subject: [PATCH 04/11] JSHint: Add Mocha globals and allow multistr --- .jshintrc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.jshintrc b/.jshintrc index 16487068b..86a65de0b 100644 --- a/.jshintrc +++ b/.jshintrc @@ -6,5 +6,10 @@ "trailing": true, "undef": true, "unused": true, - "expr":true + "expr":true, + "multistr": true, + "globals": { + "it": true, + "describe": true + } } \ No newline at end of file From a35b2dfea06cfd859598bf3b9f7651db7dee4b9b Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Thu, 2 Jan 2014 22:59:50 -0500 Subject: [PATCH 05/11] Remove outdated test.js --- test.js | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 test.js diff --git a/test.js b/test.js deleted file mode 100644 index 4f0f0ae2b..000000000 --- a/test.js +++ /dev/null @@ -1,16 +0,0 @@ -var sass = require('./sass'); - -var scssStr = '#navbar {\ - width: 80%;\ - height: 23px; }\ - #navbar ul {\ - list-style-type: none; }\ - #navbar li {\ - float: left;\ - a {\ - font-weight: bold; }}'; - -sass.render(scssStr, function(err, css){ - console.log(css) -}) - From f14b040b109f27775647858e1242250887abca7a Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Thu, 2 Jan 2014 23:02:48 -0500 Subject: [PATCH 06/11] JSHint sass.js - Fix indenting - Remove unused callback --- sass.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sass.js b/sass.js index 33b43cf1f..0eb00fabf 100644 --- a/sass.js +++ b/sass.js @@ -24,14 +24,14 @@ var SASS_OUTPUT_STYLE = { expanded: 1, compact: 2, compressed: 3 -}; + }; var SASS_SOURCE_COMMENTS = { - none: 0, - // This is called default in libsass, but is a reserved keyword here - normal: 1, - map: 2 -}; + none: 0, + // This is called default in libsass, but is a reserved keyword here + normal: 1, + map: 2 + }; var prepareOptions = function(options) { var paths, style, comments; @@ -52,7 +52,7 @@ var deprecatedRender = function(css, callback, options) { var errCallback = function(err) { callback(err); }; - var oldCallback = function(css, err) { + var oldCallback = function(css) { callback(null, css); }; return binding.render(css, oldCallback, errCallback, options.paths.join(':'), options.style, options.comments); From 43cff35fa447ba0a57e52b9eec184e9b8eb9c0c7 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Thu, 2 Jan 2014 23:12:42 -0500 Subject: [PATCH 07/11] JSHint Build.js - Tabs to spaces - Remove 'runner' Mocha var since it is only invoked --- build.js | 144 +++++++++++++++++++++++++++---------------------------- 1 file changed, 72 insertions(+), 72 deletions(-) diff --git a/build.js b/build.js index 4980835c6..b274c285c 100644 --- a/build.js +++ b/build.js @@ -1,101 +1,101 @@ #!/usr/bin/env node var cp = require('child_process'), - fs = require('fs'), - path = require('path'), - Mocha = require('mocha'); + fs = require('fs'), + path = require('path'), + Mocha = require('mocha'); // Parse args var force = false, debug = false; var arch = process.arch, - platform = process.platform, - v8 = /[0-9]+\.[0-9]+/.exec(process.versions.v8)[0]; + platform = process.platform, + v8 = /[0-9]+\.[0-9]+/.exec(process.versions.v8)[0]; var args = process.argv.slice(2).filter(function(arg) { - if (arg === '-f') { - force = true; - return false; - } else if (arg.substring(0, 13) === '--target_arch') { - arch = arg.substring(14); - } else if (arg === '--debug') { - debug = true; - } - return true; + if (arg === '-f') { + force = true; + return false; + } else if (arg.substring(0, 13) === '--target_arch') { + arch = arg.substring(14); + } else if (arg === '--debug') { + debug = true; + } + return true; }); if (!{ia32: true, x64: true, arm: true}.hasOwnProperty(arch)) { - console.error('Unsupported (?) architecture: `'+ arch+ '`'); - process.exit(1); + console.error('Unsupported (?) architecture: `'+ arch+ '`'); + process.exit(1); } // Test for pre-built library var modPath = platform + '-' + arch + '-v8-' + v8; if (!force && !process.env.SKIP_NODE_SASS_TESTS) { - try { - fs.statSync(path.join(__dirname, 'bin', modPath, 'binding.node')); - console.log('`'+ modPath+ '` exists; testing'); - - var mocha = new Mocha({ - reporter: 'dot', - ui: 'bdd', - timeout: 999999 - }); - - mocha.addFile(path.resolve(__dirname, "test", "test.js")); + try { + fs.statSync(path.join(__dirname, 'bin', modPath, 'binding.node')); + console.log('`'+ modPath+ '` exists; testing'); - var runner = mocha.run(function (done) { - if (done !== 0) { - console.log('Problem with the binary; manual build incoming'); - console.log('Please consider contributing the release binary to https://github.com/andrew/node-sass-binaries for npm distribution.'); - build(); - } else { - console.log('Binary is fine; exiting'); - } - }); - } catch (ex) { - // Stat failed - build(); - } + var mocha = new Mocha({ + reporter: 'dot', + ui: 'bdd', + timeout: 999999 + }); + + mocha.addFile(path.resolve(__dirname, "test", "test.js")); + + mocha.run(function (done) { + if (done !== 0) { + console.log('Problem with the binary; manual build incoming'); + console.log('Please consider contributing the release binary to https://github.com/andrew/node-sass-binaries for npm distribution.'); + build(); + } else { + console.log('Binary is fine; exiting'); + } + }); + } catch (ex) { + // Stat failed + build(); + } } else { - build(); + build(); } // Build it function build() { - cp.spawn( - process.platform === 'win32' ? 'node-gyp.cmd' : 'node-gyp', - ['rebuild'].concat(args), - {customFds: [0, 1, 2]}) - .on('exit', function(err) { - if (err) { - if (err === 127) { - console.error( - 'node-gyp not found! Please upgrade your install of npm! You need at least 1.1.5 (I think) '+ - 'and preferably 1.1.30.' - ); - } else { - console.error('Build failed'); - } - return process.exit(err); - } - afterBuild(); - }); + cp.spawn( + process.platform === 'win32' ? 'node-gyp.cmd' : 'node-gyp', + ['rebuild'].concat(args), + {customFds: [0, 1, 2]}) + .on('exit', function(err) { + if (err) { + if (err === 127) { + console.error( + 'node-gyp not found! Please upgrade your install of npm! You need at least 1.1.5 (I think) '+ + 'and preferably 1.1.30.' + ); + } else { + console.error('Build failed'); + } + return process.exit(err); + } + afterBuild(); + }); } // Move it to expected location function afterBuild() { - var targetPath = path.join(__dirname, 'build', debug ? 'Debug' : 'Release', 'binding.node'); - var installPath = path.join(__dirname, 'bin', modPath, 'binding.node'); + var targetPath = path.join(__dirname, 'build', debug ? 'Debug' : 'Release', 'binding.node'); + var installPath = path.join(__dirname, 'bin', modPath, 'binding.node'); - try { - fs.mkdirSync(path.join(__dirname, 'bin', modPath)); - } catch (ex) {} + try { + fs.mkdirSync(path.join(__dirname, 'bin', modPath)); + } catch (ex) {} - try { - fs.statSync(targetPath); - } catch (ex) { - console.error('Build succeeded but target not found'); - process.exit(1); - } - fs.renameSync(targetPath, installPath); - console.log('Installed in `'+ installPath+ '`'); + try { + fs.statSync(targetPath); + } catch (ex) { + console.error('Build succeeded but target not found'); + process.exit(1); + } + fs.renameSync(targetPath, installPath); + console.log('Installed in `'+ installPath+ '`'); } From 6d530baf046ef07a7a59253e0a442dd093f5227f Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Thu, 2 Jan 2014 23:17:05 -0500 Subject: [PATCH 08/11] JSHint source_comments_spec.js test Remove unused vars --- test/source_comments_spec.js | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/test/source_comments_spec.js b/test/source_comments_spec.js index e1f318163..39e88dbd7 100644 --- a/test/source_comments_spec.js +++ b/test/source_comments_spec.js @@ -4,21 +4,6 @@ var assert = require('assert'); var sampleFilename = require('path').resolve(__dirname, 'sample.scss'); -var scssStr = '#navbar {\ - width: 80%;\ - height: 23px; }\ - #navbar ul {\ - list-style-type: none; }\ - #navbar li {\ - float: left;\ - a {\ - font-weight: bold; }}\ - @mixin keyAnimation($name, $attr, $value) {\ - @-webkit-keyframes #{$name} {\ - 0% { #{$attr}: $value; }\ - }\ - }'; - var expectedCommentsScssStr = '/* line 1, ' + sampleFilename + ' */\n\ #navbar {\n\ width: 80%;\n\ @@ -35,23 +20,6 @@ var expectedCommentsScssStr = '/* line 1, ' + sampleFilename + ' */\n\ #navbar li a {\n\ font-weight: bold; }\n'; -var expectedDebugScssStr = '@media -sass-debug-info{filename{font-family:file\:' + sampleFilename + '}line{font-family:\\000031}}\n\ -#navbar {\n\ - width: 80%;\n\ - height: 23px; }\n\ -\n\ -@media -sass-debug-info{filename{font-family:file\:' + sampleFilename + '}line{font-family:\\000035}}\n\ -#navbar ul {\n\ - list-style-type: none; }\n\ -\n\ -@media -sass-debug-info{filename{font-family:file\:' + sampleFilename + '}line{font-family:\\000038}}\n\ -#navbar li {\n\ - float: left; }\n\ - @media -sass-debug-info{filename{font-family:file\:' + sampleFilename + '}line{font-family:\\0000310}}\n\ - #navbar li a {\n\ - font-weight: bold; }\n'; - - describe("compile file with source comments", function() { it("should compile with render and comment outputs", function(done) { sass.render({ From f066eb6fecf3d44661ca9f0a04454c437587e304 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Thu, 2 Jan 2014 23:20:12 -0500 Subject: [PATCH 09/11] JSHint test.js - Add missing semicolons - Remove unused parameters --- test/test.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/test.js b/test/test.js index 005fffedb..29cae8f23 100644 --- a/test/test.js +++ b/test/test.js @@ -38,7 +38,7 @@ var expectedRender = '#navbar {\n\ describe("DEPRECATED: compile scss", function() { it("should compile with render", function(done) { - sass.render(scssStr, function(err, css) { + sass.render(scssStr, function(err) { done(err); }); }); @@ -98,6 +98,7 @@ describe("compile scss", function() { sass.render({ data: '{zzz}', success: function(css) { + console.log(css); }, error: function(error, status) { assert.equal(status, 1); @@ -128,7 +129,7 @@ describe("compile file with include paths", function(){ error: function (error) { done(error); } - }) + }); }); }); @@ -145,7 +146,7 @@ describe("compile file", function() { }); }); - it("should compile with renderSync", function(done) { + it("should compile with renderSync", function(done) { done(assert.ok(sass.renderSync({file: sampleFilename}))); }); From b7574c9809e405b72f572e4e2670bed5ff71682f Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Thu, 2 Jan 2014 23:23:45 -0500 Subject: [PATCH 10/11] JSHint cli.js tests - Remove unused vars - Remove unused parameters --- test/cli.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/test/cli.js b/test/cli.js index 58955a500..571917e7f 100644 --- a/test/cli.js +++ b/test/cli.js @@ -2,7 +2,6 @@ var path = require('path'), assert = require('assert'), fs = require('fs'), exec = require('child_process').exec, - sass = require('../sass'), cli = require('../lib/cli'), cliPath = path.resolve(__dirname, '../bin/node-sass'), @@ -37,7 +36,7 @@ describe('cli', function() { exec('node ' + cliPath + ' ' + sampleFilename, { cwd: __dirname - }, function(err, stdout, stderr) { + }, function() { fs.exists(resultPath, function(exists) { assert(exists); @@ -46,12 +45,12 @@ describe('cli', function() { }); }); - it('should compile sample.scss to ../out.css', function(done) { + it('should compile sample.scss to ../out.css', function(done) { var resultPath = path.resolve(__dirname, '../out.css'); exec('node ' + cliPath + ' ' + sampleFilename + ' ../out.css', { cwd: __dirname - }, function(err, stdout, stderr) { + }, function() { fs.exists(resultPath, function(exists) { assert(exists); @@ -95,7 +94,7 @@ describe('cli', function() { var resultPath = path.join(__dirname, '../output.css'); var emitter = cli(['--output', resultPath, path.join(__dirname, 'sample.scss')]); emitter.on('error', done); - emitter.on('write', function(err, file, css){ + emitter.on('write', function(){ fs.exists(resultPath, function(exists) { assert(exists); fs.unlink(resultPath, done); @@ -139,5 +138,4 @@ describe('cli', function() { }); }); - }); From bf2e92938bb312e9db0b3a092266848bdc9b16d0 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Thu, 2 Jan 2014 23:52:06 -0500 Subject: [PATCH 11/11] Run JSHint when testing --- package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package.json b/package.json index f7a9d23ea..0fc144bfd 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "scripts": { "install": "node build.js", "test": "mocha test", + "pretest": "jshint .", "prepublish": "bash scripts/prepublish.sh" }, "bin": { @@ -42,5 +43,8 @@ "mocha": "1.13.x", "chalk": "~0.3.0", "nan": "~0.6.0" + }, + "devDependencies": { + "jshint": "~2.4.0" } }