Skip to content

JSLint.NET Settings

Ben Quarmby edited this page Sep 25, 2016 · 9 revisions

All of the tools associated with JSLint.NET can be configured using a JSLintNet.json settings file. Using this file is completely optional, as are each of the individual settings.

Settings Table

The table below explains the available options, their defaults and and which tools they're applicable to:

Option Type Default Description Visual Studio Console MSBuild
options Object empty A dictionary of switches for JSLint. See the JSLint website for the full list. Yes Yes Yes
globalVariables String[] empty A list of known global variables to pass to JSLint. Yes Yes Yes
ignore String[] empty An array of files or folders to be ignored relative to the current path. Yes Yes Yes
errorLimit Number 1000 The maximum total error limit before JSLint.NET will quit. Yes Yes Yes
fileLimit Number 1000 The maximum total files scanned before JSLint.NET will quit. Yes Yes Yes
output String Error Tells JSLint.NET how to output errors. Valid entries are "Error", "Warning" and "Message". Yes Yes
runOnSave Boolean false True if a lintable file should be scanned for errors when it is saved. Yes
runOnBuild Boolean false True if all lintable files should be scanned when the associated project is built. Yes N/A - Always on
cancelBuild Boolean false True if the build should be cancelled if any errors are found. Only applies when runOnBuild is true. Yes N/A - Depends on output

Example

{
    "options": {
        "browser": true
    },
    "globalVariables": [
        "require",
        "define"
    ],
    "ignore": [
        "\\libraries\\",
        "app-min.js"
    ],
    "output": "Warning",
    "runOnSave": true,
    "runOnBuild": true,
    "cancelBuild": true
}

Build Configuration

As of JSLint.NET 1.5.0, every setting in JSLintNet.json can be overridden for specific build configurations. This allows JSLint validation and error reporting to be easily customized for different builds.

The most common use case is switching from Warning output in Debug mode to Error output in Release mode. However every setting can be changed, from adding ignore rules to changing JSLint options like the devel flag.

This is achieved by creating JSON files with the naming convention:

JSLintNet.[CONFIG].json

Where CONFIG matches a build configuration name. For most projects this will mean Debug and Release versions can be used:

JSLintNet.Debug.json

JSLintNet.Release.json

This is quite similar to the way Web.config, Web.Debug.config and Web.Release.config work in an ASP.NET project. However, rather than performing XML transformation, JSLint.NET performs a merge. JSLint.NET will always prefer the build configuration specific version of a property if it exists, with the exception of lists (like ignore) which will have the unique values merged.

Using with Visual Studio

The simplest way to configure JSLint.NET for Visual Studio is to use the settings dialog. From the context menu of any project, select "JSLint.NET Project Settings..." to add or edit a JSLintNet.json file.

To share a single settings file among all projects in a solution, create JSLintNet.json at the solution level then "Add as Link" to the root of each child project. Remember though that the ignore list will be relative to the root of each project, not the solution.