New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@krakentech/eslint-config

Package Overview
Dependencies
Maintainers
0
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@krakentech/eslint-config

A globally shareable ESLint config for Octopus Energy repositories.

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

@krakentech/eslint-config

A publicly available ESLint config by Octopus Energy Group.


This package provides a wide range of "recommended" ESLint configs with the goal of minimising end-user configuration and increasing consistency across projects. It is designed around ESLint v9 to allow for easily shareable, modular and extensible configurations by leveraging the new "Flat" config files.

Installation

We publish our ESLint config publicy on npm. No registry token or authentication is required to install the config. Install it alongside the latest eslint version using your preferred package manager:

pnpm add -D @krakentech/eslint-config eslint
yarn add -D @krakentech/eslint-config eslint
npm install --save-dev @krakentech/eslint-config eslint

[!NOTE] If you are using a monorepo it's still recommended to install the package at the root of the project. ESlint v9 is now able to apply rules top down, making it trivial to limit specific rule-sets to the right files. For example, the recommended NextJS package can easily be restricted to apps/web if that is the only NextJS application in the monorepo.

Do I need a shared package in a monorepo?
  • Probably not! Because of how ESLint v9 and the new "Flat" configs work, this package is able to define all of the different plugins as dependencies. So, rather than having to create a shared eslint config we can easily just install this package at the root to share it across the whole repo.
  • If you would prefer to use a shared package or per-package config files then you can too. Install this package into the shared package and distribute accordingly. This package does not mind how you want to setup your repo.

Configuration

ESLint v9 now enforces the use of a file named eslint.config.js. This should be placed at the root of your project. Configuration of the whole repository can be done from this single file. Simply load the package and export linters.load(FlatConfig, ...).

Each FlatConfig only requires the user to define which files should have which plugins applied to them (or ignores) and which plugins the config extends from. You can pass as many configs as you like.

[!IMPORTANT] If you don't define any files for a config, the default behaviour it to lint all project files! This may affect performance.

Single Package ExampleMonorepo Example
// eslint.config.js

const linters = require("@krakentech/eslint-config");

module.exports = linters.load(
  // Ignore all node_modules and dist folders
  {
    ignores: ["**/node_modules/**", "**/dist/**"],
  },
  // Apply recommended typescript rules to all
  // Typescript files in the repo
  {
    files: ["**/*.{ts,tsx,mts,cts}"],
    extends: linters.configs.typescript.recommended,
  },
);
// eslint.config.js

const linters = require("@krakentech/eslint-config");

module.exports = linters.load(
  // Also ignore next build folder
  {
    ignores: [
      "**/node_modules/**",
      "**/dist/**",
      "**/.next/**"
    ],
  },
  // Apply recommended next rules to all apps
  {
    files: ["apps/**/*.{ts,tsx}"],
    extends: linters.configs.next.recommended,
  },
  // Only apply typescript rules to packages
  {
    files: ["packages/**/*.{ts,mts,cts}"],
    extends: linters.configs.typescript.recommended,
  },
);

[!TIP] We support both CJS and ESM config files! You can use import and export default if your package package type is set to module.

Fine tuning configurations

Whilst we suggest that you try to use the recommended configurations where possible to maintain consistency across projects, it is still simple to "extend" our recommended configs and "override" specific rules.

Simple Typescript Package

For example, lets say we want to create a ReactJS project that uses Typescript and disables the @typescript-eslint/no-explicit-any rule:

// eslint.config.js

const linters = require("@krakentech/eslint-config");

module.exports = linters.load(
  // ... other configs
  {
    files: ["**/*.{ts,tsx}"],
    extends: [
      // Load recommended Javascript rules
      ...linters.configs.javascript.recommended,
      // Load the recommended typescript configs
      ...linters.configs.typescript.recommended,
      // Then extend it with the React config
      ...linters.configs.react.recommended,
    ],
    // Override a specific rule
    rules: {
      "@typescript-eslint/no-explicit-any": "off",
    },
  },
);
Monorepo with multiple apps, packages and tests
// eslint.config.js

const linters = require("@krakentech/eslint-config");

module.exports = linters.load(
  // Global ignores across the whole repo
  {
    ignores: ["**/node_modules/**", "**/build/**", "**/*.typegen.*/**"],
  },
  // Apply Javascript recommended rules to all js(x) and ts(x) files
  {
    files: ["**/*.{js,jsx,ts,tsx}"],
    extends: linters.configs.javascript.recommended,
  },
  // Apply next recommended rules to all apps
  {
    files: ["apps/**/*.{ts,tsx}"],
    extends: linters.configs.next.recommended,
  },
  // Only apply typescript rules to packages
  {
    files: ["packages/**/*.{ts,mts,cts}"],
    extends: linters.configs.typescript.recommended,
  },
  // Applies react rules to all react files. This should also catch most test
  // files too.
  {
    files: ["**/*.{jsx,tsx}"],
    extends: [
      ...linters.configs.react.recommended, // Includes jsxa11y
    ],
  },
  // Applies jest rules to test files
  {
    files: ["**/*.spec.{js,jsx,ts,tsx}"],
    extends: linters.configs.jest.recommended,
  },
);

[!TIP] Some plugins have "utility" configs that do something specific to that plugin (usually to disable rules). Use these the same way you would use the base configs.

Why do we use extends
The load utility automatically merges configs inside of the extends field into a single config. This means we don't have to do fiddly spreading of multiple base configs.
Package Interface
export type LinterConfig = {
  base: FlatConfig;
  recommended: ConfigArray;
  utils?: Record<string, FlatConfig>;
};

export type PackageConfig = {
  load: (...configs: InfiniteDepthConfigWithExtends[]) => ConfigArray;
  configs: Record<string, LinterConfig>;
};

Plugins

The following plugins are supported by this package. Many of the recommended ConfigArray's only contain the base plugin, however, the recommended Typescript, React and NextJS configs contain multiple plugins, for which the table below also indicates the other plugins that are loaded.

PluginTypescriptReactNextJS
@eslint/js
typescript-eslint
eslint-plugin-import
eslint-plugin-simple-import-sort
eslint-plugin-react
eslint-plugin-react-hooks
eslint-plugin-jsx-a11y
@next/eslint-plugin-next
eslint-plugin-turbo
@vitest/eslint-plugin
eslint-plugin-jest
eslint-plugin-prettier

[!IMPORTANT] The recommended configs are configurations we think you should use in your projects, not that they necessarily use the recommended rules sets. Whilst most do use the recommended rule sets, it's good to check which rules sets using the JSDoc strings on each export or the plugin details below.

Examples

Base Configs

@eslint/js

Overrides
  • no-console - ["error", { allow: ["warn"] }]

typescript-eslint

We use the "Strict TypeChecked" rules (which automatically brings in the "Recommended" rules) to provide the most accurate type checking.

Overrides
  • @typescript-eslint/no-unused-vars
    • Allows the use of the _ prefix for unused variables
    • Will ignore unused destructured rest siblings: { ignoreMe, ...butNotMe } = someObject
  • @typescript-eslint/consistent-type-imports
  • Prefers types are always imported using the type keyword
  • e.g. import { type Foo } over import { Foo }
  • This works well the fixable rule import/consistent-type-specifier-style to ensure import consistency.

The following have been disabled:

  • @typescript-eslint/no-confusing-void-expression - Off
  • @typescript-eslint/restrict-template-expressions - Off
  • @typescript-eslint/no-unsafe-enum-comparison - Off
  • @typescript-eslint/unbound-method - Off
  • @typescript-eslint/no-floating-promises - Off

[!TIP] We provide the configs.typescript.utils.disableTypeChecking utility to disable the type checking rules if you need to disable type checking for whatever reason (e.g. old JSX only components).


eslint-plugin-import and eslint-plugin-simple-import-sort

We use both packages in configs.imports.recommended. We prefer eslint-plugin-simple-import-sort for import sorting because it requires less configuration to apply sensible sorting, is easier to configure and only creates an single issue if there's an error in the sorting. We also include eslint-plugin-import for a few rules that the former does not handle:

  • import/first - Ensure all imports appear before other statements.
  • import/newline-after-import - Enforce a newline after import statements.
  • import/no-duplicates - Forbid repeated import of the same module in multiple places.
  • import/consistent-type-specifier-style - Ensure that we consistently use import { type Foo }.
configs.imports.utils.disableSimpleImportSort

We provide the ability to disable the simple-import-sort plugin if it does not fit well with your project. Simply extend your config with this utility like so:

// eslint.config.js

import linters from "@krakentech/eslint-config";

export default linters.load({
  files: ["**/*.{ts,tsx}"],
  extends: [
    ...linters.configs.typescript.recommended,
    linters.configs.imports.utils.disableSimpleImportSort,
  ],
});

eslint-plugin-react, eslint-plugin-react-hooks and eslint-plugin-jsx-a11y

Overrides
  • react/prop-types - Off.
  • react/react-in-jsx-scope - Off.

@next/eslint-plugin-next


eslint-plugin-turbo


@vitest/eslint-plugin


eslint-plugin-jest


eslint-plugin-prettier

[!IMPORTANT] Prettier is not enabled by default in our recommended configs. The official advice by both the Prettier team and the ESLint team is to not integrate Prettier rules into your ESLint config. Formatters should be something you forget about; lots of red squiggly lines in your editor can be distracting as well as less performant.

However, it is expected that users implement Prettier into their workflow at some point. Ideally users integrate Prettier into their editors, or you run Prettier as a file watcher.

Alternatively (or in addition to), you can conditionally enable Prettier during CI to ensure committed code is formatted correctly:

// eslint.config.js

// This is the common CI ennvar, however, adjust to your system
const isCI = process.env.CI;

export default linters.load(
  ...
  // Enable Prettier in CI only
  isCI && {
    // No files array will lint all files
    extends: linters.configs.recommended.prettier,
  },
  ...
};

[!NOTE] Prettier should be enabled as your last config so that it can override any rules it might conflict with.

Rule Comparison

This table details which rules have been added or removed from the last major release (also compatibility with Biome given it looks like a promising upgrade from ESLint).

LegacyRecommendedBiome
@eslint/js - recommended
constructor-super
for-direction
getter-return
no-async-promise-executor
no-case-declarations
no-class-assign
no-compare-neg-zero
no-cond-assign
no-const-assign
no-constant-binary-expression
no-constant-condition
no-control-regex
no-debugger
no-delete-var
no-dupe-args
no-dupe-class-members
no-dupe-else-if
no-dupe-keys
no-duplicate-case
no-empty
no-empty-character-class
no-empty-pattern
no-empty-static-block
no-ex-assign
no-extra-boolean-cast
no-fallthrough
no-func-assign
no-global-assign
no-import-assign
no-invalid-regexp
no-irregular-whitespace
no-loss-of-precision
no-misleading-character-class
no-new-native-nonconstructor
no-nonoctal-decimal-escape
no-obj-calls
no-octal
no-prototype-builtins
no-redeclare
no-regex-spaces
no-self-assign
no-setter-return
no-shadow-restricted-names
no-sparse-arrays
no-this-before-super
no-undef
no-unexpected-multiline
no-unreachable
no-unsafe-finally
no-unsafe-negation
no-unsafe-optional-chaining
no-unused-labels
no-unused-private-class-members
no-unused-vars
no-useless-backreference
no-useless-catch
no-useless-escape
no-with
require-yield
use-isnan
valid-typeof
typescript-eslint - strictTypeChecked
ban-ts-comment
ban-types
no-duplicate-enum-values
no-explicit-any
no-extra-non-null-assertion
no-misused-new
no-namespace
no-non-null-asserted-optional-chain
no-this-alias
no-unnecessary-type-constraint
no-unsafe-declaration-merging
no-unused-vars
no-var-requires
prefer-as-const
triple-slash-reference
await-thenable
ban-ts-comment
no-array-delete
no-base-to-string
no-confusing-void-expression
no-deprecated
no-duplicate-type-constituents
no-dynamic-delete
no-empty-object-type
no-extraneous-class
no-floating-promises
no-for-in-array
no-implied-eval
no-invalid-void-type
no-meaningless-void-operator
no-misused-promises
no-misused-spread
no-mixed-enums
no-non-null-asserted-nullish-coalescing
no-non-null-assertion
no-redundant-type-constituents
no-require-imports
no-unnecessary-boolean-literal-compare
no-unnecessary-condition
no-unnecessary-template-expression
no-unnecessary-type-arguments
no-unnecessary-type-assertion
no-unnecessary-type-constraint
no-unnecessary-type-parameters
no-unsafe-argument
no-unsafe-assignment
no-unsafe-call
no-unsafe-enum-comparison
no-unsafe-function-type
no-unsafe-member-access
no-unsafe-return
no-unsafe-unary-minus
no-unused-expressions
no-unused-expressions
no-useless-constructor
no-useless-constructor
no-wrapper-object-types
only-throw-error
prefer-literal-enum-member
prefer-namespace-keyword
prefer-promise-reject-errors
prefer-readonly
prefer-readonly-parameter-types
prefer-regexp-exec
prefer-string-starts-ends-with
prefer-void-type
require-array-sort-compare
eslint-plugin-import
no-unresolved
named
namespace
default
export
first
newline-after-import
no-duplicates
consistent-type-specifier-style
eslint-plugin-simple-import-sort
simple-import-sort/imports
simple-import-sort/exports
eslint-plugin-react - recommended
react-in-jsx-scope
jsx-uses-react
display-name
jsx-key
jsx-no-comment-textnodes
jsx-no-duplicate-props
jsx-no-target-blank
jsx-no-undef
jsx-uses-vars
no-children-prop
no-danger-with-children
no-deprecated
no-direct-mutation-state
no-find-dom-node
no-is-mounted
no-render-return-value
no-string-refs
no-unescaped-entities
no-unknown-property
no-unsafe
prop-types
require-render-return
eslint-plugin-react-hooks
rules-of-hooks
exhaustive-deps
eslint-plugin-jsx-a11y - strict
alt-text
anchor-has-content
anchor-is-valid
aria-activedescendant-has-tabindex
aria-props
aria-proptypes
aria-role
aria-unsupported-elements
autocomplete-valid
click-events-have-key-events
control-has-associated-label
heading-has-content
html-has-lang
iframe-has-title
img-redundant-alt
interactive-supports-focus
label-has-for
label-has-associated-control
media-has-caption
mouse-events-have-key-events
no-access-key
no-autofocus
no-distracting-elements
no-interactive-element-to-noninteractive-role
no-noninteractive-element-interactions
no-noninteractive-element-to-interactive-role
no-noninteractive-tabindex
no-redundant-roles
no-static-element-interactions
role-has-required-aria-props
role-supports-aria-props
scope
tabindex-no-positive
@next/eslint-plugin-next - recommended - core-web-vitals
google-font-display
google-font-preconnect
next-script-for-ga
no-async-client-component
no-before-interactive-script-outside-document
no-css-tags
no-head-element
no-html-link-for-pages
no-img-element
no-page-custom-font
no-styled-jsx-in-document
no-sync-scripts
no-title-in-document-head
no-typos
no-unwanted-polyfillio
inline-script-id
no-assign-module-variable
no-document-import-in-page
no-duplicate-head
no-head-import-in-document
no-script-component-in-head
no-html-link-for-pages
no-sync-scripts
eslint-plugin-prettier
prettier/prettier
arrow-body-style
prefer-arrow-callback
eslint-plugin-jest - recommended
expect-expect
no-alias-methods
no-commented-out-tests
no-conditional-expect
no-deprecated-functions
no-disabled-tests
no-done-callback
no-export
no-focused-tests
no-identical-title
no-interpolation-in-snapshots
no-jasmine-globals
no-mocks-import
no-standalone-expect
no-test-prefixes
valid-describe-callback
valid-expect
valid-expect-in-promise
valid-title
eslint-plugin-vitest - recommended
expected-expect
no-identical-title
no-commented-out-tests
valid-title
valid-expect
valid-describe-callback
require-local-test-context-for-concurrent-snapshots
no-import-node-test
eslint-plugin-turbo
no-undeclared-env-vars

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.

Releasing updates

Following instructions for @changesets/cli;

Whenever you make a change, run pnpm changeset to generate documentation and include this in your last commit.

When you're ready to release changes (not necessarily after each change), follow the documentation from the changesets package above.

You may need to create a .npmrc file in packages/eslint-config 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

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.

FAQs

Package last updated on 03 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc