From 0f63da455ee496eb03ecdb043cd665807cda19a8 Mon Sep 17 00:00:00 2001 From: Jeremy Schomery Date: Thu, 9 Feb 2017 08:40:51 +0330 Subject: [PATCH] muting CSSLint --- codemirror-overwrites/addon/lint/css-lint.js | 47 ++++++++++++++++++++ edit.html | 2 +- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 codemirror-overwrites/addon/lint/css-lint.js diff --git a/codemirror-overwrites/addon/lint/css-lint.js b/codemirror-overwrites/addon/lint/css-lint.js new file mode 100644 index 00000000..c5c8bb3d --- /dev/null +++ b/codemirror-overwrites/addon/lint/css-lint.js @@ -0,0 +1,47 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +// Depends on csslint.js from https://github.com/stubbornella/csslint + +// declare global: CSSLint + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { +"use strict"; + +CodeMirror.registerHelper("lint", "css", function(text) { + var found = []; + if (!window.CSSLint) return found; + + // STYLISH: hack start + var rules = CSSLint.getRules(); + var allowedRules = ["display-property-grouping", "duplicate-properties", "empty-rules", "errors", "known-properties"]; + CSSLint.clearRules(); + rules.forEach(function(rule) { + if (allowedRules.indexOf(rule.id) >= 0) { + CSSLint.addRule(rule); + } + }); + // STYLISH: hack end + + var results = CSSLint.verify(text), messages = results.messages, message = null; + for ( var i = 0; i < messages.length; i++) { + message = messages[i]; + var startLine = message.line -1, endLine = message.line -1, startCol = message.col -1, endCol = message.col; + found.push({ + from: CodeMirror.Pos(startLine, startCol), + to: CodeMirror.Pos(endLine, endCol), + message: message.message, + severity : message.type + }); + } + return found; +}); + +}); diff --git a/edit.html b/edit.html index 54cb285e..678b23e5 100644 --- a/edit.html +++ b/edit.html @@ -26,7 +26,7 @@ - +