diff --git a/app/components/CodeEditor.tsx b/app/components/CodeEditor.tsx
index 09f3515..fb3ccde 100644
--- a/app/components/CodeEditor.tsx
+++ b/app/components/CodeEditor.tsx
@@ -1,37 +1,36 @@
-import CodeMirror from "@uiw/react-codemirror";
-import { esLint, javascript } from "@codemirror/lang-javascript";
+import CodeMirror, { useCodeMirror } from "@uiw/react-codemirror";
+import { javascript } from "@codemirror/lang-javascript";
import { useGooeyStringInput } from "~/gooeyInput";
import { dracula } from "@uiw/codemirror-theme-dracula";
import { RenderedMarkdown } from "~/renderedMarkdown";
-import { linter, lintGutter } from "@codemirror/lint";
-import { Linter } from "eslint-linter-browserify";
-import type esLintType from "eslint";
-import { OnChange } from "~/app";
+import { lintGutter, linter } from "@codemirror/lint";
+import type { OnChange } from "~/app";
+import type { LintOptions } from "jshint";
+import { JSHINT as jshint } from 'jshint';
-const LintConfig: esLintType.Linter.Config = {
- parserOptions: {
- ecmaVersion: 2019,
- sourceType: "module",
- },
- env: {
- browser: true,
- node: true,
- },
- extends: "eslint:recommended",
- rules: {
- // enable additional rules
- indent: ["off"],
- "linebreak-style": ["error", "unix"],
- "no-debugger": ["error"],
- quotes: ["error", "double"],
- semi: ["error", "always"],
- // override configuration set by extending "eslint:recommended"
- "no-empty": "warn",
- "no-undef": ["error"],
- "no-cond-assign": ["error", "always"],
- // disable rules from base configurations
- "for-direction": "off",
- },
+const jsLinter = (lintOptions: LintOptions) => {
+ return linter((view) => {
+ const diagnostics: any = [];
+ const codeText = view.state.doc.toJSON();
+ jshint(codeText, lintOptions);
+ const errors = jshint?.data()?.errors;
+
+ if (errors && errors.length > 0) {
+ errors.forEach((error) => {
+ const selectedLine = view.state.doc.line(error.line);
+
+ const diagnostic = {
+ from: selectedLine.from,
+ to: selectedLine.to,
+ severity: 'error',
+ message: error.reason,
+ };
+
+ diagnostics.push(diagnostic);
+ });
+ }
+ return diagnostics;
+ });
};
const CodeEditor = ({
@@ -49,12 +48,21 @@ const CodeEditor = ({
name,
defaultValue,
});
-
const handleChange = (val: string) => {
setValue(val);
// trigger the onChange event for Root Form
// imitate the textarea onChange
- onChange({ target: inputRef.current });
+ onChange({
+ target: inputRef.current as HTMLElement,
+ });
+ };
+
+ const lintOptions: LintOptions = {
+ esversion: 11,
+ browser: true,
+ lastsemic: true,
+ asi: true,
+ expr: true,
};
return (
@@ -65,6 +73,9 @@ const CodeEditor = ({
)}
diff --git a/app/styles/custom.css b/app/styles/custom.css
index 038f7f8..74c8655 100644
--- a/app/styles/custom.css
+++ b/app/styles/custom.css
@@ -721,4 +721,36 @@ a.text-primary:hover {
#gooey-code-editor :first-child {
border-radius: 0.25rem;
+}
+
+.cm-gutter-lint {
+ width: 0 !important;
+}
+
+.ͼ1 .cm-lint-marker-error {
+ position: absolute !important;
+ content: none !important;
+ left: 0px !important;
+ width: 100% !important;
+ height: 22.39px !important;
+ background-color: red !important;
+ opacity: 0.5 !important;
+ border-radius: 0 !important;
+ transform: translateY(-3.39px) !important;
+}
+
+.cm-foldGutter span {
+ display: inline-block !important;
+ transform: translate(-1.5px, -3px) !important;
+}
+.cm-gutterElement {
+ text-align: center;
+ overflow: hidden !important;
+}
+.ͼ1 .cm-lineNumbers .cm-gutterElement {
+ text-align: center !important;
+ padding: 0px !important;
+}
+.cm-lineNumbers .cm-gutterElement {
+ min-width: 36px !important;
}
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 5412a99..9317dfa 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "gooey-gui",
- "version": "0.0.2",
+ "version": "0.1.3",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "gooey-gui",
- "version": "0.0.2",
+ "version": "0.1.3",
"dependencies": {
"@codemirror/lang-javascript": "^6.2.2",
"@codemirror/lint": "^6.8.1",
@@ -32,7 +32,6 @@
"@uppy/url": "^3.5.0",
"@uppy/webcam": "^3.3.1",
"@uppy/xhr-upload": "^3.2.0",
- "eslint-linter-browserify": "^9.7.0",
"firebase-admin": "^11.9.0",
"html-react-parser": "^4.0.0",
"isbot": "^3.6.8",
@@ -9056,12 +9055,6 @@
"node": ">=8.6.0"
}
},
- "node_modules/eslint-linter-browserify": {
- "version": "9.7.0",
- "resolved": "https://registry.npmjs.org/eslint-linter-browserify/-/eslint-linter-browserify-9.7.0.tgz",
- "integrity": "sha512-3d9OY4vSOSB9sfXFX2uL3bUJFcEL+jsdZc7883vztflChS8hklkCZOIHsfSUkR16genGcP7gcLSSYvz+3bcLbw==",
- "license": "MIT"
- },
"node_modules/eslint-module-utils": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.8.1.tgz",
diff --git a/package.json b/package.json
index 185a2bf..410c35c 100644
--- a/package.json
+++ b/package.json
@@ -42,7 +42,6 @@
"@uppy/url": "^3.5.0",
"@uppy/webcam": "^3.3.1",
"@uppy/xhr-upload": "^3.2.0",
- "eslint-linter-browserify": "^9.7.0",
"firebase-admin": "^11.9.0",
"html-react-parser": "^4.0.0",
"isbot": "^3.6.8",