Douglas Crockford douglas@crockford.com
Branch | master (v2021.5.30) |
beta (Web Demo) |
alpha (Development) |
---|---|---|---|
CI | |||
Coverage | |||
Demo | |||
Artifacts |
- To install, just download and rename https://www.jslint.com/jslint.js to
jslint.mjs
:
#!/bin/sh
curl -L https://www.jslint.com/jslint.js > jslint.mjs
- To run
jslint.mjs
from command-line:
#!/bin/sh
node jslint.mjs hello.js
# stderr:
#
# jslint hello.js
# 1 Undeclared 'console'. // line 1, column 1
# console.log('hello world');
# 2 Use double quotes, not single quotes. // line 1, column 14
# console.log('hello world');
- To load
jslint.mjs
as es-module:
/*jslint devel*/
import jslint from "./jslint.mjs";
let code = "console.log('hello world');\n";
let result = jslint(code);
result.warnings.forEach(function ({
formatted_message
}) {
console.error(formatted_message);
});
// stderr:
//
// 1 Undeclared 'console'. // line 1, column 1
// console.log('hello world');
// 2 Use double quotes, not single quotes. // line 1, column 14
// console.log('hello world');
-
jslint.js 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 runs the jslint.js function in a web page. The page also depends on
browser.js
. -
browser.js runs the web user interface and generates the results reports in HTML.
-
function.html describes the jslint function and the results it produces.
JSLint can be run anywhere that JavaScript (or Java) can run.
The place to express yourself in programming is in the quality of your ideas and the efficiency of their execution. The role of style in programming is the same as in literature: It makes for better reading. A great writer doesn't express herself by putting the spaces before her commas instead of after, or by putting extra spaces inside her parentheses. A great writer will slavishly conform to some rules of style, and that in no way constrains her power to express herself creatively. See for example William Strunk's The Elements of Style [https://www.crockford.com/style.html].
This applies to programming as well. Conforming to a consistent style improves readability, and frees you to express yourself in ways that matter. JSLint here plays the part of a stern but benevolent editor, helping you to get the style right so that you can focus your creative energy where it is most needed.
- app - deploy jslint as chrome-extension.
- doc - add svg package-listing.
- doc - document cli-feature to jslint entire directory.
- jslint - add
for...of
syntax support. - jslint - add html and css linting back into jslint.
- jslint - add eslint-like disable-macros
/*jslint-disable*/
,/*jslint-enable*/
,//jslint-disable-line
. - jslint - add new warning if case-statements are not sorted.
- jslint - add new warning if const/let/var statements are not declared at top of function-scope.
- jslint - add new warning if const/let/var statements are not sorted.
- jslint - migrate code away from recursive-loops to for/while loops.
- node - after node-v12 is deprecated, change
require("fs").promises
torequire("fs/promises")
. - node - after node-v14 is deprecated, remove shell-code
export "NODE_OPTIONS=--unhandled-rejections=strict"
.
- bugfix - fix issue #282 - fail to warn trailing semicolon in
export default Object.freeze({})
. - ci - 100% code-coverage!
- ci - auto-update changelog in README.md from CHANGELOG.md.
- ci - auto-update version numbers in README.md and jslint.js from CHANGELOG.md.
- deadcode - replace with assertion-check in function choice() -
if (char === "|") { warn... }
. - deadcode - replace with assertion-check in function do_function() -
if (mega_mode) { warn... }
. - deadcode - replace with assertion-check in function no_space() -
const at = (free ? ...)
. - deadcode - replace with assertion-check in function no_space() -
if (open) {...}
. - deadcode - replace with assertion-check in function parse_directive() -
} else if (value === "false") {...}
. - deadcode - replace with assertion-check in function supplant() -
return ( replacement !== undefined ?...)
. - jslint - cleanup regexp code using switch-case-statements.
- jslint - inline function
activate
into functionaction_var
. - jslint - inline-document each deadcode-removal/assertion-check.
- jslint - inline-document each warning with cause that can reproduce it - part 2.
- tests - inline remaining causal-regressions from test.js into jslint.js
- tests - validate inline-multi-causes are sorted.
- website - replace links
branch.xxx
withbranch-xxx
.
- ci - fix expectedWarningCode not being validated.
- ci - in windows, disable git-autocrlf.
- deadcode - replace with assertion-check in function are_similar() - "if (a === b) { return true }".
- deadcode - replace with assertion-check in function are_similar() superseded by id-check - "if (Array.isArray(b)) { return false; }".
- deadcode - replace with assertion-check in function are_similar() superseded by is_weird() check - "if (a.arity === "function" && a.arity ===...c".
- jslint - add directive
test_internal_error
. - jslint - add directive
unordered
to tolerate unordered properties and params. - jslint - inline-document each warning with cause that can reproduce it - part 1.
- style - refactor code moving infix-operators from post-position to pre-position in multiline statements.
- website - add hotkey ctrl-enter to run jslint.