0.0.12 • Published 7 days ago

@auditorium-ai/eslint-config v0.0.12

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
7 days ago

@auditorium-ai/eslint-config

This package contains a root ESLint config, with automatic support for TypeScript and React.

Methodology

Style rules

As linting configs are often heavily debated, this config uses Prettier for most code-style choices.

The base config is eslint-config-airbnb.

TypeScript support

When working with TypeScript, the recommended rules from @typescript-eslint/eslint-plugin are applied.

You should also ensure that your IDE is set up to run ESLint on TypeScript files. In VSCode, this setting is:

  "eslint.validate": [
      "javascript",
      "javascriptreact",
      "typescript",
      "typescriptreact"
  ],

Installation

To manually install, add this package to the "extends" array in your project’s ESLint config.

{
  "extends": ["@auditorium-ai-ai/eslint-config"]
}

The following base configs are available:

  • @auditorium-ai-ai/eslint-config (JS/TS-only)
  • @auditorium-ai-ai/eslint-config/react (JS/TS and React)

Optional configs are also available, and can be added alongside either of the base configs:

  • @auditorium-ai-ai/eslint-config/jest

Support for monorepos

This config has automatic configuration for monorepos.

This requires a single root ESLint config.

If you're working with TypeScript, each package that uses TypeScript must have a tsconfig.json.

Usage in JavaScript projects

If you aren't using TypeScript, you may need to add the browser environment to your ESLint config.

module.exports = {
  extends: ["@auditorium-ai-ai/eslint-config/react", "@auditorium-ai-ai/eslint-config/jest"],
  env: {
    browser: true,
  },
};

Additionally, you will need to install TypeScript as a dependency of your project.

Customising rules

You can easily add, modify, or disable rules with this config.

module.exports = {
  extends: ["@auditorium-ai-ai/eslint-config"],
  rules: {
    "some-rule": 2,
    "some-other-rule": 1,
  },
};

Targeting TypeScript or JavaScript

If you want your rule change to only affect a certain filetype, use overrides.

module.exports = {
  extends: ["@auditorium-ai/eslint-config/react"],
  overrides: [
    {
      files: ["*.ts", "*.tsx"],
      rules: {
        "some-rule": 0,
      },
    },
    {
      files: ["*.js"],
      rules: {
        "some-rule": 2,
      },
    },
  ],
};