0.8.3 • Published 24 days ago

@krakentech/eslint-config v0.8.3

Weekly downloads
-
License
ISC
Repository
-
Last release
24 days ago

eslint-config

A publicly available ESLint config by Octopus Energy Group.

How to use

We publish our config as an ESLint config on npm. No registry token or authentication is required to install the config.

  • Add the config to your project with yarn add -D @krakentech/eslint-config
  • Extend @krakentech/eslint-config in your .eslintrc.js(on)
  • Customise rules as you wish, but prefer not to loosen rules where possible

Recommended use of Dependabot

If Dependabot is configured on your project, it will create Pull Requests to update @krakentech/eslint-config automatically when we update it, so you never need to worry about linting dependencies again. See below for more detail on how we implement this.

Available configs

We use ESLint's native extensibility to export three configurations to match your project's requirements.

We export:

  • a JS-only config, @krakentech/eslint-config/js, which applies React-enabled Javascript linting^1
  • a standard config, @krakentech/eslint-config/standard, which extends the js config with Typescript support
  • a "zero" config, @krakentech/eslint-config/zero, which set plugins and settings, but enables no rules by default

The module's default export, @krakentech/eslint-config, resolves to the standard config.

Zero config

Zero is useful for running only the rules you explicitly set whilst maintaining the regular config settings. This is useful - amongst other reasons - for parsing ignore statements.

Use with Next.js

The standard config works with Next.js projects, with some additional configuration. Always extend this config first, then optionally the Next recommended config after:

/* .eslintrc.js */
{
  extends: [
    "@krakentech/eslint-config",
    "plugin:@next/next/recommended",
    ...
  ],
  ...
}

^1: The benefit of this config over the standard one is that it'll work in projects that don't depend on Typescript. You may see a peer dependency warning but this can be ignored.

Dependency management with Rush Stack

We use the Rush Stack patch for ESLint (@rushstack/eslint-patch), which lets us bundle plugins as dependencies of this config. This means the shared config is responsible for config and plugin dependencies, not the client project.

This design enables plug-and-play configuration of new client projects, which can install @krakentech/eslint-config and forget about linting.

Releasing updates

The release process for our ESLint config is minimalist and somewhat manual at present.

In the packages/eslint-config,

  1. Increment the package version number in package.json
  2. Run yarn changeset to generate documentation for your release
  3. Ensure these changes are committed to GitHub and you are on the main branch
  4. Create a .npmrc file containing the following. The authToken can be found under "NPMJS - Global Write access token" in the KT - Vendors 1Password entry:
    @krakentech:registry=https://registry.npmjs.org/
    //registry.npmjs.org/:_authToken=WRITE_ACCESS_TOKEN_FROM_1PASSWORD
  5. Run yarn release to publish to npm

To use your new release,

  • Make a tea or coffee first, as npm takes a few minutes to propagate
  • Use yarn add -D @krakentech/eslint-config@x.y.z to install the new release

If you have trouble, check the package hasn't been made private inadvertently. Logging into our npm organisation account is required to fix this if broken.