Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@codemirror/lint

Package Overview
Dependencies
Maintainers
2
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codemirror/lint - npm Package Compare versions

Comparing version 6.4.2 to 6.5.0

12

CHANGELOG.md

@@ -0,1 +1,13 @@

## 6.5.0 (2024-01-30)
### Bug fixes
Make lint mark decorations inclusive, so that they are applied even if the marked content is replaced by a widget decoration.
### New features
`linter` can now be called with null as source to only provide a configuration.
`markerFilter` and `tooltipFilter` function now get passed the current editor state.
## 6.4.2 (2023-09-14)

@@ -2,0 +14,0 @@

9

dist/index.d.ts

@@ -65,3 +65,3 @@ import * as _codemirror_state from '@codemirror/state';

}
type DiagnosticFilter = (diagnostics: readonly Diagnostic[]) => Diagnostic[];
type DiagnosticFilter = (diagnostics: readonly Diagnostic[], state: EditorState) => Diagnostic[];
interface LintConfig {

@@ -151,5 +151,6 @@ /**

enables linting with that source. It will be called whenever the
editor is idle (after its content changed).
editor is idle (after its content changed). If `null` is given as
source, this only configures the lint extension.
*/
declare function linter(source: LintSource, config?: LintConfig): Extension;
declare function linter(source: LintSource | null, config?: LintConfig): Extension;
/**

@@ -175,2 +176,2 @@ Forces any linters [configured](https://codemirror.net/6/docs/ref/#lint.linter) to run when the

export { Action, Diagnostic, LintSource, closeLintPanel, diagnosticCount, forEachDiagnostic, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, previousDiagnostic, setDiagnostics, setDiagnosticsEffect };
export { type Action, type Diagnostic, type LintSource, closeLintPanel, diagnosticCount, forEachDiagnostic, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, previousDiagnostic, setDiagnostics, setDiagnosticsEffect };

@@ -23,3 +23,3 @@ import { Decoration, showPanel, EditorView, ViewPlugin, logException, gutter, showTooltip, hoverTooltip, getPanel, WidgetType, GutterMarker } from '@codemirror/view';

if (diagnosticFilter)
markedDiagnostics = diagnosticFilter(markedDiagnostics);
markedDiagnostics = diagnosticFilter(markedDiagnostics, state);
let ranges = Decoration.set(markedDiagnostics.map((d) => {

@@ -34,3 +34,4 @@ // For zero-length ranges or ranges covering only a line break, create a widget

attributes: { class: "cm-lintRange cm-lintRange-" + d.severity + (d.markClass ? " " + d.markClass : "") },
diagnostic: d
diagnostic: d,
inclusive: true
}).range(d.from, d.to);

@@ -111,3 +112,3 @@ }), true);

}
const activeMark = /*@__PURE__*/Decoration.mark({ class: "cm-lintRange cm-lintRange-active" });
const activeMark = /*@__PURE__*/Decoration.mark({ class: "cm-lintRange cm-lintRange-active", inclusive: true });
function lintTooltip(view, pos, side) {

@@ -126,3 +127,3 @@ let { diagnostics } = view.state.field(lintState);

if (diagnosticFilter)
found = diagnosticFilter(found);
found = diagnosticFilter(found, view.state);
if (!found.length)

@@ -232,7 +233,8 @@ return null;

let { state } = this.view, { sources } = state.facet(lintConfig);
Promise.all(sources.map(source => Promise.resolve(source(this.view)))).then(annotations => {
let all = annotations.reduce((a, b) => a.concat(b));
if (this.view.state.doc == state.doc)
this.view.dispatch(setDiagnostics(this.view.state, all));
}, error => { logException(this.view.state, error); });
if (sources.length)
Promise.all(sources.map(source => Promise.resolve(source(this.view)))).then(annotations => {
let all = annotations.reduce((a, b) => a.concat(b));
if (this.view.state.doc == state.doc)
this.view.dispatch(setDiagnostics(this.view.state, all));
}, error => { logException(this.view.state, error); });
}

@@ -263,3 +265,3 @@ }

combine(input) {
return Object.assign({ sources: input.map(i => i.source) }, combineConfig(input.map(i => i.config), {
return Object.assign({ sources: input.map(i => i.source).filter(x => x != null) }, combineConfig(input.map(i => i.config), {
delay: 750,

@@ -277,3 +279,4 @@ markerFilter: null,

enables linting with that source. It will be called whenever the
editor is idle (after its content changed).
editor is idle (after its content changed). If `null` is given as
source, this only configures the lint extension.
*/

@@ -636,3 +639,3 @@ function linter(source, config = {}) {

if (diagnosticsFilter)
diagnostics = diagnosticsFilter(diagnostics);
diagnostics = diagnosticsFilter(diagnostics, view.state);
if (diagnostics.length)

@@ -716,3 +719,3 @@ elt.onmouseover = () => gutterMarkerMouseOver(view, elt, diagnostics);

if (diagnosticFilter)
diagnostics = diagnosticFilter(diagnostics || []);
diagnostics = diagnosticFilter(diagnostics || [], tr.state);
markers = markersForDiagnostics(tr.state.doc, diagnostics.slice(0));

@@ -719,0 +722,0 @@ }

{
"name": "@codemirror/lint",
"version": "6.4.2",
"version": "6.5.0",
"description": "Linting support for the CodeMirror code editor",

@@ -5,0 +5,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc