JSPM

  • Created
  • Published
  • Downloads 433
  • Score
    100M100P100Q86913F
  • License MIT

html hint tool, focused on semantic code style.

Package Exports

  • htmlcs
  • htmlcs/lib/config

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (htmlcs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

htmlcs

Build Status NPM version Coverage Status Dependencies DevDependencies

html hint tool, focused on semantic code style.

Install

npm i -g htmlcs

Usage

  • in CLI

    htmlcs <file>
    
    htmlcs <folder>
    
    htmlcs format <file>
  • in Node.js / browser (with browserify)

    • hint file

      var htmlcs = require('htmlcs');
      var result = htmlcs.hintFile(filePath);
    • hint code (string)

      var htmlcs = require('htmlcs');
      var result = htmlcs.hint(code);
    • use hint result

      result.forEach(function(item){
          console.log(
              '[%s] line %d, column %d: %s (%s, %s)',
              item.type,
              item.line,
              item.column,
              item.message,
              item.rule,
              item.code
          );
      });
    • format file

      var htmlcs = require('htmlcs');
      console.log(htmlcs.formatFile(filePath))
    • format code (string)

      var htmlcs = require('htmlcs');
      console.log(htmlcs.format(code))
    • add rule

      var htmlcs = require('htmlcs');
      htmlcs.addRule({
          name: 'test-rule',
          desc: 'Just a test rule.',
          lint: function (getCfg, document, reporter) {
              reporter.warn(
                  1,
                  '099',
                  'This is a test waring!'
              );
          }
      });
      var result = htmlcs.hint(code);

Rules & Codes

lib/rules/

rule map

Config

  • default: lib/default/.htmlcsrc

  • custom:

    Custom rule file (.htmlcsrc) can be placed in the same/parent directory of target file, or the ~/ directory.

    If found in neither paths, the default config will be used.

  • inline:

    • disable

      <!-- htmlcs-disable -->
      <!-- htmlcs-disable img-alt -->
      <!-- htmlcs-disable img-alt, img-src, attr-value-double-quotes -->
    • enable

      <!-- htmlcs-enable -->
      <!-- htmlcs-enable img-alt -->
      <!-- htmlcs-enable img-alt, img-src, attr-value-double-quotes -->
    • config

      <!-- htmlcs img-width-height: true -->
      <!-- htmlcs img-width-height: true, indent-char: "tab" -->