Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(recipes): update htmlhint #779

Merged
merged 3 commits into from
May 7, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 36 additions & 13 deletions docs/recipes/htmlhint.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ $ npm install --save-dev gulp-htmlhint
Let's create a task in our `gulpfile.js` which runs HTMLHint across all our HTML files and outputs the error in the terminal:

```js
gulp.task('htmlhint', () => {
return gulp.src('app/**/*.html')
function htmlhint() {
return src('app/**/*.html')
.pipe($.htmlhint())
.pipe($.htmlhint.reporter());
});
}
```

Read [gulp-htmlhint's docs][api] to find out how you can pass options to HTMLHint.
Expand All @@ -30,25 +30,48 @@ Read [gulp-htmlhint's docs][api] to find out how you can pass options to HTMLHin

HTMLHint should run on serve and build.

```js
gulp.task('html', ['htmlhint', 'styles', 'scripts'], () => {
```diff
silvenon marked this conversation as resolved.
Show resolved Hide resolved
const build = series(
clean,
parallel(
lint,
- series(parallel(styles, scripts), html),
+ series(parallel(htmlhint, styles, scripts), html),
images,
fonts,
extras
),
measureSize
);
```

```js
gulp.task('serve', () => {
runSequence(['clean', 'wiredep'], ['htmlhint', 'styles', 'scripts', 'fonts'], () => {
```diff
let serve;
if (isDev) {
- serve = series(clean, parallel(styles, scripts, fonts), startAppServer);
+ serve = series(clean, parallel(htmlhint, styles, scripts, fonts), startAppServer);
} else if (isTest) {
serve = series(clean, scripts, startTestServer);
} else if (isProd) {
serve = series(build, startDistServer);
}
```

### 4. Run the task on each HTML change

In the `serve` task add the following line to run `htmlhint` every time a HTML file in the `app` directory changes:

```diff
+gulp.watch('app/**/*.html', ['htmlhint']);
gulp.watch('app/styles/**/*.scss', ['styles']);
gulp.watch('app/scripts/**/*.js', ['scripts']);
gulp.watch('app/fonts/**/*', ['fonts']);
gulp.watch('bower.json', ['wiredep', 'fonts']);
watch([
'app/*.html',
'app/images/**/*',
'.tmp/fonts/**/*'
- ]).on('change', server.reload);
+ ], {}, htmlhint).on('change', server.reload);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there are reason for passing empty options? They are optional.

Suggested change
+ ], {}, htmlhint).on('change', server.reload);
+ ], htmlhint).on('change', server.reload);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No specific reason. I've applied your suggestion.

Thanks!


watch('app/styles/**/*.css', styles);
watch('app/scripts/**/*.js', scripts);
watch('app/fonts/**/*', fonts);
```

## Usage
Expand Down