mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
80a6280231
[cm6] Add bibtex linter for missing keys in entries GitOrigin-RevId: fac79cab6420e10bfb1316262a1d0217515503f4
26 lines
723 B
TypeScript
26 lines
723 B
TypeScript
import { Compartment, EditorState } from '@codemirror/state'
|
|
import { setSyntaxValidationEffect } from './language'
|
|
import { linter } from '@codemirror/lint'
|
|
|
|
export const createLinter: typeof linter = (lintSource, config) => {
|
|
const linterConfig = new Compartment()
|
|
|
|
return [
|
|
linterConfig.of([]),
|
|
|
|
// enable/disable the linter to match the syntaxValidation setting
|
|
EditorState.transactionExtender.of(tr => {
|
|
for (const effect of tr.effects) {
|
|
if (effect.is(setSyntaxValidationEffect)) {
|
|
return {
|
|
effects: linterConfig.reconfigure(
|
|
effect.value ? linter(lintSource, config) : []
|
|
),
|
|
}
|
|
}
|
|
}
|
|
|
|
return null
|
|
}),
|
|
]
|
|
}
|