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

@wsmd/eslint-config

v1.2.0

Published

All-in-one, composable, ESLint configurations with support for TypeScript, React, Prettier, and Jest

Downloads

647

Readme

@wsmd/eslint-config

All-in-one, composable, ESLint configurations with support for:

  • Javascript (via Airbnb Javascript style guide)
  • React (via Airbnb React style guide)
  • TypeScript
  • Prettier
  • Jest

Usage

This package consists of various configurations that can be composed together depending on the needs of the project.

To get started, add @wsmd/eslint-config to your project:

# using yarn
yarn add --dev eslint @wsmd/eslint-config

# using npm
npm i --save-dev eslint @wsmd/eslint-config

Then add one or some of the configurations included in this package to your ESLint configuration file depending on the project's needs. For example, this ESLint configuration below adds support for TypeScript, Prettier and Jest:

{
  "extends": [
    "@wsmd/eslint-config/typescript",
    "@wsmd/eslint-config/prettier",
    "@wsmd/eslint-config/jest"
  ]
}

Note that some of configurations require other dependencies to be included in your project as well (npm does not allow optional peer dependencies). For more information, please refer to the documentation of each configuration below.

Configurations

@wsmd/eslint-config/base

This configuration is an extensions of the Airbnb JavaScript style guide targeted for JavaScript projects without React or TypeScript. It also serves as the base configuration for some of the other configurations included in this package.

Under the hood, this configuration extends:

  • airbnb-eslint-config-base
  • eslint-plugin-import

Usage

{
  "extends": [
    "@wsmd/eslint-config/base",
  ]
}

@wsmd/eslint-config/react

This is an extension of the base configuration targeted for React projects.

Under the hood, this configuration extends:

  • @wsmd/eslint-config/base
  • eslint-airbnb-config
    • eslint-plugin-react
    • eslint-plugin-jsx-a11y
  • eslint-plugin-react-hooks

Usage

{
  "extends": [
    "@wsmd/eslint-config/react",
  ]
}

@wsmd/eslint-config/typescript

This configuration adds support for TypeScript projects by specifying the TypeScript ESLint Parser (@typescript-eslint/parser) as the code parser. It also applies a set of rules specific to TypeScript.

It can also be used alongside @wsmd/eslint-config/base or @wsmd/eslint-config/react.

Under the hood, this configuration extends:

  • @typescript-eslint/recommended
  • plugin:import/typescript

Usage

{
  "extends": [
    "@wsmd/eslint-config/typescript",
  ]
}

If you are including this configuration in your project, make sure you have typescript installed a dependency.

@wsmd/eslint-config/prettier

This configuration enforces Prettier formatting via ESLint. This includes:

  • Disabling all ESLint rules that may conflicts with prettier formatting.
  • Reporting prettier violations as ESLint issues.

It does not extend any of the other configurations in this package. However, please note that it must be applied after all other configurations.

Usage

{
  "extends": [
    /* other eslint configurations... */
    "@wsmd/eslint-config/prettier"
  ]
}

If you are including this configuration in your project, make sure you have prettier installed a dependency.

@wsmd/eslint-config/jest

This configuration configures the ESLint environment to be compatible with Jest. It also extends the style and recommended rules included in eslint-plugin-jest.

It does not extend any of the other configurations in this package.

Usage

{
  "extends": [
    "@wsmd/eslint-config/jest",
  ]
}

@wsmd/eslint-config/all

This configuration is a convenient configuration that extends all the other configurations above.

By extending it, ESLint support will enforce rules from the Airbnb JavaScript and React style guide, and have support for TypeScript, Jest, and Prettier.

Usage

{
  "extends": [
    "@wsmd/eslint-config/all",
  ]
}

Composing Multiple Configurations

The idea of this package is to allow the composition of multiple configurations to better fit the project needs as opposed to a catch-all configuration that could potentially slow down the linting process if most of the rules are not needed.

{
  "extends": [
    "@wsmd/eslint-config/base",
    "@wsmd/eslint-config/react", // `react` already includes `base`
    "@wsmd/eslint-config/typescript",
    "@wsmd/eslint-config/prettier",
    "@wsmd/eslint-config/jest"
  ]
}

Gotchas

Order of Configs

If you are composing multiple configurations, note that the configurations must be listed in the following order:

The base/react configs come first, followed by the typescript config, then followed by the prettier config.

Custom Rules

This config builds on top of popular style guides and recommended rule sets of various plugins. However, it was originally built as a sharable ESLint configuration for my personal projects. This means that there are a small number of rule overrides that I have applied as well.

You can still override these rules and customize others in your ESLint config file:

{
  "extends": [
    "@wsmd/eslint-config/base",
    "@wsmd/eslint-config/typescript",
    "@wsmd/eslint-config/prettier",
    "@wsmd/eslint-config/jest"
  ],
  "rules": {
    // override rules here
  }
}

License

MIT