This repository was archived by the owner on Oct 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathjshint.textmate.js
More file actions
101 lines (84 loc) · 2.32 KB
/
jshint.textmate.js
File metadata and controls
101 lines (84 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*jshint asi:true*/
var QUICK = process.argv.indexOf('quick') >= 0
var JSHINT = require('./jshint/stable/jshint').JSHINT
var BS = require('./bs').BS
var TextMate = require('./TextMate')
var FILEPATH = QUICK? process.env.TM_FILEPATH : process.env.TMPDIR + "validate.me.js"
process.stdin.resume()
process.stdin.setEncoding('utf8')
var CODE = ''
process.stdin.on('data', function(chunk){
CODE += chunk
})
process.stdin.on('end', function(){
if (JSHINT(''+CODE)) QUICK? quickPASS() : PASS()
else QUICK? quickFAIL() : FAIL()
})
function quickPASS(){
console.log(JSHINT.errors.length + ' Issues - JSHint')
}
function quickFAIL(){
console.log(JSHINT.errors.length + ' Issues — JSHint')
}
function PASS(){
}
function FAIL(){
// console.log(JSHINT.errors)
console.log(''+BS('style',"\
\
table{\
width: 100%;\
}\
\
\
tr:nth-child(even){\
background-color: #f9f9f9;\
}\
\
td,th{\
font-weight: normal;\
padding: .5ex 1ex;\
text-align: left;\
vertical-align: top;\
overflow: hidden;\
text-overflow: ellipsis;\
}\
\
th{\
min-width: 25ex;\
text-align: right;\
}\
\
td code{\
white-space: pre;\
}\
\
"))
console.log('<table cellspacing=0>')
JSHINT.errors.forEach(reportError)
console.log('</table>')
}
function reportError(message){
console.log
((''+BS('')
('tr',BS('')
('th',BS('')
('A'
// +' style="display:block;background:#eee;margin:1ex;"'
+' href="' + TextMate.href(process.env.TM_FILEPATH, message.line, message.character) + '"'
,BS('')
('', message.reason)
)
)
('td',BS('code', String(message.evidence).replace(/&/g,'&').replace(/</g,'<')))
)
))
// console.log(message)
// (''+BS
// ('a style="display:block;background:#eee;margin:1ex;" href="' + TextMate.href(process.env.TM_FILEPATH, message.line, message.column) + '"',
// BS('span',
// BS('span', message.evidence)
// )
// )
// )
}