@codemirror/lint 6.4.0 → 6.4.1
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/CHANGELOG.md +6 -0
- package/dist/index.cjs +12 -18
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var view = require('@codemirror/view');
|
|
6
4
|
var state = require('@codemirror/state');
|
|
7
5
|
var elt = require('crelt');
|
|
8
6
|
|
|
9
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
-
|
|
11
|
-
var elt__default = /*#__PURE__*/_interopDefaultLegacy(elt);
|
|
12
|
-
|
|
13
7
|
class SelectedDiagnostic {
|
|
14
8
|
constructor(from, to, diagnostic) {
|
|
15
9
|
this.from = from;
|
|
@@ -141,7 +135,7 @@ function lintTooltip(view, pos, side) {
|
|
|
141
135
|
};
|
|
142
136
|
}
|
|
143
137
|
function diagnosticsTooltip(view, diagnostics) {
|
|
144
|
-
return
|
|
138
|
+
return elt("ul", { class: "cm-tooltip-lint" }, diagnostics.map(d => renderDiagnostic(view, d, false)));
|
|
145
139
|
}
|
|
146
140
|
/**
|
|
147
141
|
Command to open and focus the lint panel.
|
|
@@ -228,7 +222,7 @@ const lintPlugin = view.ViewPlugin.fromClass(class {
|
|
|
228
222
|
run() {
|
|
229
223
|
let now = Date.now();
|
|
230
224
|
if (now < this.lintTime - 10) {
|
|
231
|
-
setTimeout(this.run, this.lintTime - now);
|
|
225
|
+
this.timeout = setTimeout(this.run, this.lintTime - now);
|
|
232
226
|
}
|
|
233
227
|
else {
|
|
234
228
|
this.set = false;
|
|
@@ -312,7 +306,7 @@ function assignKeys(actions) {
|
|
|
312
306
|
function renderDiagnostic(view, diagnostic, inPanel) {
|
|
313
307
|
var _a;
|
|
314
308
|
let keys = inPanel ? assignKeys(diagnostic.actions) : [];
|
|
315
|
-
return
|
|
309
|
+
return elt("li", { class: "cm-diagnostic cm-diagnostic-" + diagnostic.severity }, elt("span", { class: "cm-diagnosticText" }, diagnostic.renderMessage ? diagnostic.renderMessage() : diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map((action, i) => {
|
|
316
310
|
let fired = false, click = (e) => {
|
|
317
311
|
e.preventDefault();
|
|
318
312
|
if (fired)
|
|
@@ -324,16 +318,16 @@ function renderDiagnostic(view, diagnostic, inPanel) {
|
|
|
324
318
|
};
|
|
325
319
|
let { name } = action, keyIndex = keys[i] ? name.indexOf(keys[i]) : -1;
|
|
326
320
|
let nameElt = keyIndex < 0 ? name : [name.slice(0, keyIndex),
|
|
327
|
-
|
|
321
|
+
elt("u", name.slice(keyIndex, keyIndex + 1)),
|
|
328
322
|
name.slice(keyIndex + 1)];
|
|
329
|
-
return
|
|
323
|
+
return elt("button", {
|
|
330
324
|
type: "button",
|
|
331
325
|
class: "cm-diagnosticAction",
|
|
332
326
|
onclick: click,
|
|
333
327
|
onmousedown: click,
|
|
334
328
|
"aria-label": ` Action: ${name}${keyIndex < 0 ? "" : ` (access key "${keys[i]})"`}.`
|
|
335
329
|
}, nameElt);
|
|
336
|
-
}), diagnostic.source &&
|
|
330
|
+
}), diagnostic.source && elt("div", { class: "cm-diagnosticSource" }, diagnostic.source));
|
|
337
331
|
}
|
|
338
332
|
class DiagnosticWidget extends view.WidgetType {
|
|
339
333
|
constructor(diagnostic) {
|
|
@@ -342,7 +336,7 @@ class DiagnosticWidget extends view.WidgetType {
|
|
|
342
336
|
}
|
|
343
337
|
eq(other) { return other.diagnostic == this.diagnostic; }
|
|
344
338
|
toDOM() {
|
|
345
|
-
return
|
|
339
|
+
return elt("span", { class: "cm-lintPoint cm-lintPoint-" + this.diagnostic.severity });
|
|
346
340
|
}
|
|
347
341
|
}
|
|
348
342
|
class PanelItem {
|
|
@@ -398,14 +392,14 @@ class LintPanel {
|
|
|
398
392
|
this.moveSelection(i);
|
|
399
393
|
}
|
|
400
394
|
};
|
|
401
|
-
this.list =
|
|
395
|
+
this.list = elt("ul", {
|
|
402
396
|
tabIndex: 0,
|
|
403
397
|
role: "listbox",
|
|
404
398
|
"aria-label": this.view.state.phrase("Diagnostics"),
|
|
405
399
|
onkeydown,
|
|
406
400
|
onclick
|
|
407
401
|
});
|
|
408
|
-
this.dom =
|
|
402
|
+
this.dom = elt("div", { class: "cm-panel-lint" }, this.list, elt("button", {
|
|
409
403
|
type: "button",
|
|
410
404
|
name: "close",
|
|
411
405
|
"aria-label": this.view.state.phrase("close"),
|
|
@@ -642,8 +636,8 @@ class LintGutterMarker extends view.GutterMarker {
|
|
|
642
636
|
function trackHoverOn(view, marker) {
|
|
643
637
|
let mousemove = (event) => {
|
|
644
638
|
let rect = marker.getBoundingClientRect();
|
|
645
|
-
if (event.clientX > rect.left - 10 /* Margin */ && event.clientX < rect.right + 10 /* Margin */ &&
|
|
646
|
-
event.clientY > rect.top - 10 /* Margin */ && event.clientY < rect.bottom + 10 /* Margin */)
|
|
639
|
+
if (event.clientX > rect.left - 10 /* Hover.Margin */ && event.clientX < rect.right + 10 /* Hover.Margin */ &&
|
|
640
|
+
event.clientY > rect.top - 10 /* Hover.Margin */ && event.clientY < rect.bottom + 10 /* Hover.Margin */)
|
|
647
641
|
return;
|
|
648
642
|
for (let target = event.target; target; target = target.parentNode) {
|
|
649
643
|
if (target.nodeType == 1 && target.classList.contains("cm-tooltip-lint"))
|
|
@@ -764,7 +758,7 @@ const lintExtensions = [
|
|
|
764
758
|
const lintGutterConfig = state.Facet.define({
|
|
765
759
|
combine(configs) {
|
|
766
760
|
return state.combineConfig(configs, {
|
|
767
|
-
hoverTime: 300 /* Time */,
|
|
761
|
+
hoverTime: 300 /* Hover.Time */,
|
|
768
762
|
markerFilter: null,
|
|
769
763
|
tooltipFilter: null
|
|
770
764
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import * as _codemirror_state from '@codemirror/state';
|
|
|
2
2
|
import { EditorState, TransactionSpec, Extension } from '@codemirror/state';
|
|
3
3
|
import { EditorView, Command, KeyBinding, ViewUpdate } from '@codemirror/view';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
type Severity = "hint" | "info" | "warning" | "error";
|
|
6
6
|
/**
|
|
7
7
|
Describes a problem or hint for a piece of code.
|
|
8
8
|
*/
|
|
@@ -62,7 +62,7 @@ interface Action {
|
|
|
62
62
|
*/
|
|
63
63
|
apply: (view: EditorView, from: number, to: number) => void;
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
type DiagnosticFilter = (diagnostics: readonly Diagnostic[]) => Diagnostic[];
|
|
66
66
|
interface LintConfig {
|
|
67
67
|
/**
|
|
68
68
|
Time to wait (in milliseconds) after a change before running
|
|
@@ -143,7 +143,7 @@ declare const lintKeymap: readonly KeyBinding[];
|
|
|
143
143
|
/**
|
|
144
144
|
The type of a function that produces diagnostics.
|
|
145
145
|
*/
|
|
146
|
-
|
|
146
|
+
type LintSource = (view: EditorView) => readonly Diagnostic[] | Promise<readonly Diagnostic[]>;
|
|
147
147
|
/**
|
|
148
148
|
Given a diagnostic source, this function returns an extension that
|
|
149
149
|
enables linting with that source. It will be called whenever the
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as _codemirror_state from '@codemirror/state';
|
|
|
2
2
|
import { EditorState, TransactionSpec, Extension } from '@codemirror/state';
|
|
3
3
|
import { EditorView, Command, KeyBinding, ViewUpdate } from '@codemirror/view';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
type Severity = "hint" | "info" | "warning" | "error";
|
|
6
6
|
/**
|
|
7
7
|
Describes a problem or hint for a piece of code.
|
|
8
8
|
*/
|
|
@@ -62,7 +62,7 @@ interface Action {
|
|
|
62
62
|
*/
|
|
63
63
|
apply: (view: EditorView, from: number, to: number) => void;
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
type DiagnosticFilter = (diagnostics: readonly Diagnostic[]) => Diagnostic[];
|
|
66
66
|
interface LintConfig {
|
|
67
67
|
/**
|
|
68
68
|
Time to wait (in milliseconds) after a change before running
|
|
@@ -143,7 +143,7 @@ declare const lintKeymap: readonly KeyBinding[];
|
|
|
143
143
|
/**
|
|
144
144
|
The type of a function that produces diagnostics.
|
|
145
145
|
*/
|
|
146
|
-
|
|
146
|
+
type LintSource = (view: EditorView) => readonly Diagnostic[] | Promise<readonly Diagnostic[]>;
|
|
147
147
|
/**
|
|
148
148
|
Given a diagnostic source, this function returns an extension that
|
|
149
149
|
enables linting with that source. It will be called whenever the
|
package/dist/index.js
CHANGED
|
@@ -220,7 +220,7 @@ const lintPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
220
220
|
run() {
|
|
221
221
|
let now = Date.now();
|
|
222
222
|
if (now < this.lintTime - 10) {
|
|
223
|
-
setTimeout(this.run, this.lintTime - now);
|
|
223
|
+
this.timeout = setTimeout(this.run, this.lintTime - now);
|
|
224
224
|
}
|
|
225
225
|
else {
|
|
226
226
|
this.set = false;
|
|
@@ -634,8 +634,8 @@ class LintGutterMarker extends GutterMarker {
|
|
|
634
634
|
function trackHoverOn(view, marker) {
|
|
635
635
|
let mousemove = (event) => {
|
|
636
636
|
let rect = marker.getBoundingClientRect();
|
|
637
|
-
if (event.clientX > rect.left - 10 /* Margin */ && event.clientX < rect.right + 10 /* Margin */ &&
|
|
638
|
-
event.clientY > rect.top - 10 /* Margin */ && event.clientY < rect.bottom + 10 /* Margin */)
|
|
637
|
+
if (event.clientX > rect.left - 10 /* Hover.Margin */ && event.clientX < rect.right + 10 /* Hover.Margin */ &&
|
|
638
|
+
event.clientY > rect.top - 10 /* Hover.Margin */ && event.clientY < rect.bottom + 10 /* Hover.Margin */)
|
|
639
639
|
return;
|
|
640
640
|
for (let target = event.target; target; target = target.parentNode) {
|
|
641
641
|
if (target.nodeType == 1 && target.classList.contains("cm-tooltip-lint"))
|
|
@@ -756,7 +756,7 @@ const lintExtensions = [
|
|
|
756
756
|
const lintGutterConfig = /*@__PURE__*/Facet.define({
|
|
757
757
|
combine(configs) {
|
|
758
758
|
return combineConfig(configs, {
|
|
759
|
-
hoverTime: 300 /* Time */,
|
|
759
|
+
hoverTime: 300 /* Hover.Time */,
|
|
760
760
|
markerFilter: null,
|
|
761
761
|
tooltipFilter: null
|
|
762
762
|
});
|