Skip to content

Commit 8276c4f

Browse files
committed
Initial commit.
0 parents  commit 8276c4f

File tree

8 files changed

+179
-0
lines changed

8 files changed

+179
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

.sublimelinterrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"@python": 3,
3+
"linters": {
4+
"flake8": {
5+
"max-line-length": 120
6+
},
7+
"pep257": {
8+
"ignore": ["D202"]
9+
},
10+
"pep8": {
11+
"max-line-length": 120
12+
}
13+
}
14+
}

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
language: python
2+
python:
3+
- "3.3"
4+
# command to install dependencies
5+
install:
6+
- pip install flake8
7+
- pip install pep257
8+
# command to run tests
9+
script:
10+
- flake8 . --max-line-length=120
11+
- pep257 . --ignore=D202

LICENSE

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Permission is hereby granted, free of charge, to any person obtaining a copy
2+
of this software and associated documentation files (the "Software"), to deal
3+
in the Software without restriction, including without limitation the rights
4+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5+
copies of the Software, and to permit persons to whom the Software is
6+
furnished to do so, subject to the following conditions:
7+
8+
The above copyright notice and this permission notice shall be included in
9+
all copies or substantial portions of the Software.
10+
11+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
17+
THE SOFTWARE.

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
SublimeLinter-contrib-htmlhint
2+
================================
3+
4+
[![Build Status](https://travis-ci.org/SublimeLinter/SublimeLinter-contrib-htmlhint.svg?branch=master)](https://travis-ci.org/SublimeLinter/SublimeLinter-contrib-htmlhint)
5+
6+
This linter plugin for [SublimeLinter][docs] provides an interface to [htmlhint](https://github.com/mmaday/SublimeLinter-contrib-htmlhint). It will be used with files that have the “HTML” syntax.
7+
8+
## Installation
9+
SublimeLinter 3 must be installed in order to use this plugin. If SublimeLinter 3 is not installed, please follow the instructions [here][installation].
10+
11+
### Linter installation
12+
Before using this plugin, you must ensure that `htmlhint` is installed on your system. To install `htmlhint`, do the following:
13+
14+
1. Install Other.
15+
16+
1. Install `htmlhint` by typing the following in a terminal:
17+
```
18+
npm install -g htmlhint
19+
```
20+
21+
**Note:** This plugin requires `htmlhint` __version__ or later.
22+
23+
### Linter configuration
24+
In order for `htmlhint` to be executed by SublimeLinter, you must ensure that its path is available to SublimeLinter. Before going any further, please read and follow the steps in [“Finding a linter executable”](http://sublimelinter.readthedocs.org/en/latest/troubleshooting.html#finding-a-linter-executable) through “Validating your PATH” in the documentation.
25+
26+
Once you have installed and configured `htmlhint`, you can proceed to install the SublimeLinter-contrib-htmlhint plugin if it is not yet installed.
27+
28+
### Plugin installation
29+
Please use [Package Control][pc] to install the linter plugin. This will ensure that the plugin will be updated when new versions are available. If you want to install from source so you can modify the source code, you probably know what you are doing so we won’t cover that here.
30+
31+
To install via Package Control, do the following:
32+
33+
1. Within Sublime Text, bring up the [Command Palette][cmd] and type `install`. Among the commands you should see `Package Control: Install Package`. If that command is not highlighted, use the keyboard or mouse to select it. There will be a pause of a few seconds while Package Control fetches the list of available plugins.
34+
35+
1. When the plugin list appears, type `htmlhint`. Among the entries you should see `SublimeLinter-contrib-htmlhint`. If that entry is not highlighted, use the keyboard or mouse to select it.
36+
37+
## Settings
38+
For general information on how SublimeLinter works with settings, please see [Settings][settings]. For information on generic linter settings, please see [Linter Settings][linter-settings].
39+
40+
You can configure `htmlhint` options in the way you would from the command line, with `.htmlhintrc` files. For more information, see the [htmlhintrc docs](https://github.com/yaniswang/HTMLHint/wiki/Developer-guide). The linter plugin does this by searching for a `.htmlhintrc` file itself, just as `htmlhint` does from the command line. You may provide a custom config file by setting the linter’s `"args"` setting to `["--config", "/path/to/file"]`. On Windows, be sure to double the backslashes in the path, for example `["--config", "C:\\Users\\Username\\htmlhint.conf"]`.
41+
42+
The path to the `.htmlhintrc` file is cached, meaning if you create a new `.htmlhintrc` that should have precedence over the previous one (meaning it is closer to the .js file) you need to clear the cache for the linter to use the new `.htmlhintrc` You can clear the cache by going to: Tools > SublimeLinter > Clear Caches.
43+
44+
45+
## Contributing
46+
If you would like to contribute enhancements or fixes, please do the following:
47+
48+
1. Fork the plugin repository.
49+
1. Hack on a separate topic branch created from the latest `master`.
50+
1. Commit and push the topic branch.
51+
1. Make a pull request.
52+
1. Be patient. ;-)
53+
54+
Please note that modifications should follow these coding guidelines:
55+
56+
- Indent is 4 spaces.
57+
- Code should pass flake8 and pep257 linters.
58+
- Vertical whitespace helps readability, don’t be afraid to use it.
59+
- Please use descriptive variable names, no abbreviations unless they are very well known.
60+
61+
Thank you for helping out!
62+
63+
[docs]: http://sublimelinter.readthedocs.org
64+
[installation]: http://sublimelinter.readthedocs.org/en/latest/installation.html
65+
[locating-executables]: http://sublimelinter.readthedocs.org/en/latest/usage.html#how-linter-executables-are-located
66+
[pc]: https://sublime.wbond.net/installation
67+
[cmd]: http://docs.sublimetext.info/en/sublime-text-3/extensibility/command_palette.html
68+
[settings]: http://sublimelinter.readthedocs.org/en/latest/settings.html
69+
[linter-settings]: http://sublimelinter.readthedocs.org/en/latest/linter_settings.html
70+
[inline-settings]: http://sublimelinter.readthedocs.org/en/latest/settings.html#inline-settings

linter.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#
2+
# linter.py
3+
# Linter for SublimeLinter3, a code checking framework for Sublime Text 3
4+
#
5+
# Written by Mark Maday
6+
# Copyright (c) 2015 Mark Maday
7+
#
8+
# License: MIT
9+
#
10+
11+
"""This module exports the Htmlhint plugin class."""
12+
13+
import re
14+
from SublimeLinter.lint import Linter, util, persist
15+
16+
17+
class Htmlhint(Linter):
18+
19+
"""Provides an interface to htmlhint."""
20+
21+
syntax = 'html'
22+
cmd = 'htmlhint'
23+
executable = None
24+
version_args = '--version'
25+
version_re = r'(?P<version>\d+\.\d+\.\d+)'
26+
version_requirement = '>= 0.9.0'
27+
regex = r'^\s*line (?P<line>\d+), col (?P<col>\d+): (?P<message>.+)'
28+
tempfile_suffix = '-'
29+
config_file = ('--config', '.htmlhintrc', '~')
30+
31+
warn_regex = (
32+
r'^(Doctype must be html5.'
33+
r'|The script tag can not be used in head'
34+
r'|The value of href \[ .*?\] must be'
35+
r'|The value of .*? can not use ad keyword.'
36+
r'|Alt of img tag must be set value.'
37+
r'|Mixed spaces and tabs in front of line'
38+
r'|Style tag can not be use'
39+
r'|The empty tag : \[ \w+ \] must closed by self.)'
40+
)
41+
warn_re = re.compile(warn_regex)
42+
43+
def split_match(self, match):
44+
split = super().split_match(match)
45+
if match:
46+
message = match.group('message')
47+
48+
warn = self.warn_re.match(message)
49+
if warn:
50+
split = (split[0], split[1], split[2], False, True, split[5], split[6])
51+
52+
persist.debug('match -- msg:"{}", split:"{}", warn: {}'.format(message, split, warn))
53+
return split

messages.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"install": "messages/install.txt"
3+
}

messages/install.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
SublimeLinter-contrib-htmlhint
2+
-------------------------------
3+
This linter plugin for SublimeLinter provides an interface to htmlhint.
4+
5+
** IMPORTANT! **
6+
7+
Before this plugin will activate, you *must*
8+
follow the installation instructions here:
9+
10+
https://github.com/mmaday/SublimeLinter-contrib-htmlhint

0 commit comments

Comments
 (0)