Skip to content

Commit 7f0967c

Browse files
author
Matthias Hecht
committed
feat: migrates to flat-config
BREAKING CHANGE: migrate to flat config BREAKING CHANGE: drop support for legacy config
1 parent f30c1ac commit 7f0967c

File tree

18 files changed

+543
-637
lines changed

18 files changed

+543
-637
lines changed

.eslintrc.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

.releaserc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ module.exports = {
77
prerelease: true,
88
},
99
{
10+
channel: '${name.replace(/^feature\\//g, "").replace(/\\/-/g, "")}',
1011
name: 'feature/**',
1112
prerelease: '${name.replace(/^feature\\//g, "").replace(/\\/-/g, "")}',
12-
channel: '${name.replace(/^feature\\//g, "").replace(/\\/-/g, "")}',
1313
},
1414
],
1515
plugins: [

README.md

Lines changed: 82 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,35 @@ npm install --save-dev @boehringer-ingelheim/eslint-config
2121

2222
### Add the configuration
2323

24-
Create or update the `.eslintrc.js` file in your projects root directory accordingly.
24+
Create or update the `eslint.config.mjs` (`eslint.config.cjs` is also possible if commonjs is preferred) file in your projects root directory accordingly.
2525

2626
```js
27-
module.exports = {
28-
extends: ['@boehringer-ingelheim/eslint-config/base/strict'],
29-
};
27+
import boehringer from '@boehringer-ingelheim/eslint-config';
28+
29+
export default boehringer.config(
30+
boehringer.configs.strict
31+
)
3032
```
3133

34+
#### `boehringer.config(...)`
35+
36+
This function is a re-export for the config-helper of typescript eslint (See [docs](https://github.com/typescript-eslint/typescript-eslint/blob/a383d5022b81eaf65ce7b0946491444c6eaa28e3/docs/packages/TypeScript_ESLint.mdx#config)).
37+
3238
#### Extend or Override configuration
3339

3440
This is not recommended as the goal is to have similar code stylings in all projects, but if for some reason you need to add or change the configuration, it is possible in the following way:
3541

3642
```js
37-
module.exports = {
38-
extends: ['@boehringer-ingelheim/eslint-config/base/strict'],
39-
rules: {
40-
'no-empty-function': 'off',
41-
},
42-
};
43+
import boehringer from '@boehringer-ingelheim/eslint-config';
44+
45+
export default boehringer.config(
46+
boehringer.configs.strict,
47+
{
48+
rules: {
49+
'no-empty-function': 'off',
50+
},
51+
}
52+
);
4353
```
4454

4555
More Information: [ESLint - Configuration Files
@@ -55,12 +65,14 @@ npx eslint .
5565

5666
Opinionated Options that differ from the standard/recommended eslint configurations.
5767

58-
### `@boehringer-ingelheim/eslint-config/base`
68+
### Base
5969

6070
```js
61-
module.exports = {
62-
extends: ['@boehringer-ingelheim/eslint-config/base'],
63-
};
71+
import boehringer from '@boehringer-ingelheim/eslint-config';
72+
73+
export default boehringer.config(
74+
boehringer.configs.base
75+
)
6476
```
6577

6678
This shared ESLint configuration is set up for TypeScript projects that adhere to modern JavaScript standards. It uses the latest version of TypeScript (ES2022) and extends several plugins and recommended rules to enforce best practices and catch potential errors.
@@ -76,57 +88,74 @@ Additionally, the [`eslint-plugin-perfectionist`](https://github.com/azat-io/esl
7688
This configuration also sets up the TypeScript parser [`@typescript-eslint/parser`](https://typescript-eslint.io/architecture/parser) and [`eslint-import-resolver-typescript`](https://github.com/import-js/eslint-import-resolver-typescript). The TypeScript project file `./tsconfig.json` is set as default value for the project option in the parser configuration. If this is not the case, this must be changed accordingly:
7789

7890
```js
79-
module.exports = {
80-
parserOptions: {
81-
// Use `tsconfing.dev.json` as typescript project configuration, see: https://typescript-eslint.io/architecture/parser/#project
82-
project: './tsconfig.dev.json',
83-
},
84-
};
91+
import boehringer from '@boehringer-ingelheim/eslint-config';
92+
93+
export default boehringer.config(
94+
boehringer.configs.base,
95+
{
96+
languageOptions: {
97+
parserOptions: {
98+
project: ['./tsconfig.dev.json'],
99+
},
100+
},
101+
}
102+
);
85103
```
86104

87-
### `@boehringer-ingelheim/eslint-config/base/local`
105+
### Local
88106

89107
```js
90-
module.exports = {
91-
extends: ['@boehringer-ingelheim/eslint-config/base/strict', '@boehringer-ingelheim/eslint-config/base/local'],
92-
};
108+
import boehringer from '@boehringer-ingelheim/eslint-config';
109+
110+
export default boehringer.config(
111+
boehringer.configs.base,
112+
boehringer.configs.local
113+
);
93114
```
94115

95116
This shared ESLint configuration configures or disables some rules for a better performance locally. With the help of [`is-ci`](https://www.npmjs.com/package/is-ci) those configs only apply to environments outside the CI pipelines.
96117

97-
### `@boehringer-ingelheim/eslint-config/base/strict`
118+
### Strict
98119

99120
```js
100-
module.exports = {
101-
extends: ['@boehringer-ingelheim/eslint-config/base/strict'],
102-
};
121+
import boehringer from '@boehringer-ingelheim/eslint-config';
122+
123+
export default boehringer.config(
124+
boehringer.configs.strict
125+
);
103126
```
104127

105-
This shared ESLint configuration extends the `@boehringer-ingelheim/eslint-config/base` configuration and adds additional strict linting rules from the `@typescript-eslint/eslint-plugin` plugin. These strict rules aim to enforce a high standard of code quality and improve code maintainability.
128+
This shared ESLint configuration extends the [base configuration](#base) and adds additional strict linting rules from the typescript-eslint plugin. These strict rules aim to enforce a high standard of code quality and improve code maintainability.
106129

107-
### `@boehringer-ingelheim/eslint-config/react`
130+
### React
108131

109132
```js
110-
module.exports = {
111-
extends: ['@boehringer-ingelheim/eslint-config/base/strict', '@boehringer-ingelheim/eslint-config/react'],
112-
};
133+
import boehringer from '@boehringer-ingelheim/eslint-config';
134+
135+
export default boehringer.config(
136+
boehringer.configs.strict,
137+
boehringer.configs.react
138+
);
113139
```
114140

115-
This shared ESLint configuration is specifically tailored for [React](https://reactjs.org/) projects, and extends `@boehringer-ingelheim/eslint-config/base`. It uses the browser environment, and includes recommended configurations for the following plugins:
141+
This shared ESLint configuration is specifically tailored for [React](https://reactjs.org/) projects, and extends the [base configuration](#base). It uses the browser environment, and includes recommended configurations for the following plugins:
116142

117143
- [`eslint-plugin-jsx-a11y`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y)
118144
- [`eslint-plugin-react`](https://github.com/jsx-eslint/eslint-plugin-react)
119145
- [`eslint-plugin-react-hooks`](https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks)
120-
- [`eslint-plugin-typescript-enum`](https://github.com/shian15810/eslint-plugin-typescript-enum)
121146

122-
The configuration sets several custom rules, including `@typescript-eslint/ban-types` and `@typescript-eslint/consistent-type-definitions`, as well as rules for organizing and formatting import statements.
147+
The configuration sets several custom rules, including [`@typescript-eslint/no-restricted-types`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-restricted-types.mdx) and [`@typescript-eslint/consistent-type-definitions`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/consistent-type-definitions.mdx), as well as rules for organizing and formatting import statements.
148+
Additionally in restricts the usage of enums using [`no-restricted-syntax`](https://github.com/eslint/eslint/blob/main/docs/src/rules/no-restricted-syntax.md).
123149

124-
### `@boehringer-ingelheim/eslint-config/playwright`
150+
### Playwright
125151

126152
```js
127-
module.exports = {
128-
extends: ['@boehringer-ingelheim/eslint-config/base/strict', '@boehringer-ingelheim/eslint-config/playwright'],
129-
};
153+
import boehringer from '@boehringer-ingelheim/eslint-config';
154+
155+
export default boehringer.config(
156+
boehringer.configs.strict,
157+
boehringer.configs.playwright
158+
);
130159
```
131160

132161
This shared ESLint configuration is designed to enforce best practices and recommendations when writing tests with Playwright. It extends the [`eslint-plugin-playwright`](https://github.com/playwright-community/eslint-plugin-playwright) configuration and adds the following rules:
@@ -135,19 +164,20 @@ This shared ESLint configuration is designed to enforce best practices and recom
135164
- [`playwright/prefer-to-have-length`](https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/prefer-to-have-length.md): enforces the use of `.toHaveLength()` instead of `.toEqual(n)` when testing the length of an object.
136165
- [`playwright/require-top-level-describe`](https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/require-top-level-describe.md): requires tests to be organized into top-level `describe()` blocks.
137166

138-
### `@boehringer-ingelheim/eslint-config/prettier-disable`
167+
### Prettier-disable
139168

140169
```js
141-
module.exports = {
142-
extends: [
143-
'@boehringer-ingelheim/eslint-config/base/strict',
144-
// Following needs eslint-plugin-prettier to be installed as described by https://github.com/prettier/eslint-plugin-prettier
145-
// Should be second to last
146-
'plugin:prettier/recommended',
147-
// Should be last
148-
'@boehringer-ingelheim/eslint-config/prettier-disable'
149-
],
150-
};
170+
import boehringer from '@boehringer-ingelheim/eslint-config';
171+
import prettier from 'eslint-plugin-prettier/recommended';
172+
173+
export default boehringer.config(
174+
boehringer.configs.strict,
175+
// Following needs eslint-plugin-prettier to be installed as described by https://github.com/prettier/eslint-plugin-prettier
176+
// Should be second to last
177+
prettier,
178+
// Should be last
179+
boehringer.configs.prettierDisable,
180+
);
151181
```
152182

153183
This shared ESLint configuration is wrapper around [`eslint-config-disable`](https://github.com/prettier/eslint-config-prettier), which is used to turn off all rules that are unnecessary or might conflict with Prettier. This wrapper reenables a few rules that can be used with our shared configurations as we are using specific options of those rules which are compatible with Prettier (see [Special Rules](https://github.com/prettier/eslint-config-prettier#special-rules)). Following rules are reenabled:
@@ -202,7 +232,7 @@ npm run release
202232
- [ ] Shared configuration: Angular
203233
- [ ] Shared configuration: Node.js
204234
- [ ] Test Cases
205-
- [ ] "[Flat](https://eslint.org/docs/latest/use/configure/configuration-files-new)" Config
235+
- [x] "[Flat](https://eslint.org/docs/latest/use/configure/configuration-files-new)" Config
206236

207237
## Show your support
208238

base/index.js

Lines changed: 0 additions & 156 deletions
This file was deleted.

0 commit comments

Comments
 (0)