Permalink
Browse files

Merge branch 'nodejs_migration'

  • Loading branch information...
2 parents f50fa07 + 4141865 commit 06f0e8a27dd3128aa6805128521df05d4cdb298c @arthurakay committed Dec 11, 2012
Showing with 211 additions and 51,116 deletions.
  1. +2 −1 .gitignore
  2. +13 −2 CHANGELOG
  3. +63 −42 PhantomLint.js → LintRoller.js
  4. +2 −29 README
  5. +0 −8 assets/jshint-master/.gitignore
  6. +0 −3 assets/jshint-master/.travis.yml
  7. +0 −105 assets/jshint-master/CONTRIBUTING.md
  8. +0 −20 assets/jshint-master/LICENSE
  9. +0 −267 assets/jshint-master/README.md
  10. +0 −3 assets/jshint-master/bin/jshint
  11. +0 −2 assets/jshint-master/examples/.jshintignore
  12. +0 −5 assets/jshint-master/examples/.jshintrc
  13. +0 −21 assets/jshint-master/examples/reporter.js
  14. +0 −14 assets/jshint-master/jshint.json
  15. +0 −106 assets/jshint-master/make.js
  16. +0 −39 assets/jshint-master/package.json
  17. +0 −4,372 assets/jshint-master/res/jshint.ai
  18. +0 −380 assets/jshint-master/src/cli/cli.js
  19. +0 −43 assets/jshint-master/src/next/constants.js
  20. +0 −193 assets/jshint-master/src/next/jshint.js
  21. +0 −302 assets/jshint-master/src/next/reason.js
  22. +0 −125 assets/jshint-master/src/next/regexp.js
  23. +0 −359 assets/jshint-master/src/next/utils.js
  24. +0 −59 assets/jshint-master/src/platforms/jsc.js
  25. +0 −29 assets/jshint-master/src/platforms/jsc.sh
  26. +0 −86 assets/jshint-master/src/platforms/rhino.js
  27. +0 −258 assets/jshint-master/src/platforms/wsh.js
  28. +0 −107 assets/jshint-master/src/reporters/checkstyle.js
  29. +0 −19 assets/jshint-master/src/reporters/default.js
  30. +0 −56 assets/jshint-master/src/reporters/jslint_xml.js
  31. +0 −45 assets/jshint-master/src/reporters/non_error.js
  32. +0 −207 assets/jshint-master/src/shared/messages.js
  33. +0 −386 assets/jshint-master/src/shared/vars.js
  34. +0 −3,588 assets/jshint-master/src/stable/jshint.js
  35. +0 −1,365 assets/jshint-master/src/stable/lex.js
  36. +0 −34 assets/jshint-master/src/stable/reg.js
  37. +0 −22 assets/jshint-master/src/stable/state.js
  38. +0 −162 assets/jshint-master/src/stable/style.js
  39. +0 −350 assets/jshint-master/tests/cli.js
  40. +0 −13 assets/jshint-master/tests/next/fixtures/parser/comments.js
  41. +0 −9 assets/jshint-master/tests/next/fixtures/parser/simple_file.js
  42. +0 −398 assets/jshint-master/tests/next/fixtures/parser/tokens.json
  43. +0 −28 assets/jshint-master/tests/next/fixtures/reason/arguments.js
  44. +0 −46 assets/jshint-master/tests/next/fixtures/reason/asi.js
  45. +0 −21 assets/jshint-master/tests/next/fixtures/reason/bitwise.js
  46. +0 −51 assets/jshint-master/tests/next/fixtures/reason/comparison.js
  47. +0 −7 assets/jshint-master/tests/next/fixtures/reason/debugger.js
  48. +0 −5 assets/jshint-master/tests/next/fixtures/reason/esprima.js
  49. +0 −11 assets/jshint-master/tests/next/fixtures/reason/expr_in_test.js
  50. +0 −58 assets/jshint-master/tests/next/fixtures/reason/fifty.js
  51. +0 −26 assets/jshint-master/tests/next/fixtures/reason/iterator.js
  52. +0 −24 assets/jshint-master/tests/next/fixtures/reason/native.js
  53. +0 −38 assets/jshint-master/tests/next/fixtures/reason/proto.js
  54. +0 −19 assets/jshint-master/tests/next/fixtures/reason/shadow.js
  55. +0 −10 assets/jshint-master/tests/next/fixtures/reason/trailing.js
  56. +0 −42 assets/jshint-master/tests/next/fixtures/reason/undef.js
  57. +0 −10 assets/jshint-master/tests/next/fixtures/regexp/dashes.js
  58. +0 −9 assets/jshint-master/tests/next/fixtures/utils/simple_file.js
  59. +0 −121 assets/jshint-master/tests/next/lib/helpers.js
  60. +0 −84 assets/jshint-master/tests/next/unit/parser.js
  61. +0 −130 assets/jshint-master/tests/next/unit/reason.js
  62. +0 −39 assets/jshint-master/tests/next/unit/regexp.js
  63. +0 −128 assets/jshint-master/tests/next/unit/utils.js
  64. +0 −82 assets/jshint-master/tests/stable/helpers/coveraje.js
  65. +0 −7 assets/jshint-master/tests/stable/helpers/fixture.js
  66. +0 −148 assets/jshint-master/tests/stable/helpers/testhelper.js
  67. +0 −1,158 assets/jshint-master/tests/stable/regression/libs/backbone.js
  68. +0 −9,304 assets/jshint-master/tests/stable/regression/libs/jquery-1.7.js
  69. +0 −487 assets/jshint-master/tests/stable/regression/libs/json2.js
  70. +0 −4,454 assets/jshint-master/tests/stable/regression/libs/lodash.js
  71. +0 −6,082 assets/jshint-master/tests/stable/regression/libs/prototype-17.js
  72. +0 −8 assets/jshint-master/tests/stable/regression/npm.js
  73. +0 −203 assets/jshint-master/tests/stable/regression/thirdparty.js
  74. +0 −574 assets/jshint-master/tests/stable/unit/core.js
  75. +0 −638 assets/jshint-master/tests/stable/unit/envs.js
  76. +0 −28 assets/jshint-master/tests/stable/unit/fixtures/asi.js
  77. +0 −31 assets/jshint-master/tests/stable/unit/fixtures/blocks.js
  78. +0 −12 assets/jshint-master/tests/stable/unit/fixtures/boss.js
  79. +0 −18 assets/jshint-master/tests/stable/unit/fixtures/browser.js
  80. +0 −17 assets/jshint-master/tests/stable/unit/fixtures/camelcase.js
  81. +0 −11 assets/jshint-master/tests/stable/unit/fixtures/caseExpressions.js
  82. +0 −40 assets/jshint-master/tests/stable/unit/fixtures/comma.js
  83. +0 −72 assets/jshint-master/tests/stable/unit/fixtures/const.js
  84. +0 −8 assets/jshint-master/tests/stable/unit/fixtures/curly.js
  85. +0 −11 assets/jshint-master/tests/stable/unit/fixtures/curly2.js
  86. +0 −23 assets/jshint-master/tests/stable/unit/fixtures/emptystmt.js
  87. +0 −10 assets/jshint-master/tests/stable/unit/fixtures/eqeqeq.js
  88. +0 −15 assets/jshint-master/tests/stable/unit/fixtures/es5.funcexpr.js
  89. +0 −78 assets/jshint-master/tests/stable/unit/fixtures/es5.js
  90. +0 −7 assets/jshint-master/tests/stable/unit/fixtures/es5Reserved.js
  91. +0 −18 assets/jshint-master/tests/stable/unit/fixtures/exported.js
  92. +0 −15 assets/jshint-master/tests/stable/unit/fixtures/forin.js
  93. +0 −8 assets/jshint-master/tests/stable/unit/fixtures/functionScopedOptions.js
  94. +0 −21 assets/jshint-master/tests/stable/unit/fixtures/gh-226.js
  95. +0 −15 assets/jshint-master/tests/stable/unit/fixtures/gh-334.js
  96. +0 −23 assets/jshint-master/tests/stable/unit/fixtures/gh247.js
  97. +0 −15 assets/jshint-master/tests/stable/unit/fixtures/gh431.js
  98. +0 −4 assets/jshint-master/tests/stable/unit/fixtures/gh56.js
  99. +0 −7 assets/jshint-master/tests/stable/unit/fixtures/gh618.js
  100. +0 −20 assets/jshint-master/tests/stable/unit/fixtures/gruntComment.js
  101. +0 −4 assets/jshint-master/tests/stable/unit/fixtures/ignored.js
  102. +0 −31 assets/jshint-master/tests/stable/unit/fixtures/immed.js
  103. +0 −12 assets/jshint-master/tests/stable/unit/fixtures/indent.js
  104. +0 −17 assets/jshint-master/tests/stable/unit/fixtures/insideEval.js
  105. +0 −4 assets/jshint-master/tests/stable/unit/fixtures/jslintInverted.js
  106. +0 −9 assets/jshint-master/tests/stable/unit/fixtures/jslintOptions.js
  107. +0 −5 assets/jshint-master/tests/stable/unit/fixtures/jslintRenamed.js
  108. +0 −6 assets/jshint-master/tests/stable/unit/fixtures/lastsemic.js
  109. +0 −21 assets/jshint-master/tests/stable/unit/fixtures/latedef.js
  110. +0 −46 assets/jshint-master/tests/stable/unit/fixtures/latedefundef.js
  111. +0 −19 assets/jshint-master/tests/stable/unit/fixtures/laxbreak.js
  112. +0 −17 assets/jshint-master/tests/stable/unit/fixtures/laxcomma.js
  113. +0 −11 assets/jshint-master/tests/stable/unit/fixtures/loopfunc.js
  114. +0 −74 assets/jshint-master/tests/stable/unit/fixtures/max-cyclomatic-complexity-per-function.js
  115. +0 −18 assets/jshint-master/tests/stable/unit/fixtures/max-nested-block-depth-per-function.js
  116. +0 −5 assets/jshint-master/tests/stable/unit/fixtures/max-parameters-per-function.js
  117. +0 −19 assets/jshint-master/tests/stable/unit/fixtures/max-statements-per-function.js
  118. +0 −3 assets/jshint-master/tests/stable/unit/fixtures/maxlen.js
  119. +0 −8 assets/jshint-master/tests/stable/unit/fixtures/missingspaces.js
  120. +0 −1 assets/jshint-master/tests/stable/unit/fixtures/nestedFunctions-locations.js
  121. +0 −35 assets/jshint-master/tests/stable/unit/fixtures/nestedFunctions.js
  122. +0 −13 assets/jshint-master/tests/stable/unit/fixtures/newcap.js
  123. +0 −7 assets/jshint-master/tests/stable/unit/fixtures/noarg.js
  124. +0 −11 assets/jshint-master/tests/stable/unit/fixtures/onevar.js
  125. +0 −37 assets/jshint-master/tests/stable/unit/fixtures/protoiterator.js
  126. +0 −3 assets/jshint-master/tests/stable/unit/fixtures/quotes.js
  127. +0 −3 assets/jshint-master/tests/stable/unit/fixtures/quotes2.js
  128. +0 −36 assets/jshint-master/tests/stable/unit/fixtures/quotes3.js
  129. +0 −11 assets/jshint-master/tests/stable/unit/fixtures/redef.js
  130. +0 −40 assets/jshint-master/tests/stable/unit/fixtures/return.js
  131. +0 −43 assets/jshint-master/tests/stable/unit/fixtures/scope.js
  132. +0 −11 assets/jshint-master/tests/stable/unit/fixtures/scripturl.js
  133. +0 −14 assets/jshint-master/tests/stable/unit/fixtures/smarttabs.js
  134. +0 −59 assets/jshint-master/tests/stable/unit/fixtures/strict_incorrect.js
  135. +0 −21 assets/jshint-master/tests/stable/unit/fixtures/strict_newcap.js
  136. +0 −17 assets/jshint-master/tests/stable/unit/fixtures/strict_this.js
  137. +0 −18 assets/jshint-master/tests/stable/unit/fixtures/strict_this2.js
  138. +0 −9 assets/jshint-master/tests/stable/unit/fixtures/strict_violations.js
  139. +0 −24 assets/jshint-master/tests/stable/unit/fixtures/strings.js
  140. +0 −11 assets/jshint-master/tests/stable/unit/fixtures/supernew.js
  141. +0 −40 assets/jshint-master/tests/stable/unit/fixtures/switchFallThrough.js
  142. +0 −24 assets/jshint-master/tests/stable/unit/fixtures/trycatch.js
  143. +0 −24 assets/jshint-master/tests/stable/unit/fixtures/undef.js
  144. +0 −8 assets/jshint-master/tests/stable/unit/fixtures/undef_func.js
  145. +0 −6 assets/jshint-master/tests/stable/unit/fixtures/undefstrict.js
  146. +0 −18 assets/jshint-master/tests/stable/unit/fixtures/unused.js
  147. +0 −4 assets/jshint-master/tests/stable/unit/fixtures/unusedglobals.js
  148. +0 −66 assets/jshint-master/tests/stable/unit/fixtures/white.js
  149. +0 −16 assets/jshint-master/tests/stable/unit/fixtures/with.js
  150. +0 −1,396 assets/jshint-master/tests/stable/unit/options.js
  151. +0 −476 assets/jshint-master/tests/stable/unit/parser.js
  152. +0 −6,400 assets/jslint.js
  153. +0 −177 assets/phantomjs-1.5.0/ChangeLog
  154. +0 −22 assets/phantomjs-1.5.0/LICENSE.BSD
  155. +0 −33 assets/phantomjs-1.5.0/README.md
  156. +0 −12 assets/phantomjs-1.5.0/bin/Info.plist
  157. BIN assets/phantomjs-1.5.0/bin/phantomjs
  158. +0 −7 assets/phantomjs-1.5.0/examples/arguments.coffee
  159. +0 −9 assets/phantomjs-1.5.0/examples/arguments.js
  160. +0 −46 assets/phantomjs-1.5.0/examples/colorwheel.coffee
  161. +0 −51 assets/phantomjs-1.5.0/examples/colorwheel.js
  162. +0 −8 assets/phantomjs-1.5.0/examples/countdown.coffee
  163. +0 −9 assets/phantomjs-1.5.0/examples/countdown.js
  164. +0 −41 assets/phantomjs-1.5.0/examples/detectsniff.coffee
  165. +0 −58 assets/phantomjs-1.5.0/examples/detectsniff.js
  166. +0 −30 assets/phantomjs-1.5.0/examples/direction.coffee
  167. +0 −35 assets/phantomjs-1.5.0/examples/direction.js
  168. +0 −20 assets/phantomjs-1.5.0/examples/echoToFile.coffee
  169. +0 −24 assets/phantomjs-1.5.0/examples/echoToFile.js
  170. +0 −30 assets/phantomjs-1.5.0/examples/features.js
  171. +0 −8 assets/phantomjs-1.5.0/examples/fibo.coffee
  172. +0 −9 assets/phantomjs-1.5.0/examples/fibo.js
  173. +0 −29 assets/phantomjs-1.5.0/examples/follow.coffee
  174. +0 −34 assets/phantomjs-1.5.0/examples/follow.js
  175. +0 −2 assets/phantomjs-1.5.0/examples/hello.coffee
  176. +0 −2 assets/phantomjs-1.5.0/examples/hello.js
  177. +0 −20 assets/phantomjs-1.5.0/examples/imagebin.coffee
  178. +0 −23 assets/phantomjs-1.5.0/examples/imagebin.js
  179. +0 −23 assets/phantomjs-1.5.0/examples/injectme.coffee
  180. +0 −25 assets/phantomjs-1.5.0/examples/injectme.js
  181. +0 −13 assets/phantomjs-1.5.0/examples/ipgeocode.coffee
  182. +0 −14 assets/phantomjs-1.5.0/examples/ipgeocode.js
  183. +0 −18 assets/phantomjs-1.5.0/examples/loadspeed.coffee
  184. +0 −23 assets/phantomjs-1.5.0/examples/loadspeed.js
  185. +0 −1,116 assets/phantomjs-1.5.0/examples/modernizr.js
  186. +0 −13 assets/phantomjs-1.5.0/examples/movies.coffee
  187. +0 −14 assets/phantomjs-1.5.0/examples/movies.js
  188. +0 −18 assets/phantomjs-1.5.0/examples/netlog.coffee
  189. +0 −25 assets/phantomjs-1.5.0/examples/netlog.js
  190. +0 −110 assets/phantomjs-1.5.0/examples/netsniff.coffee
  191. +0 −132 assets/phantomjs-1.5.0/examples/netsniff.js
  192. +0 −12 assets/phantomjs-1.5.0/examples/outputEncoding.coffee
  193. +0 −16 assets/phantomjs-1.5.0/examples/outputEncoding.js
  194. +0 −13 assets/phantomjs-1.5.0/examples/phantomwebintro.coffee
  195. +0 −19 assets/phantomjs-1.5.0/examples/phantomwebintro.js
  196. +0 −18 assets/phantomjs-1.5.0/examples/pizza.coffee
  197. +0 −20 assets/phantomjs-1.5.0/examples/pizza.js
  198. +0 −12 assets/phantomjs-1.5.0/examples/post.coffee
  199. +0 −14 assets/phantomjs-1.5.0/examples/post.js
  200. +0 −34 assets/phantomjs-1.5.0/examples/postserver.js
  201. +0 −10 assets/phantomjs-1.5.0/examples/printenv.js
  202. +0 −35 assets/phantomjs-1.5.0/examples/printmargins.js
  203. +0 −23 assets/phantomjs-1.5.0/examples/rasterize.coffee
  204. +0 −28 assets/phantomjs-1.5.0/examples/rasterize.js
  205. +0 −50 assets/phantomjs-1.5.0/examples/render_multi_url.coffee
  206. +0 −62 assets/phantomjs-1.5.0/examples/render_multi_url.js
  207. +0 −61 assets/phantomjs-1.5.0/examples/run-jasmine.coffee
  208. +0 −79 assets/phantomjs-1.5.0/examples/run-jasmine.js
  209. +0 −64 assets/phantomjs-1.5.0/examples/run-qunit.coffee
  210. +0 −76 assets/phantomjs-1.5.0/examples/run-qunit.js
  211. +0 −16 assets/phantomjs-1.5.0/examples/scandir.coffee
  212. +0 −22 assets/phantomjs-1.5.0/examples/scandir.js
  213. +0 −17 assets/phantomjs-1.5.0/examples/seasonfood.coffee
  214. +0 −19 assets/phantomjs-1.5.0/examples/seasonfood.js
  215. +0 −43 assets/phantomjs-1.5.0/examples/server.js
  216. +0 −34 assets/phantomjs-1.5.0/examples/serverkeepalive.js
  217. +0 −38 assets/phantomjs-1.5.0/examples/simpleserver.coffee
  218. +0 −42 assets/phantomjs-1.5.0/examples/simpleserver.js
  219. +0 −20 assets/phantomjs-1.5.0/examples/sleepsort.coffee
  220. +0 −25 assets/phantomjs-1.5.0/examples/sleepsort.js
  221. +0 −17 assets/phantomjs-1.5.0/examples/technews.coffee
  222. +0 −16 assets/phantomjs-1.5.0/examples/technews.js
  223. +0 −31 assets/phantomjs-1.5.0/examples/tweets.coffee
  224. +0 −37 assets/phantomjs-1.5.0/examples/tweets.js
  225. +0 −18 assets/phantomjs-1.5.0/examples/unrandomize.coffee
  226. +0 −24 assets/phantomjs-1.5.0/examples/unrandomize.js
  227. +0 −11 assets/phantomjs-1.5.0/examples/useragent.coffee
  228. +0 −14 assets/phantomjs-1.5.0/examples/useragent.js
  229. +0 −5 assets/phantomjs-1.5.0/examples/version.coffee
  230. +0 −5 assets/phantomjs-1.5.0/examples/version.js
  231. +0 −48 assets/phantomjs-1.5.0/examples/waitfor.coffee
  232. +0 −57 assets/phantomjs-1.5.0/examples/waitfor.js
  233. +0 −49 assets/phantomjs-1.5.0/examples/weather.coffee
  234. +0 −58 assets/phantomjs-1.5.0/examples/weather.js
  235. +1 −1 docs/data.js
  236. +3 −3 docs/index.html
  237. +1 −0 docs/output/LintRoller.js
  238. +0 −1 docs/output/PhantomLint.js
  239. +85 −64 docs/source/{PhantomLint.html → LintRoller.html}
  240. +1 −1 generate_docs.sh
  241. +32 −0 package.json
  242. +1 −2 test.bat
  243. +6 −4 test.js
  244. +1 −1 test.sh
View
@@ -1,3 +1,4 @@
/.idea
*.log
-.DS_Store
+.DS_Store
+node_modules/
View
@@ -1,10 +1,21 @@
-Version 1.3.0 (December 7, 2012)
+===============
+ VERSION 2.x
+===============
+
+Version 2.0.0 (December 11, 2012) - BREAKING CHANGES ALL AROUND!
+ - Changed name from "PhantomLint" to "LintRoller"
- added JSHint support
- optionally disable available linters (JSLint or JSHint)
- - refactored configuration of JSLint file and options (*** BREAKING CHANGE ***)
+ - refactored configuration of linter options
- refactored application of init() configuration
- updated test.js
+ - added documentation via JSDuck
+ - removed dependency on PhantomJS - now running on Node.js as it's more ubiquitous, and installation via NPM is easier
+
+===============
+ VERSION 1.x
+===============
Version 1.2.1 (June 7, 2012)
- updates to example
@@ -18,20 +18,21 @@
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-*/
+ */
-var filesystem = require('fs'),
- JSLINT, JSHINT;
+var fs = require('fs'),
+ JSLINT = require('jslint'),
+ JSHINT = require('jshint').JSHINT;
/**
- * @class PhantomLint
+ * @class LintRoller
* @author Arthur Kay (http://www.akawebdesign.com)
* @singleton
- * @version 1.3.0
+ * @version 2.0.0
*
* GitHub Project: https://github.com/arthurakay/PhantomLint
*/
-PhantomLint = {
+LintRoller = {
/**
* @cfg {Array} filepaths
* REQUIRED. An array of relative filepaths to the folders containing JS files
@@ -58,33 +59,30 @@ PhantomLint = {
* @cfg
* An object containing "file" and "options" properties (False to disable usage.).
*
- * - "file" is a relative filepath to the local JSLint file to use (defaults to ./assets/jslint.js).
* - "options" is an object containing the optional lint flags.
*/
jsLint : {
- file : 'assets/jslint.js',
-
options : {
nomen : true, //if names may have dangling _
plusplus : true, //if increment/decrement should be allowed
sloppy : true, //if the 'use strict'; pragma is optional
vars : true, //if multiple var statements per function should be allowed
white : true, //if sloppy whitespace is tolerated
- undef : true //if variables can be declared out of order
+ undef : true, //if variables can be declared out of order,
+ node : true, //if Node.js globals should be predefined
+ browser : true, //if the standard browser globals should be predefined
+ stupid : true //if really stupid practices are tolerated... namely blocking synchronous operations
}
},
/**
* @cfg
* An object containing "file" and "options" properties (False to disable usage.).
*
- * - "file" is a relative filepath to the local JSHint file to use (defaults to ./assets/jshint-master/src/stable/jshint.js).
* - "options" is an object containing the optional lint flags.
*
*/
jsHint : {
- file : 'assets/jshint-master/src/stable/jshint.js',
-
options : {
}
@@ -96,7 +94,6 @@ PhantomLint = {
*/
logFile : 'error_log.txt',
-
/**
* Call this method to de-lint your JavaScript codebase.
*/
@@ -105,28 +102,28 @@ PhantomLint = {
this.initConfigs(config);
if (this.jsLint) {
- this.log('Loading JSLint... ' + phantom.injectJs(this.jsLint.file), true);
+ this.log('Loading JSLint... ', true);
this.linters.push(JSLINT);
}
if (this.jsHint) {
- this.log('Loading JSHint... ' + phantom.injectJs(this.jsHint.file), true);
+ this.log('Loading JSHint... ', true);
this.linters.push(JSHINT);
}
if (!JSLINT && !JSHINT) {
- phantom.exit(1);
+ process.exit(1);
}
this.parseTree(config.filepaths);
this.log('\nFilesystem has been parsed. Looping through available files...');
+ this.clearLogFile();
this.lintFiles();
this.announceSuccess();
},
-
/**
* @private
*/
@@ -137,7 +134,6 @@ PhantomLint = {
*/
linters : [],
-
/**
* @private
*/
@@ -196,22 +192,22 @@ PhantomLint = {
}
this.log('\nFix Your Errors! Check the log file for more information.\n\n', true);
- phantom.exit(1);
+ process.exit(1);
},
/**
* @private
*/
announceSuccess : function () {
this.log('\nSuccessfully linted yo shit.\n\n', true);
- phantom.exit(0);
+ process.exit(0);
},
/**
* @private
*/
getFiles : function (path) {
- var tree = filesystem.list(path);
+ var tree = fs.readdirSync(path);
this.log('\nFILES FOUND AT PATH: ' + path);
this.log(tree);
@@ -236,14 +232,14 @@ PhantomLint = {
for (i; i < path.length; i++) {
var currPath = path[i];
+ var exclude = false;
+
this.log('\n*** currPath: ' + currPath);
if (this.exclusions) {
this.log('Checking exclusion paths...');
var j = 0;
- var exclude = false;
-
for (j; j < this.exclusions.length; j++) {
if (currPath === this.exclusions[j]) {
exclude = true;
@@ -262,7 +258,9 @@ PhantomLint = {
var spacer = ' ',
childPath, childTree;
- if (filesystem.isFile(currPath + list[x])) {
+ var stats = fs.statSync(currPath + list[x]);
+
+ if (stats.isFile()) {
this.log(spacer + list[x] + ' IS A FILE');
/*
* We only want JS files
@@ -301,7 +299,10 @@ PhantomLint = {
*/
lintFiles : function () {
var x = 0,
+ jsLintErrors = [],
+ jsHintErrors = [],
errorList = [],
+ errors = 0,
j,
linter;
@@ -315,30 +316,39 @@ PhantomLint = {
if (linter === JSLINT) {
this.log('Running JSLint against code...', false);
- errorList = this.runJSLint(errorList);
+ jsLintErrors = this.runJSLint();
+
+ errors += jsLintErrors.length;
+ jsLintErrors.splice(0,0, '=============== Running JSLint... ===============\n\n');
}
else if (linter === JSHINT) {
this.log('Running JSHint against code...', false);
- errorList = this.runJSHint(errorList);
+ jsHintErrors = this.runJSHint();
+
+ errors += jsHintErrors.length;
+ jsHintErrors.splice(0,0, '=============== Running JSHint... ===============\n\n');
}
}
- if (errorList.length > 0) {
+ if (errors > 0) {
+ errorList = errorList.concat(jsLintErrors, jsHintErrors);
this.announceErrors(errorList);
}
+
},
/**
* @private
*/
- runJSLint : function (errorList) {
+ runJSLint : function () {
var j = 0,
+ errorList = [],
file, js;
for (j; j < this.files.length; j++) {
file = this.files[j];
- js = filesystem.read(file);
+ js = fs.readFileSync(file, 'utf8');
var i = 0,
result = JSLINT(js, this.jsLint.options),
@@ -377,17 +387,18 @@ PhantomLint = {
/**
* @private
*/
- runJSHint : function (errorList) {
+ runJSHint : function () {
var j = 0,
+ errorList = [],
file, js;
for (j; j < this.files.length; j++) {
file = this.files[j];
- js = filesystem.read(file);
+ js = fs.readFileSync(file, 'utf8');
var i = 0,
- result = JSHINT(js, this.jsHint.options),
+ result = JSHINT.jshint(js, this.jsHint.options),
totalErrors = JSHINT.errors.length,
error;
@@ -424,17 +435,25 @@ PhantomLint = {
* @private
*/
logToFile : function (errorList) {
- this.log('\nWriting ' + (errorList.length / 6) + ' errors to log file.', true);
- filesystem.touch(this.logFile);
+ this.log('\nWriting ' + ((errorList.length - this.linters.length ) / 6) + ' errors to new log file.', true);
- var stream = filesystem.open(this.logFile, 'w');
+ var header = 'LintRoller : Output for ' + new Date() + '\n\n';
+ errorList.splice(0, 0, header);
- var i = 0;
- for (i; i < errorList.length; i++) {
- stream.writeLine(errorList[i]);
- }
+ var output = errorList.join().replace(/,/g, '\n');
- stream.close();
+ fs.writeFileSync(this.logFile, output);
+ },
+
+ clearLogFile : function() {
+ try {
+ this.log('\nDeleting old log file...', true);
+ fs.unlinkSync(this.logFile);
+ this.log('Done.', true);
+ }
+ catch (err) {
+ this.log('No log file currently exists.', true);
+ }
},
/**
@@ -445,4 +464,6 @@ PhantomLint = {
console.log(msg);
}
}
-};
+};
+
+module.exports = LintRoller;
View
31 README
@@ -1,38 +1,11 @@
OVERVIEW:
- - PhantomLint is an add-on to Phantom.js that recursively dives into a directory and lints your JavaScript files.
+ - LintRoller is a Node.js module that recursively dives into a directory and lints your JavaScript files.
- Available linting platforms include JSLint and JSHint.
- An example shell script (test.sh, test.bat) is provided to run the test.js demo.
-CONFIG OPTIONS:
- - filepaths (Array)
- REQUIRED. An array of relative filepaths to the directories containing JS files
+For full documentation, view /docs/index.html in your browser.
- - exclusions (Array)
- An array of relative filepaths to the directories containing JS files that should be ignored
- - jsLint (Object/Boolean)
- An object containing "file" and "options" properties (False to disable usage.).
- - "file" is a relative filepath to the local JSLint file to use (defaults to ./assets/jslint.js).
- - "options" is an object containing the optional lint flags.
- - jsHint (Object/Boolean)
- An object containing "file" and "options" properties (False to disable usage.).
- - "file" is a relative filepath to the local JSHint file to use (defaults to ./assets/jshint-master/src/stable/jshint.js).
- - "options" is an object containing the optional lint flags.
-
- - verbose (Boolean)
- Defaults to true.
-
- - stopOnFirstError (Boolean)
- Defaults to true.
-
- - logFile (String)
- A relative filepath to where the output error log should go.
- (defaults to ./error_log.txt)
-
-
-
-NOTES:
- - The PhantomJS binary included in this repo is the Mac OS X static build
@@ -1,8 +0,0 @@
-dist/*
-node_modules/*
-
-# TextMate 2 properties file.
-.tm_properties
-
-# File with my local one-off experiments.
-demo.js
@@ -1,3 +0,0 @@
-language: node_js
-node_js:
- - 0.8
Oops, something went wrong.

0 comments on commit 06f0e8a

Please sign in to comment.