@codemirror/lint 6.8.4 → 6.9.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 +16 -0
- package/dist/index.cjs +29 -15
- package/dist/index.d.cts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +29 -15
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
## 6.9.0 (2025-10-02)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Multiple configurations to `linter` will now be merged without raising an error.
|
|
6
|
+
|
|
7
|
+
### New features
|
|
8
|
+
|
|
9
|
+
The new `markClass` option to actions makes it possible to style action buttons.
|
|
10
|
+
|
|
11
|
+
## 6.8.5 (2025-03-26)
|
|
12
|
+
|
|
13
|
+
### Bug fixes
|
|
14
|
+
|
|
15
|
+
Fix a regression (since 6.8.4) that broke the `markerFilter` option.
|
|
16
|
+
|
|
1
17
|
## 6.8.4 (2024-11-28)
|
|
2
18
|
|
|
3
19
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -19,10 +19,9 @@ class LintState {
|
|
|
19
19
|
}
|
|
20
20
|
static init(diagnostics, panel, state$1) {
|
|
21
21
|
// Filter the list of diagnostics for which to create markers
|
|
22
|
-
let markedDiagnostics = diagnostics;
|
|
23
22
|
let diagnosticFilter = state$1.facet(lintConfig).markerFilter;
|
|
24
23
|
if (diagnosticFilter)
|
|
25
|
-
|
|
24
|
+
diagnostics = diagnosticFilter(diagnostics, state$1);
|
|
26
25
|
let sorted = diagnostics.slice().sort((a, b) => a.from - b.from || a.to - b.to);
|
|
27
26
|
let deco = new state.RangeSetBuilder(), active = [], pos = 0;
|
|
28
27
|
for (let i = 0;;) {
|
|
@@ -320,22 +319,36 @@ function batchResults(promises, sink, error) {
|
|
|
320
319
|
}
|
|
321
320
|
const lintConfig = state.Facet.define({
|
|
322
321
|
combine(input) {
|
|
323
|
-
return
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
322
|
+
return {
|
|
323
|
+
sources: input.map(i => i.source).filter(x => x != null),
|
|
324
|
+
...state.combineConfig(input.map(i => i.config), {
|
|
325
|
+
delay: 750,
|
|
326
|
+
markerFilter: null,
|
|
327
|
+
tooltipFilter: null,
|
|
328
|
+
needsRefresh: null,
|
|
329
|
+
hideOn: () => null,
|
|
330
|
+
}, {
|
|
331
|
+
delay: Math.max,
|
|
332
|
+
markerFilter: combineFilter,
|
|
333
|
+
tooltipFilter: combineFilter,
|
|
334
|
+
needsRefresh: (a, b) => !a ? b : !b ? a : u => a(u) || b(u),
|
|
335
|
+
hideOn: (a, b) => !a ? b : !b ? a : (t, x, y) => a(t, x, y) || b(t, x, y),
|
|
336
|
+
autoPanel: (a, b) => a || b
|
|
337
|
+
})
|
|
338
|
+
};
|
|
332
339
|
}
|
|
333
340
|
});
|
|
341
|
+
function combineFilter(a, b) {
|
|
342
|
+
return !a ? b : !b ? a : (d, s) => b(a(d, s), s);
|
|
343
|
+
}
|
|
334
344
|
/**
|
|
335
345
|
Given a diagnostic source, this function returns an extension that
|
|
336
346
|
enables linting with that source. It will be called whenever the
|
|
337
|
-
editor is idle (after its content changed).
|
|
338
|
-
|
|
347
|
+
editor is idle (after its content changed).
|
|
348
|
+
|
|
349
|
+
Note that settings given here will apply to all linters active in
|
|
350
|
+
the editor. If `null` is given as source, this only configures the
|
|
351
|
+
lint extension.
|
|
339
352
|
*/
|
|
340
353
|
function linter(source, config = {}) {
|
|
341
354
|
return [
|
|
@@ -385,9 +398,10 @@ function renderDiagnostic(view, diagnostic, inPanel) {
|
|
|
385
398
|
let nameElt = keyIndex < 0 ? name : [name.slice(0, keyIndex),
|
|
386
399
|
elt("u", name.slice(keyIndex, keyIndex + 1)),
|
|
387
400
|
name.slice(keyIndex + 1)];
|
|
401
|
+
let markClass = action.markClass ? " " + action.markClass : "";
|
|
388
402
|
return elt("button", {
|
|
389
403
|
type: "button",
|
|
390
|
-
class: "cm-diagnosticAction",
|
|
404
|
+
class: "cm-diagnosticAction" + markClass,
|
|
391
405
|
onclick: click,
|
|
392
406
|
onmousedown: click,
|
|
393
407
|
"aria-label": ` Action: ${name}${keyIndex < 0 ? "" : ` (access key "${keys[i]})"`}.`
|
|
@@ -810,7 +824,7 @@ const lintGutterTooltip = state.StateField.define({
|
|
|
810
824
|
create() { return null; },
|
|
811
825
|
update(tooltip, tr) {
|
|
812
826
|
if (tooltip && tr.docChanged)
|
|
813
|
-
tooltip = hideTooltip(tr, tooltip) ? null :
|
|
827
|
+
tooltip = hideTooltip(tr, tooltip) ? null : { ...tooltip, pos: tr.changes.mapPos(tooltip.pos) };
|
|
814
828
|
return tr.effects.reduce((t, e) => e.is(setLintGutterTooltip) ? e.value : t, tooltip);
|
|
815
829
|
},
|
|
816
830
|
provide: field => view.showTooltip.from(field)
|
package/dist/index.d.cts
CHANGED
|
@@ -56,6 +56,10 @@ interface Action {
|
|
|
56
56
|
*/
|
|
57
57
|
name: string;
|
|
58
58
|
/**
|
|
59
|
+
When given, add an extra CSS class to the action button.
|
|
60
|
+
*/
|
|
61
|
+
markClass?: string;
|
|
62
|
+
/**
|
|
59
63
|
The function to call when the user activates this action. Is
|
|
60
64
|
given the diagnostic's _current_ position, which may have
|
|
61
65
|
changed since the creation of the diagnostic, due to editing.
|
|
@@ -161,8 +165,11 @@ type LintSource = (view: EditorView) => readonly Diagnostic[] | Promise<readonly
|
|
|
161
165
|
/**
|
|
162
166
|
Given a diagnostic source, this function returns an extension that
|
|
163
167
|
enables linting with that source. It will be called whenever the
|
|
164
|
-
editor is idle (after its content changed).
|
|
165
|
-
|
|
168
|
+
editor is idle (after its content changed).
|
|
169
|
+
|
|
170
|
+
Note that settings given here will apply to all linters active in
|
|
171
|
+
the editor. If `null` is given as source, this only configures the
|
|
172
|
+
lint extension.
|
|
166
173
|
*/
|
|
167
174
|
declare function linter(source: LintSource | null, config?: LintConfig): Extension;
|
|
168
175
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -56,6 +56,10 @@ interface Action {
|
|
|
56
56
|
*/
|
|
57
57
|
name: string;
|
|
58
58
|
/**
|
|
59
|
+
When given, add an extra CSS class to the action button.
|
|
60
|
+
*/
|
|
61
|
+
markClass?: string;
|
|
62
|
+
/**
|
|
59
63
|
The function to call when the user activates this action. Is
|
|
60
64
|
given the diagnostic's _current_ position, which may have
|
|
61
65
|
changed since the creation of the diagnostic, due to editing.
|
|
@@ -161,8 +165,11 @@ type LintSource = (view: EditorView) => readonly Diagnostic[] | Promise<readonly
|
|
|
161
165
|
/**
|
|
162
166
|
Given a diagnostic source, this function returns an extension that
|
|
163
167
|
enables linting with that source. It will be called whenever the
|
|
164
|
-
editor is idle (after its content changed).
|
|
165
|
-
|
|
168
|
+
editor is idle (after its content changed).
|
|
169
|
+
|
|
170
|
+
Note that settings given here will apply to all linters active in
|
|
171
|
+
the editor. If `null` is given as source, this only configures the
|
|
172
|
+
lint extension.
|
|
166
173
|
*/
|
|
167
174
|
declare function linter(source: LintSource | null, config?: LintConfig): Extension;
|
|
168
175
|
/**
|
package/dist/index.js
CHANGED
|
@@ -17,10 +17,9 @@ class LintState {
|
|
|
17
17
|
}
|
|
18
18
|
static init(diagnostics, panel, state) {
|
|
19
19
|
// Filter the list of diagnostics for which to create markers
|
|
20
|
-
let markedDiagnostics = diagnostics;
|
|
21
20
|
let diagnosticFilter = state.facet(lintConfig).markerFilter;
|
|
22
21
|
if (diagnosticFilter)
|
|
23
|
-
|
|
22
|
+
diagnostics = diagnosticFilter(diagnostics, state);
|
|
24
23
|
let sorted = diagnostics.slice().sort((a, b) => a.from - b.from || a.to - b.to);
|
|
25
24
|
let deco = new RangeSetBuilder(), active = [], pos = 0;
|
|
26
25
|
for (let i = 0;;) {
|
|
@@ -318,22 +317,36 @@ function batchResults(promises, sink, error) {
|
|
|
318
317
|
}
|
|
319
318
|
const lintConfig = /*@__PURE__*/Facet.define({
|
|
320
319
|
combine(input) {
|
|
321
|
-
return
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
320
|
+
return {
|
|
321
|
+
sources: input.map(i => i.source).filter(x => x != null),
|
|
322
|
+
...combineConfig(input.map(i => i.config), {
|
|
323
|
+
delay: 750,
|
|
324
|
+
markerFilter: null,
|
|
325
|
+
tooltipFilter: null,
|
|
326
|
+
needsRefresh: null,
|
|
327
|
+
hideOn: () => null,
|
|
328
|
+
}, {
|
|
329
|
+
delay: Math.max,
|
|
330
|
+
markerFilter: combineFilter,
|
|
331
|
+
tooltipFilter: combineFilter,
|
|
332
|
+
needsRefresh: (a, b) => !a ? b : !b ? a : u => a(u) || b(u),
|
|
333
|
+
hideOn: (a, b) => !a ? b : !b ? a : (t, x, y) => a(t, x, y) || b(t, x, y),
|
|
334
|
+
autoPanel: (a, b) => a || b
|
|
335
|
+
})
|
|
336
|
+
};
|
|
330
337
|
}
|
|
331
338
|
});
|
|
339
|
+
function combineFilter(a, b) {
|
|
340
|
+
return !a ? b : !b ? a : (d, s) => b(a(d, s), s);
|
|
341
|
+
}
|
|
332
342
|
/**
|
|
333
343
|
Given a diagnostic source, this function returns an extension that
|
|
334
344
|
enables linting with that source. It will be called whenever the
|
|
335
|
-
editor is idle (after its content changed).
|
|
336
|
-
|
|
345
|
+
editor is idle (after its content changed).
|
|
346
|
+
|
|
347
|
+
Note that settings given here will apply to all linters active in
|
|
348
|
+
the editor. If `null` is given as source, this only configures the
|
|
349
|
+
lint extension.
|
|
337
350
|
*/
|
|
338
351
|
function linter(source, config = {}) {
|
|
339
352
|
return [
|
|
@@ -383,9 +396,10 @@ function renderDiagnostic(view, diagnostic, inPanel) {
|
|
|
383
396
|
let nameElt = keyIndex < 0 ? name : [name.slice(0, keyIndex),
|
|
384
397
|
elt("u", name.slice(keyIndex, keyIndex + 1)),
|
|
385
398
|
name.slice(keyIndex + 1)];
|
|
399
|
+
let markClass = action.markClass ? " " + action.markClass : "";
|
|
386
400
|
return elt("button", {
|
|
387
401
|
type: "button",
|
|
388
|
-
class: "cm-diagnosticAction",
|
|
402
|
+
class: "cm-diagnosticAction" + markClass,
|
|
389
403
|
onclick: click,
|
|
390
404
|
onmousedown: click,
|
|
391
405
|
"aria-label": ` Action: ${name}${keyIndex < 0 ? "" : ` (access key "${keys[i]})"`}.`
|
|
@@ -808,7 +822,7 @@ const lintGutterTooltip = /*@__PURE__*/StateField.define({
|
|
|
808
822
|
create() { return null; },
|
|
809
823
|
update(tooltip, tr) {
|
|
810
824
|
if (tooltip && tr.docChanged)
|
|
811
|
-
tooltip = hideTooltip(tr, tooltip) ? null :
|
|
825
|
+
tooltip = hideTooltip(tr, tooltip) ? null : { ...tooltip, pos: tr.changes.mapPos(tooltip.pos) };
|
|
812
826
|
return tr.effects.reduce((t, e) => e.is(setLintGutterTooltip) ? e.value : t, tooltip);
|
|
813
827
|
},
|
|
814
828
|
provide: field => showTooltip.from(field)
|