@boehringer-ingelheim/eslint-config 7.0.0-migrate-flat-config.1 → 7.0.0-naming-convetion-configuration.1

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
@@ -52,8 +52,7 @@ export default boehringer.config(
52
52
  );
53
53
  ```
54
54
 
55
- More Information: [ESLint - Configuration Files
56
- ](https://eslint.org/docs/latest/use/configure/configuration-files#extending-configuration-files)
55
+ More Information: [ESLint - Configuration Files](https://eslint.org/docs/latest/use/configure/configuration-files#extending-configuration-files)
57
56
 
58
57
  ### Run
59
58
 
@@ -63,7 +62,7 @@ npx eslint .
63
62
 
64
63
  ## Shared Configurations
65
64
 
66
- Opinionated Options that differ from the standard/recommended eslint configurations.
65
+ Opinionated Options that differ from the standard/recommended ESLint configurations.
67
66
 
68
67
  ### Base
69
68
 
@@ -85,21 +84,20 @@ The following plugins are used in this configuration:
85
84
 
86
85
  Additionally, the [`eslint-plugin-perfectionist`](https://github.com/azat-io/eslint-plugin-perfectionist) is used to automatically fix sorting issues.
87
86
 
88
- 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:
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:
89
88
 
90
89
  ```js
91
90
  import boehringer from '@boehringer-ingelheim/eslint-config';
92
91
 
93
- export default boehringer.config(
94
- boehringer.configs.base,
95
- {
96
- languageOptions: {
97
- parserOptions: {
98
- project: ['./tsconfig.dev.json'],
92
+ export default boehringer.config(boehringer.configs.base, {
93
+ languageOptions: {
94
+ parserOptions: {
95
+ projectService: {
96
+ defaultProject: ['./tsconfig.dev.json'],
99
97
  },
100
98
  },
101
- }
102
- );
99
+ },
100
+ });
103
101
  ```
104
102
 
105
103
  ### Local
@@ -143,10 +141,24 @@ This shared ESLint configuration is specifically tailored for [React](https://re
143
141
  - [`eslint-plugin-jsx-a11y`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y)
144
142
  - [`eslint-plugin-react`](https://github.com/jsx-eslint/eslint-plugin-react)
145
143
  - [`eslint-plugin-react-hooks`](https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks)
144
+ - [`eslint-plugin-react-refresh`](https://github.com/ArnaudBarre/eslint-plugin-react-refresh) (with rule severity `warn`)
146
145
 
147
146
  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
147
  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).
149
148
 
149
+ ### Next.js
150
+
151
+ ```js
152
+ import boehringer from '@boehringer-ingelheim/eslint-config';
153
+
154
+ export default boehringer.config(
155
+ boehringer.configs.strict,
156
+ boehringer.configs.nextjs
157
+ );
158
+ ```
159
+
160
+ This shared ESLint configuration is specifically tailored for [Next.js](https://nextjs.org/) projects. It extends the [react configuration](#react) and includes the [`@next/eslint-plugin-next`](https://nextjs.org/docs/app/api-reference/config/eslint) plugin with the recommended and [`core-web-vital`](https://nextjs.org/docs/app/api-reference/config/eslint#with-core-web-vitals) rule set. The configuration also adapts the rule `react-refresh/only-export-components` to be compatible with Next.js.
161
+
150
162
  ### Playwright
151
163
 
152
164
  ```js
@@ -164,6 +176,20 @@ This shared ESLint configuration is designed to enforce best practices and recom
164
176
  - [`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.
165
177
  - [`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.
166
178
 
179
+ ### Naming Convention
180
+
181
+ ```js
182
+ import boehringer from '@boehringer-ingelheim/eslint-config';
183
+
184
+ export default boehringer.config(
185
+ boehringer.configs.strict,
186
+ // possibly other configs,
187
+ boehringer.configs.namingConvention
188
+ );
189
+ ```
190
+
191
+ 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)
192
+
167
193
  ### Prettier-disable
168
194
 
169
195
  ```js
@@ -185,6 +211,69 @@ This shared ESLint configuration is wrapper around [`eslint-config-disable`](htt
185
211
  - [`curly`](https://github.com/eslint/eslint/blob/main/docs/src/rules/curly.md) with the (default) option "all": Enforce consistent brace style for all control statements
186
212
  - [`no-confusing-arrow`](https://github.com/eslint/eslint/blob/main/docs/src/rules/no-confusing-arrow.md) with allowParens `false` and onlyOneSimpleParam `true`: Disallow arrow functions where they could be confused with comparisons.
187
213
 
214
+ ## Known issues
215
+
216
+ ### Parsing error
217
+
218
+ 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`.
219
+
220
+ 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).
221
+
222
+ Our recommendation is to keep type-aware linting of those files.
223
+
224
+ #### Solution 1
225
+
226
+ Include the .(c|m)?js files in your main tsconfig.json:
227
+
228
+ ```json
229
+ {
230
+ "include": [
231
+ // your existing includes
232
+ "*.*js", // this will include all .js, .cjs, .mjs files and similar in your project root
233
+ "*.ts", // this will include all .ts files and similar in your project root
234
+ // Add all other files/folders in which this error occurs
235
+ ]
236
+ }
237
+ ```
238
+
239
+ #### Solution 2
240
+
241
+ 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):
242
+
243
+ ```json
244
+ {
245
+ "compilerOptions": {
246
+ "noEmit": true,
247
+ "allowJs": true
248
+ },
249
+ "extends": "./tsconfig.json",
250
+ "include": [
251
+ // you have to add here all the items from your original tsconfig.json as it overwrites the whole array
252
+ "*.*js", // this will include all .js, .cjs, .mjs files and similar in your project root
253
+ "*.ts", // this will include all .ts files and similar in your project root
254
+ // Add all other files/folders in which this error occurs
255
+ ]
256
+ }
257
+ ```
258
+
259
+ In this case you have to overwrite the configured tsconfig file:
260
+
261
+ ```js
262
+ import boehringer from '@boehringer-ingelheim/eslint-config';
263
+
264
+ export default boehringer.config(
265
+ // other configs,
266
+ {
267
+ languageOptions: {
268
+ parserOptions: {
269
+ project: './tsconfig.eslint.json',
270
+ tsconfigRootDir: __dirname,
271
+ },
272
+ },
273
+ },
274
+ )
275
+ ```
276
+
188
277
  ## Local Development
189
278
 
190
279
  ### Install Dependencies
@@ -240,7 +329,7 @@ Give a ⭐️ if this project helped you!
240
329
 
241
330
  ## License
242
331
 
243
- Copyright © 2023 [Boehringer Ingelheim](https://github.com/boehringer-ingelheim).<br />
332
+ Copyright © 2023 [Boehringer Ingelheim](https://github.com/boehringer-ingelheim).
244
333
  This project is [MIT](https://github.com/boehringer-ingelheim/eslint-config/blob/master/LICENSE) licensed.
245
334
 
246
335
  ## Resources
package/configs/base.js CHANGED
@@ -22,7 +22,7 @@ module.exports = tseslint.config(
22
22
  languageOptions: {
23
23
  parserOptions: {
24
24
  // find the tsconfig.json nearest each source file
25
- project: true,
25
+ projectService: true,
26
26
  },
27
27
  },
28
28
  linterOptions: {
@@ -95,14 +95,14 @@ module.exports = tseslint.config(
95
95
  'perfectionist/sort-classes': [
96
96
  'error',
97
97
  {
98
- ...perfectionist.configs['recommended-natural-legacy'].rules['perfectionist/sort-classes'][1],
98
+ ...perfectionist.configs['recommended-natural'].rules['perfectionist/sort-classes'][1],
99
99
  groups: SORT_CLASSES_GROUPS,
100
100
  },
101
101
  ],
102
102
  'perfectionist/sort-imports': [
103
103
  'error',
104
104
  {
105
- ...perfectionist.configs['recommended-natural-legacy'].rules['perfectionist/sort-imports'][1],
105
+ ...perfectionist.configs['recommended-natural'].rules['perfectionist/sort-imports'][1],
106
106
  groups: SORT_IMPORTS_GROUPS,
107
107
  newlinesBetween: 'ignore',
108
108
  },
@@ -110,21 +110,21 @@ module.exports = tseslint.config(
110
110
  'perfectionist/sort-intersection-types': [
111
111
  'error',
112
112
  {
113
- ...perfectionist.configs['recommended-natural-legacy'].rules['perfectionist/sort-intersection-types'][1],
113
+ ...perfectionist.configs['recommended-natural'].rules['perfectionist/sort-intersection-types'][1],
114
114
  groups: SORT_INTERSECTION_TYPES_GROUPS,
115
115
  },
116
116
  ],
117
117
  'perfectionist/sort-named-imports': [
118
118
  'error',
119
119
  {
120
- ...perfectionist.configs['recommended-natural-legacy'].rules['perfectionist/sort-named-imports'][1],
120
+ ...perfectionist.configs['recommended-natural'].rules['perfectionist/sort-named-imports'][1],
121
121
  ignoreAlias: true,
122
122
  },
123
123
  ],
124
124
  'perfectionist/sort-objects': [
125
125
  'error',
126
126
  {
127
- ...perfectionist.configs['recommended-natural-legacy'].rules['perfectionist/sort-objects'][1],
127
+ ...perfectionist.configs['recommended-natural'].rules['perfectionist/sort-objects'][1],
128
128
  partitionByComment: true,
129
129
  },
130
130
  ],
@@ -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
+ });
@@ -0,0 +1,46 @@
1
+ const nextPlugin = require('@next/eslint-plugin-next');
2
+ const tseslint = require('typescript-eslint');
3
+
4
+ const react = require('./react.js');
5
+
6
+ module.exports = tseslint.config(
7
+ ...react,
8
+ {
9
+ plugins: {
10
+ '@next/next': nextPlugin,
11
+ },
12
+ rules: {
13
+ // eslint-plugin-react-refresh: https://github.com/ArnaudBarre/eslint-plugin-react-refresh
14
+ 'react-refresh/only-export-components': [
15
+ 'warn',
16
+ {
17
+ /**
18
+ * Next.js allows exporting the following options in pages, layouts and route handlers
19
+ *
20
+ * @see https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config
21
+ */
22
+ allowExportNames: [
23
+ 'config',
24
+ 'dynamic',
25
+ 'dynamicParams',
26
+ 'fetchCache',
27
+ 'generateMetadata',
28
+ 'generateStaticParams',
29
+ 'generateViewport',
30
+ 'maxDuration',
31
+ 'metadata',
32
+ 'preferredRegion',
33
+ 'revalidate',
34
+ 'runtime',
35
+ 'viewport',
36
+ ],
37
+ },
38
+ ],
39
+ ...nextPlugin.configs.recommended.rules,
40
+ ...nextPlugin.configs['core-web-vitals'].rules,
41
+ },
42
+ },
43
+ {
44
+ ignores: ['.next/*'],
45
+ },
46
+ );
package/configs/react.js CHANGED
@@ -13,6 +13,7 @@ module.exports = tseslint.config(
13
13
  jsxA11y.flatConfigs.recommended,
14
14
  react.configs.flat.recommended,
15
15
  react.configs.flat['jsx-runtime'],
16
+ reactRefresh.configs.recommended,
16
17
  {
17
18
  languageOptions: {
18
19
  globals: {
@@ -25,9 +26,7 @@ module.exports = tseslint.config(
25
26
  },
26
27
  },
27
28
  plugins: {
28
- 'jsx-a11y': jsxA11y,
29
29
  'react-hooks': reactHooks,
30
- 'react-refresh': reactRefresh,
31
30
  },
32
31
  rules: {
33
32
  // @typescript-eslint: https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/eslint-plugin/docs/rules
@@ -79,8 +78,8 @@ module.exports = tseslint.config(
79
78
  'error',
80
79
  {
81
80
  customGroups: {
82
- callback: 'on*',
83
- reservedProps: ['children', 'dangerouslySetInnerHTML', 'key', 'ref'], // Reserved props from: https://github.com/jsx-eslint/eslint-plugin-react/blob/master/lib/rules/jsx-sort-props.js#L40C12-L40C12
81
+ callback: '^on.+',
82
+ reservedProps: ['children', 'dangerouslySetInnerHTML', 'key', 'ref'], // Reserved props from: https://github.com/jsx-eslint/eslint-plugin-react/blob/master/lib/rules/jsx-sort-props.js#L41-L46
84
83
  },
85
84
  groups: ['reservedProps', 'unknown', 'callback'],
86
85
  ignoreCase: true,
package/index.js CHANGED
@@ -2,6 +2,8 @@ const tseslint = require('typescript-eslint');
2
2
 
3
3
  const base = require('./configs/base.js');
4
4
  const local = require('./configs/local.js');
5
+ const namingConvention = require('./configs/naming-convention.js');
6
+ const nextjs = require('./configs/nextjs.js');
5
7
  const playwright = require('./configs/playwright.js');
6
8
  const prettierDisable = require('./configs/prettier-disable.js');
7
9
  const react = require('./configs/react.js');
@@ -12,6 +14,8 @@ module.exports = {
12
14
  configs: {
13
15
  base,
14
16
  local,
17
+ namingConvention,
18
+ nextjs,
15
19
  playwright,
16
20
  prettierDisable,
17
21
  react,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boehringer-ingelheim/eslint-config",
3
- "version": "7.0.0-migrate-flat-config.1",
3
+ "version": "7.0.0-naming-convetion-configuration.1",
4
4
  "description": "Shared eslint configuration used at Boehringer Ingelheim for code styling",
5
5
  "keywords": [
6
6
  "boehringer",
@@ -22,38 +22,39 @@
22
22
  "prepare": "husky",
23
23
  "release": "dotenv -- semantic-release --no-ci",
24
24
  "release:ci": "semantic-release",
25
- "repair": "npx --no rimraf .git/hooks node_modules package-lock.json && npm install",
25
+ "repair": "npx --no rimraf@6 .git/hooks node_modules package-lock.json && npm install",
26
26
  "lint": "eslint ."
27
27
  },
28
28
  "peerDependencies": {
29
29
  "eslint": ">= 8"
30
30
  },
31
31
  "dependencies": {
32
- "@eslint/js": "^9.17.0",
33
- "eslint-config-prettier": "^9.1.0",
32
+ "@eslint/js": "^9.18.0",
33
+ "@next/eslint-plugin-next": "^15.1.4",
34
+ "eslint-config-prettier": "^10.0.1",
34
35
  "eslint-import-resolver-typescript": "^3.7.0",
35
36
  "eslint-plugin-import": "^2.31.0",
36
37
  "eslint-plugin-jsx-a11y": "^6.10.2",
37
- "eslint-plugin-perfectionist": "^4.3.0",
38
+ "eslint-plugin-perfectionist": "^4.6.0",
38
39
  "eslint-plugin-playwright": "^2.1.0",
39
- "eslint-plugin-react": "^7.37.2",
40
+ "eslint-plugin-react": "^7.37.4",
40
41
  "eslint-plugin-react-hooks": "^5.1.0",
41
- "eslint-plugin-react-refresh": "^0.4.16",
42
+ "eslint-plugin-react-refresh": "^0.4.18",
42
43
  "eslint-plugin-sonarjs": "^1.0.4",
43
44
  "globals": "^15.14.0",
44
45
  "is-ci": "^4.1.0",
45
- "typescript-eslint": "^8.18.1"
46
+ "typescript-eslint": "^8.20.0"
46
47
  },
47
48
  "devDependencies": {
48
49
  "@boehringer-ingelheim/prettier-config": "2.0.0",
49
- "@commitlint/cli": "19.6.0",
50
+ "@commitlint/cli": "19.6.1",
50
51
  "@commitlint/config-conventional": "19.6.0",
51
52
  "@commitlint/types": "19.5.0",
52
53
  "@semantic-release/changelog": "6.0.3",
53
54
  "@semantic-release/git": "10.0.1",
54
- "dotenv-cli": "7.4.4",
55
+ "dotenv-cli": "8.0.0",
55
56
  "husky": "9.1.7",
56
57
  "prettier": "3.4.2",
57
- "semantic-release": "24.2.0"
58
+ "semantic-release": "24.2.1"
58
59
  }
59
60
  }