Skip to content

Instantly share code, notes, and snippets.

@hail2u
Last active August 29, 2015 14:04
Show Gist options
  • Save hail2u/df2a6838f13cca52d07f to your computer and use it in GitHub Desktop.
Save hail2u/df2a6838f13cca52d07f to your computer and use it in GitHub Desktop.
VimでHTMLHintする奴
#!/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);
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