Reputation: 3446
I thought this would be a trivial question, but I've done a ton of searching and haven't been able to find anything.
I have a CodeMirror div that has linting turned on. I've included JSHint.js, which is working properly; syntax errors and warnings are being displayed in my CodeMirror editor. However, I need to disable a few warnings (most importantly, I want to allow unquoted object keys).
Where can I pass preferences or disable warnings to JSHint so that it only shows the issues that I actually care about?
Or, alternatively, is there a alternative to JSHint that allows more configuration (and is usable with the CodeMirror linting framework)?
Upvotes: 4
Views: 2366
Reputation: 129
Use the lint property from the CodeMirror config object, to set any valid jshint configuration.
Example:
const config = {
lineNumbers: true,
lineWrapping: true,
mode: 'javascript',
indentWithTabs: true,
gutters: ['CodeMirror-lint-markers'],
lint: { 'esversion': '8' },
theme: 'monokai'
};
var myCodeMirror = CodeMirror(document.body, config);
Upvotes: 1
Reputation:
Just set lint option = false when initializing an instance of the codemirror
var editorSettings = CodeMirror.defaults;
editorSettings.codemirror.lint = false;
var myCodeMirror = CodeMirror(document.body, editorSettings);
In Wordpress 4.9+:
var editorSettings = wp.codeEditor.defaultSettings;
editorSettings.codemirror.lint = false;
var editor = wp.codeEditor.initialize( $('#whatever'), editorSettings);
Upvotes: 0
Reputation: 1313
codemirror.setOption('lint', { options: { bitwise: true }});
Upvotes: 1