<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Easy Javascript Validation with Javascript Lint For Rails Testing</title>
	<atom:link href="http://tommy.chheng.com/index.php/2009/06/javascript-validation-lint-for-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://tommy.chheng.com/index.php/2009/06/javascript-validation-lint-for-rails/</link>
	<description>All Things Programming!</description>
	<lastBuildDate>Fri, 09 Jul 2010 12:52:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Danny</title>
		<link>http://tommy.chheng.com/index.php/2009/06/javascript-validation-lint-for-rails/comment-page-1/#comment-47</link>
		<dc:creator>Danny</dc:creator>
		<pubDate>Thu, 30 Jul 2009 14:07:07 +0000</pubDate>
		<guid isPermaLink="false">http://tommy.chheng.com/?p=76#comment-47</guid>
		<description>I&#039;m working on a very big project containing lots of javascript, so we started putting them into subdirectories. Based on what Maxim wrote I created the following. Note that I only care about semicolons (for minimizing), so I made the assertion a little different, not to include warnings about ParseInt and stuff... I&#039;m also using jspec for test driven javascript development and we really want to ignore that directory...

def list(file_name)
  Dir.new(&quot;#{file_name}&quot;).each do &#124;file&#124;
    next if file.match(/^\.+/)
    path = &quot;#{file_name}/#{file}&quot;
    if FileTest.directory?(&quot;#{path}&quot;) &amp;&amp; (path.scan(/spec/) == [])
      list(&quot;#{path}&quot;)
    else
      if File.extname(path) == &quot;.js&quot;
        puts path
        describe &quot;JSLint on #{path}&quot; do
          before {@it = %x[jsl -process #{path}]}
          specify {@it.should include_text(&#039;0 error(s)&#039;)}
          specify {@it.should_not include_text(&#039;lint warning: missing semicolon&#039;)}
        end
      end
    end
  end
end

list(File.join(Rails.root, &#039;public&#039;, &#039;javascripts/refactored&#039;))</description>
		<content:encoded><![CDATA[<p>I&#8217;m working on a very big project containing lots of javascript, so we started putting them into subdirectories. Based on what Maxim wrote I created the following. Note that I only care about semicolons (for minimizing), so I made the assertion a little different, not to include warnings about ParseInt and stuff&#8230; I&#8217;m also using jspec for test driven javascript development and we really want to ignore that directory&#8230;</p>
<p>def list(file_name)<br />
  Dir.new(&#8220;#{file_name}&#8221;).each do |file|<br />
    next if file.match(/^\.+/)<br />
    path = &#8220;#{file_name}/#{file}&#8221;<br />
    if FileTest.directory?(&#8220;#{path}&#8221;) &amp;&amp; (path.scan(/spec/) == [])<br />
      list(&#8220;#{path}&#8221;)<br />
    else<br />
      if File.extname(path) == &#8220;.js&#8221;<br />
        puts path<br />
        describe &#8220;JSLint on #{path}&#8221; do<br />
          before {@it = %x[jsl -process #{path}]}<br />
          specify {@it.should include_text(&#8217;0 error(s)&#8217;)}<br />
          specify {@it.should_not include_text(&#8216;lint warning: missing semicolon&#8217;)}<br />
        end<br />
      end<br />
    end<br />
  end<br />
end</p>
<p>list(File.join(Rails.root, &#8216;public&#8217;, &#8216;javascripts/refactored&#8217;))</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jerry</title>
		<link>http://tommy.chheng.com/index.php/2009/06/javascript-validation-lint-for-rails/comment-page-1/#comment-38</link>
		<dc:creator>Jerry</dc:creator>
		<pubDate>Fri, 10 Jul 2009 21:13:27 +0000</pubDate>
		<guid isPermaLink="false">http://tommy.chheng.com/?p=76#comment-38</guid>
		<description>@Nick, IE certainly doesn&#039;t think so...</description>
		<content:encoded><![CDATA[<p>@Nick, IE certainly doesn&#8217;t think so&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick Grimshaw</title>
		<link>http://tommy.chheng.com/index.php/2009/06/javascript-validation-lint-for-rails/comment-page-1/#comment-37</link>
		<dc:creator>Nick Grimshaw</dc:creator>
		<pubDate>Tue, 07 Jul 2009 13:18:52 +0000</pubDate>
		<guid isPermaLink="false">http://tommy.chheng.com/?p=76#comment-37</guid>
		<description>...semicolons are optional in Javascript.</description>
		<content:encoded><![CDATA[<p>&#8230;semicolons are optional in Javascript.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maxim Kulkin</title>
		<link>http://tommy.chheng.com/index.php/2009/06/javascript-validation-lint-for-rails/comment-page-1/#comment-35</link>
		<dc:creator>Maxim Kulkin</dc:creator>
		<pubDate>Wed, 01 Jul 2009 11:43:52 +0000</pubDate>
		<guid isPermaLink="false">http://tommy.chheng.com/?p=76#comment-35</guid>
		<description>The more natural would be to have a separate test for each javascript file:

Dir[Rails.root+&#039;/public/javascripts/*.js].each do &#124;js&#124;
  test &quot;javascript #{js} contains no syntax errors&quot; do
    assert_js_valid js
  end
end

def assert_js_valid(js_path)
  output = system(&quot;jsl -process #{js_path}&quot;)
  valid = output.include?(&#039;0 error(s)&#039;)
  assert valid, &quot;Javascript #{js_path} contains following errors:\n#{output}&quot;
end</description>
		<content:encoded><![CDATA[<p>The more natural would be to have a separate test for each javascript file:</p>
<p>Dir[Rails.root+'/public/javascripts/*.js].each do |js|<br />
  test &#8220;javascript #{js} contains no syntax errors&#8221; do<br />
    assert_js_valid js<br />
  end<br />
end</p>
<p>def assert_js_valid(js_path)<br />
  output = system(&#8220;jsl -process #{js_path}&#8221;)<br />
  valid = output.include?(&#8217;0 error(s)&#8217;)<br />
  assert valid, &#8220;Javascript #{js_path} contains following errors:\n#{output}&#8221;<br />
end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Benjamin Quorning</title>
		<link>http://tommy.chheng.com/index.php/2009/06/javascript-validation-lint-for-rails/comment-page-1/#comment-33</link>
		<dc:creator>Benjamin Quorning</dc:creator>
		<pubDate>Fri, 26 Jun 2009 18:42:24 +0000</pubDate>
		<guid isPermaLink="false">http://tommy.chheng.com/?p=76#comment-33</guid>
		<description>Nice! I implemented it in RSpec. Not that pretty, but it works:

&lt;code&gt;
# spec/lib/javascript_spec.rb
require File.expand_path(File.dirname(__FILE__) + &#039;/../spec_helper&#039;)

# Download jsl from http://www.javascriptlint.com and add the jsl to your PATH environment variable
Dir[ File.join(Rails.root, &#039;public&#039;, &#039;javascripts&#039;, &#039;*.js&#039;) ].each do &#124;js_path&#124;
  describe &quot;JSLint on #{js_path}&quot; do
    before { @it = %x[jsl -process #{js_path}] }
    specify { @it.should include_text(&#039;0 error(s)&#039;) }
  end
end
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Nice! I implemented it in RSpec. Not that pretty, but it works:</p>
<p><code><br />
# spec/lib/javascript_spec.rb<br />
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')</p>
<p># Download jsl from <a href="http://www.javascriptlint.com" rel="nofollow">http://www.javascriptlint.com</a> and add the jsl to your PATH environment variable<br />
Dir[ File.join(Rails.root, 'public', 'javascripts', '*.js') ].each do |js_path|<br />
  describe "JSLint on #{js_path}" do<br />
    before { @it = %x[jsl -process #{js_path}] }<br />
    specify { @it.should include_text('0 error(s)') }<br />
  end<br />
end<br />
</code></p>
]]></content:encoded>
	</item>
</channel>
</rss>
