1.0.0-beta.17 • Published 3 years ago

@therealklanni/eslint-config v1.0.0-beta.17

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

@therealklanni/eslint-config npm downloads

❗️ It's not recommended to use these configs directly. Instead, install and configure them via @therealklanni/eslint-plugin, for ease-of-use.

This package provides multiple eslint-configurations that configure popular ESLint plugins. You should extend the appropriate config depending on your use-case.


These configs provide an opinionated set of rules that:

  1. Help you adhere to best practices.
  2. Help catch probable issue vectors in your code (common pitfalls and code-smells).
  3. Maximize readability/understanding of your code.
  4. Maximize (ease of) maintaining/refactoring your code.

Any rules that might cause excessive errors and are not auto-fixable are set to "warn".

For these reasons, many of the rules are enabled and, of those, most are using the recommended configuration except where it makes sense for achieving said goals. When used with Prettier, conflicting rules are disabled.

💁‍♂️ You might also consider using @therealklanni/prettier-config

Available configurations (and what they configure)

Usage

  1. Install required dependencies
    npm install -D @therealklanni/eslint-config eslint{,-plugin-import}
  2. Optionally, view and install any additional dependencies, as needed

    # list dependencies
    yarn view @therealklanni/eslint-config peerDependencies
    
    # install what you need
    yarn add -D eslint-plugin-{jest,node,react} @therealklanni/prettier-config ...
  3. Configure as shown here

    {
      // you only need to specify plugins not provided by these configs
      "plugins": ["some-unrelated-plugin"],
      "extends": [
        // add one or more configs, AFTER any unrelated configs
        "@therealklanni",
        "@therealklanni/eslint-config/typescript",
        "@therealklanni/eslint-config/jest"
      ],
      // override any rules, if needed
      "rules": {
        "@typescript-eslint/semi": ["error", "always"]
      }
    }
  4. ???
  5. Profit

"Hard mode" example

DIY file globs. Allows for more control over how configs are applied.

{
  "extends": [
    // apply last
    "@therealklanni"
  ],
  "overrides": [
    // if you need other unrelated overrides, add them first
    {
      "files": ["*.js"],
      "extends": ["@therealklanni"],
      "rules": {
        "semi": ["error", "always"]
      }
    },
    {
      "files": ["*.ts"],
      "extends": [
        "some-unrelated-config",
        "@therealklanni",
        "@therealklanni/eslint-config/typescript"
      ],
      "rules": {
        "@typescript-eslint/semi": ["error", "always"],
        "@typescript-eslint/init-declarations": "off"
      }
    },
    {
      "files": ["**/__tests__/**"],
      "extends": ["@therealklanni/eslint-config/jest"],
      "rules": {
        "jest/no-if": "warn"
      }
    },
    // apply last when using Prettier config
    {
      "files": ["*.?(ts,js)"],
      "extends": ["@therealklanni/eslint-config/prettier"]
    }
  ]
}

"Easy mode" example

Applies configs automatically wrapped in an override with a default files glob.

{
  "extends": [
    "some-unrelated-config",
    // apply @therealklanni configs after unrelated configs
    "@therealklanni",
    "@therealklanni/eslint-config/jest/auto",
    "@therealklanni/eslint-config/typescript/auto",
    // applied globally
    "@therealklanni/eslint-config/prettier"
  ],
  "rules": {
    "semi": ["error", "always"],
    "@typescript-eslint/semi": ["error", "always"],
    "@typescript-eslint/init-declarations": "off",
    "jest/no-if": "warn"
  }
}

Note: the prettier, node, and cli configs do not have an "auto" config, as these don't typically require an override.

1.0.0-beta.81

3 years ago

1.0.0-beta.4

3 years ago

1.0.0-beta.5

3 years ago

1.0.0-6

3 years ago

1.0.0-beta.11

3 years ago

1.0.0-beta.6

3 years ago

1.0.0-beta.7

3 years ago

1.0.0-beta.8

3 years ago

1.0.0-beta.9

3 years ago

1.0.0-beta.17

3 years ago

1.0.0-beta.15

3 years ago

1.0.0-beta.16

3 years ago

1.0.0-beta.14

3 years ago

1.0.0-5

4 years ago

1.0.0-4

4 years ago

1.0.0-3

4 years ago

1.0.0-2

4 years ago

1.0.0-1

4 years ago

1.0.0-0

4 years ago

0.1.17

4 years ago

0.1.16

4 years ago

0.1.15

4 years ago

0.1.14

4 years ago

0.1.13

4 years ago

0.1.12

4 years ago

0.1.10

4 years ago

0.1.11

4 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago