Giter VIP home page Giter VIP logo

grunt-jslint's Introduction

grunt-jslint

Build Status Dependency Status

Validates JavaScript files with JSLint as a grunt task.

Installation

Install this grunt plugin next to your project's Gruntfile with: npm install grunt-jslint

Then add this line to your project's gruntfile:

grunt.loadNpmTasks('grunt-jslint');

Documentation

A multi-task to validate your JavaScript files with JSLint.

Supports the following options:

  • files An array of files or wildcards which you want to be validated by JSLint
  • exclude An array of files or wildcards which you do not want to be validated by JSLint
  • directives Configuration options/settings to pre-define in JSLint. Pre-defined globals are included within this object as predef: ['myglobal']
  • options
    • errorsOnly A Boolean option which tells the plugin to only display errors when set to true
    • log A String/filepath option which, when provided, tells the plugin where to write a verbose log to
    • junit A String/filepath option which, when provided, tells the plugin where to write a JUnit-style XML file to
    • failOnError A Boolean option - defaults to true; when set to false, grunt will not fail if JSLint detects an error
    • checkstyle A String/filepath option which, when provided, tells the plugin where to write a CheckStyle-XML file to
    • shebang Ignore shebang lines (#!/usr/bin/whatever) from files
    • edition Specify edition of jslint to use. Either a date which is a JSLint edition (see node_modules/jslint/lib for valid choices), or 'latest' for the latest version, or a path (absolute or relative to process current directory) to the JSLint

Example Usage

module.exports = function (grunt) {
  'use strict';

  grunt.loadNpmTasks('grunt-jslint'); // load the task

  grunt.initConfig({
    jslint: { // configure the task
      // lint your project's server code
      server: {
        src: [ // some example files
          'server/lib/*.js',
          'server/routes/*.js',
          'server/*.js',
          'server/test/*.js'
        ],
        exclude: [
          'server/config.js'
        ],
        directives: { // example directives
          node: true,
          todo: true
        },
        options: {
          edition: 'latest', // specify an edition of jslint or use 'dir/mycustom-jslint.js' for own path
          junit: 'out/server-junit.xml', // write the output to a JUnit XML
          log: 'out/server-lint.log',
          jslintXml: 'out/server-jslint.xml',
          errorsOnly: true, // only display errors
          failOnError: false, // defaults to true
          checkstyle: 'out/server-checkstyle.xml' // write a checkstyle-XML
        }
      },
      // lint your project's client code
      client: {
        src: [
          'client/**/*.js'
        ],
        directives: {
          browser: true,
          predef: [
            'jQuery'
          ]
        },
        options: {
          junit: 'out/client-junit.xml'
        }
      }
    }
  });

  grunt.registerTask('default', 'jslint');
};

Contributing

All files should be validated with JSLint. Bug fixes and/or new features must be accompanied by a passing test. Tests are written with vows.

Validating coding style

Run grunt jslint in the root of your repository.

Running the tests

Run make test in the root of your repository.

License

Copyright (c) 2013 Stephen Mathieson Licensed under the WTFPL license.

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.