-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b904ee
commit 0a96aea
Showing
8 changed files
with
1,272 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = tab | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[{*.json,*.yml,*.yaml}] | ||
indent_size = 2 | ||
indent_style = space |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: Lint | ||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
types: [opened, synchronize] | ||
jobs: | ||
lint: | ||
name: Run ESLint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: '12.x' | ||
- run: npm install | ||
- run: npm run lint |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/node_modules/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Alexey | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# gulp-html-validate | ||
|
||
Validate files with `html-validate`. | ||
|
||
## Installation | ||
|
||
```sh | ||
> npm install --save-dev gulp-html-validate | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
const gulp = require('gulp'); | ||
const htmlvalidate = require('gulp-html-validate'); | ||
|
||
exports.default = () => gulp.src('index.html').pipe(htmlvalidate()); | ||
``` | ||
|
||
You can also pass options to the `htmlvalidate` function: | ||
|
||
```js | ||
exports.default = () => | ||
gulp.src('index.html').pipe( | ||
htmlvalidate({ | ||
/* Your options here */ | ||
}) | ||
); | ||
``` | ||
|
||
### Options | ||
|
||
#### format | ||
|
||
Any formatter supported by `html-validate` (`stylish` by default). | ||
|
||
Type: `string`. | ||
|
||
## License | ||
|
||
Licensed under the [MIT License](./LICENSE). |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const through = require('through2'); | ||
const PluginError = require('plugin-error'); | ||
|
||
const { HtmlValidate } = require('html-validate'); | ||
const { getFormatter } = require('html-validate/build/cli/formatter'); | ||
|
||
const pluginName = 'gulp-html-validate'; | ||
const defaultOptions = { | ||
format: 'stylish', | ||
}; | ||
|
||
module.exports = (options) => { | ||
const pluginOptions = options || defaultOptions; | ||
|
||
const htmlvalidate = new HtmlValidate(); | ||
const formatter = getFormatter(pluginOptions.format); | ||
|
||
return through.obj(function(file, encoding, callback) { | ||
if (file.isNull()) { | ||
callback(null, file); | ||
return; | ||
} | ||
|
||
if (file.isStream()) { | ||
callback(new PluginError(pluginName, 'Streaming not supported')); | ||
return; | ||
} | ||
|
||
const result = htmlvalidate.validateFile(file.path); | ||
|
||
if (!result.valid) { | ||
const resultOutput = formatter(result); | ||
|
||
this.emit( | ||
'error', | ||
new PluginError(pluginName, resultOutput, { | ||
fileName: file.path, | ||
showStack: false, | ||
}) | ||
); | ||
} | ||
|
||
callback(null, file); | ||
}); | ||
}; |
Oops, something went wrong.