vue-codemirror
vue-codemirror copied to clipboard
Dose this support Jsonlint?
I don't find an example which contains the lint for json editor. However,when I use the lint as this : component.js import { codemirror } from 'vue-codemirror' // lint import 'codemirror/addon/lint/lint.css' import 'codemirror/addon/lint/lint.js' import 'codemirror/addon/lint/json-lint.js'
editor.vue cmOptions: { lint: true },
I cannot get lint for json.. I wonder whether it supports the json-lint as codeMirror does?
json-lint.js dependent on jsonlint,but you can't use it directly in the webpack environment.
In my usecase, i copy jsonlint/lib/jsonlint.js
to my project and delete the following lines.
if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
exports.parse = function () { return jsonlint.parse.apply(jsonlint, arguments); }
exports.main = function commonjsMain(args) {
if (!args[1])
throw new Error('Usage: '+args[0]+' FILE');
if (typeof process !== 'undefined') {
var source = require('fs').readFileSync(require('path').join(process.cwd(), args[1]), "utf8");
} else {
var cwd = require("file").path(require("file").cwd());
var source = cwd.join(args[1]).read({charset: "utf-8"});
}
return exports.parser.parse(source);
}
if (typeof module !== 'undefined' && require.main === module) {
exports.main(typeof process !== 'undefined' ? process.argv.slice(1) : require("system").args);
}
}
add a line window.jsonlint = jsonlint
In vue component import the file:
import "./jsonlint"