@jslint-org/jslint 2022.3.30 → 2022.7.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.npmignore +6 -0
- package/CHANGELOG.md +270 -0
- package/README.md +543 -50
- package/asset_codemirror_rollup.js +11470 -0
- package/asset_font_daley_bold.woff2 +0 -0
- package/asset_image_folder_open_solid.svg +1 -0
- package/asset_image_github_brands.svg +1 -0
- package/asset_image_jslint_wrapper_vim.png +0 -0
- package/asset_image_jslint_wrapper_vscode.png +0 -0
- package/asset_image_json_160.svg +104 -0
- package/asset_image_logo_512.png +0 -0
- package/asset_image_logo_512.svg +39 -0
- package/jslint.mjs +504 -184
- package/jslint_wrapper_cjs.cjs +28 -0
- package/jslint_wrapper_vscode.js +227 -0
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ Douglas Crockford <douglas@crockford.com>
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
# Status
|
|
6
|
-
| Branch | [master<br>(v2022.
|
|
6
|
+
| Branch | [master<br>(v2022.7.20)](https://github.com/jslint-org/jslint/tree/master) | [beta<br>(Web Demo)](https://github.com/jslint-org/jslint/tree/beta) | [alpha<br>(Development)](https://github.com/jslint-org/jslint/tree/alpha) |
|
|
7
7
|
|--:|:--:|:--:|:--:|
|
|
8
8
|
| CI | [](https://github.com/jslint-org/jslint/actions?query=branch%3Amaster) | [](https://github.com/jslint-org/jslint/actions?query=branch%3Abeta) | [](https://github.com/jslint-org/jslint/actions?query=branch%3Aalpha) |
|
|
9
9
|
| Coverage | [](https://jslint-org.github.io/jslint/branch-master/.artifact/coverage/index.html) | [](https://jslint-org.github.io/jslint/branch-beta/.artifact/coverage/index.html) | [](https://jslint-org.github.io/jslint/branch-alpha/.artifact/coverage/index.html) |
|
|
@@ -18,33 +18,59 @@ Douglas Crockford <douglas@crockford.com>
|
|
|
18
18
|
|
|
19
19
|
2. [Web Demo Archived](#web-demo-archived)
|
|
20
20
|
|
|
21
|
-
3. [
|
|
22
|
-
|
|
23
|
-
4. [Quickstart Install](#quickstart-install)
|
|
24
|
-
- [To install, just download https://www.jslint.com/jslint.mjs and save to file:](#to-install-just-download-httpswwwjslintcomjslintmjs-and-save-to-file)
|
|
21
|
+
3. [Quickstart Install](#quickstart-install)
|
|
22
|
+
- [To install, just download and save https://www.jslint.com/jslint.mjs to file:](#to-install-just-download-and-save-httpswwwjslintcomjslintmjs-to-file)
|
|
25
23
|
- [To run `jslint.mjs` in shell:](#to-run-jslintmjs-in-shell)
|
|
26
24
|
- [To import `jslint.mjs` in ES Module environment:](#to-import-jslintmjs-in-es-module-environment)
|
|
27
25
|
- [To import `jslint.mjs` in CommonJS environment:](#to-import-jslintmjs-in-commonjs-environment)
|
|
28
26
|
- [To JSLint entire directory in shell:](#to-jslint-entire-directory-in-shell)
|
|
29
27
|
|
|
30
|
-
|
|
28
|
+
4. [Quickstart JSLint Report](#quickstart-jslint-report)
|
|
31
29
|
- [To create a JSLint report in shell:](#to-create-a-jslint-report-in-shell)
|
|
32
30
|
- [To create a JSLint report in javascript:](#to-create-a-jslint-report-in-javascript)
|
|
33
31
|
|
|
34
|
-
|
|
32
|
+
5. [Quickstart V8 Coverage Report](#quickstart-v8-coverage-report)
|
|
35
33
|
- [To create V8 coverage report from Node.js / Npm program in shell:](#to-create-v8-coverage-report-from-nodejs--npm-program-in-shell)
|
|
36
34
|
- [To create V8 coverage report from Node.js / Npm program in javascript:](#to-create-v8-coverage-report-from-nodejs--npm-program-in-javascript)
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
- [To run JSLint in Vim:](#to-run-jslint-in-vim)
|
|
40
|
-
|
|
41
|
-
8. [Description](#description)
|
|
36
|
+
6. [Quickstart JSLint in CodeMirror](#quickstart-jslint-in-codemirror)
|
|
42
37
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
10. [Changelog](#changelog)
|
|
38
|
+
7. [Quickstart JSLint in Vim](#quickstart-jslint-in-vim)
|
|
46
39
|
|
|
47
|
-
|
|
40
|
+
8. [Quickstart JSLint in VSCode](#quickstart-jslint-in-vscode)
|
|
41
|
+
|
|
42
|
+
9. [Documentation](#documentation)
|
|
43
|
+
- [API Doc](#api-doc)
|
|
44
|
+
- [Directive `/*jslint*/`](#directive-jslint)
|
|
45
|
+
- [`/*jslint beta*/`](#jslint-beta)
|
|
46
|
+
- [`/*jslint bitwise*/`](#jslint-bitwise)
|
|
47
|
+
- [`/*jslint browser*/`](#jslint-browser)
|
|
48
|
+
- [`/*jslint convert*/`](#jslint-convert)
|
|
49
|
+
- [`/*jslint couch*/`](#jslint-couch)
|
|
50
|
+
- [`/*jslint devel*/`](#jslint-devel)
|
|
51
|
+
- [`/*jslint eval*/`](#jslint-eval)
|
|
52
|
+
- [`/*jslint for*/`](#jslint-for)
|
|
53
|
+
- [`/*jslint getset*/`](#jslint-getset)
|
|
54
|
+
- [`/*jslint indent2*/`](#jslint-indent2)
|
|
55
|
+
- [`/*jslint long*/`](#jslint-long)
|
|
56
|
+
- [`/*jslint node*/`](#jslint-node)
|
|
57
|
+
- [`/*jslint nomen*/`](#jslint-nomen)
|
|
58
|
+
- [`/*jslint single*/`](#jslint-single)
|
|
59
|
+
- [`/*jslint subscript*/`](#jslint-subscript)
|
|
60
|
+
- [`/*jslint this*/`](#jslint-this)
|
|
61
|
+
- [`/*jslint trace*/`](#jslint-trace)
|
|
62
|
+
- [`/*jslint unordered*/`](#jslint-unordered)
|
|
63
|
+
- [`/*jslint white*/`](#jslint-white)
|
|
64
|
+
- [Directive `/*global*/`](#directive-global)
|
|
65
|
+
- [Directive `/*property*/`](#directive-property)
|
|
66
|
+
- [Directive `/*jslint-disable*/.../*jslint-enable*/`](#directive-jslint-disablejslint-enable)
|
|
67
|
+
- [Directive `//jslint-ignore-line`](#directive-jslint-ignore-line)
|
|
68
|
+
|
|
69
|
+
10. [Package Listing](#package-listing)
|
|
70
|
+
|
|
71
|
+
11. [Changelog](#changelog)
|
|
72
|
+
|
|
73
|
+
12. [License](#license)
|
|
48
74
|
|
|
49
75
|
|
|
50
76
|
<br><br>
|
|
@@ -61,19 +87,12 @@ Douglas Crockford <douglas@crockford.com>
|
|
|
61
87
|
- [Web Demo 2013 (ES5, CSS, HTML)](https://www.jslint.com/branch-v2013.3.13/jslint.html)
|
|
62
88
|
|
|
63
89
|
|
|
64
|
-
<br><br>
|
|
65
|
-
# API Doc
|
|
66
|
-
- https://www.jslint.com/apidoc.html
|
|
67
|
-
|
|
68
|
-
[](https://www.jslint.com/apidoc.html)
|
|
69
|
-
|
|
70
|
-
|
|
71
90
|
<br><br>
|
|
72
91
|
# Quickstart Install
|
|
73
92
|
|
|
74
93
|
|
|
75
94
|
<br><br>
|
|
76
|
-
### To install, just download https://www.jslint.com/jslint.mjs
|
|
95
|
+
### To install, just download and save https://www.jslint.com/jslint.mjs to file:
|
|
77
96
|
```shell <!-- shRunWithScreenshotTxt .artifact/screenshot_sh_install_download.svg -->
|
|
78
97
|
#!/bin/sh
|
|
79
98
|
|
|
@@ -81,7 +100,7 @@ curl -L https://www.jslint.com/jslint.mjs > jslint.mjs
|
|
|
81
100
|
```
|
|
82
101
|
- shell output
|
|
83
102
|
|
|
84
|
-

|
|
85
104
|
|
|
86
105
|
|
|
87
106
|
<br><br>
|
|
@@ -95,7 +114,7 @@ node jslint.mjs hello.js
|
|
|
95
114
|
```
|
|
96
115
|
- shell output
|
|
97
116
|
|
|
98
|
-

|
|
99
118
|
|
|
100
119
|
|
|
101
120
|
<br><br>
|
|
@@ -129,7 +148,7 @@ result.warnings.forEach(function ({
|
|
|
129
148
|
```
|
|
130
149
|
- shell output
|
|
131
150
|
|
|
132
|
-

|
|
133
152
|
|
|
134
153
|
|
|
135
154
|
<br><br>
|
|
@@ -166,7 +185,7 @@ node --eval '
|
|
|
166
185
|
```
|
|
167
186
|
- shell output
|
|
168
187
|
|
|
169
|
-

|
|
170
189
|
|
|
171
190
|
|
|
172
191
|
<br><br>
|
|
@@ -180,7 +199,7 @@ node jslint.mjs .
|
|
|
180
199
|
```
|
|
181
200
|
- shell output
|
|
182
201
|
|
|
183
|
-

|
|
184
203
|
|
|
185
204
|
|
|
186
205
|
<br><br>
|
|
@@ -202,11 +221,11 @@ node jslint.mjs \
|
|
|
202
221
|
```
|
|
203
222
|
- shell output
|
|
204
223
|
|
|
205
|
-

|
|
206
225
|
|
|
207
226
|
- screenshot file [.artifact/jslint_report_hello.html](https://jslint-org.github.io/jslint/branch-beta/.artifact/jslint_report_hello.html)
|
|
208
227
|
|
|
209
|
-
[](https://jslint-org.github.io/jslint/branch-beta/.artifact/jslint_report_hello.html)
|
|
210
229
|
|
|
211
230
|
|
|
212
231
|
<br><br>
|
|
@@ -220,17 +239,17 @@ node --input-type=module --eval '
|
|
|
220
239
|
import jslint from "./jslint.mjs";
|
|
221
240
|
import fs from "fs";
|
|
222
241
|
(async function () {
|
|
223
|
-
let report;
|
|
224
242
|
let result;
|
|
225
243
|
let source = "function foo() {console.log(\u0027hello world\u0027);}\n";
|
|
226
244
|
|
|
227
245
|
// Create JSLint report from <source> in javascript.
|
|
228
246
|
|
|
229
247
|
result = jslint.jslint(source);
|
|
230
|
-
|
|
248
|
+
result = jslint.jslint_report(result);
|
|
249
|
+
result = `<body class="JSLINT_ JSLINT_REPORT_">\n${result}</body>\n`;
|
|
231
250
|
|
|
232
251
|
await fs.promises.mkdir(".artifact/", {recursive: true});
|
|
233
|
-
await fs.promises.writeFile(".artifact/jslint_report_hello.html",
|
|
252
|
+
await fs.promises.writeFile(".artifact/jslint_report_hello.html", result);
|
|
234
253
|
console.error("wrote file .artifact/jslint_report_hello.html");
|
|
235
254
|
}());
|
|
236
255
|
|
|
@@ -238,11 +257,11 @@ import fs from "fs";
|
|
|
238
257
|
```
|
|
239
258
|
- shell output
|
|
240
259
|
|
|
241
|
-

|
|
242
261
|
|
|
243
262
|
- screenshot file [.artifact/jslint_report_hello.html](https://jslint-org.github.io/jslint/branch-beta/.artifact/jslint_report_hello.html)
|
|
244
263
|
|
|
245
|
-
[](https://jslint-org.github.io/jslint/branch-beta/.artifact/jslint_report_hello.html)
|
|
246
265
|
|
|
247
266
|
|
|
248
267
|
<br><br>
|
|
@@ -266,22 +285,36 @@ npm install
|
|
|
266
285
|
|
|
267
286
|
node ../jslint.mjs \
|
|
268
287
|
v8_coverage_report=../.artifact/coverage_sqlite3_sh/ \
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
288
|
+
--exclude=tes?/ \
|
|
289
|
+
--exclude=tes[!0-9A-Z_a-z-]/ \
|
|
290
|
+
--exclude=tes[0-9A-Z_a-z-]/ \
|
|
291
|
+
--exclude=tes[^0-9A-Z_a-z-]/ \
|
|
292
|
+
--exclude=test/**/*.js \
|
|
293
|
+
--exclude=test/suppor*/*elper.js \
|
|
294
|
+
--exclude=test/suppor?/?elper.js \
|
|
295
|
+
--exclude=test/support/helper.js \
|
|
296
|
+
--include=**/*.cjs \
|
|
297
|
+
--include=**/*.js \
|
|
298
|
+
--include=**/*.mjs \
|
|
299
|
+
--include=li*/*.js \
|
|
300
|
+
--include=li?/*.js \
|
|
301
|
+
--include=lib/ \
|
|
302
|
+
--include=lib/**/*.js \
|
|
303
|
+
--include=lib/*.js \
|
|
304
|
+
--include=lib/sqlite3.js \
|
|
272
305
|
npm run test
|
|
273
306
|
```
|
|
274
307
|
- shell output
|
|
275
308
|
|
|
276
|
-

|
|
277
310
|
|
|
278
311
|
- screenshot file [.artifact/coverage_sqlite3_sh/index.html](https://jslint-org.github.io/jslint/branch-beta/.artifact/coverage_sqlite3_sh/index.html)
|
|
279
312
|
|
|
280
|
-
[](https://jslint-org.github.io/jslint/branch-beta/.artifact/coverage_sqlite3_sh/index.html)
|
|
281
314
|
|
|
282
315
|
- 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)
|
|
283
316
|
|
|
284
|
-
[](https://jslint-org.github.io/jslint/branch-beta/.artifact/coverage_sqlite3_sh/lib/sqlite3.js.html)
|
|
285
318
|
|
|
286
319
|
|
|
287
320
|
<br><br>
|
|
@@ -308,8 +341,23 @@ import jslint from "../jslint.mjs";
|
|
|
308
341
|
await jslint.v8CoverageReportCreate({
|
|
309
342
|
coverageDir: "../.artifact/coverage_sqlite3_js/",
|
|
310
343
|
processArgv: [
|
|
311
|
-
"--
|
|
312
|
-
"--
|
|
344
|
+
"--exclude=tes?/",
|
|
345
|
+
"--exclude=tes[!0-9A-Z_a-z-]/",
|
|
346
|
+
"--exclude=tes[0-9A-Z_a-z-]/",
|
|
347
|
+
"--exclude=tes[^0-9A-Z_a-z-]/",
|
|
348
|
+
"--exclude=test/**/*.js",
|
|
349
|
+
"--exclude=test/suppor*/*elper.js",
|
|
350
|
+
"--exclude=test/suppor?/?elper.js",
|
|
351
|
+
"--exclude=test/support/helper.js",
|
|
352
|
+
"--include=**/*.cjs",
|
|
353
|
+
"--include=**/*.js",
|
|
354
|
+
"--include=**/*.mjs",
|
|
355
|
+
"--include=li*/*.js",
|
|
356
|
+
"--include=li?/*.js",
|
|
357
|
+
"--include=lib/",
|
|
358
|
+
"--include=lib/**/*.js",
|
|
359
|
+
"--include=lib/*.js",
|
|
360
|
+
"--include=lib/sqlite3.js",
|
|
313
361
|
"npm", "run", "test"
|
|
314
362
|
]
|
|
315
363
|
});
|
|
@@ -319,23 +367,136 @@ import jslint from "../jslint.mjs";
|
|
|
319
367
|
```
|
|
320
368
|
- shell output
|
|
321
369
|
|
|
322
|
-

|
|
323
371
|
|
|
324
372
|
- screenshot file [.artifact/coverage_sqlite3_js/index.html](https://jslint-org.github.io/jslint/branch-beta/.artifact/coverage_sqlite3_js/index.html)
|
|
325
373
|
|
|
326
|
-
[](https://jslint-org.github.io/jslint/branch-beta/.artifact/coverage_sqlite3_js/index.html)
|
|
327
375
|
|
|
328
376
|
- 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)
|
|
329
377
|
|
|
330
|
-
[](https://jslint-org.github.io/jslint/branch-beta/.artifact/coverage_sqlite3_js/lib/sqlite3.js.html)
|
|
331
379
|
|
|
332
380
|
|
|
333
381
|
<br><br>
|
|
334
|
-
# Quickstart JSLint in
|
|
382
|
+
# Quickstart JSLint in CodeMirror
|
|
383
|
+
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.
|
|
384
|
+
|
|
385
|
+
2. Edit, save, and serve example html-file below:
|
|
386
|
+
```html <!-- jslint_wrapper_codemirror.html -->
|
|
387
|
+
<!DOCTYPE html>
|
|
388
|
+
<html lang="en">
|
|
389
|
+
<head>
|
|
390
|
+
<meta charset="utf-8">
|
|
391
|
+
<title>CodeMirror: JSLint Demo</title>
|
|
392
|
+
|
|
393
|
+
<!-- Assets from codemirror. -->
|
|
394
|
+
|
|
395
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/codemirror.css">
|
|
396
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/addon/lint/lint.css">
|
|
397
|
+
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/codemirror.js"></script>
|
|
398
|
+
<script defer src="https://codemirror.net/mode/javascript/javascript.js"></script>
|
|
399
|
+
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/addon/lint/lint.js"></script>
|
|
400
|
+
|
|
401
|
+
<!-- Assets from jslint. -->
|
|
402
|
+
|
|
403
|
+
<script type="module" src="./jslint.mjs?window_jslint=1"></script>
|
|
404
|
+
<script defer src="./jslint_wrapper_codemirror.js"></script>
|
|
405
|
+
<style>
|
|
406
|
+
body {
|
|
407
|
+
background: #bbb;
|
|
408
|
+
color: #333;
|
|
409
|
+
font-family: sans-serif;
|
|
410
|
+
margin: 20px;
|
|
411
|
+
}
|
|
412
|
+
.JSLINT_.JSLINT_REPORT_ {
|
|
413
|
+
margin-top: 20px;
|
|
414
|
+
}
|
|
415
|
+
#editor1 {
|
|
416
|
+
height: 300px;
|
|
417
|
+
width: 100%;
|
|
418
|
+
}
|
|
419
|
+
</style>
|
|
420
|
+
</head>
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
<body>
|
|
424
|
+
<h1>CodeMirror: JSLint Demo</h1>
|
|
425
|
+
<h3>
|
|
426
|
+
This demo will auto-lint the code below, and auto-generate a report as you type.
|
|
427
|
+
</h3>
|
|
428
|
+
|
|
429
|
+
<!-- Container for codemirror-editor. -->
|
|
430
|
+
|
|
431
|
+
<textarea id="editor1">console.log('hello world');</textarea>
|
|
432
|
+
|
|
433
|
+
<!-- Container for jslint-report. -->
|
|
434
|
+
|
|
435
|
+
<div class="JSLINT_ JSLINT_REPORT_"></div>
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
<script type=module>
|
|
439
|
+
window.addEventListener("load", function () {
|
|
440
|
+
let editor = window.CodeMirror.fromTextArea(document.getElementById(
|
|
441
|
+
"editor1"
|
|
442
|
+
), {
|
|
443
|
+
gutters: [
|
|
444
|
+
"CodeMirror-lint-markers"
|
|
445
|
+
],
|
|
446
|
+
indentUnit: 4,
|
|
447
|
+
lineNumbers: true,
|
|
448
|
+
lint: {
|
|
449
|
+
lintOnChange: true, // Enable auto-lint.
|
|
450
|
+
options: {
|
|
451
|
+
// browser: true,
|
|
452
|
+
// node: true
|
|
453
|
+
globals: [
|
|
454
|
+
// "caches",
|
|
455
|
+
// "indexedDb"
|
|
456
|
+
]
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
mode: "javascript"
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
// Initialize event-handling before linter is run.
|
|
463
|
+
|
|
464
|
+
editor.on("lintJslintBefore", function (/* options */) {
|
|
465
|
+
// options.browser = true;
|
|
466
|
+
// options.node = true;
|
|
467
|
+
// options.globals = [
|
|
468
|
+
// "caches",
|
|
469
|
+
// "indexedDb"
|
|
470
|
+
// ];
|
|
471
|
+
return;
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
// Initialize event-handling after linter is run.
|
|
475
|
+
|
|
476
|
+
editor.on("lintJslintAfter", function (options) {
|
|
477
|
+
|
|
478
|
+
// Generate jslint-report from options.result.
|
|
479
|
+
|
|
480
|
+
document.querySelector(
|
|
481
|
+
".JSLINT_REPORT_"
|
|
482
|
+
).innerHTML = window.jslint.jslint_report(options.result);
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
// Manually trigger linter.
|
|
486
|
+
|
|
487
|
+
editor.performLint();
|
|
488
|
+
});
|
|
489
|
+
</script>
|
|
490
|
+
</body>
|
|
491
|
+
</html>
|
|
492
|
+
```
|
|
493
|
+
3. Live example at https://www.jslint.com/jslint_wrapper_codemirror.html
|
|
494
|
+
|
|
495
|
+
[](https://jslint-org.github.io/jslint/jslint_wrapper_codemirror.html)
|
|
335
496
|
|
|
336
497
|
|
|
337
498
|
<br><br>
|
|
338
|
-
|
|
499
|
+
# Quickstart JSLint in Vim
|
|
339
500
|
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/`
|
|
340
501
|
2. Add vim-command `:source ~/.vim/jslint_wrapper_vim.vim` to file `~/.vimrc`
|
|
341
502
|
3. Vim can now jslint files (via nodejs):
|
|
@@ -343,11 +504,25 @@ import jslint from "../jslint.mjs";
|
|
|
343
504
|
- with vim-key-combo `<Ctrl-S> <Ctrl-J>`
|
|
344
505
|
- screenshot
|
|
345
506
|
|
|
346
|
-
](https://www.jslint.com/jslint_wrapper_vim.vim)
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
<br><br>
|
|
511
|
+
# Quickstart JSLint in VSCode
|
|
512
|
+
1. In VSCode, search and install extension [`vscode-jslint`](https://marketplace.visualstudio.com/items?itemName=jslint.vscode-jslint)
|
|
513
|
+
2. In VSCode, while editing a javascript file:
|
|
514
|
+
- right-click context-menu and select `[JSLint - Lint File]`
|
|
515
|
+
- or use key-binding `[Ctrl + Shift + J], [L]`
|
|
516
|
+
- or use key-binding `[ Cmd + Shift + J], [L]` for Mac
|
|
517
|
+
- screenshot
|
|
518
|
+
|
|
519
|
+
[](https://marketplace.visualstudio.com/items?itemName=jslint.vscode-jslint)
|
|
347
520
|
|
|
348
521
|
|
|
349
522
|
<br><br>
|
|
350
|
-
#
|
|
523
|
+
# Documentation
|
|
524
|
+
|
|
525
|
+
|
|
351
526
|
- [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.
|
|
352
527
|
|
|
353
528
|
- [index.html](index.html) runs the jslint.mjs function in a web page.
|
|
@@ -371,6 +546,324 @@ plays the part of a stern but benevolent editor, helping you to get the style
|
|
|
371
546
|
right so that you can focus your creative energy where it is most needed.
|
|
372
547
|
|
|
373
548
|
|
|
549
|
+
<br><br>
|
|
550
|
+
### API Doc
|
|
551
|
+
- https://www.jslint.com/apidoc.html
|
|
552
|
+
|
|
553
|
+
[](https://www.jslint.com/apidoc.html)
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
<br><br>
|
|
557
|
+
### Directive `/*jslint*/`
|
|
558
|
+
|
|
559
|
+
<br>
|
|
560
|
+
|
|
561
|
+
##### `/*jslint beta*/`
|
|
562
|
+
|
|
563
|
+
```js
|
|
564
|
+
/*jslint beta*/
|
|
565
|
+
// Enable experimental warnings.
|
|
566
|
+
// Warn if global variables are redefined.
|
|
567
|
+
// Warn if const / let statements are not declared at top of function or
|
|
568
|
+
// script, similar to var statements.
|
|
569
|
+
// Warn if const / let / var statements are not declared in ascii-order.
|
|
570
|
+
// Warn if named-functions are not declared in ascii-order.
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
<br>
|
|
574
|
+
|
|
575
|
+
##### `/*jslint bitwise*/`
|
|
576
|
+
|
|
577
|
+
```js
|
|
578
|
+
/*jslint bitwise*/
|
|
579
|
+
// Allow bitwise operators.
|
|
580
|
+
|
|
581
|
+
let foo = 0 | 1;
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
<br>
|
|
585
|
+
|
|
586
|
+
##### `/*jslint browser*/`
|
|
587
|
+
|
|
588
|
+
```js
|
|
589
|
+
/*jslint browser*/
|
|
590
|
+
// Assume browser environment.
|
|
591
|
+
|
|
592
|
+
localStorage.getItem("foo");
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
<br>
|
|
596
|
+
|
|
597
|
+
##### `/*jslint convert*/`
|
|
598
|
+
|
|
599
|
+
```js
|
|
600
|
+
/*jslint convert*/
|
|
601
|
+
// Allow conversion operators.
|
|
602
|
+
|
|
603
|
+
let foo = new Date() + "";
|
|
604
|
+
let bar = !!0;
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
<br>
|
|
608
|
+
|
|
609
|
+
##### `/*jslint couch*/`
|
|
610
|
+
|
|
611
|
+
```js
|
|
612
|
+
/*jslint couch*/
|
|
613
|
+
// Assume CouchDb environment.
|
|
614
|
+
|
|
615
|
+
registerType("text-json", "text/json");
|
|
616
|
+
```
|
|
617
|
+
|
|
618
|
+
<br>
|
|
619
|
+
|
|
620
|
+
##### `/*jslint devel*/`
|
|
621
|
+
|
|
622
|
+
```js
|
|
623
|
+
/*jslint devel*/
|
|
624
|
+
// Allow console.log() and friends.
|
|
625
|
+
|
|
626
|
+
console.log("hello");
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
<br>
|
|
630
|
+
|
|
631
|
+
##### `/*jslint eval*/`
|
|
632
|
+
|
|
633
|
+
```js
|
|
634
|
+
/*jslint eval*/
|
|
635
|
+
// Allow eval().
|
|
636
|
+
|
|
637
|
+
eval("1");
|
|
638
|
+
```
|
|
639
|
+
|
|
640
|
+
<br>
|
|
641
|
+
|
|
642
|
+
##### `/*jslint for*/`
|
|
643
|
+
|
|
644
|
+
```js
|
|
645
|
+
/*jslint for*/
|
|
646
|
+
// Allow for-loop.
|
|
647
|
+
|
|
648
|
+
function foo() {
|
|
649
|
+
let ii;
|
|
650
|
+
for (ii = 0; ii < 10; ii += 1) {
|
|
651
|
+
foo();
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
```
|
|
655
|
+
|
|
656
|
+
<br>
|
|
657
|
+
|
|
658
|
+
##### `/*jslint getset*/`
|
|
659
|
+
|
|
660
|
+
```js
|
|
661
|
+
/*jslint getset, this, devel*/
|
|
662
|
+
// Allow get() and set().
|
|
663
|
+
|
|
664
|
+
let foo = {
|
|
665
|
+
bar: 0,
|
|
666
|
+
get getBar() {
|
|
667
|
+
return this.bar;
|
|
668
|
+
},
|
|
669
|
+
set setBar(value) {
|
|
670
|
+
this.bar = value;
|
|
671
|
+
}
|
|
672
|
+
};
|
|
673
|
+
console.log(foo.getBar); // 0
|
|
674
|
+
foo.setBar = 1;
|
|
675
|
+
console.log(foo.getBar); // 1
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
<br>
|
|
679
|
+
|
|
680
|
+
##### `/*jslint indent2*/`
|
|
681
|
+
|
|
682
|
+
```js
|
|
683
|
+
/*jslint indent2*/
|
|
684
|
+
// Use 2-space indent.
|
|
685
|
+
|
|
686
|
+
function foo() {
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
<br>
|
|
692
|
+
|
|
693
|
+
##### `/*jslint long*/`
|
|
694
|
+
|
|
695
|
+
```js
|
|
696
|
+
/*jslint long*/
|
|
697
|
+
// Allow long lines.
|
|
698
|
+
|
|
699
|
+
let foo = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
|
700
|
+
```
|
|
701
|
+
|
|
702
|
+
<br>
|
|
703
|
+
|
|
704
|
+
##### `/*jslint node*/`
|
|
705
|
+
|
|
706
|
+
```js
|
|
707
|
+
/*jslint node*/
|
|
708
|
+
// Assume Node.js environment.
|
|
709
|
+
|
|
710
|
+
require("fs");
|
|
711
|
+
```
|
|
712
|
+
|
|
713
|
+
<br>
|
|
714
|
+
|
|
715
|
+
##### `/*jslint nomen*/`
|
|
716
|
+
|
|
717
|
+
```js
|
|
718
|
+
/*jslint nomen*/
|
|
719
|
+
// Allow weird property names.
|
|
720
|
+
|
|
721
|
+
let foo = {};
|
|
722
|
+
foo._bar = 1;
|
|
723
|
+
```
|
|
724
|
+
|
|
725
|
+
<br>
|
|
726
|
+
|
|
727
|
+
##### `/*jslint single*/`
|
|
728
|
+
|
|
729
|
+
```js
|
|
730
|
+
/*jslint single*/
|
|
731
|
+
// Allow single-quote strings.
|
|
732
|
+
|
|
733
|
+
let foo = '';
|
|
734
|
+
```
|
|
735
|
+
|
|
736
|
+
<br>
|
|
737
|
+
|
|
738
|
+
##### `/*jslint subscript*/`
|
|
739
|
+
|
|
740
|
+
```js
|
|
741
|
+
/*jslint subscript*/
|
|
742
|
+
// Allow identifiers in subscript-notation.
|
|
743
|
+
|
|
744
|
+
let foo = {};
|
|
745
|
+
foo["bar"] = 1;
|
|
746
|
+
```
|
|
747
|
+
|
|
748
|
+
<br>
|
|
749
|
+
|
|
750
|
+
##### `/*jslint this*/`
|
|
751
|
+
|
|
752
|
+
```js
|
|
753
|
+
/*jslint this*/
|
|
754
|
+
// Allow 'this'.
|
|
755
|
+
|
|
756
|
+
function foo() {
|
|
757
|
+
return this;
|
|
758
|
+
}
|
|
759
|
+
```
|
|
760
|
+
|
|
761
|
+
<br>
|
|
762
|
+
|
|
763
|
+
##### `/*jslint trace*/`
|
|
764
|
+
|
|
765
|
+
```js
|
|
766
|
+
/*jslint trace*/
|
|
767
|
+
// Include jslint stack-trace in warnings.
|
|
768
|
+
|
|
769
|
+
console.log('hello world');
|
|
770
|
+
/*
|
|
771
|
+
1. Undeclared 'console'.
|
|
772
|
+
console.log('hello world');
|
|
773
|
+
Error
|
|
774
|
+
at warn_at (...)
|
|
775
|
+
at warn (...)
|
|
776
|
+
at lookup (...)
|
|
777
|
+
at pre_v (...)
|
|
778
|
+
at jslint.mjs
|
|
779
|
+
2. Use double quotes, not single quotes.
|
|
780
|
+
console.log(...);
|
|
781
|
+
Error
|
|
782
|
+
at warn_at (...)
|
|
783
|
+
at lex_string (...)
|
|
784
|
+
at lex_token (...)
|
|
785
|
+
at jslint_phase2_lex (...)
|
|
786
|
+
at Function.jslint (...)
|
|
787
|
+
at jslint.mjs
|
|
788
|
+
*/
|
|
789
|
+
```
|
|
790
|
+
|
|
791
|
+
<br>
|
|
792
|
+
|
|
793
|
+
##### `/*jslint unordered*/`
|
|
794
|
+
|
|
795
|
+
```js
|
|
796
|
+
/*jslint unordered*/
|
|
797
|
+
// Allow unordered cases, params, properties, and variables.
|
|
798
|
+
|
|
799
|
+
let foo = {bb: 1, aa: 0};
|
|
800
|
+
|
|
801
|
+
function bar({
|
|
802
|
+
bb = 1,
|
|
803
|
+
aa = 0
|
|
804
|
+
}) {
|
|
805
|
+
return aa + bb;
|
|
806
|
+
}
|
|
807
|
+
```
|
|
808
|
+
|
|
809
|
+
<br>
|
|
810
|
+
|
|
811
|
+
##### `/*jslint white*/`
|
|
812
|
+
|
|
813
|
+
```js
|
|
814
|
+
/*jslint white*/
|
|
815
|
+
// Allow messy whitespace.
|
|
816
|
+
|
|
817
|
+
let foo = 1; let bar = 2;
|
|
818
|
+
```
|
|
819
|
+
|
|
820
|
+
|
|
821
|
+
<br><br>
|
|
822
|
+
### Directive `/*global*/`
|
|
823
|
+
|
|
824
|
+
```js
|
|
825
|
+
/*global foo, bar*/
|
|
826
|
+
// Declare global variables foo, bar.
|
|
827
|
+
|
|
828
|
+
foo();
|
|
829
|
+
bar();
|
|
830
|
+
```
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
<br><br>
|
|
834
|
+
### Directive `/*property*/`
|
|
835
|
+
|
|
836
|
+
```js
|
|
837
|
+
/*property foo, bar*/
|
|
838
|
+
// Restrict property-access to only .foo, .bar.
|
|
839
|
+
|
|
840
|
+
let aa = {bar: 1, foo: 2};
|
|
841
|
+
```
|
|
842
|
+
|
|
843
|
+
|
|
844
|
+
<br><br>
|
|
845
|
+
### Directive `/*jslint-disable*/.../*jslint-enable*/`
|
|
846
|
+
|
|
847
|
+
```js
|
|
848
|
+
/*jslint-disable*/
|
|
849
|
+
|
|
850
|
+
JSLint will ignore and treat this region as blank-lines.
|
|
851
|
+
Syntax error.
|
|
852
|
+
|
|
853
|
+
/*jslint-enable*/
|
|
854
|
+
```
|
|
855
|
+
|
|
856
|
+
|
|
857
|
+
<br><br>
|
|
858
|
+
### Directive `//jslint-ignore-line`
|
|
859
|
+
|
|
860
|
+
```js
|
|
861
|
+
// JSLint will ignore non-fatal warnings at given line.
|
|
862
|
+
|
|
863
|
+
eval("1"); //jslint-ignore-line
|
|
864
|
+
```
|
|
865
|
+
|
|
866
|
+
|
|
374
867
|
<br><br>
|
|
375
868
|
# Package Listing
|
|
376
869
|

|