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

slint

v0.1.0

Published

Linting gone overboard

Downloads

109

Readme

slint

Lint-tool for web projects

What it does

It takes a basic recipe of what linters you want to apply to which files (and, optionally, the linter configuration):

[
    {
        "tool": "jshint",
        "files": ["**/*.js", "!node_modules"]
    },
    {
        "tool": "trailing-spaces",
        "files": ["**", "!node_modules"]
    },
    {
        "tool": "json",
        "files": ["**/*.json", "!node_modules"]
    }
]

Running the tool with this configuration file will use gitignore-style expansion to figure out what file to lint and run them through the relevant linter and report any errors.

Trying it out

  1. Install slint using npm install slint.
  2. Copy/paste the example code below into a slint.json in the root of your project.
  3. Run ./node_modules/.bin/slint slint.json.

If you want to add slint as a git pre-commit hook, fire off the following stanza:

echo ./node_modules/.bin/slint slint.json > .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit

Advanced slinting

The linters can be given optional configurations (strings will be read as JSON files and objects will be passed directly).

It is also important that linters can be run multiple times with different configurations/different files. (Ex. to allow ES5-stuff in Node.js-code, but disallow it in front-end code.)

[
    {
        "tool": "jshint",
        "files": ["./frontend-code/**/*.js", "!3rdparty"],
        "config": "./misc/jshint-frontend.conf"
    },
    {
        "tool": "jshint",
        "files": ["lib/**.js", "test/**.js" ],
        "config": "./misc/jshint-nodejs.conf"
    },
    {
        "tool": "trailing-spaces",
        "files": ["**", "!node_modules", "!3rdparty"]
    },
    {
        "tool": "json",
        "files": ["**/*.json", "!node_modules", "!3rdparty"],
        "config": {
            "indent": "  ",     // Use two spaces
            "canonical": false  // Don't sort object keys
        }
    }
]

Goals

  • Uniform output from all linters (and reporters to format output).
  • Pluggable linting infrastructure.
  • Fast. I/O seem to be the limiting factor, so by being async and work to not read files multiple times, it should improve.

Linters

  • trailing-spaces: Verifies that files doesn't have lines ending with whitespace-characters.
  • jshint:
    • Configuration is an ordinary jshint-configuration.
  • json:
    • Configuration: canonical (default: false) - checks if keys are sorted. indent (default: off) will check if the file is indented with the given string.
  • npm-packages: Compares what's in package.json versus output of npm ls.
  • less: Runs files through the less-compiler and checks for parse-errors.

TODO

  • HTML
  • CSS
  • package.json (all packages are pinned to versions, where to publish, ...)
  • package.json sanity checks
  • Check magic bytes binary data vs. extension
  • JPEGs are RGB (and not CMYK)
  • Consistent indentation (tabs vs spaces. And how many?)

See also

License

BSD (3-clause variety)