Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to lint code #469

Open
Jenny-pyl opened this issue Mar 9, 2023 · 4 comments
Open

How to lint code #469

Jenny-pyl opened this issue Mar 9, 2023 · 4 comments

Comments

@Jenny-pyl
Copy link

I use 'uiwjs/react-codemmmirror' to write a 'json-editor' component, but I have no idea about how to lint code.Thanks

@jaywcjlove
Copy link
Member

@Jenny-pyl https://codemirror.net/examples/lint/

@edymusajev
Copy link

@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>
  );
}

@fabpico
Copy link

fabpico commented Feb 15, 2024

Can this be added to the documentatoin or readme? Consider also the very important but almost hiddenly documented lintGutter.

@jaywcjlove
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants