fix(#1214): fixed code mirror lint issues

This commit is contained in:
Anoop M D
2024-01-05 16:11:33 +05:30
parent 05cab18e18
commit 51d4dbd69b
3 changed files with 102 additions and 4 deletions

View File

@@ -103,6 +103,12 @@ export default class CodeEditor extends React.Component {
// unnecessary updates during the update lifecycle.
this.cachedValue = props.value || '';
this.variables = {};
this.lintOptions = {
esversion: 11,
expr: true,
asi: true
};
}
componentDidMount() {
@@ -118,7 +124,7 @@ export default class CodeEditor extends React.Component {
showCursorWhenSelecting: true,
foldGutter: true,
gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter', 'CodeMirror-lint-markers'],
lint: { esversion: 11 },
lint: this.lintOptions,
readOnly: this.props.readOnly,
scrollbarStyle: 'overlay',
theme: this.props.theme === 'dark' ? 'monokai' : 'default',
@@ -209,7 +215,7 @@ export default class CodeEditor extends React.Component {
return found;
});
if (editor) {
editor.setOption('lint', this.props.mode && editor.getValue().trim().length > 0 ? { esversion: 11 } : false);
editor.setOption('lint', this.props.mode && editor.getValue().trim().length > 0 ? this.lintOptions : false);
editor.on('change', this._onEdit);
this.addOverlay();
}
@@ -299,7 +305,7 @@ export default class CodeEditor extends React.Component {
_onEdit = () => {
if (!this.ignoreChangeEvent && this.editor) {
this.editor.setOption('lint', this.editor.getValue().trim().length > 0 ? { esversion: 11 } : false);
this.editor.setOption('lint', this.editor.getValue().trim().length > 0 ? this.lintOptions : false);
this.cachedValue = this.editor.getValue();
if (this.props.onEdit) {
this.props.onEdit(this.cachedValue);