-
Notifications
You must be signed in to change notification settings - Fork 5
Jshint fixes #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Jshint fixes #31
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
bf60c5b
Add linting to the npm test script.
impaler d306d06
jshint fixes cli.js.
impaler 643164a
jshint fixes build.js.
impaler fe25ca8
jshint fixes css.js.
impaler cc1ac80
jshint fixes html.js.
impaler bb05a6d
jshint fixes init.js.
impaler a88d577
jshint fixes javascript.js.
impaler 6919622
jshint fixes release.js.
impaler a620ee8
jshint fixes server.js.
impaler 81767c7
jshint fixes test.js.
impaler e72a4eb
jshint fixes watch.js.
impaler e234c83
jshint fixe webstorm.js.
impaler 9a62230
Adjust jshint configuration to allow javascript url syntax that confl…
impaler 86f46b3
jshint fixes for specs.
impaler 41c66f0
jshint fixes for browserify.js.
impaler 80d3093
jshint fixes for node-sass.js.
impaler 22b6b4b
jshint fixes for defaults.js.
impaler 726701b
jshint fixes for platform.js.
impaler 7d8bd06
jshint fixes for streams.js.
impaler 1cae44a
jshint fixes for adjacent-files.js.
impaler caf812f
jshint fixes for brower-files.js.
impaler 7826432
jshint fixes for karma.js.
impaler e0c0c3f
jshint fixes for hr.js.
impaler 23275a1
jshint fixes for jshint-reporter.js.
impaler 18bd5da
jshint fixes for task-yargs-run.js.
impaler 31be93e
jshint fixes for task-yargs.js.
impaler baadcec
jshint fixes for yargs.js.
impaler 4300cc1
Remove interactive menus, they maybe reimplemented in a future version.
impaler 79847c6
=BG= fixing/ ignoring misc jshint violations
bguiz 177bbb7
=BG= clean up extraneous yargs instance usages in individual tasks
bguiz 63c451d
=BG= experimental commit to test if local jasmine installation works …
bguiz 2802f26
=BG= update test directory fro jasmine-node
bguiz fe25d1e
=BG= try npm run test instead
bguiz e38025e
=BG= reinstate global install
bguiz 5485ce9
removed dependency on global gulp
a66d309
Merge remote-tracking branch 'origin/jshint' into jshint
ddaac53
fail the build on lint error.
impaler 5f6e194
fixed jshint warnings, most were valid only a couple are spurious
95c6c0b
Merge remote-tracking branch 'origin/jshint' into jshint
6b5ff57
run the linting test after the integration tests.
impaler ac39ece
Merge remote-tracking branch 'origin/jshint' into jshint
impaler 50d8903
improvements suggested by @bguiz
e8725f6
Merge remote-tracking branch 'origin/jshint' into jshint
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ | |
| "maxparams": 20, | ||
| "maxdepth": 5, | ||
| "maxlen": 120, | ||
| "scripturl": true, | ||
| "node": true, | ||
| "jasmine": true | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,9 @@ | ||
| 'use strict'; | ||
|
|
||
| var fs = require('fs'), | ||
| path = require('path'), | ||
| through = require('through2'), | ||
| path = require('path'); | ||
|
|
||
| var through = require('through2'), | ||
| merge = require('lodash.merge'), | ||
| trackFilenames = require('gulp-track-filenames'), | ||
| transformTools = require('browserify-transform-tools'), | ||
|
|
@@ -22,7 +23,7 @@ var fs = require('fs'), | |
| function isLiteralAST(node) { | ||
| var candidates = Array.prototype.slice.call(arguments, 1); | ||
| return (node) && (node.type === 'Literal') && candidates.some(function (candidate) { | ||
| return (node.value === candidate) | ||
| return (node.value === candidate); | ||
| }); | ||
| } | ||
|
|
||
|
|
@@ -49,7 +50,7 @@ function isMethodAST(node) { | |
| * @return A jasmine transform | ||
| */ | ||
| function jasmineTransform(symbol) { | ||
| return transformTools.makeFalafelTransform('jasmineTransform', null, function (node, options, done) { | ||
| return transformTools.makeFalafelTransform('jasmineTransform', null, function jasmineASTWalker(node, options, done) { | ||
| var isValid = isLiteralAST(node, symbol) && isMethodAST(node.parent, 'describe', 'module'); | ||
| if (isValid) { | ||
| node.update('\'' + options.file.replace(/\\/g, '\\\\') + ':0:0\''); | ||
|
|
@@ -112,11 +113,11 @@ function compile(bannerWidth, transforms) { | |
| * @return {string} The transformed file path | ||
| */ | ||
| function rootRelative(filePath, i, array) { | ||
| var rootRelative = slash(path.relative(process.cwd(), path.resolve(filePath))); // resolve relative references | ||
| var isProject = (rootRelative.slice(0, 2) !== '..'); | ||
| var result = [ | ||
| var rootRelPath = slash(path.relative(process.cwd(), path.resolve(filePath))); // resolve relative references | ||
| var isProject = (rootRelPath.slice(0, 2) !== '..'); | ||
| var result = [ | ||
| sourceMapBase || '', | ||
| isProject ? rootRelative : path.basename(rootRelative) | ||
| isProject ? rootRelPath : path.basename(rootRelPath) | ||
| ].join(path.sep); | ||
| if ((typeof i === 'number') && (typeof array === 'object')) { | ||
| array[i] = result; | ||
|
|
@@ -130,7 +131,7 @@ function compile(bannerWidth, transforms) { | |
| var BOWER = path.relative(process.cwd(), bowerDir.sync()); | ||
| return transformTools.makeRequireTransform('requireTransform', null, function (args, opts, done) { | ||
|
|
||
| // transform the original path where relevent | ||
| // transform the original path where relevant | ||
| var original = args[0]; | ||
| var split = original.split(/[\\\/]/g); // keep delimiters | ||
| var firstTerm = split.splice(0, 1)[0]; // remove the first term from the split | ||
|
|
@@ -178,39 +179,57 @@ function compile(bannerWidth, transforms) { | |
| // error handler | ||
| var timeout; | ||
| function errorHandler(error) { | ||
| var text = error.toString(); | ||
| var analysis; | ||
| var message; | ||
|
|
||
| // SyntaxError: <file>:<reason>:<line>:<column> | ||
| if (analysis = /^\s*SyntaxError\:\s*([^:]*)\s*\:\s*([^(]*)\s*\((\d+:\d+)\)\s*\n/.exec(text)) { | ||
| message = [analysis[1], analysis[3], analysis[2]].join(':') + '\n'; | ||
|
|
||
| // Error: SyntaxError: <reason> while parsing json file <file> | ||
| } else if (analysis = /^\s*Error: SyntaxError\:\s*(.*)\s*while parsing json file\s*([^]*)/.exec(text)) { | ||
| message = [analysis[2], '0', '0', ' ' + analysis[1]].join(':') + '\n'; | ||
|
|
||
| // Line <line>: <reason>: <file> | ||
| } else if (analysis = /Line\s*(\d+)\s*\:\s*([^:]*)\s*:\s*(.*)\s*/.exec(text)) { | ||
| message = [analysis[3], analysis[1], 0, ' ' + analysis[2]].join(':') + '\n'; | ||
|
|
||
| // Error: Cannot find module '<reason>' from '<directory>' | ||
| // find the first text match for any text quoted in <reason> | ||
| } else if (analysis = /^\s*Error\: Cannot find module '(.*)\'\s*from\s*\'(.*)\'\s*$/.exec(text)) { | ||
| var filename = fs.readdirSync(analysis[2]) | ||
| .filter(RegExp.prototype.test.bind(/\.js$/i)) | ||
| .filter(function (jsFilename) { | ||
| var fullPath = path.join(analysis[2], jsFilename); | ||
| var fileText = fs.readFileSync(fullPath).toString(); | ||
| return (new RegExp('[\'"]' + analysis[1] + '[\'"]')).test(fileText); | ||
| }) | ||
| .shift(); | ||
| message = path.join(analysis[2], filename) + ':0:0: Cannot find import ' + analysis[1] + '\n'; | ||
|
|
||
| // Unknown | ||
| } else { | ||
| message = 'TODO parse this error\n' + text + '\n'; | ||
| } | ||
|
|
||
| // run a bunch of tests against the error in order to determine the appropriate error message | ||
| // there will be at least one truthy value, even if that is the final placeholder | ||
| var text = error.toString(); | ||
| var message = [ | ||
|
|
||
| // SyntaxError: <file>:<reason>:<line>:<column> | ||
| function testSyntaxError() { | ||
| var analysis = /^\s*SyntaxError\:\s*([^:]*)\s*\:\s*([^(]*)\s*\((\d+:\d+)\)\s*\n/.exec(text); | ||
| return analysis && ([analysis[1], analysis[3], analysis[2]].join(':') + '\n'); | ||
| }, | ||
|
|
||
| // Error: SyntaxError: <reason> while parsing json file <file> | ||
| function testSyntaxErrorJSON() { | ||
| var analysis = /^\s*Error: SyntaxError\:\s*(.*)\s*while parsing json file\s*([^]*)/.exec(text); | ||
| return analysis && ([analysis[2], '0', '0', ' ' + analysis[1]].join(':') + '\n'); | ||
| }, | ||
|
|
||
| // Line <line>: <reason>: <file> | ||
| function testGeneric() { | ||
| var analysis = /Line\s*(\d+)\s*\:\s*([^:]*)\s*:\s*(.*)\s*/.exec(text); | ||
| return analysis && ([analysis[3], analysis[1], 0, ' ' + analysis[2]].join(':') + '\n'); | ||
| }, | ||
|
|
||
| // Error: Cannot find module '<reason>' from '<directory>' | ||
| // find the first text match for any text quoted in <reason> | ||
| function testBadImport() { | ||
| var analysis = /^\s*Error\: Cannot find module '(.*)\'\s*from\s*\'(.*)\'\s*$/.exec(text); | ||
| if (analysis) { | ||
| var filename = fs.readdirSync(analysis[2]) | ||
| .filter(RegExp.prototype.test.bind(/\.js$/i)) | ||
| .filter(function (jsFilename) { | ||
| var fullPath = path.join(analysis[2], jsFilename); | ||
| var fileText = fs.readFileSync(fullPath).toString(); | ||
| return (new RegExp('[\'"]' + analysis[1] + '[\'"]')).test(fileText); | ||
| }) | ||
| .shift(); | ||
| return path.join(analysis[2], filename) + ':0:0: Cannot find import ' + analysis[1] + '\n'; | ||
| } | ||
| }, | ||
|
|
||
| // Unknown | ||
| function otherwise() { | ||
| return 'TODO parse this error\n' + text + '\n'; | ||
| } | ||
| ] | ||
| .map(function invokeTestMethod(testMethod) { | ||
| return testMethod(); | ||
| }) | ||
| .filter(Boolean) | ||
| .shift(); | ||
|
|
||
| // add unique | ||
| if (output.indexOf(message) < 0) { | ||
|
|
@@ -238,7 +257,7 @@ function compile(bannerWidth, transforms) { | |
| // transforms | ||
| transforms | ||
| .concat(requireTransform(false)) | ||
| .forEach(function (item, i, list) { | ||
| .forEach(function eachItem(item, i, list) { | ||
| if (typeof item === 'function') { | ||
| var opts = (typeof list[i+1] === 'object') ? merge({ global: true }, list[i+1]) : { global: true }; | ||
| bundler.transform(item, opts); | ||
|
|
@@ -247,7 +266,7 @@ function compile(bannerWidth, transforms) { | |
|
|
||
| // require statements | ||
| [].concat(files) | ||
| .forEach(function (item) { | ||
| .forEach(function eachItem(item) { | ||
| bundler.require(item, {entry: true}); | ||
| }); | ||
|
|
||
|
|
@@ -258,7 +277,7 @@ function compile(bannerWidth, transforms) { | |
| uglify : { | ||
| compress: { // anything that changes semicolons to commas will cause debugger problems | ||
| sequences: false, | ||
| join_vars: false | ||
| join_vars: false // jshint ignore:line | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'join_vars': false possible? |
||
| }, | ||
| mangle : { | ||
| toplevel: true | ||
|
|
@@ -269,7 +288,7 @@ function compile(bannerWidth, transforms) { | |
|
|
||
| // when we use minification we will get: error, code, source-map | ||
| // when we don't we will get: error, buffer(with embedded source map) | ||
| bundler.bundle(function (error, codeOrBuffer, map) { | ||
| bundler.bundle(function onComplete(error, codeOrBuffer, map) { | ||
| if (!error) { | ||
| var code = codeOrBuffer.toString(); | ||
| var sourceMap = map ? JSON.parse(map) : convert.fromComment(code).toObject(); | ||
|
|
@@ -296,10 +315,10 @@ function compile(bannerWidth, transforms) { | |
| * @param {string} [sourceMapBase] Base path for source map file | ||
| * @returns {stream.Through} | ||
| */ | ||
| each: function (isMinify, sourceMapBase) { | ||
| return through.obj(function (file, encoding, done) { | ||
| each: function gulpBundleEach(isMinify, sourceMapBase) { | ||
| return through.obj(function transformFn(file, encoding, done) { | ||
| bundle(this, [file.path], file.relative, isMinify, sourceMapBase, done); | ||
| }, function (done) { | ||
| }, function flushFn(done) { | ||
| flushErrors(); | ||
| done(); | ||
| }); | ||
|
|
@@ -312,12 +331,12 @@ function compile(bannerWidth, transforms) { | |
| * @param {string} [sourceMapBase] Base path for source map file | ||
| * @returns {stream.Through} | ||
| */ | ||
| all: function (outPath, isMinify, sourceMapBase) { | ||
| all: function gulpBundleAll(outPath, isMinify, sourceMapBase) { | ||
| var pending = []; | ||
| return through.obj(function (file, encoding, done) { | ||
| return through.obj(function transformFn(file, encoding, done) { | ||
| pending.push(file.path); | ||
| done(); | ||
| }, function (done) { | ||
| }, function flushFn(done) { | ||
| if (pending.length) { | ||
| bundle(this, pending, outPath, isMinify, sourceMapBase, function () { | ||
| flushErrors(); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not as intended. We want the final method above to be the fall-through. As it stands, it will be added always.