Open Jenny-pyl opened 1 year ago
@Jenny-pyl https://codemirror.net/examples/lint/
@Jenny-pyl Here's how to add linting to react-codemirror
import CodeMirror from "@uiw/react-codemirror";
import { json, jsonParseLinter } from "@codemirror/lang-json";
import { linter } from "@codemirror/lint";
import { useState } from "react";
export function JsonEditor() {
const [value, setValue] = useState("");
return (
<div>
<CodeMirror
value={value}
onChange={(value) => setValue(value)}
height="200px"
extensions={[json(), linter(jsonParseLinter())]}
/>
</div>
);
}
Can this be added to the documentatoin or readme? Consider also the very important but almost hiddenly documented lintGutter.
Can this be added to the documentatoin or readme? Consider also the very important but almost hiddenly documented lintGutter.
@fabpico Welcome to update the documentation
I use 'uiwjs/react-codemmmirror' to write a 'json-editor' component, but I have no idea about how to lint code.Thanks