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

Can I lint the HTML immediately after pug→html conversion? #34

Open
ghost opened this issue Nov 19, 2017 · 0 comments
Open

Can I lint the HTML immediately after pug→html conversion? #34

ghost opened this issue Nov 19, 2017 · 0 comments

Comments

@ghost
Copy link

ghost commented Nov 19, 2017

Thank you for your amazing plugin!
When I make it works, the HTML validation routine becomes to past.

The following code is working in gulp#4.0:

    gulp.task('Development Build',
        gulp.series(
            gulp.parallel('pug', 'sass')
        )
    );
    
    gulp.task('Watch Assets And Source', function() {   
        gulp.watch(/* ... */, gulp.series('pug'));
        gulp.watch(/* ... */, gulp.series('sass'));
    });
    
    gulp.task('Static Server', function() {         
        browserSync.init({
            server: // ...
        });
        
        browserSync.watch(/* ... */).on('change', browserSync.reload);
        
    });

    gulp.task('Development Run',    
        gulp.series('Development Build', 
            gulp.parallel('Watch Assets And Source', 'Static Server')
        )
    );

As far as I can tell according documentation, the htmlhint is infinite task:

    var htmlhint = require("gulp-htmlhint");
    
    gulp.src("./src/*.html")
    	.pipe(htmlhint())
    	.pipe(htmlhint.reporter())

I tried to lint HTML immediately after pug → html conversion - zero effect, no messages in console:


    gulp.task('pug', function(){
        
        return gulp.src(/* ... */)
            .pipe(gulpIf(isDevelopment, sourcemaps.init()))
            .pipe(pug({pretty: true }))
            .pipe(htmlhint())
            .pipe(htmlhint.reporter())
            // ...

Other approach: add the Html Lint task to gulp.parallel('Watch Assets And Source', 'Static Server'). With below code, gulp is working, but there are no messages in console when HTML is invalid:

    gulp.task('Html Lint', function() {
        
        gulp.src('development/devBuild/public/01_top.html')
    	.pipe(htmlhint())
    	.pipe(htmlhint.reporter());
        
    });
    
    gulp.task('Development Run',    
        gulp.series('Development Build', 
            gulp.parallel('Watch Assets And Source', 'Static Server', 'Html Lint')
        )
    );

Ideally, it's comfortable to lint HTML immediately after pug → html conversion. Even if impossible, how I can see the invalid HTML messages?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants