Linter Demo

x
 
1
var widgets = []
2
function updateHints() {
3
  editor.operation(function(){
4
    for (var i = 0; i < widgets.length; ++i)
5
      editor.removeLineWidget(widgets[i]);
6
    widgets.length = 0;
7
8
    JSHINT(editor.getValue());
9
    for (var i = 0; i < JSHINT.errors.length; ++i) {
10
      var err = JSHINT.errors[i];
11
      if (!err) continue;
12
      var msg = document.createElement("div");
13
      var icon = msg.appendChild(document.createElement("span"));
14
      icon.innerHTML = "!!";
15
      icon.className = "lint-error-icon";
16
      msg.appendChild(document.createTextNode(err.reason));
17
      msg.className = "lint-error";
18
      widgets.push(editor.addLineWidget(err.line - 1, msg, {coverGutter: false, noHScroll: true}));
19
    }
20
  });
21
  var info = editor.getScrollInfo();
22
  var after = editor.charCoords({line: editor.getCursor().line + 1, ch: 0}, "local").top;
23
  if (info.top + info.clientHeight < after)
24
    editor.scrollTo(null, after - info.clientHeight + 3);
25
}
26

21
 
1
[
2
 {
3
  _id: "post 1",
4
  "author": "Bob",
5
  "content": "...",
6
  "page_views": 5
7
 },
8
 {
9
  "_id": "post 2",
10
  "author": "Bob",
11
  "content": "...",
12
  "page_views": 9
13
 },
14
 {
15
  "_id": "post 3",
16
  "author": "Bob",
17
  "content": "...",
18
  "page_views": 8
19
 }
20
]
21

60
 
1
@charset "UTF-8";
2
3
@import url("booya.css") print, screen;
4
@import "whatup.css" screen;
5
@import "wicked.css";
6
7
/*Error*/
8
@charset "UTF-8";
9
10
11
@namespace "http://www.w3.org/1999/xhtml";
12
@namespace svg "http://www.w3.org/2000/svg";
13
14
/*Warning: empty ruleset */
15
.foo {
16
}
17
18
h1 {
19
    font-weight: bold;
20
}
21
22
/*Warning: qualified heading */
23
.foo h1 {
24
    font-weight: bold;
25
}
26
27
/*Warning: adjoining classes */
28
.foo.bar {
29
    zoom: 1;
30
}
31
32
li.inline {
33
    width: 100%;  /*Warning: 100% can be problematic*/
34
}
35
36
li.last {
37
  display: inline;
38
  padding-left: 3px !important;
39
  padding-right: 3px;
40
  border-right: 0px;
41
}
42
43
@media print {
44
    li.inline {
45
      color: black;
46
    }
47
}
48
49
@page {
50
  margin: 10%;
51
  counter-increment: page;
52
53
  @top-center {
54
    font-family: sans-serif;
55
    font-weight: bold;
56
    font-size: 2em;
57
    content: counter(page);
58
  }
59
}
60