@boehringer-ingelheim/eslint-config 7.0.0-next.7 → 7.0.0-next.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -84,21 +84,7 @@ The following plugins are used in this configuration:
84
84
 
85
85
  Additionally, the [`eslint-plugin-perfectionist`](https://github.com/azat-io/eslint-plugin-perfectionist) is used to automatically fix sorting issues.
86
86
 
87
- This configuration also sets up the TypeScript parser [`@typescript-eslint/parser`](https://typescript-eslint.io/packages/parser/) and [`eslint-import-resolver-typescript`](https://github.com/import-js/eslint-import-resolver-typescript). The TypeScript project configuration file `./tsconfig.json` is set as default value in the parser configuration. If this is not the case, this must be changed accordingly:
88
-
89
- ```js
90
- import boehringer from '@boehringer-ingelheim/eslint-config';
91
-
92
- export default boehringer.config(boehringer.configs.base, {
93
- languageOptions: {
94
- parserOptions: {
95
- projectService: {
96
- defaultProject: ['./tsconfig.dev.json'],
97
- },
98
- },
99
- },
100
- });
101
- ```
87
+ This configuration also sets up the TypeScript parser [`@typescript-eslint/parser`](https://typescript-eslint.io/packages/parser/) and [`eslint-import-resolver-typescript`](https://github.com/import-js/eslint-import-resolver-typescript).
102
88
 
103
89
  ### Local
104
90
 
@@ -176,6 +162,20 @@ This shared ESLint configuration is designed to enforce best practices and recom
176
162
  - [`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.
177
163
  - [`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.
178
164
 
165
+ ### (experimental) Naming Convention
166
+
167
+ ```js
168
+ import boehringer from '@boehringer-ingelheim/eslint-config';
169
+
170
+ export default boehringer.config(
171
+ boehringer.configs.strict,
172
+ // possibly other configs,
173
+ boehringer.configs.experimentalNamingConvention
174
+ );
175
+ ```
176
+
177
+ This shared ESLint configuration is designed to enforce some naming conventions. It uses the [`@typescript-eslint/naming-convention`](https://typescript-eslint.io/rules/naming-convention/) rule for enforcing the naming conventions. The enforced conventions can be found in [configs/naming-convention.js](./configs/naming-convention.js#L7-L65)
178
+
179
179
  ### Prettier-disable
180
180
 
181
181
  ```js
@@ -201,9 +201,12 @@ This shared ESLint configuration is wrapper around [`eslint-config-disable`](htt
201
201
 
202
202
  ### Parsing error
203
203
 
204
- ESLint may throw the following error for some files (even for its own eslint.config.js): `ESLint was configured to run ... However, that TSConfig does not / none of those TSConfigs include this file`.
204
+ ESLint may throw one of the following errors for some files (even for its own eslint.config.js):
205
+
206
+ - `ESLint was configured to run ... However, that TSConfig does not / none of those TSConfigs include this file`.
207
+ - `... was not found by the project service. Consider either including it in the tsconfig.json or including it in allowDefaultProject`
205
208
 
206
- This error is caused by including the respective file in the scope of ESLint but not in the scope of TypeScript. For more information about this error and more suggestions how to solve it you can check the [FAQ of typescript-eslint](https://typescript-eslint.io/troubleshooting/typed-linting/#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file).
209
+ This error is caused by including the respective file in the scope of ESLint but not in the scope of TypeScript. For more information about this error and more suggestions how to solve it you can check the [troubleshooting of typescript-eslint](https://typescript-eslint.io/troubleshooting/typed-linting/#i-get-errors-telling-me--was-not-found-by-the-project-service-consider-either-including-it-in-the-tsconfigjson-or-including-it-in-allowdefaultproject).
207
210
 
208
211
  Our recommendation is to keep type-aware linting of those files.
209
212
 
@@ -211,7 +214,7 @@ Our recommendation is to keep type-aware linting of those files.
211
214
 
212
215
  Include the .(c|m)?js files in your main tsconfig.json:
213
216
 
214
- ```json
217
+ ```jsonc
215
218
  {
216
219
  "include": [
217
220
  // your existing includes
@@ -224,25 +227,7 @@ Include the .(c|m)?js files in your main tsconfig.json:
224
227
 
225
228
  #### Solution 2
226
229
 
227
- Extend your main tsconfig.json in a tsconfig.eslint.json (or similar) which includes those files and ensures allowJs is set to true, which is used in a similar way by typescript-eslint in [their own repo](https://github.com/typescript-eslint/typescript-eslint/tree/v8.20.0):
228
-
229
- ```json
230
- {
231
- "compilerOptions": {
232
- "noEmit": true,
233
- "allowJs": true
234
- },
235
- "extends": "./tsconfig.json",
236
- "include": [
237
- // you have to add here all the items from your original tsconfig.json as it overwrites the whole array
238
- "*.*js", // this will include all .js, .cjs, .mjs files and similar in your project root
239
- "*.ts", // this will include all .ts files and similar in your project root
240
- // Add all other files/folders in which this error occurs
241
- ]
242
- }
243
- ```
244
-
245
- In this case you have to overwrite the configured tsconfig file:
230
+ You can use the new [`allowDefaultProject`](https://typescript-eslint.io/packages/parser#allowdefaultproject) option, which works perfectly with our [`projectService` configuration](./configs/base.js#L25):
246
231
 
247
232
  ```js
248
233
  import boehringer from '@boehringer-ingelheim/eslint-config';
@@ -252,8 +237,14 @@ export default boehringer.config(
252
237
  {
253
238
  languageOptions: {
254
239
  parserOptions: {
255
- project: './tsconfig.eslint.json',
256
- tsconfigRootDir: __dirname,
240
+ projectService: {
241
+ allowDefaultProject: [
242
+ '*.*js',
243
+ '.*.*js',
244
+ ],
245
+ // defaultProject can be used to specify separate tsconfig options for "out-of-project" files included by allowDefaultProject
246
+ // defaultProject: 'tsconfig.eslint.json',
247
+ },
257
248
  },
258
249
  },
259
250
  },
@@ -0,0 +1,68 @@
1
+ const tseslint = require('typescript-eslint');
2
+
3
+ module.exports = tseslint.config({
4
+ rules: {
5
+ '@typescript-eslint/naming-convention': [
6
+ 'error',
7
+ {
8
+ // Enforce that interface names do not start with an 'I'
9
+ custom: {
10
+ match: false,
11
+ regex: '^I[A-Z]',
12
+ },
13
+ format: ['StrictPascalCase'],
14
+ leadingUnderscore: 'forbid',
15
+ selector: 'interface',
16
+ trailingUnderscore: 'forbid',
17
+ },
18
+ {
19
+ // Enforce that type alias names do not start with an 'T'
20
+ custom: {
21
+ match: false,
22
+ regex: '^T[A-Z]',
23
+ },
24
+ format: ['StrictPascalCase'],
25
+ leadingUnderscore: 'forbid',
26
+ selector: 'typeAlias',
27
+ trailingUnderscore: 'forbid',
28
+ },
29
+ {
30
+ // Enforce that all top-level variables are in UPPER_CASE
31
+ format: ['UPPER_CASE'],
32
+ leadingUnderscore: 'forbid',
33
+ modifiers: ['global'],
34
+ selector: 'variable',
35
+ trailingUnderscore: 'forbid',
36
+ types: ['boolean', 'number', 'string'],
37
+ },
38
+ {
39
+ // Enforce that all top-level array variables are in UPPER_CASE and are suffixed with a 'S' to indicate plural form
40
+ format: ['UPPER_CASE'],
41
+ leadingUnderscore: 'forbid',
42
+ modifiers: ['global'],
43
+ selector: 'variable',
44
+ suffix: ['S'],
45
+ trailingUnderscore: 'forbid',
46
+ types: ['array'],
47
+ },
48
+ {
49
+ // Enforce that array variables are suffixed with a 's' to indicate plural form
50
+ format: ['strictCamelCase'],
51
+ leadingUnderscore: 'forbid',
52
+ selector: 'variable',
53
+ suffix: ['s'],
54
+ trailingUnderscore: 'forbid',
55
+ types: ['array'],
56
+ },
57
+ {
58
+ // Enforce that boolean variables are prefixed with an allowed verb
59
+ format: ['StrictPascalCase'],
60
+ leadingUnderscore: 'forbid',
61
+ prefix: ['is', 'has', 'should', 'can'],
62
+ selector: 'variable',
63
+ trailingUnderscore: 'forbid',
64
+ types: ['boolean'],
65
+ },
66
+ ],
67
+ },
68
+ });
package/index.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import { Config } from 'typescript-eslint';
2
+
3
+ type Configs =
4
+ | 'base'
5
+ | 'experimentalNamingConvention'
6
+ | 'local'
7
+ | 'nextjs'
8
+ | 'playwright'
9
+ | 'prettierDisable'
10
+ | 'react'
11
+ | 'strict';
12
+
13
+ declare module './index' {
14
+ const config: typeof import('typescript-eslint').config;
15
+ const configs: Record<Configs, Config>;
16
+
17
+ export { config, configs };
18
+ }
package/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  const tseslint = require('typescript-eslint');
2
2
 
3
3
  const base = require('./configs/base.js');
4
+ const experimentalNamingConvention = require('./configs/experimental-naming-convention.js');
4
5
  const local = require('./configs/local.js');
5
6
  const nextjs = require('./configs/nextjs.js');
6
7
  const playwright = require('./configs/playwright.js');
@@ -12,6 +13,7 @@ module.exports = {
12
13
  config: tseslint.config,
13
14
  configs: {
14
15
  base,
16
+ experimentalNamingConvention,
15
17
  local,
16
18
  nextjs,
17
19
  playwright,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boehringer-ingelheim/eslint-config",
3
- "version": "7.0.0-next.7",
3
+ "version": "7.0.0-next.9",
4
4
  "description": "Shared eslint configuration used at Boehringer Ingelheim for code styling",
5
5
  "keywords": [
6
6
  "boehringer",
@@ -15,9 +15,12 @@
15
15
  "license": "MIT",
16
16
  "files": [
17
17
  "configs",
18
- "lib"
18
+ "lib",
19
+ "index.js",
20
+ "index.d.ts"
19
21
  ],
20
22
  "main": "index.js",
23
+ "types": "index.d.ts",
21
24
  "scripts": {
22
25
  "prepare": "husky",
23
26
  "release": "dotenv -- semantic-release --no-ci",