How to use the htmlhint.HTMLHint.verify function in htmlhint

To help you get started, we’ve selected a few htmlhint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github learningequality / kolibri / frontend_build / src / prettier-frontend.js View on Github external
// Raw JS or SCSS file
        if (file.endsWith('.js')) {
          options.parser = 'babylon';
          formatted = prettier.format(source, options);
          if (formatted !== source) {
            notSoPretty = true;
          }
          formatted = eslint(formatted);
        } else if (file.endsWith('.scss')) {
          formatted = lintScss(source);
        } else if (file.endsWith('.vue')) {
          let block;
          // First lint the whole vue component with eslint
          formatted = eslint(source);
          // Now run htmlhint on the whole vue component
          let htmlMessages = HTMLHint.verify(formatted, htmlHintConfig);
          if (htmlMessages.length) {
            messages.push(...HTMLHint.format(htmlMessages, { colors: true }));
          }

          let vueComponent = compiler.parseComponent(formatted);
          // Prettier strips the 2 space indentation that we enforce within script tags for vue
          // components. So here we account for those 2 spaces that will be added.
          options.printWidth = options.printWidth - 2;

          // Format script block
          if (vueComponent.script) {
            block = vueComponent.script;

            const js = block.content;
            options.parser = 'babylon';
            let formattedJs = prettier.format(js, options);
github bezoerb / grunt-php2html / tasks / php2html.js View on Github external
var finish = function (target, response, cb) {
                        var messages = [],
                            empty = typeof response === 'undefined' || response === '';


                        // Lint generated html and check if response is  empty
                        if (options.htmlhint !== false) {
                            messages = HTMLHint.verify(response || '', options.htmlhint);
                        }

                        // move on to the next file if everything went right
                        if (!error && messages.length === 0 && !empty) {
                            grunt.file.write(target, response);
                            grunt.log.ok();
                            grunt.log.debug(target + ' written');
                            compiled.push(target);

                            // there was an error, show messages to the user if applicable and move on
                        } else {
                            grunt.log.error();

                            if (empty) {
                                grunt.log.warn('Resulting HTML is empty');
                            }
github bezoerb / gulp-htmlhint / index.js View on Github external
return through2.obj((file, enc, cb) => {
    const report = HTMLHint.verify(file.contents.toString(), ruleset);

    // Send status down-stream
    file.htmlhint = formatOutput(report, file, options);
    cb(null, file);
  });
};
github learningequality / kolibri / packages / kolibri-tools / lib / lint.js View on Github external
formatted = eslint(source);

          let vueComponent = compiler.parseComponent(formatted);

          // Format template block
          if (vueComponent.template && vueComponent.template.content) {
            formatted = insertContent(
              formatted,
              vueComponent.template,
              vueComponent.template.content
            );
            vueComponent = compiler.parseComponent(formatted);
          }

          // Now run htmlhint on the whole vue component
          let htmlMessages = HTMLHint.verify(formatted, htmlHintConfig);
          if (htmlMessages.length) {
            messages.push(...HTMLHint.format(htmlMessages, { colors: true }));
          }

          // Format script block
          if (vueComponent.script) {
            block = vueComponent.script;

            const js = block.content;
            let formattedJs = prettierFormat(js, 'babel', true);
            formatted = insertContent(formatted, block, formattedJs);
            if (formattedJs.trim() !== js.trim()) {
              notSoPretty = true;
            }
          }
github DefinitelyTyped / DefinitelyTyped / htmlhint / htmlhint-tests.ts View on Github external
const htmlHintRules: RuleSet = {
    "tagname-lowercase": true,
    "attr-lowercase": true,
    "attr-value-double-quotes": true,
    "doctype-first": true,
    "tag-pair": true,
    "spec-char-escape": true,
    "id-unique": true,
    "src-not-empty": true,
    "attr-no-duplication": true,
    "title-require": true,
    "space-tab-mixed-disabled": "tab"
};

const result = HTMLHint.verify('<span></span>', htmlHintRules);
const formatted = HTMLHint.format(result, { indent: 2 });
github alan-agius4 / speedy-build-tools / src / lint / lint-html / lint-html.ts View on Github external
async function lintFile(filePath: string, configData: RuleSet): Promise {
	logger.debug(lintFile.name, `filePath: ${filePath}`);

	return {
		result: HTMLHint.verify(await fileSystem.readFileAsync(filePath), configData),
		filePath
	};
}
github htmlhint / grunt-htmlhint / tasks / htmlhint.js View on Github external
arrFilesSrc.forEach(function(filepath) {
            var file = grunt.file.read(filepath),
                msg = "   " + filepath,
                messages;
            if (file.length) {
                messages = HTMLHint.verify(file, options);
                if (messages.length > 0) {
                    grunt.log.writeln(msg);
                    var arrLogs = HTMLHint.format(messages, {
                        colors: true,
                        indent: 6
                    });
                    arrLogs.forEach(function(log){
                        grunt.log.writeln(log);
                    });
                    grunt.log.writeln('');
                    hintCount += messages.length;
                    fileCount ++;
                }
            }
        });
github hellofresh / lentil / lib / ingredients / HTMLHintIngredient.js View on Github external
.then((contents) => ({
                        filePath: file,
                        report: HTMLHint.verify(contents, this.ingredientConfig),
                    }))
            )