• This repository has been archived on 30/May/2019
  • Stars
    star
    103
  • Rank 322,026 (Top 7 %)
  • Language
    JavaScript
  • License
    BSD 2-Clause "Sim...
  • Created over 11 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Grunt task to validate JavaScript source

grunt-jsvalidate

This is a Grunt task to validate JavaScript source. It uses Esprima to look for possible syntax errors.

Features

Grunt has a built-in task to lint JavaScript source. This validator task complements the linter by offering the following features:

  • It is extremely fast. Validating three.js (800 KB source) takes less than a second on a modern machine.
  • It looks only for syntax errors, it does not care about coding style at all.
  • It handles generated files as the result of minification or compilation (CoffeeScript, Dart, TypeScript, etc).
  • It would try to be tolerant and not give up immediately on the first error, especially for strict mode violations.

Note: The last feature is still a work-in-process, see Esprima issue 130.

How to Use It

First, install the package:

npm install grunt-jsvalidate

Modify your Gruntfile.js file to have the following line somewhere:

grunt.loadNpmTasks('grunt-jsvalidate');

If it has been installed correctly, running grunt --help should include jsvalidate in the list of available tasks.

Set the files to be validated, as part of Grunt configuration via the new jsvalidate key. As an example, initConfig in your Gruntfile.js might look like the following fragment:

grunt.initConfig({
  jsvalidate: {
    options:{
      globals: {},
      esprimaOptions: {},
      verbose: false
    },
    targetName:{
      files:{
        src:['<%=jshint.all%>']
      }
    }
  },
  nodeunit: {
    files: ['test/**/*.js']
  }
}

You can specify the files to be validated using the usual file pattern. In the above examples, it will validate every *.js files in the main directory, the lib directory, and the test directory.

Whenever you want the validation task to run, just invoke it using:

grunt jsvalidate

It is recommended to include the validation task in your default:

grunt.registerTask('default', ['jsvalidate', 'jshint', 'nodeunit', 'concat', 'uglify']);

License

Copyright (C) 2012 Ariya Hidayat.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

More Repositories

1

phantomjs

Scriptable Headless Browser
C++
29,406
star
2

kinetic

Kinetic Scrolling with JavaScript
HTML
810
star
3

FastLZ

Small & portable byte-aligned LZ77 compression
C
393
star
4

kabarvirus

KabarVirus.com: cepat (PageSpeed 100), ringan (10 KB)
JavaScript
118
star
5

esrefactor

JavaScript
95
star
6

unmix

Undo the so-called mix lingo, a code-mixing style (Bahasa Jaksel)
JavaScript
87
star
7

dekontaminasi

DIY static API server for COVID-19 data in Indonesia
JavaScript
65
star
8

esmorph

ECMAScript source modification tool
JavaScript
64
star
9

X2

Mirror of http://gitorious.org/ofi-labs/x2
JavaScript
60
star
10

pico-jarvis

JavaScript
51
star
11

eightpack

Collection of select JavaScript-based command-line tools
C++
42
star
12

screenie

Fancy screenshot composer
C++
33
star
13

berkala

Run scheduled tasks
JavaScript
31
star
14

tinker-chat

Clojure
29
star
15

ama

Ask me anything!
29
star
16

coverage-mocha-istanbul-karma

Mocha code coverage example via Istanbul and Karma
JavaScript
24
star
17

coverage-jasmine-istanbul-karma

Jasmine code coverage example via Istanbul and Karma
JavaScript
23
star
18

ioquake3

Unofficial git mirror of ioquake3
C
22
star
19

hello-react-native

Hello world for React Native
Objective-C
22
star
20

uainfer

Infer the user agent from its User Agent string
JavaScript
22
star
21

ariya.github.com

Test cases of various web technologies (HTML5, CSS3, JavaScript)
JavaScript
20
star
22

awesome-bosque

A curated list of awesome Bosque related stuff
20
star
23

pictureflow

Cover Flow clone at a Qt widget
C++
18
star
24

hello-c90

Hello world in C90 (ANSI C) built for Intel/AMD, PowerPC, System z, ARM, MIPS, RISC-V
Makefile
18
star
25

tapdigit

Simple JavaScript-based math evaluator
JavaScript
16
star
26

penjabarberita

Extract the article list from its raw news HTML
JavaScript
16
star
27

es6-minify

Simplistic ES6 minifier
JavaScript
15
star
28

ask-llm

Interact with an LLM service
JavaScript
14
star
29

from-zero-to-hero

"From Zero to Hero" Example
JavaScript
13
star
30

ant-javascript-validate

Example Ant task to validate JavaScript using Esprima
JavaScript
11
star
31

evergreen-browser-tests

Running tests on web browsers on various CI systems
JavaScript
10
star
32

tebakmasa

Infer the date and time from the general description in Bahasa Indonesia
JavaScript
9
star
33

karma-appveyor

Karma AppVeyor integration demo
JavaScript
9
star
34

bosque-by-examples

Simple examples of Bosque language features
9
star
35

calculator.clj

Learning Clojure by writing a lexer, parser, evaluator
Clojure
8
star
36

metabase-tests

Experiment with testing Metabase
Clojure
8
star
37

coverage-qunit-istanbul-karma

QUnit code coverage example via Istanbul and Karma
JavaScript
4
star
38

hello-android

Hello world for Android
Java
4
star
39

hello-ios

Hello world for iOS
Swift
2
star
40

ariya

whoami
1
star
41

hello-firebase-experiment

Firebase experiment: TDD for Serverless and NoSQL
JavaScript
1
star
42

ghcr-test

1
star
43

timeline2sqlite

Convert location history to a database
Clojure
1
star
44

vscode-wsl-gcc

GCC/GDB on WSL with VS Code
C++
1
star