New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

svglint

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svglint

Linter for SVGs


Version published
Weekly downloads
5.6K
increased by22.65%
Maintainers
1
Weekly downloads
 
Created

SVGLint

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

Example of a commandline execution

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

  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

The tool can also be used through the JS API.

const SVGLint = require("svglint");
SVGLint.lintSource("<svg>...</svg>", {
    // ... config goes here
});

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 - this is similar to tools such as ESLint.

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

module.exports = {
    // 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.

FAQs

Package last updated on 10 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts