npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mitsue/vlint

v0.11.3

Published

A linter for HTML and CSS using [Nu html Checker](https://validator.github.io/validator/).

Downloads

1,722

Readme

@mitsue/vlint

A linter for HTML and CSS using Nu html Checker.

Usage

  1. Install vlint

    npm i --save-dev @mitsue/vlint
  2. Put .vlintrc.yml in your project directory.

    html:
        vnu: https://example.com/nu/
    css:
        vnu: https://example.com/nu/

    Note: vlint transmits your content to Nu Html Checker.

  3. Run vlint

    # html
    # HTML files (extension is either .htm, .html, or .shtml) will be checked.
    npx vlint
    
    # css
    # CSS files (extension is .css) will be checked.
    npx vlint --css

Configuring

vlint can be configured from a .vlintrc.yml.

html:
    vnu: https://example.com/nu/
    validator: https://example.com/check
    timeout: 5000
    charset: utf-8
    include: '**/*.+(htm|html|shtml)'
    ignore:
        - '**/node_modules/**'
css:
    vnu: https://example.com/nu/
    timeout: 120000
    charset: utf-8
    include: '**/*.css'
    ignore:
        - '**/node_modules/**'
  • vnu

    URL of Nu Html Checker

    Default: no default value. This must be specified.

  • validator

    URL of W3C Markup Validator. If this option was specified, XHTML 1.0, HTML 4.01 and so on are validated by W3C Markup Validator.

    HTML files which are not supported by W3C Markup Validator are validated by Nu Html Checker even if this option was specified.

    Specifying this option for css has no effect. CSS files are validated by Nu Html Checker even if this option was specified.

    Default: no default value.

  • timeout

    Time to wait until a response from network in milliseconds. Set 0 to disable timeout.

    Default: 5,000 (HTML) or 120,000 (CSS)

  • charset

    Encoding (charset) of the file. If this option was omitted, Nu Html Checker detects encoding automatically.

    Default: no default value.

  • include

    glob pattern of HTML or CSS. This can be a string or an array of string.

    Default: **/*.+(htm|html|shtml) (HTML) or **/*.css (CSS)

  • ignore

    glob pattern of files which ignored by vlint. This can be a string or an array of string.

    Default: [**/node_modules/**]

Cache

vlint can cache the result of the Nu Html Checker. The cache allows vlint validate only changed files. This will improve vlint's performance in most cases.

vlint --cache
vlint --cache --rebaseline
vlint --cache --css
vlint --cache --css --rebaseline

Notes:

  • vlint considers a file is changed if hash of its content is different
    • Metadata based caching is not planned
  • If the version of the Nu Html Checker is different from the cache, every file will be validated even if it isn't changed

The cache is stored at .cache/@mitsue/vlint by default. You can change the cache location by specifying --cache-dir.

vlint --cache --cache-dir path/to/directory

Specifying --cache-dir without --cache has no effect.

# This has no effect
vlint --cache-dir path/to/directory

Ignoring errors and warnings

vlint ignores errors and warnings defined in .vlintignore.yml.

You can generate or update the entire of .vlintignore.yml by running following commands:

vlint --rebaseline
vlint --css --rebaseline

Note: above mentioned commands remove comments from and sort keys (file paths) of .vlintignore.yml.

Also, you can update the specific parts of .vlintignore.yml by running following commands:

vlint --update path/to/html
vlint --css --update path/to/css

Note: above mentioned commands remove comments from and sort keys (file paths) of .vlintignore.yml.

Additionally, you can edit .vlintignore.yml manually.

html:
    # glob pattern
    '**/*.html':
        # regular expression
        - 'Legacy encoding “.*” used\. Documents must use UTF-8\.'
        - 'The only allowed value for the “charset” attribute for the “meta” element is “utf-8”\.'
css:
    # glob pattern
    path_to_css/styles.css:
        # regular expression
        - 'Warning: Document uses the Unicode Private Use Area\(s\), which should not be used in publicly exchanged documents\. \(Charmod C073\)'

Changelog

0.11.3 - 2024-05-21

  • Made default timeout be 120,000 milliseconds for CSS

0.11.2 - 2024-05-21

  • Made default timeout be 30,000 milliseconds for CSS
  • Use synchronous file system operation to improve performance though performance gain is unnoticeable in most cases

0.11.1 - 2024-04-01

  • Made default timeout be 5,000 milliseconds
  • Fix various issue preventing W3C Markup Validator validate files

0.11.0 - 2024-04-01

0.10.0 - 2023-10-24

  • vlint --rebaseline and vlint --update sort keys (file paths) of .vlintignore.yml

0.10.0-beta.0 - 2023-01-12

  • Added cache feature
  • Made vlint throw when unknown command line arguments were supplied
  • Updated dependencies

0.9.1 - 2022-10-26

  • Fixed error message format

0.9.0 - 2022-10-26

  • Made vlint reject invalid config files (.vlintrc.yml and .vlintignore.yml)
  • Made vlint reject invalid validation messages from Nu Html Checker and W3C Markup Validator
  • Made vlint throw there are unused messages in .vlintignore.yml
  • Updated dependencies

0.8.1 - 2022-01-01

  • Made README.md use example.com in config examples
  • Updated dependencies

0.8.0 - 2021-09-06

  • Made filtering faster
  • Dropped Node.js 10 support
  • Added ability to display the number of files to be validated
  • Updated dependencies

0.7.0 - 2021-04-22

  • Restored Node.js 10 support
  • Fixed an issue that vlint escaped RegExp literals incorrectly
  • Replaced meow with cac to reduce package install size
  • Updated dependencies

0.6.1 - 2020-04-03

  • Fixed wrong calculation of basic authorization credentials
  • Updated dependencies

0.6.0 - 2020-04-01

  • Added basic authorization support
  • Updated dependencies

0.5.0 - 2020-02-25

0.4.1 - 2020-01-31

  • Removed test coverage information from npm package

0.4.0 - 2020-01-31

  • Added --update flag to support updating the specific part of .vlintignore.yml
  • Added support '.yml' extension for '.vlintrc' and '.vlintignore' (.vlintrc.yml and .vlintignore.yml)
  • Updated dependencies

0.3.0 - 2019-09-27

  • Escape more regexp meta characters
  • Fixed removing used patterns in .vlintignore.yaml

0.2.0 - 2019-09-21

  • Respect ignore option in pre-commit hook scenario
  • Updated dependencies

0.1.0 - 2019-08-08

  • Initial release