@kununu/eslint-config
v7.6.3
Published
kununu's ESLint config
Maintainers
Readme
@kununu/eslint-config
kununu's shared ESLint configuration (ESLint v9, flat config)
Shared linting rules that keep JavaScript, JSX, TypeScript and TSX consistent
across kununu's frontend apps, BFFs and shared libraries. eslint, every plugin
and the TypeScript parser are direct dependencies of this package, so consumers
install a single package and never wire up parsers or plugins themselves.
Flat config only. Version 6.0.0 and later publish an
eslint.config.mjsfor ESLint v9's flat config. There is no legacy.eslintrcexport; version 5 and earlier used that format.
📦 Installation
npm install --save-dev @kununu/eslint-configtypescript is the only peer dependency (>=6.0.0), and it is optional: you
need it for the type-aware TypeScript rules described below. The package pins
Node 24.13.1 and npm 11.8.0 in engines, matching the toolchain kununu's
repos run on.
💻 Usage
Create an eslint.config.mjs in the project root. The config is published as an
ES module and exports an array of flat-config objects, so spread it:
import kununuConfig from '@kununu/eslint-config';
export default [
...kununuConfig,
// Project-specific overrides go here.
];Then add a lint script to package.json:
{
"scripts": {
"lint": "eslint ."
}
}The ESLint documentation covers the remaining command-line and configuration options.
TypeScript
The TypeScript rules are scoped to .ts and .tsx files and run through
@typescript-eslint/parser with projectService enabled, which discovers your
tsconfig.json automatically. The project therefore needs a tsconfig.json at
its root; without one, the type-aware rules fail. .js and .jsx files are
parsed by ESLint's default parser, Espree, with JSX support enabled.
Overrides
Add your own flat-config objects after the spread, and scope them with files
when they should not apply everywhere. The last matching entry wins:
import kununuConfig from '@kununu/eslint-config';
export default [
...kununuConfig,
{
rules: {
'no-console': 'off',
},
},
{
files: ['**/*.spec.*'],
rules: {
// Test-only adjustments.
},
},
];Flat config replaces a rule's options instead of merging them, so changing a single option of an already configured rule means restating that rule's full option object.
🎨 What's included
The config is built on @eslint/js, typescript-eslint and the React
ecosystem, with kununu's own conventions layered on top.
| Area | Plugins |
| --- | --- |
| Base | @eslint/js, typescript-eslint |
| React | eslint-plugin-react, eslint-plugin-react-hooks (incl. React Compiler rules) |
| Accessibility | eslint-plugin-jsx-a11y |
| Style / formatting | @stylistic/eslint-plugin |
| Code smells | eslint-plugin-sonarjs |
| Imports / ordering | eslint-plugin-perfectionist |
| Tests (*.spec.*) | eslint-plugin-jest, eslint-plugin-jest-dom, eslint-plugin-testing-library |
| kununu-specific | eslint-plugin-lodash, eslint-plugin-granular-selectors |
Notable conventions
- No default React import.
import React from 'react'is disallowed; import the named hooks and types instead, as inimport {useState} from 'react'. - Per-method lodash imports. Use
import debounce from 'lodash/debounce'rather thanimport {debounce} from 'lodash'. - Import ordering (
perfectionist/sort-imports):react, then types, then builtins and externals, then@kununu/*internals, then path aliases, then relative imports. - Granular Redux selectors are enforced for
use*Selector*anduse*Store*hooks. - Formatting comes from
@stylistic: 120-character lines (ignoring comments, strings and URLs), semicolons and single quotes, among others. - React Compiler rules such as
react-hooks/refsandreact-hooks/set-state-in-effectreport as warnings, not errors. - Test files matching
**/*.spec.*get the Jest globals and the jest, jest-dom and testing-library rule sets automatically. A few source-only rules, such asreact/prop-typesandsonarjs/no-hardcoded-passwords, are relaxed there.
⚡️ Editor integration
Linting runs in CI, and in pre-commit hooks where they are configured, but catching problems in the editor is faster. We recommend the ESLint VS Code extension.
Recent versions detect flat config on their own. If your editor still falls back
to the legacy format, enable it explicitly in .vscode/settings.json:
{
"eslint.useFlatConfig": true
}