[英]Disable JSHint warnings in CodeMirror
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. 我有一个打开linting的CodeMirror div。 I've included JSHint.js, which is working properly;
我已经包含了正常工作的JSHint.js; syntax errors and warnings are being displayed in my CodeMirror editor.
语法错误和警告正在我的CodeMirror编辑器中显示。 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? 我在哪里可以向JSHint传递首选项或禁用警告,以便它只显示我真正关心的问题?
Or, alternatively, is there a alternative to JSHint that allows more configuration (and is usable with the CodeMirror linting framework)? 或者,是否有JSHint的替代方案允许更多配置(并且可以与CodeMirror linting框架一起使用)?
您应该能够在您使用的对象中直接设置JSHint特定的选项 ,作为CodeMirror的“lint”选项的值。
codemirror.setOption('lint', { options: { bitwise: true }});
Just set lint option = false when initializing an instance of the codemirror 只需在初始化codemirror的实例时设置lint option = false
var editorSettings = CodeMirror.defaults;
editorSettings.codemirror.lint = false;
var myCodeMirror = CodeMirror(document.body, editorSettings);
In Wordpress 4.9+: 在Wordpress 4.9+中:
var editorSettings = wp.codeEditor.defaultSettings;
editorSettings.codemirror.lint = false;
var editor = wp.codeEditor.initialize( $('#whatever'), editorSettings);
Use the lint property from the CodeMirror config object, to set any valid jshint configuration. 使用CodeMirror配置对象中的lint属性来设置任何有效的jshint配置。
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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.