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

svglint

v2.7.1

Published

Linter for SVGs

Downloads

9,157

Readme

SVGLint

Lints SVG files. Can be run as a commandline utility, or as a NodeJS library.

Usage

The tool can be used as a commandline tool by executing the CLI. If installed as a dependency by NPM this will be found at ./node_modules/.bin/svglint. If installed globally by NPM it can be executed directly as svglint.

$ svglint --help

  Linter for SVGs

  Usage:
      svglint [--config config.js] [--ci] [--debug] file1.svg file2.svg
      svglint --stdin [--config config.js] [--ci] [--debug] < file1.svg

  Options:
      --help        Display this help text
      --version     Show the current SVGLint version
      --config, -c  Specify the config file. Defaults to '.svglintrc.js'
      --debug,  -d  Show debug logs
      --ci, -C      Only output to stdout once, when linting is finished
      --stdin       Read an SVG from stdin

The tool can also be used through the JS API.

import SVGLint from "svglint";

const linting = await SVGLint.lintSource("<svg>...</svg>", {
    // ... config goes here
});
linting.on("done", () => {
    if (!linting.valid) {
        console.log("You've been a naughty boy!");
    }
});

Config

In order to specify what should be linted SVGLint must be given a configuration object. If you are using the CLI, this configuration object is read from the file specified by --config. This defaults to .svglintrc.js, which will be searched for up through the directory tree, or in the user's home directory (e.g. ~/.svglintrc.js on Unix-like systems) - this is similar to tools such as ESLint.

This configuration file should export a single object, of the format:

export default {
    // additional configuration may go here in the future
    // for now, "rules" is the only useful key
    rules: {
        elm: [{
            // config 1 for the "elm" rule
        }, {
            // config 2 for the "elm" rule
        }],
        attr: {
            // config 1 for the "attr" rule
        },
        custom: [
            function() { // config 1 for the "custom" rule }
        ]
    }
}

For specifics on how the config for each rule should be formatted, see their specific rule files.

If you are using the JS API, this configuration object is passed as the second parameter.

If no configuration is found or provided, a default configuration object is used. This default configuration may be changed such that previously valid SVGs become invalid in minor releases and patches.