# Table of Contents
1. [Quickstart Install](#quickstart-install)
- [To install, just download and save https://www.jslint.com/jslint.mjs to file:](#to-install-just-download-and-save-httpswwwjslintcomjslintmjs-to-file)
- [To run `jslint.mjs` in shell:](#to-run-jslintmjs-in-shell)
- [To import `jslint.mjs` in ES Module environment:](#to-import-jslintmjs-in-es-module-environment)
- [To import `jslint.mjs` in CommonJS environment:](#to-import-jslintmjs-in-commonjs-environment)
- [To JSLint entire directory in shell:](#to-jslint-entire-directory-in-shell)
2. [Quickstart JSLint Report](#quickstart-jslint-report)
- [To create a JSLint report in shell:](#to-create-a-jslint-report-in-shell)
- [To create a JSLint report in javascript:](#to-create-a-jslint-report-in-javascript)
3. [Quickstart V8 Coverage Report](#quickstart-v8-coverage-report)
- [To create V8 coverage report from Node.js / Npm program in shell:](#to-create-v8-coverage-report-from-nodejs--npm-program-in-shell)
- [To create V8 coverage report from Node.js / Npm program in javascript:](#to-create-v8-coverage-report-from-nodejs--npm-program-in-javascript)
4. [Quickstart JSLint in CodeMirror](#quickstart-jslint-in-codemirror)
5. [Quickstart JSLint in Vim](#quickstart-jslint-in-vim)
6. [Quickstart JSLint in VSCode](#quickstart-jslint-in-vscode)
7. [Documentation](#documentation)
- [API Doc](#api-doc)
- [Directive](#directive)
- [`/*jslint beta*/`](#jslint-beta)
- [`/*jslint bitwise*/`](#jslint-bitwise)
- [`/*jslint browser*/`](#jslint-browser)
- [`/*jslint convert*/`](#jslint-convert)
- [`/*jslint couch*/`](#jslint-couch)
- [`/*jslint devel*/`](#jslint-devel)
- [`/*jslint eval*/`](#jslint-eval)
- [`/*jslint fart*/`](#jslint-fart)
- [`/*jslint for*/`](#jslint-for)
- [`/*jslint getset*/`](#jslint-getset)
- [`/*jslint indent2*/`](#jslint-indent2)
- [`/*jslint long*/`](#jslint-long)
- [`/*jslint node*/`](#jslint-node)
- [`/*jslint nomen*/`](#jslint-nomen)
- [`/*jslint single*/`](#jslint-single)
- [`/*jslint subscript*/`](#jslint-subscript)
- [`/*jslint this*/`](#jslint-this)
- [`/*jslint trace*/`](#jslint-trace)
- [`/*jslint unordered*/`](#jslint-unordered)
- [`/*jslint white*/`](#jslint-white)
- [`/*global*/`](#global)
- [`/*property*/`](#property)
- [`/*jslint-disable*/.../*jslint-enable*/`](#jslint-disablejslint-enable)
- [`//jslint-ignore-line`](#jslint-ignore-line)
- [`/*coverage-disable*/.../*coverage-enable*/`](#coverage-disablecoverage-enable)
- [`//coverage-ignore-line`](#coverage-ignore-line)
- [ECMAScript Feature Support](#ecmascript-feature-support)
8. [Package Listing](#package-listing)
9. [Changelog](#changelog)
10. [License](#license)
11. [Devops Instruction](#devops-instruction)
- [pull-request merge](#pull-request-merge)
- [branch-master commit](#branch-master-commit)
- [branch-master publish](#branch-master-publish)
- [vscode-jslint publish](#vscode-jslint-publish)
# Quickstart Install
### To install, just download and save https://www.jslint.com/jslint.mjs to file:
```shell
#!/bin/sh
curl -L https://www.jslint.com/jslint.mjs > jslint.mjs
```
- shell output

### To run `jslint.mjs` in shell:
```shell
#!/bin/sh
printf "console.log('hello world');\n" > hello.js
node jslint.mjs hello.js
```
- shell output

### To import `jslint.mjs` in ES Module environment:
```shell
#!/bin/sh
node --input-type=module --eval '
/*jslint devel*/
// Import JSLint in ES Module environment.
import jslint from "./jslint.mjs";
let globals = ["caches", "indexedDb"];
let options = {browser: true};
let result;
let source = "console.log(\u0027hello world\u0027);\n";
// JSLint and print .
result = jslint.jslint(source, options, globals);
result.warnings.forEach(function ({
formatted_message
}) {
console.error(formatted_message);
});
'
```
- shell output

### To import `jslint.mjs` in CommonJS environment:
```shell
#!/bin/sh
node --eval '
/*jslint devel*/
(async function () {
let globals = ["caches", "indexedDb"];
let jslint;
let options = {browser: true};
let result;
let source = "console.log(\u0027hello world\u0027);\n";
// Import JSLint in CommonJS environment.
jslint = await import("./jslint.mjs");
jslint = jslint.default;
// JSLint and print .
result = jslint.jslint(source, options, globals);
result.warnings.forEach(function ({
formatted_message
}) {
console.error(formatted_message);
});
}());
'
```
- shell output

### To create a JSLint report in shell:
```shell
#!/bin/sh
printf "function foo() {console.log('hello world');}\n" > hello.js
# Create JSLint report from file 'hello.js' in shell.
node jslint.mjs \
jslint_report=.artifact/jslint_report_hello.html \
hello.js
```
- shell output

- screenshot file [.artifact/jslint_report_hello.html](https://jslint-org.github.io/jslint/branch-beta/.artifact/jslint_report_hello.html)
[](https://jslint-org.github.io/jslint/branch-beta/.artifact/jslint_report_hello.html)
### To create a JSLint report in javascript:
```shell
#!/bin/sh
node --input-type=module --eval '
/*jslint devel*/
import jslint from "./jslint.mjs";
import fs from "fs";
(async function () {
let result;
let source = "function foo() {console.log(\u0027hello world\u0027);}\n";
// Create JSLint report from in javascript.
result = jslint.jslint(source);
result = jslint.jslint_report(result);
result = `\n${result}\n`;
await fs.promises.mkdir(".artifact/", {recursive: true});
await fs.promises.writeFile(".artifact/jslint_report_hello.html", result);
console.error("wrote file .artifact/jslint_report_hello.html");
}());
'
```
- shell output

- screenshot file [.artifact/jslint_report_hello.html](https://jslint-org.github.io/jslint/branch-beta/.artifact/jslint_report_hello.html)
[](https://jslint-org.github.io/jslint/branch-beta/.artifact/jslint_report_hello.html)
# Quickstart V8 Coverage Report
### To create V8 coverage report from Node.js / Npm program in shell:
```shell
#!/bin/sh
git clone https://github.com/tryghost/node-sqlite3 node-sqlite3-sh \
--branch=v5.0.11 \
--depth=1 \
--single-branch
cd node-sqlite3-sh
npm install
# Create V8 coverage report from program `npm run test` in shell.
node ../jslint.mjs \
v8_coverage_report=../.artifact/coverage_sqlite3_sh/ \
--exclude=tes?/ \
--exclude=tes[!0-9A-Z_a-z-]/ \
--exclude=tes[0-9A-Z_a-z-]/ \
--exclude=tes[^0-9A-Z_a-z-]/ \
--exclude=test/**/*.js \
--exclude=test/suppor*/*elper.js \
--exclude=test/suppor?/?elper.js \
--exclude=test/support/helper.js \
--include=**/*.cjs \
--include=**/*.js \
--include=**/*.mjs \
--include=li*/*.js \
--include=li?/*.js \
--include=lib/ \
--include=lib/**/*.js \
--include=lib/*.js \
--include=lib/sqlite3.js \
npm run test
```
- shell output

- screenshot file [.artifact/coverage_sqlite3_sh/index.html](https://jslint-org.github.io/jslint/branch-beta/.artifact/coverage_sqlite3_sh/index.html)
[](https://jslint-org.github.io/jslint/branch-beta/.artifact/coverage_sqlite3_sh/index.html)
- screenshot file [.artifact/coverage_sqlite3_sh/lib/sqlite3.js.html](https://jslint-org.github.io/jslint/branch-beta/.artifact/coverage_sqlite3_sh/lib/sqlite3.js.html)
[](https://jslint-org.github.io/jslint/branch-beta/.artifact/coverage_sqlite3_sh/lib/sqlite3.js.html)
### To create V8 coverage report from Node.js / Npm program in javascript:
```shell
#!/bin/sh
git clone https://github.com/tryghost/node-sqlite3 node-sqlite3-js \
--branch=v5.0.11 \
--depth=1 \
--single-branch
cd node-sqlite3-js
npm install
node --input-type=module --eval '
/*jslint node*/
import jslint from "../jslint.mjs";
(async function () {
// Create V8 coverage report from program `npm run test` in javascript.
await jslint.v8CoverageReportCreate({
coverageDir: "../.artifact/coverage_sqlite3_js/",
processArgv: [
"--exclude=tes?/",
"--exclude=tes[!0-9A-Z_a-z-]/",
"--exclude=tes[0-9A-Z_a-z-]/",
"--exclude=tes[^0-9A-Z_a-z-]/",
"--exclude=test/**/*.js",
"--exclude=test/suppor*/*elper.js",
"--exclude=test/suppor?/?elper.js",
"--exclude=test/support/helper.js",
"--include=**/*.cjs",
"--include=**/*.js",
"--include=**/*.mjs",
"--include=li*/*.js",
"--include=li?/*.js",
"--include=lib/",
"--include=lib/**/*.js",
"--include=lib/*.js",
"--include=lib/sqlite3.js",
"npm", "run", "test"
]
});
}());
'
```
- shell output

- screenshot file [.artifact/coverage_sqlite3_js/index.html](https://jslint-org.github.io/jslint/branch-beta/.artifact/coverage_sqlite3_js/index.html)
[](https://jslint-org.github.io/jslint/branch-beta/.artifact/coverage_sqlite3_js/index.html)
- screenshot file [.artifact/coverage_sqlite3_js/lib/sqlite3.js.html](https://jslint-org.github.io/jslint/branch-beta/.artifact/coverage_sqlite3_js/lib/sqlite3.js.html)
[](https://jslint-org.github.io/jslint/branch-beta/.artifact/coverage_sqlite3_js/lib/sqlite3.js.html)
# Quickstart JSLint in CodeMirror
1. Download and save [`jslint.mjs`](https://www.jslint.com/jslint.mjs), [`jslint_wrapper_codemirror.js`](https://www.jslint.com/jslint_wrapper_codemirror.js) to file.
2. Edit, save, and serve example html-file below:
```html
CodeMirror: JSLint Demo
CodeMirror: JSLint Demo
This demo will auto-lint the code below, and auto-generate a report as you type.
```
3. Live example at https://www.jslint.com/jslint_wrapper_codemirror.html
[](https://jslint-org.github.io/jslint/jslint_wrapper_codemirror.html)
# Quickstart JSLint in Vim
1. Download and save [`jslint.mjs`](https://www.jslint.com/jslint.mjs), [`jslint_wrapper_vim.vim`](https://www.jslint.com/jslint_wrapper_vim.vim) to directory `~/.vim/`
2. Add vim-command `:source ~/.vim/jslint_wrapper_vim.vim` to file `~/.vimrc`
- If above files were saved to custom-directory, then use that directory instead, e.g.:
- save [`jslint.mjs`](https://www.jslint.com/jslint.mjs), [`jslint_wrapper_vim.vim`](https://www.jslint.com/jslint_wrapper_vim.vim) to directory `~/vimfiles/`
- vim-command `:source ~/vimfiles/jslint_wrapper_vim.vim`
3. Vim can now jslint files (via nodejs):
- with vim-command `:SaveAndJslint`
- with vim-key-combo ``
- screenshot
[](https://www.jslint.com/jslint_wrapper_vim.vim)
# Quickstart JSLint in VSCode
1. In VSCode, search and install extension [`vscode-jslint`](https://marketplace.visualstudio.com/items?itemName=jslint.vscode-jslint)
2. In VSCode, while editing a javascript file:
- right-click context-menu and select `[JSLint - Lint File]`
- or use key-binding `[Ctrl + Shift + J], [L]`
- or use key-binding `[ Cmd + Shift + J], [L]` for Mac
- screenshot
[](https://marketplace.visualstudio.com/items?itemName=jslint.vscode-jslint)
# Documentation
- [jslint.mjs](jslint.mjs) contains the jslint function. It parses and analyzes a source file, returning an object with information about the file. It can also take an object that sets options.
- [index.html](index.html) runs the jslint.mjs function in a web page.
### API Doc
- https://www.jslint.com/apidoc.html
[](https://www.jslint.com/apidoc.html)
### Directive
##### `/*jslint beta*/`
```js
/*jslint beta*/
// Enable experimental warnings.
// Warn if global variables are redefined.
// Warn if const / let statements are not declared at top of function or
// script, similar to var statements.
// Warn if const / let / var statements are not declared in ascii-order.
// Warn if named-functions are not declared in ascii-order.
// Warn if cases in switch-statements are not in ascii-order.
```
##### `/*jslint bitwise*/`
```js
/*jslint bitwise*/
// Allow bitwise operator.
let foo = 0 | 1;
```
##### `/*jslint browser*/`
```js
/*jslint browser*/
// Assume browser environment.
localStorage.getItem("foo");
```
##### `/*jslint convert*/`
```js
/*jslint convert*/
// Allow conversion operator.
let foo = new Date() + "";
let bar = !!0;
```
##### `/*jslint couch*/`
```js
/*jslint couch*/
// Assume CouchDb environment.
registerType("text-json", "text/json");
```
##### `/*jslint devel*/`
```js
/*jslint devel*/
// Allow console.log() and friends.
console.log("hello");
```
##### `/*jslint eval*/`
```js
/*jslint eval*/
// Allow eval().
eval("1");
```
##### `/*jslint fart*/`
```js
/*jslint fart*/
// Allow complex fat-arrow.
let foo = async ({bar, baz}) => {
return await bar(baz);
};
```
##### `/*jslint for*/`
```js
/*jslint for*/
// Allow for-loop.
function foo() {
let ii;
for (ii = 0; ii < 10; ii += 1) {
foo();
}
}
```
##### `/*jslint getset*/`
```js
/*jslint getset, this, devel*/
// Allow get() and set().
let foo = {
bar: 0,
get getBar() {
return this.bar;
},
set setBar(value) {
this.bar = value;
}
};
console.log(foo.getBar); // 0
foo.setBar = 1;
console.log(foo.getBar); // 1
```
##### `/*jslint indent2*/`
```js
/*jslint indent2*/
// Use 2-space indent.
function foo() {
return;
}
```
##### `/*jslint long*/`
```js
/*jslint long*/
// Allow long lines.
let foo = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
```
##### `/*jslint node*/`
```js
/*jslint node*/
// Assume Node.js environment.
require("fs");
```
##### `/*jslint nomen*/`
```js
/*jslint nomen*/
// Allow weird property name.
let foo = {};
foo._bar = 1;
```
##### `/*jslint single*/`
```js
/*jslint single*/
// Allow single-quote strings.
let foo = '';
```
##### `/*jslint subscript*/`
```js
/*jslint subscript*/
// Allow identifiers in subscript-notation.
let foo = {};
foo["bar"] = 1;
```
##### `/*jslint this*/`
```js
/*jslint this*/
// Allow 'this'.
function foo() {
return this;
}
```
##### `/*jslint trace*/`
```js
/*jslint trace*/
// Include jslint stack-trace in warnings.
console.log('hello world');
/*
1. Undeclared 'console'.
console.log('hello world');
Error
at warn_at (...)
at warn (...)
at lookup (...)
at pre_v (...)
at jslint.mjs
2. Use double quotes, not single quotes.
console.log(...);
Error
at warn_at (...)
at lex_string (...)
at lex_token (...)
at jslint_phase2_lex (...)
at Function.jslint (...)
at jslint.mjs
*/
```
##### `/*jslint unordered*/`
```js
/*jslint unordered*/
// Allow unordered cases, params, properties, variables, and exports.
let foo = {bb: 1, aa: 0};
function bar({
bb = 1,
aa = 0
}) {
return aa + bb;
}
export {
foo,
bar
};
```
##### `/*jslint white*/`
```js
/*jslint white*/
// Allow messy whitespace.
let foo = 1; let bar = 2;
```
##### `/*global*/`
```js
/*global foo, bar*/
// Declare global variables foo, bar.
foo();
bar();
```
##### `/*property*/`
```js
/*property foo, bar*/
// Restrict property-access to only .foo, .bar.
let aa = {bar: 1, foo: 2};
```
##### `/*jslint-disable*/.../*jslint-enable*/`
```js
/*jslint-disable*/
JSLint will ignore and treat this region as blank-lines.
Syntax error.
/*jslint-enable*/
```
##### `//jslint-ignore-line`
```js
// JSLint will ignore non-fatal warnings at given line.
eval("1"); //jslint-ignore-line
```
##### `/*coverage-disable*/.../*coverage-enable*/`
```js
/*coverage-disable*/
// JSLint will ignore code-coverage in this region.
if (false) {
console.log("hello world");
}
/*coverage-enable*/
```
##### `//coverage-ignore-line`
```js
// JSLint will ignore code-coverage at given line.
if (false) {
console.log("hello world"); //coverage-ignore-line
}
```
# License
- JSLint is under [Unlicense License](LICENSE).
- CodeMirror editor is under [MIT License](https://github.com/codemirror/codemirror5/blob/d0e3b2e727c41aa4fd89fbad0adfb3815339174c/LICENSE).
- Function `v8CoverageListMerge` is derived from [MIT Licensed v8-coverage](https://github.com/demurgos/v8-coverage/blob/73446087dc38f61b09832c9867122a23f8577099/ts/LICENSE.md).
# Devops Instruction
### pull-request merge
1. update `.github/workflows/ci.yml` `.github/workflows/publish.yml` to:
- latest nodejs-lts version @ https://nodejs.org/en/about/previous-releases
1. update `CHANGELOG.md`
- verify `` is most-relevant to pull-request.
- run
```shell
# re-run until version propagates
npm run test2
# update 'PR-xxx' placeholder
sh jslint_ci.sh shGithubPrUpdatePrxxx
# re-run until version propagates
sh jslint_ci.sh shGithubPrCreate alpha beta # v20yy.mm.dd __pr_beta_pre
git push upstream alpha -f
```
- verify ci-success @ https://github.com/kaizhu256/jslint/actions
- verify ci-success @ https://github.com/jslint-org/jslint/actions
1. goto https://github.com/jslint-org/jslint/compare/beta...kaizhu256:jslint:branch-p2026.7.3
- click `Create pull request`
- input `Add a title *` with: ``
- input `Add a description` with:
```
Fixes #xxx.
This PR will:
This PR will additionally:
```
- click `Preview` and review
- verify:
- base respository: `jslint-org/jslint`
- base: `beta`
- click `Create pull request`
- verify ci-success @ https://github.com/jslint-org/jslint/actions/workflows/on_pull_request.yml
1. wait awhile before continuing ...
- click `Squash and merge`
- verify ci-success @ https://github.com/jslint-org/jslint/actions
- run
```shell
sh jslint_ci.sh shGithubPrCleanup
git push upstream alpha -f
```
- verify ci-success @ https://github.com/kaizhu256/jslint/actions
- verify ci-success @ https://github.com/jslint-org/jslint/actions
- click `Delete branch`
### branch-master commit
1. update `.github/workflows/ci.yml` `.github/workflows/publish.yml` to:
- latest nodejs-lts version @ https://nodejs.org/en/about/previous-releases
1. update `CHANGELOG.md`
- verify `` is most-relevant to pull-request.
- run
```shell
# re-run until version propagates
npm run test2
# update 'PR-xxx' placeholder
sh jslint_ci.sh shGithubPrUpdatePrxxx
# re-run until version propagates
sh jslint_ci.sh shGithubPrCreate alpha master # v20yy.mm.dd __pr_master_pre
git push upstream alpha -f
```
- verify ci-success @ https://github.com/kaizhu256/jslint/actions
- verify ci-success @ https://github.com/jslint-org/jslint/actions
1. goto https://github.com/jslint-org/jslint/compare/beta...kaizhu256:jslint:branch-v2026.6.30
- click `Create pull request`
- input `Add a title *` with: `# v20yy.mm.dd`
- input `Add a description` with:
```
```
- click `Preview` and review
- verify:
- base respository: `jslint-org/jslint`
- base: `beta`
- click `Create pull request`
- verify ci-success @ https://github.com/jslint-org/jslint/actions/workflows/on_pull_request.yml
1. wait awhile before continuing ...
- click `Squash and merge`
- verify ci-success @ https://github.com/jslint-org/jslint/actions
- run
```shell
sh jslint_ci.sh shGithubPrCleanup
git push upstream alpha -f
```
- verify ci-success @ https://github.com/kaizhu256/jslint/actions
- verify ci-success @ https://github.com/jslint-org/jslint/actions
- click `Delete branch`
- run
```shell
git push origin beta:master
git push upstream beta:master
```
- verify ci-success @ https://github.com/kaizhu256/jslint/actions
- verify ci-success @ https://github.com/jslint-org/jslint/actions