Socket
Socket
Sign inDemoInstall

@codemirror/lint

Package Overview
Dependencies
5
Maintainers
2
Versions
36
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.18.0 to 0.18.1

6

CHANGELOG.md

@@ -0,1 +1,7 @@

## 0.18.1 (2021-03-15)
### Bug fixes
Adjust to current @codemirror/panel and @codemirror/tooltip interfaces.
## 0.18.0 (2021-03-03)

@@ -2,0 +8,0 @@

import { EditorView, Command, KeyBinding } from '@codemirror/view';
import { EditorState, TransactionSpec, Extension } from '@codemirror/state';
/**
Describes a problem or hint for a piece of code.
*/
interface Diagnostic {
/**
The start position of the relevant text.
*/
from: number;
/**
The end position. May be equal to `from`, though actually
covering text is preferable.
*/
to: number;
/**
The severity of the problem. This will influence how it is
displayed.
*/
severity: "info" | "warning" | "error";
/**
An optional source string indicating where the diagnostic is
coming from. You can put the name of your linter here, if
applicable.
*/
source?: string;
/**
The message associated with this diagnostic.
*/
message: string;
/**
An optional array of actions that can be taken on this
diagnostic.
*/
actions?: readonly Action[];
}
/**
An action associated with a diagnostic.
*/
interface Action {
/**
The label to show to the user. Should be relatively short.
*/
name: string;
/**
The function to call when the user activates this action. Is
given the diagnostic's _current_ position, which may have
changed since the creation of the diagnostic due to editing.
*/
apply: (view: EditorView, from: number, to: number) => void;
}
/**
State effect that is used to update the current set of
diagnostics.
*/
declare function setDiagnostics(state: EditorState, diagnostics: readonly Diagnostic[]): TransactionSpec;
/**
Command to open and focus the lint panel.
*/
declare const openLintPanel: Command;
/**
Command to close the lint panel, when open.
*/
declare const closeLintPanel: Command;
/**
Move the selection to the next diagnostic.
*/
declare const nextDiagnostic: Command;
/**
A set of default key bindings for the lint functionality.
- Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](https://codemirror.net/6/docs/ref/#lint.openLintPanel)
- F8: [`nextDiagnostic`](https://codemirror.net/6/docs/ref/#lint.nextDiagnostic)
*/
declare const lintKeymap: readonly KeyBinding[];
/**
Given a diagnostic source, this function returns an extension that
enables linting with that source. It will be called whenever the
editor is idle (after its content changed).
*/
declare function linter(source: (view: EditorView) => readonly Diagnostic[] | Promise<readonly Diagnostic[]>): Extension;
export { Action, Diagnostic, closeLintPanel, lintKeymap, linter, nextDiagnostic, openLintPanel, setDiagnostics };

47

dist/index.js
import { EditorView, Decoration, ViewPlugin, logException, WidgetType } from '@codemirror/view';
import { StateEffect, StateField } from '@codemirror/state';
import { hoverTooltip } from '@codemirror/tooltip';
import { panels, showPanel, getPanel } from '@codemirror/panel';
import { showPanel, getPanel } from '@codemirror/panel';
import elt from 'crelt';

@@ -40,3 +40,2 @@

}),
panels(),
hoverTooltip(lintTooltip),

@@ -46,4 +45,6 @@ baseTheme

}
/// State effect that is used to update the current set of
/// diagnostics.
/**
State effect that is used to update the current set of
diagnostics.
*/
function setDiagnostics(state, diagnostics) {

@@ -94,3 +95,3 @@ return {

},
provide: f => [showPanel.computeN([f], s => { let { panel } = s.field(f); return panel ? [panel] : []; }),
provide: f => [showPanel.from(f, val => val.panel),
EditorView.decorations.from(f, s => s.diagnostics)]

@@ -116,9 +117,10 @@ });

above: view.state.doc.lineAt(stackStart).to < stackEnd,
class: "cm-tooltip-lint",
create() {
return { dom: elt("ul", found.map(d => renderDiagnostic(view, d, false))) };
return { dom: elt("ul", { class: "cm-tooltip-lint" }, found.map(d => renderDiagnostic(view, d, false))) };
}
};
}
/// Command to open and focus the lint panel.
/**
Command to open and focus the lint panel.
*/
const openLintPanel = (view) => {

@@ -133,3 +135,5 @@ let field = view.state.field(lintState, false);

};
/// Command to close the lint panel, when open.
/**
Command to close the lint panel, when open.
*/
const closeLintPanel = (view) => {

@@ -142,3 +146,5 @@ let field = view.state.field(lintState, false);

};
/// Move the selection to the next diagnostic.
/**
Move the selection to the next diagnostic.
*/
const nextDiagnostic = (view) => {

@@ -157,6 +163,8 @@ let field = view.state.field(lintState, false);

};
/// A set of default key bindings for the lint functionality.
///
/// - Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](#lint.openLintPanel)
/// - F8: [`nextDiagnostic`](#lint.nextDiagnostic)
/**
A set of default key bindings for the lint functionality.
- Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](https://codemirror.net/6/docs/ref/#lint.openLintPanel)
- F8: [`nextDiagnostic`](https://codemirror.net/6/docs/ref/#lint.nextDiagnostic)
*/
const lintKeymap = [

@@ -167,5 +175,7 @@ { key: "Mod-Shift-m", run: openLintPanel },

const LintDelay = 500;
/// Given a diagnostic source, this function returns an extension that
/// enables linting with that source. It will be called whenever the
/// editor is idle (after its content changed).
/**
Given a diagnostic source, this function returns an extension that
enables linting with that source. It will be called whenever the
editor is idle (after its content changed).
*/
function linter(source) {

@@ -314,3 +324,3 @@ return ViewPlugin.fromClass(class {

});
this.dom = elt("div", this.list, elt("button", {
this.dom = elt("div", { class: "cm-panel-lint" }, this.list, elt("button", {
name: "close",

@@ -433,3 +443,2 @@ "aria-label": this.view.state.phrase("close"),

}
get class() { return "cm-panel-lint"; }
static open(view) { return new LintPanel(view); }

@@ -436,0 +445,0 @@ }

{
"name": "@codemirror/lint",
"version": "0.18.0",
"version": "0.18.1",
"description": "Linting support for the CodeMirror code editor",
"scripts": {
"test": "echo 'No tests'",
"prepare": "tsc -p tsconfig.local.json && rollup -c"
"prepare": "cm-buildhelper src/lint.ts"
},

@@ -29,5 +29,5 @@ "keywords": [

"dependencies": {
"@codemirror/panel": "^0.18.0",
"@codemirror/panel": "^0.18.1",
"@codemirror/state": "^0.18.0",
"@codemirror/tooltip": "^0.18.0",
"@codemirror/tooltip": "^0.18.4",
"@codemirror/view": "^0.18.0",

@@ -37,5 +37,3 @@ "crelt": "^1.0.5"

"devDependencies": {
"rollup": "^2.35.1",
"rollup-plugin-dts": "^2.0.1",
"typescript": "^4.1.3"
"@codemirror/buildhelper": "^0.1.0"
},

@@ -42,0 +40,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc