@codemirror/lint 6.3.0 → 6.4.0
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 +8 -0
- package/dist/index.cjs +10 -5
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +10 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 6.4.0 (2023-07-03)
|
|
2
|
+
|
|
3
|
+
### New features
|
|
4
|
+
|
|
5
|
+
Diagnostics can now use `"hint"` as a severity level.
|
|
6
|
+
|
|
7
|
+
Diagnostics can now set a `markClass` property to add an additional CSS class to the text marked by the diagnostic.
|
|
8
|
+
|
|
1
9
|
## 6.3.0 (2023-06-23)
|
|
2
10
|
|
|
3
11
|
### New features
|
package/dist/index.cjs
CHANGED
|
@@ -37,7 +37,7 @@ class LintState {
|
|
|
37
37
|
diagnostic: d
|
|
38
38
|
}).range(d.from)
|
|
39
39
|
: view.Decoration.mark({
|
|
40
|
-
attributes: { class: "cm-lintRange cm-lintRange-" + d.severity },
|
|
40
|
+
attributes: { class: "cm-lintRange cm-lintRange-" + d.severity + (d.markClass ? " " + d.markClass : "") },
|
|
41
41
|
diagnostic: d
|
|
42
42
|
}).range(d.from, d.to);
|
|
43
43
|
}), true);
|
|
@@ -537,6 +537,7 @@ const baseTheme = view.EditorView.baseTheme({
|
|
|
537
537
|
".cm-diagnostic-error": { borderLeft: "5px solid #d11" },
|
|
538
538
|
".cm-diagnostic-warning": { borderLeft: "5px solid orange" },
|
|
539
539
|
".cm-diagnostic-info": { borderLeft: "5px solid #999" },
|
|
540
|
+
".cm-diagnostic-hint": { borderLeft: "5px solid #66d" },
|
|
540
541
|
".cm-diagnosticAction": {
|
|
541
542
|
font: "inherit",
|
|
542
543
|
border: "none",
|
|
@@ -559,6 +560,7 @@ const baseTheme = view.EditorView.baseTheme({
|
|
|
559
560
|
".cm-lintRange-error": { backgroundImage: underline("#d11") },
|
|
560
561
|
".cm-lintRange-warning": { backgroundImage: underline("orange") },
|
|
561
562
|
".cm-lintRange-info": { backgroundImage: underline("#999") },
|
|
563
|
+
".cm-lintRange-hint": { backgroundImage: underline("#66d") },
|
|
562
564
|
".cm-lintRange-active": { backgroundColor: "#ffdd9980" },
|
|
563
565
|
".cm-tooltip-lint": {
|
|
564
566
|
padding: 0,
|
|
@@ -582,6 +584,9 @@ const baseTheme = view.EditorView.baseTheme({
|
|
|
582
584
|
".cm-lintPoint-info": {
|
|
583
585
|
"&:after": { borderBottomColor: "#999" }
|
|
584
586
|
},
|
|
587
|
+
".cm-lintPoint-hint": {
|
|
588
|
+
"&:after": { borderBottomColor: "#66d" }
|
|
589
|
+
},
|
|
585
590
|
".cm-panel.cm-panel-lint": {
|
|
586
591
|
position: "relative",
|
|
587
592
|
"& ul": {
|
|
@@ -613,14 +618,14 @@ const baseTheme = view.EditorView.baseTheme({
|
|
|
613
618
|
}
|
|
614
619
|
}
|
|
615
620
|
});
|
|
621
|
+
function severityWeight(sev) {
|
|
622
|
+
return sev == "error" ? 4 : sev == "warning" ? 3 : sev == "info" ? 2 : 1;
|
|
623
|
+
}
|
|
616
624
|
class LintGutterMarker extends view.GutterMarker {
|
|
617
625
|
constructor(diagnostics) {
|
|
618
626
|
super();
|
|
619
627
|
this.diagnostics = diagnostics;
|
|
620
|
-
this.severity = diagnostics.reduce((max, d) =>
|
|
621
|
-
let s = d.severity;
|
|
622
|
-
return s == "error" || s == "warning" && max == "info" ? s : max;
|
|
623
|
-
}, "info");
|
|
628
|
+
this.severity = diagnostics.reduce((max, d) => severityWeight(max) < severityWeight(d.severity) ? d.severity : max, "hint");
|
|
624
629
|
}
|
|
625
630
|
toDOM(view) {
|
|
626
631
|
let elt = document.createElement("div");
|
package/dist/index.d.cts
CHANGED
|
@@ -2,6 +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
|
+
declare type Severity = "hint" | "info" | "warning" | "error";
|
|
5
6
|
/**
|
|
6
7
|
Describes a problem or hint for a piece of code.
|
|
7
8
|
*/
|
|
@@ -19,7 +20,12 @@ interface Diagnostic {
|
|
|
19
20
|
The severity of the problem. This will influence how it is
|
|
20
21
|
displayed.
|
|
21
22
|
*/
|
|
22
|
-
severity:
|
|
23
|
+
severity: Severity;
|
|
24
|
+
/**
|
|
25
|
+
When given, add an extra CSS class to parts of the code that
|
|
26
|
+
this diagnostic applies to.
|
|
27
|
+
*/
|
|
28
|
+
markClass?: string;
|
|
23
29
|
/**
|
|
24
30
|
An optional source string indicating where the diagnostic is
|
|
25
31
|
coming from. You can put the name of your linter here, if
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +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
|
+
declare type Severity = "hint" | "info" | "warning" | "error";
|
|
5
6
|
/**
|
|
6
7
|
Describes a problem or hint for a piece of code.
|
|
7
8
|
*/
|
|
@@ -19,7 +20,12 @@ interface Diagnostic {
|
|
|
19
20
|
The severity of the problem. This will influence how it is
|
|
20
21
|
displayed.
|
|
21
22
|
*/
|
|
22
|
-
severity:
|
|
23
|
+
severity: Severity;
|
|
24
|
+
/**
|
|
25
|
+
When given, add an extra CSS class to parts of the code that
|
|
26
|
+
this diagnostic applies to.
|
|
27
|
+
*/
|
|
28
|
+
markClass?: string;
|
|
23
29
|
/**
|
|
24
30
|
An optional source string indicating where the diagnostic is
|
|
25
31
|
coming from. You can put the name of your linter here, if
|
package/dist/index.js
CHANGED
|
@@ -29,7 +29,7 @@ class LintState {
|
|
|
29
29
|
diagnostic: d
|
|
30
30
|
}).range(d.from)
|
|
31
31
|
: Decoration.mark({
|
|
32
|
-
attributes: { class: "cm-lintRange cm-lintRange-" + d.severity },
|
|
32
|
+
attributes: { class: "cm-lintRange cm-lintRange-" + d.severity + (d.markClass ? " " + d.markClass : "") },
|
|
33
33
|
diagnostic: d
|
|
34
34
|
}).range(d.from, d.to);
|
|
35
35
|
}), true);
|
|
@@ -529,6 +529,7 @@ const baseTheme = /*@__PURE__*/EditorView.baseTheme({
|
|
|
529
529
|
".cm-diagnostic-error": { borderLeft: "5px solid #d11" },
|
|
530
530
|
".cm-diagnostic-warning": { borderLeft: "5px solid orange" },
|
|
531
531
|
".cm-diagnostic-info": { borderLeft: "5px solid #999" },
|
|
532
|
+
".cm-diagnostic-hint": { borderLeft: "5px solid #66d" },
|
|
532
533
|
".cm-diagnosticAction": {
|
|
533
534
|
font: "inherit",
|
|
534
535
|
border: "none",
|
|
@@ -551,6 +552,7 @@ const baseTheme = /*@__PURE__*/EditorView.baseTheme({
|
|
|
551
552
|
".cm-lintRange-error": { backgroundImage: /*@__PURE__*/underline("#d11") },
|
|
552
553
|
".cm-lintRange-warning": { backgroundImage: /*@__PURE__*/underline("orange") },
|
|
553
554
|
".cm-lintRange-info": { backgroundImage: /*@__PURE__*/underline("#999") },
|
|
555
|
+
".cm-lintRange-hint": { backgroundImage: /*@__PURE__*/underline("#66d") },
|
|
554
556
|
".cm-lintRange-active": { backgroundColor: "#ffdd9980" },
|
|
555
557
|
".cm-tooltip-lint": {
|
|
556
558
|
padding: 0,
|
|
@@ -574,6 +576,9 @@ const baseTheme = /*@__PURE__*/EditorView.baseTheme({
|
|
|
574
576
|
".cm-lintPoint-info": {
|
|
575
577
|
"&:after": { borderBottomColor: "#999" }
|
|
576
578
|
},
|
|
579
|
+
".cm-lintPoint-hint": {
|
|
580
|
+
"&:after": { borderBottomColor: "#66d" }
|
|
581
|
+
},
|
|
577
582
|
".cm-panel.cm-panel-lint": {
|
|
578
583
|
position: "relative",
|
|
579
584
|
"& ul": {
|
|
@@ -605,14 +610,14 @@ const baseTheme = /*@__PURE__*/EditorView.baseTheme({
|
|
|
605
610
|
}
|
|
606
611
|
}
|
|
607
612
|
});
|
|
613
|
+
function severityWeight(sev) {
|
|
614
|
+
return sev == "error" ? 4 : sev == "warning" ? 3 : sev == "info" ? 2 : 1;
|
|
615
|
+
}
|
|
608
616
|
class LintGutterMarker extends GutterMarker {
|
|
609
617
|
constructor(diagnostics) {
|
|
610
618
|
super();
|
|
611
619
|
this.diagnostics = diagnostics;
|
|
612
|
-
this.severity = diagnostics.reduce((max, d) =>
|
|
613
|
-
let s = d.severity;
|
|
614
|
-
return s == "error" || s == "warning" && max == "info" ? s : max;
|
|
615
|
-
}, "info");
|
|
620
|
+
this.severity = diagnostics.reduce((max, d) => severityWeight(max) < severityWeight(d.severity) ? d.severity : max, "hint");
|
|
616
621
|
}
|
|
617
622
|
toDOM(view) {
|
|
618
623
|
let elt = document.createElement("div");
|