4.0.1 • Published 2 years ago

@jtomaszewski/eslint-config v4.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Introduction

ESLint config to be used in some of our projects, that includes recommended rules of the following plugins:

  • eslint-config-airbnb / eslint-config-airbnb-base / eslint-config-airbnb-typescript
  • eslint-plugin-react
  • eslint-plugin-react-hooks
  • eslint-plugin-jsx-a11y
  • eslint-config-prettier
  • eslint-import-resolver-typescript
  • eslint-plugin-import
  • eslint-plugin-jest
  • eslint-plugin-promise
  • eslint-plugin-unicorn

With some slight modifications to some of the defaults on our side.

Usage

  1. Setup eslint as you would normally do.

  2. yarn add -D @jtomaszewski/eslint-config

  3. Add all peer dependencies of @jtomaszewski/eslint-config as dev dependencies in your project. Use npm info @jtomaszewski/eslint-config peerDependencies to look them up.

  4. Extend the config as in the following example:

    Node.js service:

    // .eslintrc.js
    module.exports = {
      parser: "@typescript-eslint/parser",
      parserOptions: {
        project: ["./tsconfig.json"],
      },
      extends: [require.resolve("@jtomaszewski/eslint-config/configs/ts-node")],
    };

    Node.js service without TS:

    // .eslintrc.js
    module.exports = {
      parser: "babel-eslint",
      extends: [require.resolve("@jtomaszewski/eslint-config/configs/node")],
    };

    Front-end React app:

    // .eslintrc.js
    module.exports = {
      parser: "@typescript-eslint/parser",
      parserOptions: {
        project: ["./tsconfig.json"],
      },
      extends: [require.resolve("@jtomaszewski/eslint-config/configs/ts-react")],
    };

    Cypress:

    // .eslintrc.js
    module.exports = {
      parser: "@typescript-eslint/parser",
      parserOptions: {
        project: ["./tsconfig.json"],
      },
      extends: [
        require.resolve("@jtomaszewski/eslint-config/configs/ts-cypress"),
      ],
    };

    Replace ts-node with other name of another config file if your environment differs.

Adding it to existing codebase

If your codebase is large and introducing this config makes eslint yell with hundreds of errors, you might find following advices to be useful:

Releasing

yarn release