<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jenkins Archives - Creatronix</title>
	<atom:link href="https://creatronix.de/tag/jenkins/feed/" rel="self" type="application/rss+xml" />
	<link>https://creatronix.de/tag/jenkins/</link>
	<description>My adventures in code &#38; business</description>
	<lastBuildDate>Mon, 18 Jul 2022 08:11:50 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Lint your JavaScript with grunt and jshint</title>
		<link>https://creatronix.de/lint-your-javascript-with-grunt-and-jshint/</link>
		
		<dc:creator><![CDATA[Jörn]]></dc:creator>
		<pubDate>Tue, 08 Aug 2017 08:30:58 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[grunt]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Jenkins]]></category>
		<category><![CDATA[jshint]]></category>
		<category><![CDATA[yarn]]></category>
		<guid isPermaLink="false">http://creatronix.de/?p=948</guid>

					<description><![CDATA[<p>After I&#8217;ve introduced You to Yarn I will show You more client side tools in this post. Grunt is a task runner which comes in handy for a lot of setup and configuring work e.g. concatenating and minimizing JavaScript or CSS files To get started You can add grunt via yarn to your project yarn&#8230;</p>
<p>The post <a href="https://creatronix.de/lint-your-javascript-with-grunt-and-jshint/">Lint your JavaScript with grunt and jshint</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>After I&#8217;ve introduced You to <a href="https://creatronix.de/yarn-package-manager/">Yarn</a> I will show You more client side tools in this post.</p>
<p><a href="https://gruntjs.com/">Grunt </a>is a task runner which comes in handy for a lot of setup and configuring work e.g. concatenating and minimizing JavaScript or CSS files</p>
<p>To get started You can add grunt via yarn to your project</p>
<pre>yarn add grunt</pre>
<h2>Configuration</h2>
<p>Grunt looks for a Gruntfile.js file in your root directory. Yes it is Gruntfile.js with a capital &#8216;G&#8217;.</p>
<h2>Linting with JShint</h2>
<pre>yarn add grunt-contrib-jshint</pre>
<pre>module.exports = function(grunt) {
  grunt.initConfig({
    jshint: {
      all: ['Gruntfile.js', '/js/*.js'],
      options: {
        globals: {
          jQuery: true
        }
      }
    }
  });
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.registerTask('lint', ['jshint']);
};</pre>
<p>This configuration will print all findings directly onto the console which is nice for testing the script but when you burn down your lint issues a file comes in handy.</p>
<h2>Configuring JSHint&#8217;s Output Format</h2>
<p>To visualize the findings in Jenkins you can configure the checkstyle format. It produces an XML file which you can use inside Jenkins&#8217; checkstyle plugin.</p>
<p>When You want to have a more human readable format you can generate an html report. Therefore You have to install the jshint-html-reporter:</p>
<pre>yarn add jshint-html-reporter</pre>
<p>and configure the JSHint task accordingly.</p>
<pre>options: {
   reporter: require('jshint-html-reporter'),
   reporterOutput: 'jshint.html'
 },</pre>
<p>You can have both configurations in one file</p>
<pre>module.exports = function(grunt) {

  grunt.initConfig({
    jshint: {
      options: {
        globals: {
          jQuery: true
        }
      },
      src_files: ['Gruntfile.js', 'app/static/js/*.js'],
      local: {
        options: {
          reporter: require('jshint-html-reporter'),
          reporterOutput: 'jshint.html'
        },
        src: [ "&lt;%= jshint.src_files %&gt;" ]
      },
      jenkins: {
        options: {
            reporter: 'checkstyle',
            reporterOutput: 'jshint.xml'
        },
        src: [ "&lt;%= jshint.src_files %&gt;" ]
    }
    }
  });
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.registerTask('lint', ['jshint:jenkins']);
  grunt.registerTask('lint-local', ['jshint:local']);
};</pre>
<p>&nbsp;</p>
<p>The post <a href="https://creatronix.de/lint-your-javascript-with-grunt-and-jshint/">Lint your JavaScript with grunt and jshint</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
