Coder Social home page Coder Social logo

jslint-jenkins-plugin's Introduction

JSLint for Jenkins

A Jenkins plugin which bundles JSLint and Rhino and lints your code. Official plugin page.

Provided by Box UK - see our Labs Page for more info on this plugin!

For more on why we believe in coding standards, see Rhodri Pugh's post on coding standards

The version of JSLint is modified to run in a "pure Java" version of Rhino, and to be less exacting than the "main" version of JSLint, which can be found here. JSLint is the work of the wonderful Douglas Crockford. This plugin exposes no options for JSLint, please feel free to fork the project and contribute!

Using this plugin

Install this plugin on your Jenkins (url will be something like http://{jenkins}/pluginManager/advanced) and restart Jenkins.

There are no global configuration options for this plugin, it's all done per-job.

Then, go to the Jenkins job you want to lint. All you need to do is click "Add build step" and select "JSLint". Then, set the files you want to include/exclude. These are standard Apache Ant filters and if you need help just click the question mark icon for some tips.

The next thing to set is the output file. This is in the checkstyle XML format so we recommend using it with the Jenkins CheckStyle plugin. This will integrate the JSLint output into your build output screen. Pretty handy!

We recommend clicking "Advanced" and setting the status thresholds to "0" so any jslint failure will fail the build.

You'll probably find that if you use library "foo" you get a lot of "undefined foo" errors at first. Just put a globals statement at the top of your JavaScript file so jslint knows that "foo" is a global:

/*globals foo, bar*/
var baz = function() {
    foo.doSomethingWith(bar);
};

Please note: you must NOT have a space between "*" and "globals", otherwise it won't work

Deploying via Maven

You need permissions to do this. This serves as an aide memoire for the maintainer!

First, commit everything that you've done. Then, let Maven manage it all.

mvn release:clean
mvn release:prepare
mvn release:perform
mvn deploy

Make sure the Jenkins Github repo is up to date with the Box UK one.

Here are the instructions for Jenkins hosted plugins. Make sure you have set up ~/.m2/settings.xml with your credentials as per the instructions.

The package should show up in http://repo.jenkins-ci.org/releases/org/jenkins-ci/plugins/jslint/

http://mirrors.karan.org/jenkins/updates/update-center.json Takes about 6 hours to update so check back there later!

License

MIT LICENSE

Copyright (c) 2012 Box UK

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 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.

jslint-jenkins-plugin's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jslint-jenkins-plugin's Issues

Wrapped java.io.FileNotFoundException ... (Is a directory)

I got this error:

Wrapped java.io.FileNotFoundException: /vp/jenkins/workspace/painel-console-01-code_pull (Is a directory) (jslint.js#5732) org.mozilla.javascript.WrappedException: Wrapped java.io.FileNotFoundException: /vp/jenkins/workspace/painel-console-01-code_pull (Is a directory)

Every time I put something inside of the field "Files to scan", i.e: "app/**/*.js, app.js"

Any ideas?

Scan of UTF-8 Fails

I've started configuring this plugin on an existing project of mine and run into an error stating that parsing failed on my file.

errorsample

Looking at the error and the contents of the file, the best that I'm able to determine is that the analysis is failing on the leader bytes for a UTF-8 encoded file.

Previous testing I've done with this plugin on ASCII encoded files have all worked.

I'm guessing this is actually an issue with the build of jslint being shipped as part of the plugin. I've tested other versions of jslint and jshint on these files and had successful scans.

Any thoughts?

JSLint and globals

It appears you can't have a space between /* and globals in the directive declaration, so the sample in the README is a little misleading

/* globals foo, bar */

should be

/*globals foo, bar */

Except that, works great, thanks for your job!

Jenklins Status

It's possible to give status error to Jenkins if jsLint send erreor in checkstyle ?

Configuration will not take affect

Hi,

i'm trying to get some Condifuration working, but none of it will work and affect jslint.

I tried:

-Dnode=true -Dpredef=require 

as command in the project panel. I also tried to set a .jslintrc file in the jenkins home folder AND in the project workspace. I also put a Header into the file: /*jslint node: true, predef: require */, but none of these will take any affekt, I still got:

require' is not defined.  

Any help, how i can check node sources without this false positives?
Thanks a lot,
ps

IO Error java.io.FileNotFoundException

Hi,

This looks similar to a previous issue, but after upgrading our Jenkins installation we are now getting the following error with the jslint-jenkins-plugin:

[JSLint] IO Error java.io.FileNotFoundException: jar:\C:\Program Files (x86)\Jenkins\plugins\jslint\WEB-INF\lib\classes.jar!\com\boxuk\jenkins\jslint\JSLintBuilder\jslint.js (The filename, directory name, or volume label syntax is incorrect)

I have checked on the server and the C:\Program Files (x86)\Jenkins\plugins\jslint\WEB-INF\lib\classes.jar is present.

We are running Jenkins v1.520 on Windows Server 2008 R2, using version 0.8.0 of the plugin.

Any assistance would be greatly appreciated.

The generated XML file can be invalid

When the JSLint error message contains a "&" or "<" char the generated XML file is invalid.

For example when JSLint finds an issue which creates one of these error messages:

  • "Unexpected use of '&'."
  • "Unexpected use of '<<'."

An invalid xml file is created:

<?xml version="1.0" encoding="UTF-8"?>
<checkstyle version="1.3.3">
 <file name="/var/lib/jenkins/jobs/test/workspace/test.js">
  <error line="38" column="56" severity="error" message="Unexpected use of '&'." source="jslint"/>
  <error line="38" column="64" severity="error" message="Unexpected use of '<<'." source="jslint"/>
 </file>
</checkstyle>

The chars "<" and "&" are strictly illegal in XML these should be replaced with "<" and "&"

FileNotFoundException

I'm trying to use the JSLint plugin however I'm having the following error:

[JSLint] Ready
[JSLint] calling jslint with args[-DxmlOutput=C:\Documents and Settings\gcampos.jenkins\jobs\ens\workspace/jslint_result.xml, C:\Documents and Settings\gcampos.jenkins\jobs\ens\workspace\src\Weg.Applications.ENS.Web\js\combobox\ens.comboBase.js]
[JSLint] IO Error java.io.FileNotFoundException: C:\Documents%20and%20Settings\gcampos.jenkins\plugins\jslint\WEB-INF\classes\com\boxuk\jenkins\jslint\JSLintBuilder\jslint.js (system can not find the specified path)
[JSLint] Complete
Finished: SUCCESS

How to use JsLint in Jenkinsfile?

How to use JsLint in Jenkinsfile? I can not use JsLint plugin for my pipeline for example:
jsLint {
// Specifies the arguments to pass to JSLint.
arguments(String arguments)
// Specifies the files to exclude in an Ant-style filter.
excludePattern(String excludePattern)
// Specifies the files to include in an Ant-style filter.
includePattern(String includePattern)
// Specifies the file to output to in a Checkstyle XML format.
logFile(String logFile)
}
anyone can help me?

java.io.FileNotFoundException on Windows Server 2008 R2

On Windows platform, file paths calculated in not quite right way. Here is the console log:

[JSLint] Ready
[JSLint] calling jslint with args[-DxmlOutput=c:\projectnamegoeshere\ci\trunk\Source/jslint.xml]
[JSLint] IO Error java.io.FileNotFoundException: file:\C:\Program Files (x86)\Jenkins\plugins\jslint\WEB-INF\classes\com\boxuk\jenkins\jslint\JSLintBuilder\jslint.js (The filename, directory name, or volume label syntax is incorrect)
[JSLint] Complete

NullPointerException running build

Hey,

Getting the following exception when running this plugin. Am I missing any config??

[JSLint] Ready
[JSLint] calling jslint with args[-DxmlOutput=C:\workspace\yflowing\target\package\flow\jenkins\jobs\Build Pipeline Plugin Compile\workspace/jslint.xml, C:\workspace\yflowing\target\package\flow\jenkins\jobs\Build Pipeline Plugin Compile\workspace\src\main\webapp\css\PIE.js, C:\workspace\yflowing\target\package\flow\jenkins\jobs\Build Pipeline Plugin Compile\workspace\src\main\webapp\css\PIE_uncompressed.js, C:\workspace\yflowing\target\package\flow\jenkins\jobs\Build Pipeline Plugin Compile\workspace\src\main\webapp\js\build-pipeline.js, C:\workspace\yflowing\target\package\flow\jenkins\jobs\Build Pipeline Plugin Compile\workspace\src\main\webapp\js\handlebars-1.0.0.beta.6.js, C:\workspace\yflowing\target\package\flow\jenkins\jobs\Build Pipeline Plugin Compile\workspace\src\main\webapp\js\jquery-1.7.1.min.js, C:\workspace\yflowing\target\package\flow\jenkins\jobs\Build Pipeline Plugin Compile\workspace\src\main\webapp\js\jquery-ui-1.8.14.custom.min.js, C:\workspace\yflowing\target\package\flow\jenkins\jobs\Build Pipeline Plugin Compile\workspace\src\main\webapp\js\jquery.1.5.1.min.js, C:\workspace\yflowing\target\package\flow\jenkins\jobs\Build Pipeline Plugin Compile\workspace\src\main\webapp\js\jquery.fancybox-1.3.4.js, C:\workspace\yflowing\target\package\flow\jenkins\jobs\Build Pipeline Plugin Compile\workspace\src\main\webapp\js\jquery.tooltip.min.js]
FATAL: null
java.lang.NullPointerException
    at com.boxuk.jenkins.jslint.LintRunner.call(LintRunner.java:98)
    at com.boxuk.jenkins.jslint.LintRunner.call(LintRunner.java:25)
    at hudson.remoting.LocalChannel.call(LocalChannel.java:45)
    at com.boxuk.jenkins.jslint.JSLintBuilder.perform(JSLintBuilder.java:102)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
    at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:710)
    at hudson.model.Build$RunnerImpl.build(Build.java:178)
    at hudson.model.Build$RunnerImpl.doRun(Build.java:139)
    at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:480)
    at hudson.model.Run.run(Run.java:1434)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:239)
'''

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.