Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Validate files with Google Linter
JavaScript
branch: master

This branch is 5 commits ahead, 22 commits behind jmendiara:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
tasks
test
.gitignore
.gjslintrc
.jshintrc
.npmignore
Gruntfile.js
LICENSE-MIT
README.md
package.json

README.md

grunt-gjslint

Validate files with Google Linter.

Getting Started

This plugin requires Grunt ~0.4.1 and just python installed

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-gjslint --save-dev

One the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-gjslint');

The "gjslint" task

Run this task with the grunt gjslint command.

Overview

In your project's Gruntfile, add a section named gjslint to the data object passed into grunt.initConfig().

grunt.initConfig({
  gjslint: {
    options: {
      flags: [
        '--disable 220' //ignore error code 220 from gjslint
      ],
      reporter: {
        name: 'console'
      }
    },
    all: {
      src: '<%= jshint.all %>'
    }
  }
})

As this is a Multitask, you can specify several targets to be called sharing the same root options

Documentation

grunt-gjslint uses node-closure-linter-wrapper to lint files

Options

flags

Type: Array Default value: []

Please, refer to node-closure-linter-wrapper documentation for flags reference.

reporter

Type: Object Default value: {}

Please, refer to node-closure-linter-wrapper documentation for reporter reference.

reporterOutput

options.reporterOutput

Type: String Default value: null

Specify a filepath to write the results of a reporter into a file instead of printed to stdout.

force

Type: Boolean Default value: false

Set force to true if:

  • You want gsjlint to report errors but not fail the task.
  • You want gsjlint not to fail the task when python is not installed on the computer.

Usage Examples

Use a flag file to store the closure-linter flags, and have two different source directories. Output the lint results to the console. You can use wildcards in file paths.

grunt.initConfig({
  gjslint: {
    options: {
      flags: [
        '--flagfile .gjslintrc' //use flag file
      ],
      reporter: {
        name: 'console' //report to console
      },
      force: false //don't fail if python is not installed on the computer
    },
    lib: {
      src: ['lib/module/**/*.js', 'lib/foo.js'],
    },
    test: {
      src: ['test/*.js'],
    }
  }
})

Use reporterOutput option if you want to write the output into a file instead of printing it in the console.

grunt.initConfig({
  gjslint: {
    options: {
      flags: [
        '--flagfile .gjslintrc' //use flag file
      ],
      reporter: {
        name: 'gjslint_xml'
      },
      reporterOutput: 'gjslint_report.xml', // save the output to this file
      force: true //don't fail the task
    },
    lib: {
      src: ['lib/module/**/*.js', 'lib/foo.js'],
    }
  }
})

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

  • v0.1.0
    • First version
Something went wrong with that request. Please try again.