Skip to content

Commit 8434a43

Browse files
committed
initial commit
0 parents  commit 8434a43

File tree

9 files changed

+554
-0
lines changed

9 files changed

+554
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.DS_Store
2+
*.log
3+
node_modules

.htlmhintrc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"tagname-lowercase": true,
3+
"attr-lowercase": true,
4+
"attr-value-double-quotes": true,
5+
"attr-value-not-empty": true,
6+
"attr-no-duplication": true,
7+
"doctype-first": true,
8+
"tag-pair": true,
9+
"tag-self-close": true,
10+
"spec-char-escape": true,
11+
"id-unique": true,
12+
"src-not-empty": true,
13+
"head-script-disabled": true,
14+
"img-alt-require": true,
15+
"doctype-html5": true,
16+
"id-class-value": true,
17+
"style-disabled": true,
18+
"space-tab-mixed-disabled": true,
19+
"id-class-ad-disabled": true,
20+
"href-abs-or-rel": true,
21+
"attr-unsafe-chars": true
22+
}

.jshintrc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"asi": true,
3+
"curly": true,
4+
"eqeqeq": true,
5+
"immed": true,
6+
"latedef": true,
7+
"newcap": true,
8+
"noarg": true,
9+
"sub": true,
10+
"undef": true,
11+
"boss": true,
12+
"eqnull": true,
13+
"node": true,
14+
"indent": 4
15+
}

LICENSE

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

Readme.md

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
gulp-htmlhint-inline
2+
================
3+
4+
## Usage
5+
6+
First, install `gulp-htmlhint-inline` as a development dependency:
7+
8+
```shell
9+
npm install --save-dev gulp-htmlhint-inline
10+
```
11+
12+
Then, add it to your `gulpfile.js`:
13+
14+
```javascript
15+
var gulp = require('gulp'),
16+
htmlhint_inline = require('gulp-htmlhint-inline');
17+
18+
gulp.task('htmlhint', function () {
19+
var options = {
20+
htmlhintrc: './.htmlhintrc',
21+
ignores: {
22+
'<?php': '?>'
23+
},
24+
patterns: [
25+
{
26+
match: /hoge/g,
27+
replacement: 'fuga'
28+
}
29+
]
30+
};
31+
32+
gulp.src('test/*.phtml')
33+
.pipe(htmlhint_inline(options))
34+
.pipe(htmlhint_inline.reporter())
35+
.pipe(htmlhint_inline.reporter('fail'));
36+
});
37+
```
38+
39+
## Options
40+
41+
#### htmlhintrc
42+
Type: String Default value: null
43+
44+
```htmlhintrc``` file must be a valid JSON.
45+
If you specify this file, options that have been defined in it will be used in the global.
46+
If there is specified in the task options, the options in this file will be overwritten.
47+
48+
```json
49+
{
50+
"tagname-lowercase": true
51+
}
52+
```
53+
54+
#### ignores
55+
Type: Object Default: {}
56+
57+
Remove program tag pairs.
58+
59+
#### patterns
60+
Type: Array Default: []
61+
62+
Enable the replacement by the pattern
63+
64+
##### patterns.match
65+
66+
Type: RegExp|String
67+
68+
Indicates the matching expression.
69+
70+
##### patterns.replacement
71+
72+
Type: String | Function
73+
74+
#### reporter
75+
76+
##### Default Reporter
77+
78+
```js
79+
var gulp = require('gulp'),
80+
htmlhint_inline = require('gulp-htmlhint-inline');
81+
82+
gulp.task('htmlhint', function () {
83+
var options = {
84+
htmlhintrc: './.htmlhintrc',
85+
ignores: {
86+
'<?php': '?>'
87+
}
88+
};
89+
90+
gulp.src('test/*.phtml')
91+
.pipe(htmlhint_inline(options))
92+
.pipe(htmlhint_inline.reporter());
93+
});
94+
```
95+
96+
##### Fail Reporter
97+
98+
In order to end the task when your task happened error of HTMLHint, please use this reporter.
99+
100+
```js
101+
var gulp = require('gulp'),
102+
htmlhint_inline = require('gulp-htmlhint-inline');
103+
104+
gulp.task('htmlhint', function () {
105+
var options = {
106+
htmlhintrc: './.htmlhintrc',
107+
ignores: {
108+
'<?php': '?>'
109+
}
110+
};
111+
112+
gulp.src('test/*.phtml')
113+
.pipe(htmlhint_inline(options))
114+
.pipe(htmlhint_inline.reporter('fail'));
115+
});
116+
```
117+
118+
##### Custom Reporter
119+
120+
You can also use the custom reporter that you have created.
121+
122+
```js
123+
124+
var gulp = require('gulp'),
125+
htmlhint_inline = require('gulp-htmlhint-inline');
126+
127+
gulp.task('htmlhint', function () {
128+
var options = {
129+
htmlhintrc: './.htmlhintrc',
130+
ignores: {
131+
'<?php': '?>'
132+
}
133+
};
134+
135+
var cutomReporter = function (file) {
136+
if (!file.htmlhint_inline.success) {
137+
console.log('custom reporter: htmlhint-inline fail in '+ file.path);
138+
}
139+
}
140+
141+
return gulp.src('test/*.phtml')
142+
.pipe(htmlhint_inline(options))
143+
.pipe(htmlhint_inline.reporter())
144+
.pipe(htmlhint_inline.reporter(cutomReporter));
145+
});
146+
147+
```
148+
149+
## License
150+
151+
[MIT License](http://en.wikipedia.org/wiki/MIT_License)
152+
153+
[npm-url]: https://npmjs.org/package/gulp-htmlhint-inline
154+
[npm-image]: https://badge.fury.io/js/gulp-htmlhint-inline.png

gulpfile.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
'use strict';
2+
3+
var gulp = require('gulp'),
4+
jshint = require('gulp-jshint'),
5+
htmlhint_inline = require('./index.js');
6+
7+
gulp.task('lint', function () {
8+
return gulp.src('./*.js')
9+
.pipe(jshint())
10+
.pipe(jshint.reporter('default', { verbose: true }))
11+
.pipe(jshint.reporter('fail'));
12+
});
13+
14+
gulp.task('test', ['lint'], function () {
15+
var options = {
16+
htmlhintrc: './.htmlhintrc',
17+
ignores: {
18+
'<?php': '?>'
19+
},
20+
patterns: [
21+
{
22+
match: /hoge/g,
23+
replacement: 'fuga'
24+
}
25+
]
26+
};
27+
return gulp.src('test/*.phtml')
28+
.pipe(htmlhint_inline(options))
29+
.pipe(htmlhint_inline.reporter())
30+
.pipe(htmlhint_inline.reporter('fail'));
31+
});

0 commit comments

Comments
 (0)