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

@bonniernews/eslint-config

v1.2.0

Published

ESLint config

Downloads

7,640

Readme

@bonniernews/eslint-config

Test application

Basic ESLint rules used by Bonnier News. The configuration works both with CommonJS and ES6 modules, and the appropriate setup will be used by looking at the projects package.json type property.

For Node versions that support it (version 16 and above), the es2022 environment will also be activated. Otherwise es2021 will be used.

Usage

Install eslint and @bonniernews/eslint-config:

npm install --save-dev eslint @bonniernews/eslint-config

Base configuration

To activate the config, you need to add the following to your .eslintrc.json-file:

{
  "root": true,
  "extends": [ "@bonniernews" ]
}

React configuration

To activate the config, you need to add the following to your .eslintrc.json-file:

{
  "root": true,
  "extends": [ "@bonniernews/eslint-config/react" ]
}

This will enable the react plugin for *.jsx-files.

TypeScript configuration

To activate the config, you need to add the following to your .eslintrc.json-file:

{
  "root": true,
  "extends": [ "@bonniernews/eslint-config/typescript" ]
}

This will enable the typescript plugin for *.ts-files.

React with TypeScript configuration

To activate the config, you need to add the following to your .eslintrc.json-file:

{
  "root": true,
  "extends": [ "@bonniernews/eslint-config/typescript-react" ]
}

This will enable the typescript and react plugin for *.tsx-files.

Test configuration

You can also choose to use the test config, which is adapted to testing using mocha, mocha-cakes-2 and chai. To also enable this, either add a separate test configuration file extending from "@bonniernews/eslint-config/test", or use the "@bonniernews/eslint-config/all" in your root configuration to activate everything together:

{
  "root": true,
  "extends": [ "@bonniernews/eslint-config/all" ]
}

This will activate the test configuration for all files inside directories named test or tests.

Running eslint

Run with:

npx eslint .

Usage in an existing project

  • We advice to remove any husky hooks that uses libraries such as pretty-quick from your package.json
  • Subsequently remove any use of pretty-quick if possible.
  • Remove any previous use of sharable ESLint configs from package.json, i.e.:
    • eslint-config-airbnb
    • eslint-config-google
    • eslint-config-prettier
  • Remove eslint-plugin-prettier from package.json
  • If you get errors similar to the ones below, please update the eslint dependancy.
    • Definition for rule 'no-nonoctal-decimal-escape' was not found
    • Definition for rule 'no-unsafe-optional-chaining' was not found
  • If you still have issues; try updating npm (if you use nvm nvm install-latest-npm) & prettier as-well
  • Remove any 'eslint-disable-line no-unused-expressions' directives added because of chai assertions, they are not needed anymore (eslint-plugin-chai-friendly is used in test).
  • Remove any globals and special rules related to mocha-cakes-2 in your test configuration, they already exist in the @bonniernews/eslint-config/test and @bonniernews/eslint-config/all configs.

Once you complete the steps above run the following:

npx eslint . --fix

Usage with Prettier

If you want to use Prettier, run it before eslint. ESLint should be the final judge, i.e. run:

npx prettier --save .
npx eslint . --fix

This will format the entire code base according to the rules of Prettier and the config.

Enable format on save

Changelog

Can be found here.

License

Released under the MIT license.