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

eslint-plugin-sfgov

v3.0.0-alpha.0

Published

This is the shared [eslint] configuration for the [SF Digital Services team].

Downloads

1,106

Readme

eslint-plugin-sfgov

This is the shared eslint configuration for the SF Digital Services team.

Usage

  1. Upgrade npm (optional, but strongly recommended):

    npm --version

    If you're running npm version 6.x or earlier, you're going to have issues with shared eslint rule dependencies. You can upgrade npm to the latest version with:

    npm i -g npm@latest
  2. Install eslint and eslint-plugin-sfgov as dev dependencies:

    npm install --save-dev eslint@8 eslint-plugin-sfgov@latest
  3. Set up your eslint configuration, either in a standalone config file, e.g. .eslintrc.json:

    {
      "plugins": [
        "sfgov"
      ],
      "extends": [
        "plugin:sfgov/recommended"
      ]
    }

    or paste the above JSON into the eslintConfig key of your package.json.

  4. Configure additional eslint overrides or environments in your project, if necessary. See the list of available configurations for more info.

  5. Test it! Run npx eslint to lint all of the known JS files in your project, or pass specific file paths a la npx eslint src/**/*.js.

    ℹ️ If the issues that your new eslint config surfaces are overwhelming, you can use eslint-nibble to get an overview and focus on specific rules.

    Assuming your JavaScript is committed to git, and depending on the nature of your rule violations, it may also be possible to fix many of them by running eslint with the --fix flag.

  6. Add a lint or lint-js entry in the scripts field of your package.json that runs eslint on all of the relevant files in your project.

  7. Call npm run lint in your CI workflow to fail builds with malformed code.

Available configurations

Each of the configurations below can be included in the extends array of your eslint configuration.

plugin:sfgov/recommended

This is the "base" configuration that includes:

These rules should work in any environment.

plugin:sfgov/node

This configuration is intended for JavaScript that runs directly in Node, and includes:

plugin:sfgov/babel

This configuration is intended for JavaScript that will be compiled with Babel, and includes:

  • Setting ESLint's parser to @babel/eslint-parser
  • Setting parserOptions.sourceType to module
  • Setting parserOptions.ecmaVersion to 2020

plugin:sfgov/jest

This configuration includes:

Why a plugin?

You may have noticed that this package is published as an eslint plugin rather than a "config" (i.e. eslint-config-sfgov). One challenge with shareable configs is that they can't reference their own plugins, which means that you (a consumer of this configuration) have to install all of them in your project. Popular configurations like Airbnb's suggest npx and/or shell one-liners to install all of their peer dependencies in your own package.json, which stinks. This configuration comes with the batteries included, and adds a single dev dependency to your package.json.