@jslint-org/jslint 2021.12.20 → 2022.5.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.
@@ -0,0 +1,50 @@
1
+ // The Unlicense
2
+ //
3
+ // This is free and unencumbered software released into the public domain.
4
+ //
5
+ // Anyone is free to copy, modify, publish, use, compile, sell, or
6
+ // distribute this software, either in source code form or as a compiled
7
+ // binary, for any purpose, commercial or non-commercial, and by any
8
+ // means.
9
+ //
10
+ // In jurisdictions that recognize copyright laws, the author or authors
11
+ // of this software dedicate any and all copyright interest in the
12
+ // software to the public domain. We make this dedication for the benefit
13
+ // of the public at large and to the detriment of our heirs and
14
+ // successors. We intend this dedication to be an overt act of
15
+ // relinquishment in perpetuity of all present and future rights to this
16
+ // software under copyright law.
17
+ //
18
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21
+ // IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22
+ // OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23
+ // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24
+ // OTHER DEALINGS IN THE SOFTWARE.
25
+ //
26
+ // For more information, please refer to <https://unlicense.org/>
27
+
28
+
29
+ /*jslint beta, node*/
30
+ /*property
31
+ module, readFileSync, replace, runInNewContext
32
+ */
33
+ require("vm").runInNewContext(
34
+ (
35
+ "\"use strict\";"
36
+ + require("fs").readFileSync(
37
+ __dirname + "/jslint.mjs",
38
+ "utf8"
39
+ ).replace(
40
+ "\nexport default Object.freeze(jslint_export);",
41
+ "\nmodule.exports = jslint_export;"
42
+ ).replace(
43
+ "\njslint_import_meta_url = import.meta.url;",
44
+ "\n// jslint_import_meta_url = import.meta.url;"
45
+ )
46
+ ),
47
+ {
48
+ module
49
+ }
50
+ );
@@ -0,0 +1,178 @@
1
+ // The Unlicense
2
+ //
3
+ // This is free and unencumbered software released into the public domain.
4
+ //
5
+ // Anyone is free to copy, modify, publish, use, compile, sell, or
6
+ // distribute this software, either in source code form or as a compiled
7
+ // binary, for any purpose, commercial or non-commercial, and by any
8
+ // means.
9
+ //
10
+ // In jurisdictions that recognize copyright laws, the author or authors
11
+ // of this software dedicate any and all copyright interest in the
12
+ // software to the public domain. We make this dedication for the benefit
13
+ // of the public at large and to the detriment of our heirs and
14
+ // successors. We intend this dedication to be an overt act of
15
+ // relinquishment in perpetuity of all present and future rights to this
16
+ // software under copyright law.
17
+ //
18
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21
+ // IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22
+ // OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23
+ // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24
+ // OTHER DEALINGS IN THE SOFTWARE.
25
+ //
26
+ // For more information, please refer to <https://unlicense.org/>
27
+
28
+
29
+ /*jslint beta, node*/
30
+ /*property
31
+ Diagnostic, DiagnosticSeverity, ProgressLocation, Warning, Window, activate,
32
+ cancellable, character, clear, column, commands, createDiagnosticCollection,
33
+ document, end, exports, getText, increment, jslint, languages, line,
34
+ location, map, message, module, push, readFileSync,
35
+ registerTextEditorCommand, replace, report, runInNewContext, set, slice,
36
+ start, subscriptions, title, uri, warnings, window, withProgress
37
+ */
38
+
39
+ "use strict";
40
+
41
+ function activate({
42
+ subscriptions
43
+ }) {
44
+ /**
45
+ * @param {vscode.ExtensionContext} context
46
+ */
47
+ // This method is called when your extension is activated.
48
+ // Your extension is activated the very first time the command is executed.
49
+
50
+ // Directly print diagnostic without language-server.
51
+ // https://stackoverflow.com/questions/35581332
52
+ // /create-diagnostics-entries-without-language-server-in-visual-studio-code
53
+
54
+ let diagnosticCollection;
55
+ let jslint;
56
+ let vscode;
57
+
58
+ function jslintClear() {
59
+ return vscode.window.withProgress({
60
+ cancellable: false,
61
+ location: vscode.ProgressLocation.Window,
62
+ title: "JSLint clear warnings ..."
63
+ }, async function (progress) {
64
+ progress.report({
65
+ increment: 0
66
+ });
67
+
68
+ // Clear "Problems" tab.
69
+
70
+ diagnosticCollection.clear();
71
+
72
+ // Wait awhile for flicker to give user visual confirmation "Problems" tab
73
+ // is refreshed.
74
+
75
+ await new Promise(function (resolve) {
76
+ setTimeout(resolve, 500);
77
+ });
78
+
79
+ progress.report({
80
+ increment: 100
81
+ });
82
+ });
83
+ }
84
+
85
+ function jslintLint({
86
+ document
87
+ }) {
88
+ return vscode.window.withProgress({
89
+ cancellable: false,
90
+ location: vscode.ProgressLocation.Window,
91
+ title: "JSLint lint file ..."
92
+ }, async function (progress) {
93
+ let result;
94
+ progress.report({
95
+ increment: 0
96
+ });
97
+
98
+ // Clear "Problems" tab.
99
+
100
+ diagnosticCollection.clear();
101
+ result = document.getText();
102
+ result = jslint.jslint(result);
103
+ result = result.warnings.slice(0, 100).map(function ({
104
+ column,
105
+ line,
106
+ // line_source,
107
+ message
108
+ }) {
109
+ return new vscode.Diagnostic(
110
+ // code: line_source,
111
+ {
112
+ end: {
113
+ character: column - 1,
114
+ line: line - 1
115
+ },
116
+ start: {
117
+ character: column - 1,
118
+ line: line - 1
119
+ }
120
+ },
121
+ `JSLint - ${message}`,
122
+ vscode.DiagnosticSeverity.Warning
123
+ );
124
+ });
125
+
126
+ // Wait awhile for flicker to give user visual confirmation "Problems" tab
127
+ // is refreshed.
128
+
129
+ await new Promise(function (resolve) {
130
+ setTimeout(resolve, 100);
131
+ });
132
+
133
+ // Update "Problems" tab.
134
+
135
+ diagnosticCollection.set(document.uri, result);
136
+ progress.report({
137
+ increment: 100
138
+ });
139
+ });
140
+ }
141
+
142
+ // Initialize vscode and jslint.
143
+
144
+ vscode = require("vscode");
145
+ diagnosticCollection = vscode.languages.createDiagnosticCollection(
146
+ "jslint"
147
+ );
148
+ require("vm").runInNewContext(
149
+ (
150
+ "\"use strict\";"
151
+ + require("fs").readFileSync( //jslint-quiet
152
+ __dirname + "/jslint.mjs",
153
+ "utf8"
154
+ ).replace(
155
+ "\nexport default Object.freeze(jslint_export);",
156
+ "\nmodule.exports = jslint_export;"
157
+ ).replace(
158
+ "\njslint_import_meta_url = import.meta.url;",
159
+ "\n// jslint_import_meta_url = import.meta.url;"
160
+ )
161
+ ),
162
+ {
163
+ module
164
+ }
165
+ );
166
+ jslint = module.exports;
167
+
168
+ // Register extension commands.
169
+
170
+ subscriptions.push(vscode.commands.registerTextEditorCommand((
171
+ "jslint.clear"
172
+ ), jslintClear));
173
+ subscriptions.push(vscode.commands.registerTextEditorCommand((
174
+ "jslint.lint"
175
+ ), jslintLint));
176
+ }
177
+
178
+ exports.activate = activate;
package/package.json CHANGED
@@ -2,22 +2,26 @@
2
2
  "bin": {
3
3
  "jslint": "./jslint.mjs"
4
4
  },
5
+ "bugs": {
6
+ "url": "https://github.com/jslint-org/jslint/issues"
7
+ },
5
8
  "counter": 7,
6
9
  "description": "JSLint, The JavaScript Code Quality and Coverage Tool",
7
10
  "exports": {
8
- "default": "./jslint.cjs",
11
+ "default": "./jslint_wrapper_cjs.cjs",
9
12
  "import": "./jslint.mjs"
10
13
  },
11
- "fileCount": 28,
14
+ "fileCount": 34,
12
15
  "keywords": [
13
16
  "coverage-report",
14
17
  "javascript",
15
18
  "jslint",
19
+ "linter",
16
20
  "zero-config",
17
21
  "zero-dependency"
18
22
  ],
19
23
  "license": "UNLICENSE",
20
- "main": "./jslint.cjs",
24
+ "main": "./jslint_wrapper_cjs.cjs",
21
25
  "module": "./jslint.mjs",
22
26
  "name": "@jslint-org/jslint",
23
27
  "repository": {
@@ -29,5 +33,5 @@
29
33
  "test2": "sh jslint_ci.sh shCiBase"
30
34
  },
31
35
  "type": "module",
32
- "version": "2021.12.20"
36
+ "version": "2022.5.20"
33
37
  }
package/jslint.cjs DELETED
@@ -1,14 +0,0 @@
1
- /*jslint beta, node*/
2
- /*property
3
- readFileSync, replace, runInNewContext
4
- */
5
- require("vm").runInNewContext(
6
- require("fs").readFileSync(__dirname + "/jslint.mjs", "utf8").replace(
7
- "\nexport default Object.freeze(jslint_export);",
8
- "\nexports = jslint_export;"
9
- ).replace(
10
- "\njslint_import_meta_url = import.meta.url;",
11
- "\n// jslint_import_meta_url = import.meta.url;"
12
- ),
13
- module
14
- );