feat(frontend): add fork awesome linter

This linter will tell users that their fork awesome icon is deprecated and will stop working in the future and that they should replace it with a new bootstrap icon.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2023-01-15 19:32:15 +01:00
parent e2c4e2eccf
commit 16b1065a51
4 changed files with 21 additions and 17 deletions

View file

@ -51,25 +51,28 @@ export class SingleLineRegexLinter implements Linter {
.map(({ lineStartIndex, regexResult }) => this.createDiagnostic(lineStartIndex, regexResult as RegExpExecArray))
}
private createDiagnostic(from: number, found: RegExpExecArray): Diagnostic {
let actions: Action[] = []
if (this.replace !== undefined) {
const replacedText = this.replace(found[1])
actions = [
{
name: t(this.actionLabel ?? 'editor.linter.defaultAction'),
apply: (view: EditorView, from: number, to: number) => {
view.dispatch({
changes: { from, to, insert: replacedText }
})
}
}
]
private buildActions(found: RegExpExecArray): Action[] {
if (this.replace === undefined) {
return []
}
const replacedText = this.replace(found[1])
return [
{
name: t(this.actionLabel ?? 'editor.linter.defaultAction'),
apply: (view: EditorView, from: number, to: number) => {
view.dispatch({
changes: { from, to, insert: replacedText }
})
}
}
]
}
private createDiagnostic(from: number, found: RegExpExecArray): Diagnostic {
return {
from: from,
to: from + found[0].length,
actions: actions,
actions: this.buildActions(found),
message: this.message,
severity: 'warning'
}