diff --git a/README.md b/README.md index 37ef0a8..075c455 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ You can configure linter-htmlhint by editing ~/.atom/config.cson (choose Open Yo ``` 'linter-htmlhint': 'htmlhintExecutablePath': null #htmlhint path. run 'which htmlhint' to find the path + 'htmlHintRcFilePath': #OPTIONAL custom path to the htmlhintrc file (which can be used to customize rulesets that are run against the HTML) + 'htmlHintRcFileName': #OPTIONAL filename of the htmlhintrc file (defaults to '.htmlhintrc', but can be overridden) ``` ## Contributing diff --git a/lib/linter-htmlhint.coffee b/lib/linter-htmlhint.coffee index e5a9519..c795144 100644 --- a/lib/linter-htmlhint.coffee +++ b/lib/linter-htmlhint.coffee @@ -19,15 +19,23 @@ class LinterHtmlhint extends Linter isNodeExecutable: yes - constructor: (editor) -> - super(editor) - - config = findFile @cwd, ['.htmlhintrc'] + # update the ruleset anytime the watched htmlhintrc file changes + setupHtmlHintRc: => + htmlHintRcPath = atom.config.get 'linter.linter-htmlhint.htmlhintRcFilePath' + fileName = atom.config.get('linter.linter-htmlhint.htmlhintRcFileName') || '.htmlhintrc' + config = findFile htmlHintRcPath, [fileName] if config @cmd = @cmd.concat ['-c', config] + + constructor: (editor) -> + super(editor) atom.config.observe 'linter-htmlhint.htmlhintExecutablePath', @formatShellCmd + # reload if path or file name changed of the htmlhintrc file + atom.config.observe 'linter-htmlhint.htmlHintRcFilePath', @setupHtmlHintRc + atom.config.observe 'linter-htmlhint.htmlHintRcFileName', @setupHtmlHintRc + formatShellCmd: => htmlhintExecutablePath = atom.config.get 'linter-htmlhint.htmlhintExecutablePath' @executablePath = "#{htmlhintExecutablePath}"