-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: show the error in the right box (#150)
* feat: add casbin linter to editor component * feat: add missing sections check in casbinLinter * feat: add model-specific linter for RBAC and priority models * fix: handle and display errors in useRunTest hook and casbinLinter * fix: improve error handling in casbinLinter
- Loading branch information
1 parent
02b7efc
commit 8a6458a
Showing
6 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Diagnostic } from '@codemirror/lint'; | ||
import { EditorView } from '@codemirror/view'; | ||
import { getError } from './errorManager'; | ||
|
||
export const casbinLinter = (view: EditorView): Diagnostic[] => { | ||
const diagnostics: Diagnostic[] = []; | ||
|
||
const runTestError = getError(); | ||
if (runTestError) { | ||
const lineMatch = runTestError.match(/line (\d+)/); | ||
if (lineMatch) { | ||
const errorLine = parseInt(lineMatch[1], 10); | ||
const line = view.state.doc.line(errorLine); | ||
diagnostics.push({ | ||
from: line.from, | ||
to: line.to, | ||
severity: 'error', | ||
message: runTestError, | ||
}); | ||
} else { | ||
diagnostics.push({ | ||
from: 0, | ||
to: view.state.doc.length, | ||
severity: 'error', | ||
message: runTestError, | ||
}); | ||
} | ||
} | ||
|
||
return diagnostics; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
let currentError: string | null = null; | ||
|
||
export const setError = (error: string | null) => { | ||
currentError = error; | ||
}; | ||
|
||
export const getError = () => {return currentError}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters