Last active
August 29, 2015 14:04
-
-
Save hail2u/df2a6838f13cca52d07f to your computer and use it in GitHub Desktop.
VimでHTMLHintする奴
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
'use strict'; | |
var fs = require('fs'); | |
var htmlhint = require('htmlhint').HTMLHint; | |
var path = require('path'); | |
var ruleset = { | |
'tagname-lowercase': true, | |
'attr-lowercase': true, | |
'attr-value-double-quotes': true, | |
'attr-no-duplication': true, | |
'doctype-first': true, | |
'tag-pair': true, | |
'spec-char-escape': true, | |
'id-unique': true, | |
'src-not-empty': true, | |
'doctype-html5': true, | |
'style-disabled': true | |
}; | |
var file = process.argv[2]; | |
var html = fs.readFileSync(file, 'utf-8'); | |
var messages = htmlhint.verify(html, ruleset); | |
messages.forEach(function (message) { | |
file = path.relative(process.cwd(), file); | |
console.log([file, message.line, message.col, message.message].join(':')); | |
}); | |
process.exit(messages.length); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if exists('current_compiler') | |
finish | |
endif | |
let current_compiler = 'htmlhint' | |
if exists(":CompilerSet") != 2 " older Vim always used :setlocal | |
command -nargs=* CompilerSet setlocal <args> | |
endif | |
let s:cpo_save = &cpo | |
set cpo-=C | |
CompilerSet makeprg=htmlhint\ % | |
let &cpo = s:cpo_save | |
unlet s:cpo_save | |
" autocmd FileType html compiler htmlhint |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment