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

@totominc/eslint-config-react

v0.9.0

Published

Personal ESLint config for React + TypeScript projects.

Downloads

8

Readme

@totominc/eslint-config-react

About this configuration

  • eslint:recommended: recommended ESLint rules.
  • eslint-airbnb + eslint-airbnb-typescript: based on the Airbnb code-styleguide both TypeScript, with adaptations for React projects.
  • eslint-jsx-a11y: enforce a11y best-practices.
  • eslint-react-hooks: rules to help you enforce Rules of Hooks and avoid common issues.
  • eslint-comments: better control over ESLint comments to avoid ESLint comments disable abuse.
  • eslint-unicorn: some more powerful and stricter rules for JavaScript.
  • eslint-promise: enforce best-practices around JS promises.
  • eslint-jest: enforce best-practices when writing unit-tests with Jest.
  • prettier: an opinionated code-styleguide which is pre-configured. It is possible to overwrite this for your personal preference.
  • prettier-plugin-tailwindcss: a Prettier plugin for TailwindCSS v3.0+ that automatically sorts classes based on their recommended class order.
  • Some extra stuff such as lintint JSON and YML files.

Installation

In order to work around a known limitation in ESLint, we recommend you to use @rushstack/eslint-patch so that you don't have to manage ESLint dependencies by yourself.

npm i --save-dev @totominc/eslint-config-react @rushstack/eslint-patch prettier eslint

Usage

Create an .eslintrc.js file at the root of your project and add the following configuration:

require("@rushstack/eslint-patch/modern-module-resolution");

module.exports = {
  root: true,
  extends: ['@totominc/react'],
  parserOptions: {
    tsconfigRootDir: __dirname,
    project: ['./tsconfig.json'],
  },
};

Jest & Testing-Library support

If your project contains unit-tests written with Jest and Testing-Library (for React), you can extend the ESLint config by doing the following:

module.exports = {
  extends: ['@totominc/react', '@totominc/react/jest'],
};

Jest ESLint rules will only applies on the test files matching **/__tests__/**/* and **/*.{spec,test}.*.

Next.js support

For Next.js project, we also provide a custom ESLint config which you can extend by doing the following:

module.exports = {
  extends: ['@totominc/react', '@totominc/react/next'],
};

FAQ

I want to register custom path aliases

# Install ESLint plugin to resolve alias imports.
npm i --save-dev eslint-import-resolver-alias
module.exports = {
  settings: {
    // Register `@/` as an import alias to `src/**/*`.
    "import/resolver": {
      alias: {
        map: [['@', './src/']],
        extensions: ['.js', '.jsx', '.ts', '.tsx'],
      },
    },
  },
};

I have multiple tsconfig.json files

module.exports = {
  parserOptions: {
    tsconfigRootDir: __dirname,
    project: ['./tsconfig.json', './tsconfig.web.json'],
  },
};

However, if you have multiple tsconfig.json files, we recommend you to create a dedicated tsconfig.json file for ESLint such as tsconfig.eslint.json:

  • https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/README.md#parseroptionsproject
  • https://github.com/typescript-eslint/typescript-eslint/blob/main/tsconfig.eslint.json
  • https://typescript-eslint.io/docs/linting/monorepo/#one-root-tsconfigjson

I am getting error "The file must be included in at least one of the projects provided"

Please follow this explanation from the official @typescript-eslint documentation.

License

MIT license, please see the LICENSE file in this project.