Package detail

eslint-config-ackama

ackama7.1kISC4.1.0

Standard ESLint configurations for Ackama projects.

readme

Ackama ESLint Configuration

Standard ESLint configurations for Ackama projects.

Basic Setup

Install this package & the required plugins:

npm install --save-dev eslint-config-ackama @types/eslint @eslint-community/eslint-plugin-eslint-comments @eslint/js @stylistic/eslint-plugin-js eslint eslint-plugin-import eslint-plugin-n eslint-plugin-prettier prettier

Add an eslint.config.js to your repo that imports this config:

const configAckamaBase = require('eslint-config-ackama');

/** @type {import('eslint').Linter.FlatConfig[]} */
const config = [
  { files: ['**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}'] },
  ...configAckamaBase
];

module.exports = config;

To reduce potential errors, the configurations provided by this package deliberately avoid making assumptions about the environment you're working in, meaning you will need to configure what globals are available using the globals package:

const configAckamaBase = require('eslint-config-ackama');
const globals = require('globals');

/** @type {import('eslint').Linter.FlatConfig[]} */
const config = [
  { files: ['**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}'] },
  ...configAckamaBase,
  {
    languageOptions: {
      globals: {
        ...globals.node, // for NodeJS apps
        ...globals.browser, // for browser apps
        ...globals.commonjs // for browser apps that are bundled using a bundler such as webpack
      }
    }
  }
];

module.exports = config;

[!NOTE]

The legacy configuration set the es2017 env by default, since the majority of projects should be using ES2017 or higher.

The equivalent to this in the flat configuration format is the languageOptions.ecmaVersion property, which defaults to latest meaning you don't need to set it unless you're using a different version of ECMAScript.

You can also add a lint script to the scripts property in your apps package.json to make it easier for developers to run eslint against the app:

{
  "scripts": {
    "lint": "eslint"
  }
}

This can be called via npm run lint or yarn run lint, depending on the package manager you're using.

Additional Configs

In addition to the ackama config (which pulls in index.js) for vanilla Javascript, this config package ships with a number of other configs for linting specific packages and frameworks.

You can use these by extending them by their names in the same way as the base config, except you must prefix them with ackama/. You will also be required to install any extra plugins and dependencies these configs require that are not required for the base config.

Below is a complete list of the configs provided, and their dependencies:

  • ackama
    • @eslint-community/eslint-plugin-eslint-comments
    • @stylistic/eslint-plugin-js
    • eslint-plugin-prettier
    • eslint-plugin-import
    • eslint-plugin-n
  • ackama/jest
    • eslint-plugin-jest
  • ackama/react
    • eslint-plugin-prettier
    • eslint-plugin-react
    • eslint-plugin-react-hooks
    • eslint-plugin-jsx-a11y
  • ackama/typescript
    • @typescript-eslint/parser
    • @typescript-eslint/eslint-plugin
    • @stylistic/eslint-plugin-ts
    • eslint-plugin-prettier

Ignoring files

Often there are files and folders that you don't want ESLint to check. While the base config already setups ignores for common folders, including node_modules, vendor, coverage, lib, out, and a few more, unique projects might need to ignore additional folders, or inversely might want to un-ignore a preset ignore.

This can be done by including a configuration object with just an ignores key, making it act as a global ignore:

const configAckamaBase = require('eslint-config-ackama');

/** @type {import('eslint').Linter.FlatConfig[]} */
const config = [
  { files: ['**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}'] },
  { ignores: ['infra'] },
  ...configAckamaBase
];

module.exports = config;

Typical complete example

Here's what a typical eslint.config.js would look like for a TypeScript project that uses jest & react:

const configAckamaBase = require('eslint-config-ackama');
const configAckamaJest = require('eslint-config-ackama/jest');
const configAckamaReact = require('eslint-config-ackama/react');
const configAckamaTypeScript = require('eslint-config-ackama/typescript');
const globals = require('globals');

/** @type {import('eslint').Linter.FlatConfig[]} */
const config = [
  { files: ['**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}'] },
  { ignores: ['infra'] },
  ...configAckamaBase,
  ...configAckamaTypeScript,
  {
    languageOptions: {
      parserOptions: { projectService: true },
      globals: globals.commonjs
    }
  },
  ...configAckamaReact,
  ...[
    ...configAckamaJest,
    /** @type {import('eslint').Linter.FlatConfig} */ ({
      rules: { 'jest/prefer-expect-assertions': 'off' }
    })
  ].map(c => ({ ...c, files: ['test/**'] })),
  {
    files: ['**/*.js'],
    languageOptions: { sourceType: 'script' },
    rules: {
      '@typescript-eslint/no-require-imports': 'off',
      '@typescript-eslint/no-var-requires': 'off'
    }
  }
];

module.exports = config;

Notes & Considerations

While the majority of rules enabled by these configurations are sound, a few have edge cases or are potentially not as suitable as initially hoped.

Some of these edge cases are already well-known, and may have possible fixes in the future; the details of these rules are documented below.

In general, we are more acceptance of rules that don't catch everything than rules that report too many false positives.

Usage with legacy ESLint configurations

Officially configurations are now exported as flat configuration objects which can only be used with the "flat config" system introduced in ESLint v8.23.0, since that is required to be able to move beyond ESLint v8 so codebases should be migrating to that system.

Unofficially however, since the upgrade involves replacing a number of plugins unrelated to flat configuration, the configurations will export a legacy configuration if the ESLINT_USE_FLAT_CONFIG environment variable is set to false.

[!NOTE]

This environment variable is also what tells ESLint v9 to use the legacy configuration format.

This allows complex codebases to handle the upgrade as a two-step process: first upgrading to the latest version of ESLint and the new plugins, and then upgrading to the flat configuration system.

This legacy configuration will be removed in the next major if not sooner, so should not be relied on beyond the upgrade process.

React: Lint custom hooks that accept a dependency array

If you create a custom hook for a project that takes a dependency array, you can have react-hooks/exhaustive-deps lint it in the same manner as core hooks by passing it the name of your custom hook via its additionalHooks option:

{
  "rules": {
    "react-hooks/exhaustive-deps": ["error", { "additionalHooks": "useHook" }]
  }
}

Note that this option expects a RegExp string.

Versioning

Versioning is modeled after semantic versioning; however, since these configurations are for a code quality tool meaning just about every change to a config is likely going to result in a new error in at least one of our codebases (and so arguably be a breaking change), we consider general configuration changes to be minor features, and release them as such.

In addition to this covering changes like enabling a new rule and adjusting the configuration of an already-enabled rule, this also includes updating to new major versions of a plugin which might have removed or renamed rules used in our configs.

We specify which versions of plugins is expected by our configs as optional peer dependencies, meaning your package manager should warn you if a minor version of our package requires a related plugin to be updated for compatibility.

Major versions are generally reserved for when we're making a significant number of changes, which can be common with new major versions of ESLint that have significant breaking changes that require the surrounding ecosystem to release new major versions.

Releasing

Releases are handled using semantic release, which is run on main and releases versions based on the commit messages.

Contributing

This repo uses conventional commits to enable semantic releases & changelog generation, which requires that commits on the main branch follow that format.

As we squash our pull requests when merging by default, you should ideally use title your pull requests using the conventional commit format since that will be used as the commit message for the squashed commit.

We run commitlint on pull requests to ensure that commit messages follow the format - while not strictly required when the commits will be squashed, it can help ensure you're following the format correctly.

changelog

4.1.0 (2025-02-16)

Features

  • make all rules error instead of warn (#356) (150887c)

4.0.0 (2024-12-06)

Bug Fixes

  • javascript: remove deprecated no-return-await rule (e5a5f35)
  • javascript: replace no-new-object with no-object-constructor (d2005ce)
  • omit negation from ignores in flat configuration to avoid breaking @eslint/config-inspector (d6e497f)
  • typescript: ensure that eslint recommended overrides are applied (27c2961)
  • typescript: explicitly disable @typescript-eslint/no-require-imports (619df3d)
  • typescript: remove @typescript-eslint/sort-type-constituents (e6180b7)

Features

  • add names to configs (e408fdb)
  • convert configs to flat style (88ec9f6)
  • javascript: drop support for ESLint v7 (be9b002)
  • javascript: enable built-in reportUnusedDisableDirectives check (b9c8f21)
  • javascript: switch to @eslint-community/eslint-plugin-eslint-comments (245dcee)
  • javascript: switch to @stylistic/eslint-plugin-js (e93ef65)
  • javascript: switch to eslint-plugin-n (afac2bc)
  • jest: drop support for eslint-plugin-jest v27 (e838458)
  • jest: source formatting rules from eslint-plugin-jest (ea36362)
  • make @eslint/js a required peer dependency (873100f)
  • only officially export flat configuration type configs (b8cc031)
  • react: remove jsx-no-bind rule (9fa7ef5)
  • remove flowtype config and related plugins (a781613)
  • rename [@typescript-eslint](https://github.com/typescript-eslint) config to typescript (64eaaec)
  • support @typescript-eslint/* v8 (81d286b)
  • switch to exporting arrays to allow multiple configuration objects (6d956e0)
  • typescript: drop support for @typescript-eslint/* v6 (87968fc)
  • typescript: switch to @stylistic/eslint-plugin-ts (ec6f9de)
  • upgrade eslint-config-prettier to v9 (0b66abb)

BREAKING CHANGES

  • you must now use typescript instead of @typescript-eslint
  • you must now ensure @eslint/js is installed
  • configs are now flat by default, unless ESLINT_USE_FLAT_CONFIG is 'false'
  • flowtype config is no longer available
  • typescript: you must now install @stylistic/eslint-plugin-ts
  • javascript: you must now install @stylistic/eslint-plugin-js
  • jest: eslint-plugin-jest v27 is no longer supported
  • typescript: @typescript-eslint/* v6 is no longer supported
  • javascript: ESLint v7 is no longer supported

3.4.0 (2024-12-06)

Features

3.3.0 (2024-11-11)

Features

3.2.3 (2024-08-06)

Bug Fixes

3.2.2 (2024-05-10)

Bug Fixes

  • allow v7 of [@typescript-eslint](https://github.com/typescript-eslint) and v28 of eslint-plugin-jest (#321) (99f27da)

3.2.1 (2023-10-22)

Bug Fixes

  • explicitly enable curly in configs that include prettier (#293) (496a4fa)

3.2.0 (2023-08-28)

Features

  • @typescript-eslint: upgrade to v6 and enable a few new rules (#285) (96aab43)

3.1.1 (2023-07-14)

Bug Fixes

  • @typescript-eslint: replace no-parameter-properties with parameter-properties (#284) (7274099)

3.1.0 (2022-10-18)

Features

3.0.1 (2022-03-25)

Bug Fixes

  • jest: switch to using no-conditional-in-test rule (#234) (4ddb974)

3.0.0 (2021-11-23)

Bug Fixes

  • jest: update renamed rules (89b3fa9)

Features

  • @typescript-eslint: enable ban-tslint-comment (c7a3921)
  • @typescript-eslint: enable no-base-to-string (63fe11a)
  • @typescript-eslint: enable no-confusing-void-expression (4fdb5c3)
  • @typescript-eslint: enable no-dupe-class-members (881ac65)
  • @typescript-eslint: enable no-invalid-this (84de298)
  • @typescript-eslint: enable no-meaningless-void-operator (eab50a1)
  • @typescript-eslint: enable no-non-null-asserted-nullish-coalescing (d400c17)
  • @typescript-eslint: enable no-unnecessary-boolean-literal-compare (18ac8f3)
  • @typescript-eslint: enable switch-exhaustiveness-check (8a275c5)
  • @typescript-eslint: use extended version of dot-notation (eadef42)
  • javascript: enable no-promise-executor-return (7cd705f)
  • jest: enable prefer-expect-resolves (f7873fd)
  • jest: enable require-hook (2cb2534)
  • update [@typescript-eslint](https://github.com/typescript-eslint) to v5 (8ff77f2)
  • update eslint-plugin-flowtype to v8 (adca9ec)
  • update eslint-plugin-jest to v25 (ae54b14)
  • update to eslint v8 (729e217)

BREAKING CHANGES

  • require `eslint-plugin-flowtype v8
  • require eslint-plugin-jest v25
  • require @typescript-eslint v5

2.3.0 (2021-10-28)

Features

  • specify config dependencies as optional peer dependencies (#188) (a15ab94)

2.2.1 (2021-10-16)

Bug Fixes

  • deps: update dependency eslint-config-prettier to v8 (#76) (708e436)

2.2.0 (2021-08-11)

Features

  • jest: use enhanced version of unbound-method rule (#146) (9357d36)

2.1.2 (2021-04-29)

Bug Fixes

  • bring quote props rule inline with prettier config (#101) (98b448b)

2.1.1 (2021-04-26)

Bug Fixes

  • flowtype: switch to @babel/eslint-parser (#98) (09bc833)

2.1.0 (2021-02-18)

Features

  • react: make jsx-no-bind warn instead of error (#75) (c570c76)

2.0.1 (2020-10-22)

Bug Fixes

  • @typescript-eslint: remove interface-name-prefix rule (e1c5271)

2.0.0 (2020-09-11)

Features

BREAKING CHANGES

  • require eslint 7 or higher
  • require prettier 2 or higher
  • require @typescript-eslint 4 or higher
  • require eslint-plugin-jest 24 or higher
  • require eslint-plugin-jest-formatting 2 or higher
  • require eslint-plugin-flowtype 5 or higher
  • require eslint-plugin-node

1.7.2 (2020-08-13)

Bug Fixes

  • don't ignore parent dirs, to allow for negation globs (3192bd1)

1.7.1 (2020-07-28)

Bug Fixes

  • specify eslint-plugin-import as peerDependencies (46ef44a)

1.7.0 (2020-07-20)

Features

  • use ignorePatterns in configs instead of .eslintignore (4420a9b)

1.6.0 (2020-07-05)

Features

  • @typescript-eslint: enable exceptAfterSingleLine option (419725d)
  • javascript: enable exceptAfterSingleLine option (edd25f9)

1.5.0 (2020-06-26)

Bug Fixes

  • @typescript-eslint: replace deprecated rules (81291c3)
  • jest: replace deprecated rules (193d6e1)

Features

  • @typescript-eslint: enable lines-between-class-members (b933691)
  • @typescript-eslint: enable no-unsafe-assignment (d9526b9)
  • @typescript-eslint: enable prefer-reduce-type-parameter (e7d8832)
  • @typescript-eslint: enable prefer-ts-expect-error (10bbc22)
  • javascript: always require a newline between class members (fefb98d)
  • jest: add eslint-plugin-jest-formatting (c87a4f8)
  • jest: enable ignoreTopLevelDescribe for lowercase-name (f4650a5)
  • jest: enable no-conditional-expect (4929337)
  • jest: enable no-deprecated-functions (1368a62)

1.4.2 (2020-05-24)

Bug Fixes

  • javascript: group index with parent & sibling when ordering (b8c299e)

1.4.1 (2020-05-24)

Bug Fixes

  • @typescript-eslint: disable method-signature-style (5c73f45)

1.4.0 (2020-04-07)

Features

  • @typescript-eslint: enable method-signature-style rule (e0ca7cc)
  • @typescript-eslint: enable new no-unsafe-<subject> rules (fb70bb9)

1.3.0 (2020-02-21)

Bug Fixes

  • @typescript-eslint: add default name formats (b7b1168)
  • @typescript-eslint: allow leading underscores for parameters (e82c398)
  • @typescript-eslint: allow properties to be any format (de31f6a)
  • @typescript-eslint: allow variables to be PascalCase named (5abbf1c)
  • @typescript-eslint: require enum names to be pascal or upper case (ad64b1f)
  • @typescript-eslint: require typeLike names to be PascalCase (c839b33)
  • @typescript-eslint: require var names to be camel or upper case (52d2a30)
  • @typescript-eslint: use naming-convention for generic type naming (ef2b574)
  • @typescript-eslint: use naming-convention for interface naming (32a4b95)
  • @typescript-eslint: use naming-convention for member naming (e7a890e)

Features

  • @typescript-eslint: enable @typescript-eslint/naming-convention (52885ac)

1.2.3 (2020-02-10)

Bug Fixes

  • javascript: enable allowWholeFile for disable-enable-pair (9f21c19)

1.2.2 (2020-02-07)

Bug Fixes

  • @typescript-eslint: use @typescript-eslint/no-unused-expressions (0ddddad)

1.2.1 (2020-01-24)

Bug Fixes

  • javascript: exclude ESLintUtils.RuleCreator from new-cap (5356bf9)

1.2.0 (2020-01-24)

Features

  • create react config (d825552)
  • javascript: add eslint-plugin-import (aace8f0)
  • create [@typescript-eslint](https://github.com/typescript-eslint) config (d8c0e31)
  • create flowtype config (313935c)
  • create jest config (1f039f4)
  • javascript: enable primary rules (b23c244)

1.1.0 (2020-01-05)

Features

  • add eslint-plugin-eslint-comments plugin (3799de4)

1.0.1 (2020-01-05)

Bug Fixes

  • package: add files field to package.json (1932b59)

1.0.0 (2020-01-05)

Bug Fixes

Features

  • index: add prettier configuration (f7993fb)
  • create initial eslint configuration (3cbd349)