Codemirror show CSSLint errors inline (.addLineWidget)












0














I have been using these references:



http://codemirror.net/demo/lint.html
http://codemirror.net/demo/widget.html
http://codemirror.net/doc/manual.html#addLineWidget



I been trying to get CSSLint to show inline instead of JSHint using .addLineWidget. Codemirror provides a demo of what I'm trying to do using JSHint here however I'm having a hard time transitioning from JSHint to CSSLint.






var widgets = ;
var waiting;

function updateHints() {
editor.operation(function(){
for (var i = 0; i < widgets.length; ++i)
editor.removeLineWidget(widgets[i]);
widgets.length = 0;

JSHINT(editor.getValue());
for (var i = 0; i < JSHINT.errors.length; ++i) {
var err = JSHINT.errors[i];
if (!err) continue;
var msg = document.createElement("div");
var icon = msg.appendChild(document.createElement("span"));
icon.innerHTML = "!!";
icon.className = "lint-error-icon";
msg.appendChild(document.createTextNode(err.reason));
msg.className = "lint-error";
widgets.push(editor.addLineWidget(err.line - 1, msg, {coverGutter: false, noHScroll: true}));
}
});
var info = editor.getScrollInfo();
var after = editor.charCoords({line: editor.getCursor().line + 1, ch: 0}, "local").top;
if (info.top + info.clientHeight < after)
editor.scrollTo(null, after - info.clientHeight + 3);
}

window.onload = function() {
window.editor = CodeMirror(document.getElementById("code"), {
lineNumbers: true,
mode: "css",
gutters: ["CodeMirror-lint-markers"],
lint: true,
value: '@charset "UTF-8";nn@import url("booya.css") print, screen;n@import "whatup.css" screen;n@import "wicked.css";nn/*Error*/n@charset "UTF-8";nnn@namespace "http://www.w3.org/1999/xhtml";n@namespace svg "http://www.w3.org/2000/svg";nn/*Warning: empty ruleset */n.foo {n}nnh1 {n font-weight: bold;n}nn/*Warning: qualified heading */n.foo h1 {n font-weight: bold;n}nn/*Warning: adjoining classes */n.foo.bar {n zoom: 1;n}nnli.inline {n width: 100%; /*Warning: 100% can be problematic*/n}nnli.last {n display: inline;n padding-left: 3px !important;n padding-right: 3px;n border-right: 0px;n}nn@media print {n li.inline {n color: black;n }n}nn@page {n margin: 10%;n counter-increment: page;nn @top-center {n font-family: sans-serif;n font-weight: bold;n font-size: 2em;n content: counter(page);n }n}'
});

editor.on("change", function() {
clearTimeout(waiting);
waiting = setTimeout(updateHints, 500);
});

setTimeout(updateHints, 100);
};

"long line to create a horizontal scrollbar, in order to test whether the (non-inline) widgets stay in place when scrolling to the right";

.CodeMirror {
float: left;
width: 50%;
border: 1px solid black;
}
.lint-error {
font-family: arial;
font-size: 70%;
background: #ffa;
color: #a00;
padding: 2px 5px 3px;
}
.lint-error-icon {
color: white;
background-color: red;
font-weight: bold;
border-radius: 50%;
padding: 0 3px;
margin-right: 7px;
}

<!DOCTYPE html>
<html>
<head>
<title>Codemirror: Inline CSS Errors</title>
<meta charset='utf-8'>
<meta name='viewport' content='initial-scale=1.0'>
<meta http-equiv='X-UA-Compatible' content='IE=9' />
<link type='text/css' rel='stylesheet' href='http://necolas.github.io/normalize.css/3.0.1/normalize.css'/>
<script type='text/javascript' src='http://code.jquery.com/jquery-latest.min.js'></script>
<script src='http://codemirror.net/lib/codemirror.js'></script>
<link rel='stylesheet' href='http://codemirror.net/lib/codemirror.css'>
<link rel='stylesheet' href='http://codemirror.net/addon/fold/foldgutter.css' />
<script src='http://codemirror.net/javascripts/code-completion.js'></script>
<script src='http://codemirror.net/javascripts/css-completion.js'></script>
<script src='http://codemirror.net/mode/javascript/javascript.js'></script>
<script src='http://codemirror.net/mode/xml/xml.js'></script>
<script src='http://codemirror.net/mode/css/css.js'></script>
<script src='http://codemirror.net/mode/htmlmixed/htmlmixed.js'></script>
<script src='http://codemirror.net/addon/edit/closetag.js'></script>
<script src='http://codemirror.net/addon/edit/matchbrackets.js'></script>
<script src='http://codemirror.net/addon/selection/active-line.js'></script>
<script src='http://codemirror.net/keymap/extra.js'></script>
<script src='http://codemirror.net/addon/fold/foldcode.js'></script>
<script src='http://codemirror.net/addon/fold/foldgutter.js'></script>
<script src='http://codemirror.net/addon/fold/brace-fold.js'></script>
<script src='http://codemirror.net/addon/fold/xml-fold.js'></script>
<script src='http://codemirror.net/addon/fold/comment-fold.js'></script>

<link rel="stylesheet" href="http://codemirror.net/addon/lint/lint.css">
<script src="http://codemirror.net/mode/javascript/javascript.js"></script>
<script src="http://codemirror.net/mode/css/css.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jshint/r07/jshint.js"></script>
<script src="https://rawgithub.com/zaach/jsonlint/79b553fb65c192add9066da64043458981b3972b/lib/jsonlint.js"></script>
<script src="https://rawgithub.com/stubbornella/csslint/master/release/csslint.js"></script>
<script src="http://codemirror.net/addon/lint/lint.js"></script>
<script src="http://codemirror.net/addon/lint/javascript-lint.js"></script>
<script src="http://codemirror.net/addon/lint/css-lint.js"></script>
</head>
<body>
<div id="code"></div>
</body>
</html>





Here is a Fiddle of the same: http://jsbin.com/miwatidica/1/edit?js,output










share|improve this question





























    0














    I have been using these references:



    http://codemirror.net/demo/lint.html
    http://codemirror.net/demo/widget.html
    http://codemirror.net/doc/manual.html#addLineWidget



    I been trying to get CSSLint to show inline instead of JSHint using .addLineWidget. Codemirror provides a demo of what I'm trying to do using JSHint here however I'm having a hard time transitioning from JSHint to CSSLint.






    var widgets = ;
    var waiting;

    function updateHints() {
    editor.operation(function(){
    for (var i = 0; i < widgets.length; ++i)
    editor.removeLineWidget(widgets[i]);
    widgets.length = 0;

    JSHINT(editor.getValue());
    for (var i = 0; i < JSHINT.errors.length; ++i) {
    var err = JSHINT.errors[i];
    if (!err) continue;
    var msg = document.createElement("div");
    var icon = msg.appendChild(document.createElement("span"));
    icon.innerHTML = "!!";
    icon.className = "lint-error-icon";
    msg.appendChild(document.createTextNode(err.reason));
    msg.className = "lint-error";
    widgets.push(editor.addLineWidget(err.line - 1, msg, {coverGutter: false, noHScroll: true}));
    }
    });
    var info = editor.getScrollInfo();
    var after = editor.charCoords({line: editor.getCursor().line + 1, ch: 0}, "local").top;
    if (info.top + info.clientHeight < after)
    editor.scrollTo(null, after - info.clientHeight + 3);
    }

    window.onload = function() {
    window.editor = CodeMirror(document.getElementById("code"), {
    lineNumbers: true,
    mode: "css",
    gutters: ["CodeMirror-lint-markers"],
    lint: true,
    value: '@charset "UTF-8";nn@import url("booya.css") print, screen;n@import "whatup.css" screen;n@import "wicked.css";nn/*Error*/n@charset "UTF-8";nnn@namespace "http://www.w3.org/1999/xhtml";n@namespace svg "http://www.w3.org/2000/svg";nn/*Warning: empty ruleset */n.foo {n}nnh1 {n font-weight: bold;n}nn/*Warning: qualified heading */n.foo h1 {n font-weight: bold;n}nn/*Warning: adjoining classes */n.foo.bar {n zoom: 1;n}nnli.inline {n width: 100%; /*Warning: 100% can be problematic*/n}nnli.last {n display: inline;n padding-left: 3px !important;n padding-right: 3px;n border-right: 0px;n}nn@media print {n li.inline {n color: black;n }n}nn@page {n margin: 10%;n counter-increment: page;nn @top-center {n font-family: sans-serif;n font-weight: bold;n font-size: 2em;n content: counter(page);n }n}'
    });

    editor.on("change", function() {
    clearTimeout(waiting);
    waiting = setTimeout(updateHints, 500);
    });

    setTimeout(updateHints, 100);
    };

    "long line to create a horizontal scrollbar, in order to test whether the (non-inline) widgets stay in place when scrolling to the right";

    .CodeMirror {
    float: left;
    width: 50%;
    border: 1px solid black;
    }
    .lint-error {
    font-family: arial;
    font-size: 70%;
    background: #ffa;
    color: #a00;
    padding: 2px 5px 3px;
    }
    .lint-error-icon {
    color: white;
    background-color: red;
    font-weight: bold;
    border-radius: 50%;
    padding: 0 3px;
    margin-right: 7px;
    }

    <!DOCTYPE html>
    <html>
    <head>
    <title>Codemirror: Inline CSS Errors</title>
    <meta charset='utf-8'>
    <meta name='viewport' content='initial-scale=1.0'>
    <meta http-equiv='X-UA-Compatible' content='IE=9' />
    <link type='text/css' rel='stylesheet' href='http://necolas.github.io/normalize.css/3.0.1/normalize.css'/>
    <script type='text/javascript' src='http://code.jquery.com/jquery-latest.min.js'></script>
    <script src='http://codemirror.net/lib/codemirror.js'></script>
    <link rel='stylesheet' href='http://codemirror.net/lib/codemirror.css'>
    <link rel='stylesheet' href='http://codemirror.net/addon/fold/foldgutter.css' />
    <script src='http://codemirror.net/javascripts/code-completion.js'></script>
    <script src='http://codemirror.net/javascripts/css-completion.js'></script>
    <script src='http://codemirror.net/mode/javascript/javascript.js'></script>
    <script src='http://codemirror.net/mode/xml/xml.js'></script>
    <script src='http://codemirror.net/mode/css/css.js'></script>
    <script src='http://codemirror.net/mode/htmlmixed/htmlmixed.js'></script>
    <script src='http://codemirror.net/addon/edit/closetag.js'></script>
    <script src='http://codemirror.net/addon/edit/matchbrackets.js'></script>
    <script src='http://codemirror.net/addon/selection/active-line.js'></script>
    <script src='http://codemirror.net/keymap/extra.js'></script>
    <script src='http://codemirror.net/addon/fold/foldcode.js'></script>
    <script src='http://codemirror.net/addon/fold/foldgutter.js'></script>
    <script src='http://codemirror.net/addon/fold/brace-fold.js'></script>
    <script src='http://codemirror.net/addon/fold/xml-fold.js'></script>
    <script src='http://codemirror.net/addon/fold/comment-fold.js'></script>

    <link rel="stylesheet" href="http://codemirror.net/addon/lint/lint.css">
    <script src="http://codemirror.net/mode/javascript/javascript.js"></script>
    <script src="http://codemirror.net/mode/css/css.js"></script>
    <script src="http://ajax.aspnetcdn.com/ajax/jshint/r07/jshint.js"></script>
    <script src="https://rawgithub.com/zaach/jsonlint/79b553fb65c192add9066da64043458981b3972b/lib/jsonlint.js"></script>
    <script src="https://rawgithub.com/stubbornella/csslint/master/release/csslint.js"></script>
    <script src="http://codemirror.net/addon/lint/lint.js"></script>
    <script src="http://codemirror.net/addon/lint/javascript-lint.js"></script>
    <script src="http://codemirror.net/addon/lint/css-lint.js"></script>
    </head>
    <body>
    <div id="code"></div>
    </body>
    </html>





    Here is a Fiddle of the same: http://jsbin.com/miwatidica/1/edit?js,output










    share|improve this question



























      0












      0








      0







      I have been using these references:



      http://codemirror.net/demo/lint.html
      http://codemirror.net/demo/widget.html
      http://codemirror.net/doc/manual.html#addLineWidget



      I been trying to get CSSLint to show inline instead of JSHint using .addLineWidget. Codemirror provides a demo of what I'm trying to do using JSHint here however I'm having a hard time transitioning from JSHint to CSSLint.






      var widgets = ;
      var waiting;

      function updateHints() {
      editor.operation(function(){
      for (var i = 0; i < widgets.length; ++i)
      editor.removeLineWidget(widgets[i]);
      widgets.length = 0;

      JSHINT(editor.getValue());
      for (var i = 0; i < JSHINT.errors.length; ++i) {
      var err = JSHINT.errors[i];
      if (!err) continue;
      var msg = document.createElement("div");
      var icon = msg.appendChild(document.createElement("span"));
      icon.innerHTML = "!!";
      icon.className = "lint-error-icon";
      msg.appendChild(document.createTextNode(err.reason));
      msg.className = "lint-error";
      widgets.push(editor.addLineWidget(err.line - 1, msg, {coverGutter: false, noHScroll: true}));
      }
      });
      var info = editor.getScrollInfo();
      var after = editor.charCoords({line: editor.getCursor().line + 1, ch: 0}, "local").top;
      if (info.top + info.clientHeight < after)
      editor.scrollTo(null, after - info.clientHeight + 3);
      }

      window.onload = function() {
      window.editor = CodeMirror(document.getElementById("code"), {
      lineNumbers: true,
      mode: "css",
      gutters: ["CodeMirror-lint-markers"],
      lint: true,
      value: '@charset "UTF-8";nn@import url("booya.css") print, screen;n@import "whatup.css" screen;n@import "wicked.css";nn/*Error*/n@charset "UTF-8";nnn@namespace "http://www.w3.org/1999/xhtml";n@namespace svg "http://www.w3.org/2000/svg";nn/*Warning: empty ruleset */n.foo {n}nnh1 {n font-weight: bold;n}nn/*Warning: qualified heading */n.foo h1 {n font-weight: bold;n}nn/*Warning: adjoining classes */n.foo.bar {n zoom: 1;n}nnli.inline {n width: 100%; /*Warning: 100% can be problematic*/n}nnli.last {n display: inline;n padding-left: 3px !important;n padding-right: 3px;n border-right: 0px;n}nn@media print {n li.inline {n color: black;n }n}nn@page {n margin: 10%;n counter-increment: page;nn @top-center {n font-family: sans-serif;n font-weight: bold;n font-size: 2em;n content: counter(page);n }n}'
      });

      editor.on("change", function() {
      clearTimeout(waiting);
      waiting = setTimeout(updateHints, 500);
      });

      setTimeout(updateHints, 100);
      };

      "long line to create a horizontal scrollbar, in order to test whether the (non-inline) widgets stay in place when scrolling to the right";

      .CodeMirror {
      float: left;
      width: 50%;
      border: 1px solid black;
      }
      .lint-error {
      font-family: arial;
      font-size: 70%;
      background: #ffa;
      color: #a00;
      padding: 2px 5px 3px;
      }
      .lint-error-icon {
      color: white;
      background-color: red;
      font-weight: bold;
      border-radius: 50%;
      padding: 0 3px;
      margin-right: 7px;
      }

      <!DOCTYPE html>
      <html>
      <head>
      <title>Codemirror: Inline CSS Errors</title>
      <meta charset='utf-8'>
      <meta name='viewport' content='initial-scale=1.0'>
      <meta http-equiv='X-UA-Compatible' content='IE=9' />
      <link type='text/css' rel='stylesheet' href='http://necolas.github.io/normalize.css/3.0.1/normalize.css'/>
      <script type='text/javascript' src='http://code.jquery.com/jquery-latest.min.js'></script>
      <script src='http://codemirror.net/lib/codemirror.js'></script>
      <link rel='stylesheet' href='http://codemirror.net/lib/codemirror.css'>
      <link rel='stylesheet' href='http://codemirror.net/addon/fold/foldgutter.css' />
      <script src='http://codemirror.net/javascripts/code-completion.js'></script>
      <script src='http://codemirror.net/javascripts/css-completion.js'></script>
      <script src='http://codemirror.net/mode/javascript/javascript.js'></script>
      <script src='http://codemirror.net/mode/xml/xml.js'></script>
      <script src='http://codemirror.net/mode/css/css.js'></script>
      <script src='http://codemirror.net/mode/htmlmixed/htmlmixed.js'></script>
      <script src='http://codemirror.net/addon/edit/closetag.js'></script>
      <script src='http://codemirror.net/addon/edit/matchbrackets.js'></script>
      <script src='http://codemirror.net/addon/selection/active-line.js'></script>
      <script src='http://codemirror.net/keymap/extra.js'></script>
      <script src='http://codemirror.net/addon/fold/foldcode.js'></script>
      <script src='http://codemirror.net/addon/fold/foldgutter.js'></script>
      <script src='http://codemirror.net/addon/fold/brace-fold.js'></script>
      <script src='http://codemirror.net/addon/fold/xml-fold.js'></script>
      <script src='http://codemirror.net/addon/fold/comment-fold.js'></script>

      <link rel="stylesheet" href="http://codemirror.net/addon/lint/lint.css">
      <script src="http://codemirror.net/mode/javascript/javascript.js"></script>
      <script src="http://codemirror.net/mode/css/css.js"></script>
      <script src="http://ajax.aspnetcdn.com/ajax/jshint/r07/jshint.js"></script>
      <script src="https://rawgithub.com/zaach/jsonlint/79b553fb65c192add9066da64043458981b3972b/lib/jsonlint.js"></script>
      <script src="https://rawgithub.com/stubbornella/csslint/master/release/csslint.js"></script>
      <script src="http://codemirror.net/addon/lint/lint.js"></script>
      <script src="http://codemirror.net/addon/lint/javascript-lint.js"></script>
      <script src="http://codemirror.net/addon/lint/css-lint.js"></script>
      </head>
      <body>
      <div id="code"></div>
      </body>
      </html>





      Here is a Fiddle of the same: http://jsbin.com/miwatidica/1/edit?js,output










      share|improve this question















      I have been using these references:



      http://codemirror.net/demo/lint.html
      http://codemirror.net/demo/widget.html
      http://codemirror.net/doc/manual.html#addLineWidget



      I been trying to get CSSLint to show inline instead of JSHint using .addLineWidget. Codemirror provides a demo of what I'm trying to do using JSHint here however I'm having a hard time transitioning from JSHint to CSSLint.






      var widgets = ;
      var waiting;

      function updateHints() {
      editor.operation(function(){
      for (var i = 0; i < widgets.length; ++i)
      editor.removeLineWidget(widgets[i]);
      widgets.length = 0;

      JSHINT(editor.getValue());
      for (var i = 0; i < JSHINT.errors.length; ++i) {
      var err = JSHINT.errors[i];
      if (!err) continue;
      var msg = document.createElement("div");
      var icon = msg.appendChild(document.createElement("span"));
      icon.innerHTML = "!!";
      icon.className = "lint-error-icon";
      msg.appendChild(document.createTextNode(err.reason));
      msg.className = "lint-error";
      widgets.push(editor.addLineWidget(err.line - 1, msg, {coverGutter: false, noHScroll: true}));
      }
      });
      var info = editor.getScrollInfo();
      var after = editor.charCoords({line: editor.getCursor().line + 1, ch: 0}, "local").top;
      if (info.top + info.clientHeight < after)
      editor.scrollTo(null, after - info.clientHeight + 3);
      }

      window.onload = function() {
      window.editor = CodeMirror(document.getElementById("code"), {
      lineNumbers: true,
      mode: "css",
      gutters: ["CodeMirror-lint-markers"],
      lint: true,
      value: '@charset "UTF-8";nn@import url("booya.css") print, screen;n@import "whatup.css" screen;n@import "wicked.css";nn/*Error*/n@charset "UTF-8";nnn@namespace "http://www.w3.org/1999/xhtml";n@namespace svg "http://www.w3.org/2000/svg";nn/*Warning: empty ruleset */n.foo {n}nnh1 {n font-weight: bold;n}nn/*Warning: qualified heading */n.foo h1 {n font-weight: bold;n}nn/*Warning: adjoining classes */n.foo.bar {n zoom: 1;n}nnli.inline {n width: 100%; /*Warning: 100% can be problematic*/n}nnli.last {n display: inline;n padding-left: 3px !important;n padding-right: 3px;n border-right: 0px;n}nn@media print {n li.inline {n color: black;n }n}nn@page {n margin: 10%;n counter-increment: page;nn @top-center {n font-family: sans-serif;n font-weight: bold;n font-size: 2em;n content: counter(page);n }n}'
      });

      editor.on("change", function() {
      clearTimeout(waiting);
      waiting = setTimeout(updateHints, 500);
      });

      setTimeout(updateHints, 100);
      };

      "long line to create a horizontal scrollbar, in order to test whether the (non-inline) widgets stay in place when scrolling to the right";

      .CodeMirror {
      float: left;
      width: 50%;
      border: 1px solid black;
      }
      .lint-error {
      font-family: arial;
      font-size: 70%;
      background: #ffa;
      color: #a00;
      padding: 2px 5px 3px;
      }
      .lint-error-icon {
      color: white;
      background-color: red;
      font-weight: bold;
      border-radius: 50%;
      padding: 0 3px;
      margin-right: 7px;
      }

      <!DOCTYPE html>
      <html>
      <head>
      <title>Codemirror: Inline CSS Errors</title>
      <meta charset='utf-8'>
      <meta name='viewport' content='initial-scale=1.0'>
      <meta http-equiv='X-UA-Compatible' content='IE=9' />
      <link type='text/css' rel='stylesheet' href='http://necolas.github.io/normalize.css/3.0.1/normalize.css'/>
      <script type='text/javascript' src='http://code.jquery.com/jquery-latest.min.js'></script>
      <script src='http://codemirror.net/lib/codemirror.js'></script>
      <link rel='stylesheet' href='http://codemirror.net/lib/codemirror.css'>
      <link rel='stylesheet' href='http://codemirror.net/addon/fold/foldgutter.css' />
      <script src='http://codemirror.net/javascripts/code-completion.js'></script>
      <script src='http://codemirror.net/javascripts/css-completion.js'></script>
      <script src='http://codemirror.net/mode/javascript/javascript.js'></script>
      <script src='http://codemirror.net/mode/xml/xml.js'></script>
      <script src='http://codemirror.net/mode/css/css.js'></script>
      <script src='http://codemirror.net/mode/htmlmixed/htmlmixed.js'></script>
      <script src='http://codemirror.net/addon/edit/closetag.js'></script>
      <script src='http://codemirror.net/addon/edit/matchbrackets.js'></script>
      <script src='http://codemirror.net/addon/selection/active-line.js'></script>
      <script src='http://codemirror.net/keymap/extra.js'></script>
      <script src='http://codemirror.net/addon/fold/foldcode.js'></script>
      <script src='http://codemirror.net/addon/fold/foldgutter.js'></script>
      <script src='http://codemirror.net/addon/fold/brace-fold.js'></script>
      <script src='http://codemirror.net/addon/fold/xml-fold.js'></script>
      <script src='http://codemirror.net/addon/fold/comment-fold.js'></script>

      <link rel="stylesheet" href="http://codemirror.net/addon/lint/lint.css">
      <script src="http://codemirror.net/mode/javascript/javascript.js"></script>
      <script src="http://codemirror.net/mode/css/css.js"></script>
      <script src="http://ajax.aspnetcdn.com/ajax/jshint/r07/jshint.js"></script>
      <script src="https://rawgithub.com/zaach/jsonlint/79b553fb65c192add9066da64043458981b3972b/lib/jsonlint.js"></script>
      <script src="https://rawgithub.com/stubbornella/csslint/master/release/csslint.js"></script>
      <script src="http://codemirror.net/addon/lint/lint.js"></script>
      <script src="http://codemirror.net/addon/lint/javascript-lint.js"></script>
      <script src="http://codemirror.net/addon/lint/css-lint.js"></script>
      </head>
      <body>
      <div id="code"></div>
      </body>
      </html>





      Here is a Fiddle of the same: http://jsbin.com/miwatidica/1/edit?js,output






      var widgets = ;
      var waiting;

      function updateHints() {
      editor.operation(function(){
      for (var i = 0; i < widgets.length; ++i)
      editor.removeLineWidget(widgets[i]);
      widgets.length = 0;

      JSHINT(editor.getValue());
      for (var i = 0; i < JSHINT.errors.length; ++i) {
      var err = JSHINT.errors[i];
      if (!err) continue;
      var msg = document.createElement("div");
      var icon = msg.appendChild(document.createElement("span"));
      icon.innerHTML = "!!";
      icon.className = "lint-error-icon";
      msg.appendChild(document.createTextNode(err.reason));
      msg.className = "lint-error";
      widgets.push(editor.addLineWidget(err.line - 1, msg, {coverGutter: false, noHScroll: true}));
      }
      });
      var info = editor.getScrollInfo();
      var after = editor.charCoords({line: editor.getCursor().line + 1, ch: 0}, "local").top;
      if (info.top + info.clientHeight < after)
      editor.scrollTo(null, after - info.clientHeight + 3);
      }

      window.onload = function() {
      window.editor = CodeMirror(document.getElementById("code"), {
      lineNumbers: true,
      mode: "css",
      gutters: ["CodeMirror-lint-markers"],
      lint: true,
      value: '@charset "UTF-8";nn@import url("booya.css") print, screen;n@import "whatup.css" screen;n@import "wicked.css";nn/*Error*/n@charset "UTF-8";nnn@namespace "http://www.w3.org/1999/xhtml";n@namespace svg "http://www.w3.org/2000/svg";nn/*Warning: empty ruleset */n.foo {n}nnh1 {n font-weight: bold;n}nn/*Warning: qualified heading */n.foo h1 {n font-weight: bold;n}nn/*Warning: adjoining classes */n.foo.bar {n zoom: 1;n}nnli.inline {n width: 100%; /*Warning: 100% can be problematic*/n}nnli.last {n display: inline;n padding-left: 3px !important;n padding-right: 3px;n border-right: 0px;n}nn@media print {n li.inline {n color: black;n }n}nn@page {n margin: 10%;n counter-increment: page;nn @top-center {n font-family: sans-serif;n font-weight: bold;n font-size: 2em;n content: counter(page);n }n}'
      });

      editor.on("change", function() {
      clearTimeout(waiting);
      waiting = setTimeout(updateHints, 500);
      });

      setTimeout(updateHints, 100);
      };

      "long line to create a horizontal scrollbar, in order to test whether the (non-inline) widgets stay in place when scrolling to the right";

      .CodeMirror {
      float: left;
      width: 50%;
      border: 1px solid black;
      }
      .lint-error {
      font-family: arial;
      font-size: 70%;
      background: #ffa;
      color: #a00;
      padding: 2px 5px 3px;
      }
      .lint-error-icon {
      color: white;
      background-color: red;
      font-weight: bold;
      border-radius: 50%;
      padding: 0 3px;
      margin-right: 7px;
      }

      <!DOCTYPE html>
      <html>
      <head>
      <title>Codemirror: Inline CSS Errors</title>
      <meta charset='utf-8'>
      <meta name='viewport' content='initial-scale=1.0'>
      <meta http-equiv='X-UA-Compatible' content='IE=9' />
      <link type='text/css' rel='stylesheet' href='http://necolas.github.io/normalize.css/3.0.1/normalize.css'/>
      <script type='text/javascript' src='http://code.jquery.com/jquery-latest.min.js'></script>
      <script src='http://codemirror.net/lib/codemirror.js'></script>
      <link rel='stylesheet' href='http://codemirror.net/lib/codemirror.css'>
      <link rel='stylesheet' href='http://codemirror.net/addon/fold/foldgutter.css' />
      <script src='http://codemirror.net/javascripts/code-completion.js'></script>
      <script src='http://codemirror.net/javascripts/css-completion.js'></script>
      <script src='http://codemirror.net/mode/javascript/javascript.js'></script>
      <script src='http://codemirror.net/mode/xml/xml.js'></script>
      <script src='http://codemirror.net/mode/css/css.js'></script>
      <script src='http://codemirror.net/mode/htmlmixed/htmlmixed.js'></script>
      <script src='http://codemirror.net/addon/edit/closetag.js'></script>
      <script src='http://codemirror.net/addon/edit/matchbrackets.js'></script>
      <script src='http://codemirror.net/addon/selection/active-line.js'></script>
      <script src='http://codemirror.net/keymap/extra.js'></script>
      <script src='http://codemirror.net/addon/fold/foldcode.js'></script>
      <script src='http://codemirror.net/addon/fold/foldgutter.js'></script>
      <script src='http://codemirror.net/addon/fold/brace-fold.js'></script>
      <script src='http://codemirror.net/addon/fold/xml-fold.js'></script>
      <script src='http://codemirror.net/addon/fold/comment-fold.js'></script>

      <link rel="stylesheet" href="http://codemirror.net/addon/lint/lint.css">
      <script src="http://codemirror.net/mode/javascript/javascript.js"></script>
      <script src="http://codemirror.net/mode/css/css.js"></script>
      <script src="http://ajax.aspnetcdn.com/ajax/jshint/r07/jshint.js"></script>
      <script src="https://rawgithub.com/zaach/jsonlint/79b553fb65c192add9066da64043458981b3972b/lib/jsonlint.js"></script>
      <script src="https://rawgithub.com/stubbornella/csslint/master/release/csslint.js"></script>
      <script src="http://codemirror.net/addon/lint/lint.js"></script>
      <script src="http://codemirror.net/addon/lint/javascript-lint.js"></script>
      <script src="http://codemirror.net/addon/lint/css-lint.js"></script>
      </head>
      <body>
      <div id="code"></div>
      </body>
      </html>





      var widgets = ;
      var waiting;

      function updateHints() {
      editor.operation(function(){
      for (var i = 0; i < widgets.length; ++i)
      editor.removeLineWidget(widgets[i]);
      widgets.length = 0;

      JSHINT(editor.getValue());
      for (var i = 0; i < JSHINT.errors.length; ++i) {
      var err = JSHINT.errors[i];
      if (!err) continue;
      var msg = document.createElement("div");
      var icon = msg.appendChild(document.createElement("span"));
      icon.innerHTML = "!!";
      icon.className = "lint-error-icon";
      msg.appendChild(document.createTextNode(err.reason));
      msg.className = "lint-error";
      widgets.push(editor.addLineWidget(err.line - 1, msg, {coverGutter: false, noHScroll: true}));
      }
      });
      var info = editor.getScrollInfo();
      var after = editor.charCoords({line: editor.getCursor().line + 1, ch: 0}, "local").top;
      if (info.top + info.clientHeight < after)
      editor.scrollTo(null, after - info.clientHeight + 3);
      }

      window.onload = function() {
      window.editor = CodeMirror(document.getElementById("code"), {
      lineNumbers: true,
      mode: "css",
      gutters: ["CodeMirror-lint-markers"],
      lint: true,
      value: '@charset "UTF-8";nn@import url("booya.css") print, screen;n@import "whatup.css" screen;n@import "wicked.css";nn/*Error*/n@charset "UTF-8";nnn@namespace "http://www.w3.org/1999/xhtml";n@namespace svg "http://www.w3.org/2000/svg";nn/*Warning: empty ruleset */n.foo {n}nnh1 {n font-weight: bold;n}nn/*Warning: qualified heading */n.foo h1 {n font-weight: bold;n}nn/*Warning: adjoining classes */n.foo.bar {n zoom: 1;n}nnli.inline {n width: 100%; /*Warning: 100% can be problematic*/n}nnli.last {n display: inline;n padding-left: 3px !important;n padding-right: 3px;n border-right: 0px;n}nn@media print {n li.inline {n color: black;n }n}nn@page {n margin: 10%;n counter-increment: page;nn @top-center {n font-family: sans-serif;n font-weight: bold;n font-size: 2em;n content: counter(page);n }n}'
      });

      editor.on("change", function() {
      clearTimeout(waiting);
      waiting = setTimeout(updateHints, 500);
      });

      setTimeout(updateHints, 100);
      };

      "long line to create a horizontal scrollbar, in order to test whether the (non-inline) widgets stay in place when scrolling to the right";

      .CodeMirror {
      float: left;
      width: 50%;
      border: 1px solid black;
      }
      .lint-error {
      font-family: arial;
      font-size: 70%;
      background: #ffa;
      color: #a00;
      padding: 2px 5px 3px;
      }
      .lint-error-icon {
      color: white;
      background-color: red;
      font-weight: bold;
      border-radius: 50%;
      padding: 0 3px;
      margin-right: 7px;
      }

      <!DOCTYPE html>
      <html>
      <head>
      <title>Codemirror: Inline CSS Errors</title>
      <meta charset='utf-8'>
      <meta name='viewport' content='initial-scale=1.0'>
      <meta http-equiv='X-UA-Compatible' content='IE=9' />
      <link type='text/css' rel='stylesheet' href='http://necolas.github.io/normalize.css/3.0.1/normalize.css'/>
      <script type='text/javascript' src='http://code.jquery.com/jquery-latest.min.js'></script>
      <script src='http://codemirror.net/lib/codemirror.js'></script>
      <link rel='stylesheet' href='http://codemirror.net/lib/codemirror.css'>
      <link rel='stylesheet' href='http://codemirror.net/addon/fold/foldgutter.css' />
      <script src='http://codemirror.net/javascripts/code-completion.js'></script>
      <script src='http://codemirror.net/javascripts/css-completion.js'></script>
      <script src='http://codemirror.net/mode/javascript/javascript.js'></script>
      <script src='http://codemirror.net/mode/xml/xml.js'></script>
      <script src='http://codemirror.net/mode/css/css.js'></script>
      <script src='http://codemirror.net/mode/htmlmixed/htmlmixed.js'></script>
      <script src='http://codemirror.net/addon/edit/closetag.js'></script>
      <script src='http://codemirror.net/addon/edit/matchbrackets.js'></script>
      <script src='http://codemirror.net/addon/selection/active-line.js'></script>
      <script src='http://codemirror.net/keymap/extra.js'></script>
      <script src='http://codemirror.net/addon/fold/foldcode.js'></script>
      <script src='http://codemirror.net/addon/fold/foldgutter.js'></script>
      <script src='http://codemirror.net/addon/fold/brace-fold.js'></script>
      <script src='http://codemirror.net/addon/fold/xml-fold.js'></script>
      <script src='http://codemirror.net/addon/fold/comment-fold.js'></script>

      <link rel="stylesheet" href="http://codemirror.net/addon/lint/lint.css">
      <script src="http://codemirror.net/mode/javascript/javascript.js"></script>
      <script src="http://codemirror.net/mode/css/css.js"></script>
      <script src="http://ajax.aspnetcdn.com/ajax/jshint/r07/jshint.js"></script>
      <script src="https://rawgithub.com/zaach/jsonlint/79b553fb65c192add9066da64043458981b3972b/lib/jsonlint.js"></script>
      <script src="https://rawgithub.com/stubbornella/csslint/master/release/csslint.js"></script>
      <script src="http://codemirror.net/addon/lint/lint.js"></script>
      <script src="http://codemirror.net/addon/lint/javascript-lint.js"></script>
      <script src="http://codemirror.net/addon/lint/css-lint.js"></script>
      </head>
      <body>
      <div id="code"></div>
      </body>
      </html>






      javascript jquery






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 '18 at 22:27









      halfer

      14.4k758109




      14.4k758109










      asked Jan 10 '15 at 10:18









      Michael SchwartzMichael Schwartz

      3,0981051104




      3,0981051104
























          1 Answer
          1






          active

          oldest

          votes


















          1





          +50









          Test below code.



          keyword is JSHINT -> CSSLint.verify



          var widgets = ;
          var waiting;

          function updateHints() {
          editor.operation(function(){
          for (var i = 0; i < widgets.length; ++i){
          editor.removeLineWidget(widgets[i]);
          }

          widgets.length = 0;

          //***** HERE *****
          var result= CSSLint.verify(editor.getValue());

          //***** HERE *****
          for (var i = 0; i < result.messages.length; ++i) {

          //***** HERE *****
          var err = result.messages[i];
          if (!err) continue;
          var msg = document.createElement("div");
          var icon = msg.appendChild(document.createElement("span"));
          icon.innerHTML = "!!";
          icon.className = "lint-error-icon";
          //***** HERE *****
          msg.appendChild(document.createTextNode(err.message));
          msg.className = "lint-error";
          widgets.push(editor.addLineWidget(err.line - 1, msg,coverGutter: false, noHScroll: true}));
          }//end of for i
          });// end of editor.operation

          var info = editor.getScrollInfo();
          var after = editor.charCoords({line: editor.getCursor().line + 1, ch: 0}, "local").top;
          if (info.top + info.clientHeight < after){
          editor.scrollTo(null, after - info.clientHeight + 3);
          }
          }// end of updateHints

          window.onload = function() {
          window.editor = CodeMirror(document.getElementById("code"), {
          lineNumbers: true,
          mode: "css",
          gutters: ["CodeMirror-lint-markers"],
          //***** HERE *****
          //lint: true,
          value: '@charset "UTF-8";nn@import url("booya.css") print, screen;n@import "whatup.css" screen;n@import "wicked.css";nn/*Error*/n@charset "UTF-8";nnn@namespace "http://www.w3.org/1999/xhtml";n@namespace svg "http://www.w3.org/2000/svg";nn/*Warning: empty ruleset */n.foo {n}nnh1 {n font-weight: bold;n}nn/*Warning: qualified heading */n.foo h1 {n font-weight: bold;n}nn/*Warning: adjoining classes */n.foo.bar {n zoom: 1;n}nnli.inline {n width: 100%; /*Warning: 100% can be problematic*/n}nnli.last {n display: inline;n padding-left: 3px !important;n padding-right: 3px;n border-right: 0px;n}nn@media print {n li.inline {n color: black;n }n}nn@page {n margin: 10%;n counter-increment: page;nn @top-center {n font-family: sans-serif;n font-weight: bold;n font-size: 2em;n content: counter(page);n }n}'
          });

          editor.on("change", function() {
          clearTimeout(waiting);
          waiting = setTimeout(updateHints, 500);
          });

          setTimeout(updateHints, 100);
          };





          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f27875083%2fcodemirror-show-csslint-errors-inline-addlinewidget%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1





            +50









            Test below code.



            keyword is JSHINT -> CSSLint.verify



            var widgets = ;
            var waiting;

            function updateHints() {
            editor.operation(function(){
            for (var i = 0; i < widgets.length; ++i){
            editor.removeLineWidget(widgets[i]);
            }

            widgets.length = 0;

            //***** HERE *****
            var result= CSSLint.verify(editor.getValue());

            //***** HERE *****
            for (var i = 0; i < result.messages.length; ++i) {

            //***** HERE *****
            var err = result.messages[i];
            if (!err) continue;
            var msg = document.createElement("div");
            var icon = msg.appendChild(document.createElement("span"));
            icon.innerHTML = "!!";
            icon.className = "lint-error-icon";
            //***** HERE *****
            msg.appendChild(document.createTextNode(err.message));
            msg.className = "lint-error";
            widgets.push(editor.addLineWidget(err.line - 1, msg,coverGutter: false, noHScroll: true}));
            }//end of for i
            });// end of editor.operation

            var info = editor.getScrollInfo();
            var after = editor.charCoords({line: editor.getCursor().line + 1, ch: 0}, "local").top;
            if (info.top + info.clientHeight < after){
            editor.scrollTo(null, after - info.clientHeight + 3);
            }
            }// end of updateHints

            window.onload = function() {
            window.editor = CodeMirror(document.getElementById("code"), {
            lineNumbers: true,
            mode: "css",
            gutters: ["CodeMirror-lint-markers"],
            //***** HERE *****
            //lint: true,
            value: '@charset "UTF-8";nn@import url("booya.css") print, screen;n@import "whatup.css" screen;n@import "wicked.css";nn/*Error*/n@charset "UTF-8";nnn@namespace "http://www.w3.org/1999/xhtml";n@namespace svg "http://www.w3.org/2000/svg";nn/*Warning: empty ruleset */n.foo {n}nnh1 {n font-weight: bold;n}nn/*Warning: qualified heading */n.foo h1 {n font-weight: bold;n}nn/*Warning: adjoining classes */n.foo.bar {n zoom: 1;n}nnli.inline {n width: 100%; /*Warning: 100% can be problematic*/n}nnli.last {n display: inline;n padding-left: 3px !important;n padding-right: 3px;n border-right: 0px;n}nn@media print {n li.inline {n color: black;n }n}nn@page {n margin: 10%;n counter-increment: page;nn @top-center {n font-family: sans-serif;n font-weight: bold;n font-size: 2em;n content: counter(page);n }n}'
            });

            editor.on("change", function() {
            clearTimeout(waiting);
            waiting = setTimeout(updateHints, 500);
            });

            setTimeout(updateHints, 100);
            };





            share|improve this answer


























              1





              +50









              Test below code.



              keyword is JSHINT -> CSSLint.verify



              var widgets = ;
              var waiting;

              function updateHints() {
              editor.operation(function(){
              for (var i = 0; i < widgets.length; ++i){
              editor.removeLineWidget(widgets[i]);
              }

              widgets.length = 0;

              //***** HERE *****
              var result= CSSLint.verify(editor.getValue());

              //***** HERE *****
              for (var i = 0; i < result.messages.length; ++i) {

              //***** HERE *****
              var err = result.messages[i];
              if (!err) continue;
              var msg = document.createElement("div");
              var icon = msg.appendChild(document.createElement("span"));
              icon.innerHTML = "!!";
              icon.className = "lint-error-icon";
              //***** HERE *****
              msg.appendChild(document.createTextNode(err.message));
              msg.className = "lint-error";
              widgets.push(editor.addLineWidget(err.line - 1, msg,coverGutter: false, noHScroll: true}));
              }//end of for i
              });// end of editor.operation

              var info = editor.getScrollInfo();
              var after = editor.charCoords({line: editor.getCursor().line + 1, ch: 0}, "local").top;
              if (info.top + info.clientHeight < after){
              editor.scrollTo(null, after - info.clientHeight + 3);
              }
              }// end of updateHints

              window.onload = function() {
              window.editor = CodeMirror(document.getElementById("code"), {
              lineNumbers: true,
              mode: "css",
              gutters: ["CodeMirror-lint-markers"],
              //***** HERE *****
              //lint: true,
              value: '@charset "UTF-8";nn@import url("booya.css") print, screen;n@import "whatup.css" screen;n@import "wicked.css";nn/*Error*/n@charset "UTF-8";nnn@namespace "http://www.w3.org/1999/xhtml";n@namespace svg "http://www.w3.org/2000/svg";nn/*Warning: empty ruleset */n.foo {n}nnh1 {n font-weight: bold;n}nn/*Warning: qualified heading */n.foo h1 {n font-weight: bold;n}nn/*Warning: adjoining classes */n.foo.bar {n zoom: 1;n}nnli.inline {n width: 100%; /*Warning: 100% can be problematic*/n}nnli.last {n display: inline;n padding-left: 3px !important;n padding-right: 3px;n border-right: 0px;n}nn@media print {n li.inline {n color: black;n }n}nn@page {n margin: 10%;n counter-increment: page;nn @top-center {n font-family: sans-serif;n font-weight: bold;n font-size: 2em;n content: counter(page);n }n}'
              });

              editor.on("change", function() {
              clearTimeout(waiting);
              waiting = setTimeout(updateHints, 500);
              });

              setTimeout(updateHints, 100);
              };





              share|improve this answer
























                1





                +50







                1





                +50



                1




                +50




                Test below code.



                keyword is JSHINT -> CSSLint.verify



                var widgets = ;
                var waiting;

                function updateHints() {
                editor.operation(function(){
                for (var i = 0; i < widgets.length; ++i){
                editor.removeLineWidget(widgets[i]);
                }

                widgets.length = 0;

                //***** HERE *****
                var result= CSSLint.verify(editor.getValue());

                //***** HERE *****
                for (var i = 0; i < result.messages.length; ++i) {

                //***** HERE *****
                var err = result.messages[i];
                if (!err) continue;
                var msg = document.createElement("div");
                var icon = msg.appendChild(document.createElement("span"));
                icon.innerHTML = "!!";
                icon.className = "lint-error-icon";
                //***** HERE *****
                msg.appendChild(document.createTextNode(err.message));
                msg.className = "lint-error";
                widgets.push(editor.addLineWidget(err.line - 1, msg,coverGutter: false, noHScroll: true}));
                }//end of for i
                });// end of editor.operation

                var info = editor.getScrollInfo();
                var after = editor.charCoords({line: editor.getCursor().line + 1, ch: 0}, "local").top;
                if (info.top + info.clientHeight < after){
                editor.scrollTo(null, after - info.clientHeight + 3);
                }
                }// end of updateHints

                window.onload = function() {
                window.editor = CodeMirror(document.getElementById("code"), {
                lineNumbers: true,
                mode: "css",
                gutters: ["CodeMirror-lint-markers"],
                //***** HERE *****
                //lint: true,
                value: '@charset "UTF-8";nn@import url("booya.css") print, screen;n@import "whatup.css" screen;n@import "wicked.css";nn/*Error*/n@charset "UTF-8";nnn@namespace "http://www.w3.org/1999/xhtml";n@namespace svg "http://www.w3.org/2000/svg";nn/*Warning: empty ruleset */n.foo {n}nnh1 {n font-weight: bold;n}nn/*Warning: qualified heading */n.foo h1 {n font-weight: bold;n}nn/*Warning: adjoining classes */n.foo.bar {n zoom: 1;n}nnli.inline {n width: 100%; /*Warning: 100% can be problematic*/n}nnli.last {n display: inline;n padding-left: 3px !important;n padding-right: 3px;n border-right: 0px;n}nn@media print {n li.inline {n color: black;n }n}nn@page {n margin: 10%;n counter-increment: page;nn @top-center {n font-family: sans-serif;n font-weight: bold;n font-size: 2em;n content: counter(page);n }n}'
                });

                editor.on("change", function() {
                clearTimeout(waiting);
                waiting = setTimeout(updateHints, 500);
                });

                setTimeout(updateHints, 100);
                };





                share|improve this answer












                Test below code.



                keyword is JSHINT -> CSSLint.verify



                var widgets = ;
                var waiting;

                function updateHints() {
                editor.operation(function(){
                for (var i = 0; i < widgets.length; ++i){
                editor.removeLineWidget(widgets[i]);
                }

                widgets.length = 0;

                //***** HERE *****
                var result= CSSLint.verify(editor.getValue());

                //***** HERE *****
                for (var i = 0; i < result.messages.length; ++i) {

                //***** HERE *****
                var err = result.messages[i];
                if (!err) continue;
                var msg = document.createElement("div");
                var icon = msg.appendChild(document.createElement("span"));
                icon.innerHTML = "!!";
                icon.className = "lint-error-icon";
                //***** HERE *****
                msg.appendChild(document.createTextNode(err.message));
                msg.className = "lint-error";
                widgets.push(editor.addLineWidget(err.line - 1, msg,coverGutter: false, noHScroll: true}));
                }//end of for i
                });// end of editor.operation

                var info = editor.getScrollInfo();
                var after = editor.charCoords({line: editor.getCursor().line + 1, ch: 0}, "local").top;
                if (info.top + info.clientHeight < after){
                editor.scrollTo(null, after - info.clientHeight + 3);
                }
                }// end of updateHints

                window.onload = function() {
                window.editor = CodeMirror(document.getElementById("code"), {
                lineNumbers: true,
                mode: "css",
                gutters: ["CodeMirror-lint-markers"],
                //***** HERE *****
                //lint: true,
                value: '@charset "UTF-8";nn@import url("booya.css") print, screen;n@import "whatup.css" screen;n@import "wicked.css";nn/*Error*/n@charset "UTF-8";nnn@namespace "http://www.w3.org/1999/xhtml";n@namespace svg "http://www.w3.org/2000/svg";nn/*Warning: empty ruleset */n.foo {n}nnh1 {n font-weight: bold;n}nn/*Warning: qualified heading */n.foo h1 {n font-weight: bold;n}nn/*Warning: adjoining classes */n.foo.bar {n zoom: 1;n}nnli.inline {n width: 100%; /*Warning: 100% can be problematic*/n}nnli.last {n display: inline;n padding-left: 3px !important;n padding-right: 3px;n border-right: 0px;n}nn@media print {n li.inline {n color: black;n }n}nn@page {n margin: 10%;n counter-increment: page;nn @top-center {n font-family: sans-serif;n font-weight: bold;n font-size: 2em;n content: counter(page);n }n}'
                });

                editor.on("change", function() {
                clearTimeout(waiting);
                waiting = setTimeout(updateHints, 500);
                });

                setTimeout(updateHints, 100);
                };






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 3 '15 at 7:24









                easywarueasywaru

                863612




                863612






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f27875083%2fcodemirror-show-csslint-errors-inline-addlinewidget%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    404 Error Contact Form 7 ajax form submitting

                    How to know if a Active Directory user can login interactively

                    TypeError: fit_transform() missing 1 required positional argument: 'X'