@boehringer-ingelheim/eslint-config 6.0.1 → 7.0.0-migrate-flat-config.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
@@ -21,25 +21,35 @@ npm install --save-dev @boehringer-ingelheim/eslint-config
21
21
 
22
22
  ### Add the configuration
23
23
 
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.
25
25
 
26
26
  ```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
+ )
30
32
  ```
31
33
 
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
+
32
38
  #### Extend or Override configuration
33
39
 
34
40
  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:
35
41
 
36
42
  ```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
+ );
43
53
  ```
44
54
 
45
55
  More Information: [ESLint - Configuration Files
@@ -55,12 +65,14 @@ npx eslint .
55
65
 
56
66
  Opinionated Options that differ from the standard/recommended eslint configurations.
57
67
 
58
- ### `@boehringer-ingelheim/eslint-config/base`
68
+ ### Base
59
69
 
60
70
  ```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
+ )
64
76
  ```
65
77
 
66
78
  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
76
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:
77
89
 
78
90
  ```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
+ );
85
103
  ```
86
104
 
87
- ### `@boehringer-ingelheim/eslint-config/base/local`
105
+ ### Local
88
106
 
89
107
  ```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
+ );
93
114
  ```
94
115
 
95
116
  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.
96
117
 
97
- ### `@boehringer-ingelheim/eslint-config/base/strict`
118
+ ### Strict
98
119
 
99
120
  ```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
+ );
103
126
  ```
104
127
 
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.
106
129
 
107
- ### `@boehringer-ingelheim/eslint-config/react`
130
+ ### React
108
131
 
109
132
  ```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
+ );
113
139
  ```
114
140
 
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:
116
142
 
117
143
  - [`eslint-plugin-jsx-a11y`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y)
118
144
  - [`eslint-plugin-react`](https://github.com/jsx-eslint/eslint-plugin-react)
119
145
  - [`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)
121
146
 
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).
123
149
 
124
- ### `@boehringer-ingelheim/eslint-config/playwright`
150
+ ### Playwright
125
151
 
126
152
  ```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
+ );
130
159
  ```
131
160
 
132
161
  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
135
164
  - [`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.
136
165
  - [`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.
137
166
 
138
- ### `@boehringer-ingelheim/eslint-config/prettier-disable`
167
+ ### Prettier-disable
139
168
 
140
169
  ```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
+ );
151
181
  ```
152
182
 
153
183
  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
202
232
  - [ ] Shared configuration: Angular
203
233
  - [ ] Shared configuration: Node.js
204
234
  - [ ] 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
206
236
 
207
237
  ## Show your support
208
238
 
@@ -0,0 +1,148 @@
1
+ const eslint = require('@eslint/js');
2
+ const importPlugin = require('eslint-plugin-import');
3
+ const perfectionist = require('eslint-plugin-perfectionist');
4
+ const sonarjs = require('eslint-plugin-sonarjs');
5
+ const tseslint = require('typescript-eslint');
6
+
7
+ const {
8
+ SORT_CLASSES_GROUPS,
9
+ SORT_IMPORTS_GROUPS,
10
+ SORT_INTERSECTION_TYPES_GROUPS,
11
+ } = require('../lib/eslint-plugin-perfectionist.js');
12
+
13
+ module.exports = tseslint.config(
14
+ eslint.configs.recommended,
15
+ tseslint.configs.recommendedTypeChecked,
16
+ tseslint.configs.stylisticTypeChecked,
17
+ importPlugin.flatConfigs.recommended,
18
+ importPlugin.flatConfigs.typescript,
19
+ perfectionist.configs['recommended-natural'],
20
+ sonarjs.configs.recommended,
21
+ {
22
+ languageOptions: {
23
+ parserOptions: {
24
+ // find the tsconfig.json nearest each source file
25
+ project: true,
26
+ },
27
+ },
28
+ linterOptions: {
29
+ reportUnusedDisableDirectives: 'error',
30
+ },
31
+ rules: {
32
+ // @typescript-eslint: https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/eslint-plugin/docs/rules
33
+ '@typescript-eslint/adjacent-overload-signatures': 'off', // disabled due to conflict with eslint-plugin-perfectionist
34
+ '@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }],
35
+ '@typescript-eslint/no-misused-promises': [
36
+ 'error',
37
+ {
38
+ checksVoidReturn: false,
39
+ },
40
+ ],
41
+ '@typescript-eslint/no-unused-vars': [
42
+ 'error',
43
+ {
44
+ argsIgnorePattern: '^_',
45
+ caughtErrorsIgnorePattern: '^_',
46
+ varsIgnorePattern: '^_',
47
+ },
48
+ ],
49
+ '@typescript-eslint/sort-type-constituents': 'off', // disabled due to conflict with eslint-plugin-perfectionist
50
+
51
+ // eslint: https://github.com/eslint/eslint/tree/main/lib/rules
52
+ '@typescript-eslint/dot-notation': ['error', { allowPattern: '^[a-z]+(_[a-z]+)+$' }],
53
+ 'arrow-body-style': ['error', 'as-needed'],
54
+ camelcase: 'warn',
55
+ curly: 'error',
56
+ 'default-case': 'error',
57
+ eqeqeq: 'error',
58
+ 'logical-assignment-operators': ['error', 'never'],
59
+ 'no-console': ['warn', { allow: ['warn', 'error'] }],
60
+ 'no-else-return': ['error', { allowElseIf: false }],
61
+ 'no-empty-function': 'error',
62
+ 'no-lonely-if': 'error',
63
+ 'no-negated-condition': 'error',
64
+ 'no-nested-ternary': 'error',
65
+ 'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
66
+ 'no-unneeded-ternary': 'error',
67
+ 'no-useless-concat': 'error',
68
+ 'operator-assignment': ['error', 'never'],
69
+ 'prefer-const': 'error',
70
+ 'prefer-rest-params': 'error',
71
+ 'prefer-template': 'error',
72
+ 'sort-imports': 'off', // disabled due to conflict with eslint-plugin-perfectionist
73
+ 'sort-keys': 'off', // disabled due to conflict with eslint-plugin-perfectionist
74
+
75
+ // eslint-plugin-import: https://github.com/import-js/eslint-plugin-import/tree/main/docs/rules
76
+ 'import/no-cycle': 'error',
77
+ 'import/no-unused-modules': [
78
+ 'error',
79
+ {
80
+ missingExports: true,
81
+ src: ['.'],
82
+ unusedExports: true,
83
+ },
84
+ ],
85
+ 'import/order': 'off', // disabled due to conflict with eslint-plugin-perfectionist
86
+ 'import/prefer-default-export': 'off',
87
+
88
+ // Deactivated as TypeScript provides the same checks as part of standard type checking: https://typescript-eslint.io/linting/troubleshooting/performance-troubleshooting
89
+ 'import/default': 'off',
90
+ 'import/named': 'off',
91
+ 'import/namespace': 'off',
92
+ 'import/no-named-as-default-member': 'off',
93
+
94
+ // eslint-plugin-perfectionist: https://github.com/azat-io/eslint-plugin-perfectionist
95
+ 'perfectionist/sort-classes': [
96
+ 'error',
97
+ {
98
+ ...perfectionist.configs['recommended-natural-legacy'].rules['perfectionist/sort-classes'][1],
99
+ groups: SORT_CLASSES_GROUPS,
100
+ },
101
+ ],
102
+ 'perfectionist/sort-imports': [
103
+ 'error',
104
+ {
105
+ ...perfectionist.configs['recommended-natural-legacy'].rules['perfectionist/sort-imports'][1],
106
+ groups: SORT_IMPORTS_GROUPS,
107
+ newlinesBetween: 'ignore',
108
+ },
109
+ ],
110
+ 'perfectionist/sort-intersection-types': [
111
+ 'error',
112
+ {
113
+ ...perfectionist.configs['recommended-natural-legacy'].rules['perfectionist/sort-intersection-types'][1],
114
+ groups: SORT_INTERSECTION_TYPES_GROUPS,
115
+ },
116
+ ],
117
+ 'perfectionist/sort-named-imports': [
118
+ 'error',
119
+ {
120
+ ...perfectionist.configs['recommended-natural-legacy'].rules['perfectionist/sort-named-imports'][1],
121
+ ignoreAlias: true,
122
+ },
123
+ ],
124
+ 'perfectionist/sort-objects': [
125
+ 'error',
126
+ {
127
+ ...perfectionist.configs['recommended-natural-legacy'].rules['perfectionist/sort-objects'][1],
128
+ partitionByComment: true,
129
+ },
130
+ ],
131
+ },
132
+ settings: {
133
+ 'import/resolver': {
134
+ typescript: true,
135
+ },
136
+ },
137
+ },
138
+ {
139
+ files: [
140
+ '**/*.d.ts', // TypeScript declaration files
141
+ '**/*.{spec,test}.*', // Usually test files
142
+ './*.{js,cjs,mjs,ts,cts,mts}', // Mostly configuration files on root level
143
+ ],
144
+ rules: {
145
+ 'import/no-unused-modules': 'off',
146
+ },
147
+ },
148
+ );
@@ -0,0 +1,16 @@
1
+ const isCI = require('is-ci');
2
+ const tseslint = require('typescript-eslint');
3
+
4
+ module.exports = tseslint.config(
5
+ isCI
6
+ ? {}
7
+ : {
8
+ rules: {
9
+ // Only activate in CI, as suggested here: https://typescript-eslint.io/linting/troubleshooting/performance-troubleshooting#eslint-plugin-import
10
+ 'import/no-cycle': 'off',
11
+ 'import/no-deprecated': 'off',
12
+ 'import/no-named-as-default': 'off',
13
+ 'import/no-unused-modules': 'off',
14
+ },
15
+ },
16
+ );
@@ -0,0 +1,13 @@
1
+ const playwright = require('eslint-plugin-playwright');
2
+ const tseslint = require('typescript-eslint');
3
+
4
+ module.exports = tseslint.config({
5
+ ...playwright.configs['flat/recommended'],
6
+ rules: {
7
+ ...playwright.configs['flat/recommended'].rules,
8
+ // eslint-plugin-playwright: https://github.com/playwright-community/eslint-plugin-playwright
9
+ 'playwright/prefer-to-be': 'error',
10
+ 'playwright/prefer-to-have-length': 'error',
11
+ 'playwright/require-top-level-describe': 'error',
12
+ },
13
+ });
@@ -0,0 +1,10 @@
1
+ const prettier = require('eslint-config-prettier');
2
+ const tseslint = require('typescript-eslint');
3
+
4
+ module.exports = tseslint.config({
5
+ ...prettier,
6
+ rules: {
7
+ ...prettier.rules,
8
+ curly: 'error',
9
+ },
10
+ });
@@ -0,0 +1,109 @@
1
+ const jsxA11y = require('eslint-plugin-jsx-a11y');
2
+ const react = require('eslint-plugin-react');
3
+ const reactHooks = require('eslint-plugin-react-hooks');
4
+ const reactRefresh = require('eslint-plugin-react-refresh');
5
+ const globals = require('globals');
6
+ const tseslint = require('typescript-eslint');
7
+
8
+ const { SORT_IMPORTS_GROUPS } = require('../lib/eslint-plugin-perfectionist.js');
9
+ const base = require('./base.js');
10
+
11
+ module.exports = tseslint.config(
12
+ ...base,
13
+ jsxA11y.flatConfigs.recommended,
14
+ react.configs.flat.recommended,
15
+ react.configs.flat['jsx-runtime'],
16
+ {
17
+ languageOptions: {
18
+ globals: {
19
+ ...globals.browser,
20
+ },
21
+ parserOptions: {
22
+ ecmaFeatures: {
23
+ jsx: true,
24
+ },
25
+ },
26
+ },
27
+ plugins: {
28
+ 'jsx-a11y': jsxA11y,
29
+ 'react-hooks': reactHooks,
30
+ 'react-refresh': reactRefresh,
31
+ },
32
+ rules: {
33
+ // @typescript-eslint: https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/eslint-plugin/docs/rules
34
+ '@typescript-eslint/consistent-type-definitions': ['error', 'type'],
35
+ '@typescript-eslint/no-restricted-types': [
36
+ 'error',
37
+ {
38
+ types: {
39
+ 'React.FC': {
40
+ message:
41
+ 'Please use object type destructure declaration, see: https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/function_components',
42
+ },
43
+ 'React.FunctionalComponent': {
44
+ message:
45
+ 'Please use object type destructure declaration, see: https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/function_components',
46
+ },
47
+ },
48
+ },
49
+ ],
50
+
51
+ // eslint-plugin-react: https://github.com/jsx-eslint/eslint-plugin-react/tree/master/lib/rules
52
+ 'react/jsx-pascal-case': 'error',
53
+ 'react/jsx-sort-props': 'off', // disabled due to conflict with eslint-plugin-perfectionist
54
+ 'react/sort-default-props': 'error',
55
+
56
+ // eslint-plugin-react-hooks: https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/README.md
57
+ 'react-hooks/exhaustive-deps': 'error',
58
+ 'react-hooks/rules-of-hooks': 'error',
59
+
60
+ // eslint-plugin-perfectionist: https://github.com/azat-io/eslint-plugin-perfectionist
61
+ 'perfectionist/sort-imports': [
62
+ 'error',
63
+ {
64
+ customGroups: {
65
+ type: {
66
+ react: ['react'],
67
+ },
68
+ value: {
69
+ react: ['react'],
70
+ },
71
+ },
72
+ groups: ['react', ...SORT_IMPORTS_GROUPS],
73
+ ignoreCase: true,
74
+ newlinesBetween: 'ignore',
75
+ type: 'natural',
76
+ },
77
+ ],
78
+ 'perfectionist/sort-jsx-props': [
79
+ 'error',
80
+ {
81
+ 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
84
+ },
85
+ groups: ['reservedProps', 'unknown', 'callback'],
86
+ ignoreCase: true,
87
+ type: 'natural',
88
+ },
89
+ ],
90
+
91
+ // eslint-plugin-react-refresh: https://github.com/ArnaudBarre/eslint-plugin-react-refresh
92
+ 'react-refresh/only-export-components': 'warn',
93
+
94
+ // Forbid enum declaration
95
+ 'no-restricted-syntax': [
96
+ 'error',
97
+ {
98
+ message: "Don't declare enums",
99
+ selector: 'TSEnumDeclaration',
100
+ },
101
+ ],
102
+ },
103
+ settings: {
104
+ react: {
105
+ version: 'detect',
106
+ },
107
+ },
108
+ },
109
+ );
@@ -1,14 +1,8 @@
1
- /**
2
- * Workaround to allow ESLint to resolve plugins that were installed
3
- * by an external config, see https://github.com/eslint/eslint/issues/3458.
4
- */
5
- require('@rushstack/eslint-patch/modern-module-resolution');
1
+ const tseslint = require('typescript-eslint');
6
2
 
7
- const typescriptEslintPlugin = require('@typescript-eslint/eslint-plugin');
3
+ const base = require('./base.js');
8
4
 
9
- /** @type {import('eslint').ESLint.ConfigData} */
10
- module.exports = {
11
- extends: ['./index.js', 'plugin:@typescript-eslint/strict-type-checked'],
5
+ module.exports = tseslint.config(...base, tseslint.configs.strictTypeChecked, {
12
6
  rules: {
13
7
  // @typescript-eslint: https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/eslint-plugin/docs/rules
14
8
  '@typescript-eslint/consistent-type-imports': 'error',
@@ -16,7 +10,7 @@ module.exports = {
16
10
  '@typescript-eslint/restrict-template-expressions': [
17
11
  'error',
18
12
  {
19
- ...typescriptEslintPlugin.rules['restrict-template-expressions'].meta.docs.recommended.strict[0],
13
+ ...tseslint.plugin.rules['restrict-template-expressions'].meta.docs.recommended.strict[0],
20
14
  allowNumber: true,
21
15
  },
22
16
  ],
@@ -24,4 +18,4 @@ module.exports = {
24
18
  // eslint-plugin-import: https://github.com/import-js/eslint-plugin-import/tree/main/docs/rules
25
19
  'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
26
20
  },
27
- };
21
+ });
package/index.js ADDED
@@ -0,0 +1,20 @@
1
+ const tseslint = require('typescript-eslint');
2
+
3
+ const base = require('./configs/base.js');
4
+ const local = require('./configs/local.js');
5
+ const playwright = require('./configs/playwright.js');
6
+ const prettierDisable = require('./configs/prettier-disable.js');
7
+ const react = require('./configs/react.js');
8
+ const strict = require('./configs/strict.js');
9
+
10
+ module.exports = {
11
+ config: tseslint.config,
12
+ configs: {
13
+ base,
14
+ local,
15
+ playwright,
16
+ prettierDisable,
17
+ react,
18
+ strict,
19
+ },
20
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boehringer-ingelheim/eslint-config",
3
- "version": "6.0.1",
3
+ "version": "7.0.0-migrate-flat-config.1",
4
4
  "description": "Shared eslint configuration used at Boehringer Ingelheim for code styling",
5
5
  "keywords": [
6
6
  "boehringer",
@@ -14,26 +14,22 @@
14
14
  ],
15
15
  "license": "MIT",
16
16
  "files": [
17
- "base",
18
- "lib",
19
- "react",
20
- "playwright",
21
- "prettier-disable"
17
+ "configs",
18
+ "lib"
22
19
  ],
23
- "main": "base/index.js",
20
+ "main": "index.js",
24
21
  "scripts": {
25
22
  "prepare": "husky",
26
23
  "release": "dotenv -- semantic-release --no-ci",
27
24
  "release:ci": "semantic-release",
28
- "repair": "npx --no rimraf .git/hooks node_modules package-lock.json && npm install"
25
+ "repair": "npx --no rimraf .git/hooks node_modules package-lock.json && npm install",
26
+ "lint": "eslint ."
29
27
  },
30
28
  "peerDependencies": {
31
- "eslint": "^8.57.1"
29
+ "eslint": ">= 8"
32
30
  },
33
31
  "dependencies": {
34
- "@rushstack/eslint-patch": "^1.10.4",
35
- "@typescript-eslint/eslint-plugin": "^8.18.0",
36
- "@typescript-eslint/parser": "^8.18.0",
32
+ "@eslint/js": "^9.17.0",
37
33
  "eslint-config-prettier": "^9.1.0",
38
34
  "eslint-import-resolver-typescript": "^3.7.0",
39
35
  "eslint-plugin-import": "^2.31.0",
@@ -44,8 +40,9 @@
44
40
  "eslint-plugin-react-hooks": "^5.1.0",
45
41
  "eslint-plugin-react-refresh": "^0.4.16",
46
42
  "eslint-plugin-sonarjs": "^1.0.4",
47
- "eslint-plugin-typescript-enum": "^2.1.0",
48
- "is-ci": "^4.1.0"
43
+ "globals": "^15.14.0",
44
+ "is-ci": "^4.1.0",
45
+ "typescript-eslint": "^8.18.1"
49
46
  },
50
47
  "devDependencies": {
51
48
  "@boehringer-ingelheim/prettier-config": "2.0.0",
package/base/index.js DELETED
@@ -1,156 +0,0 @@
1
- const {
2
- SORT_CLASSES_GROUPS,
3
- SORT_IMPORTS_GROUPS,
4
- SORT_INTERSECTION_TYPES_GROUPS,
5
- } = require('../lib/eslint-plugin-perfectionist');
6
-
7
- /**
8
- * Workaround to allow ESLint to resolve plugins that were installed
9
- * by an external config, see https://github.com/eslint/eslint/issues/3458.
10
- */
11
- require('@rushstack/eslint-patch/modern-module-resolution');
12
- const eslintPluginPerfectionist = require('eslint-plugin-perfectionist');
13
-
14
- /** @type {import('eslint').ESLint.ConfigData & { parserOptions: import('eslint').ESLint.ConfigData['parserOptions'] & import('@typescript-eslint/parser').ParserOptions } } */
15
- module.exports = {
16
- env: {
17
- es2022: true,
18
- },
19
- extends: [
20
- 'eslint:recommended',
21
- 'plugin:@typescript-eslint/recommended-type-checked',
22
- 'plugin:@typescript-eslint/stylistic-type-checked',
23
- 'plugin:import/recommended',
24
- 'plugin:import/typescript',
25
- 'plugin:perfectionist/recommended-natural-legacy',
26
- 'plugin:sonarjs/recommended-legacy',
27
- ],
28
- overrides: [
29
- {
30
- files: [
31
- '**/*.d.ts', // TypeScript declaration files
32
- '**/*.{spec,test}.*', // Usually test files
33
- './*.{js,cjs,mjs,ts,cts,mts}', // Mostly configuration files on root level
34
- ],
35
- rules: {
36
- 'import/no-unused-modules': 'off',
37
- },
38
- },
39
- ],
40
- parser: '@typescript-eslint/parser',
41
- parserOptions: {
42
- // find the tsconfig.json nearest each source file
43
- project: true,
44
- },
45
- plugins: ['@typescript-eslint', 'sonarjs'],
46
- // Warn about unused eslint-disable directives
47
- reportUnusedDisableDirectives: true,
48
- rules: {
49
- // @typescript-eslint: https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/eslint-plugin/docs/rules
50
- '@typescript-eslint/adjacent-overload-signatures': 'off', // disabled due to conflict with eslint-plugin-perfectionist
51
- '@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }],
52
- '@typescript-eslint/no-misused-promises': [
53
- 'error',
54
- {
55
- checksVoidReturn: false,
56
- },
57
- ],
58
- '@typescript-eslint/no-unused-vars': [
59
- 'error',
60
- {
61
- argsIgnorePattern: '^_',
62
- caughtErrorsIgnorePattern: '^_',
63
- varsIgnorePattern: '^_',
64
- },
65
- ],
66
- '@typescript-eslint/sort-type-constituents': 'off', // disabled due to conflict with eslint-plugin-perfectionist
67
-
68
- // eslint: https://github.com/eslint/eslint/tree/main/lib/rules
69
- '@typescript-eslint/dot-notation': ['error', { allowPattern: '^[a-z]+(_[a-z]+)+$' }],
70
- 'arrow-body-style': ['error', 'as-needed'],
71
- camelcase: 'warn',
72
- curly: 'error',
73
- 'default-case': 'error',
74
- eqeqeq: 'error',
75
- 'logical-assignment-operators': ['error', 'never'],
76
- 'no-console': ['warn', { allow: ['warn', 'error'] }],
77
- 'no-else-return': ['error', { allowElseIf: false }],
78
- 'no-empty-function': 'error',
79
- 'no-lonely-if': 'error',
80
- 'no-negated-condition': 'error',
81
- 'no-nested-ternary': 'error',
82
- 'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
83
- 'no-unneeded-ternary': 'error',
84
- 'no-useless-concat': 'error',
85
- 'operator-assignment': ['error', 'never'],
86
- 'prefer-const': 'error',
87
- 'prefer-rest-params': 'error',
88
- 'prefer-template': 'error',
89
- 'sort-imports': 'off', // disabled due to conflict with eslint-plugin-perfectionist
90
- 'sort-keys': 'off', // disabled due to conflict with eslint-plugin-perfectionist
91
-
92
- // eslint-plugin-import: https://github.com/import-js/eslint-plugin-import/tree/main/docs/rules
93
- 'import/no-cycle': 'error',
94
- 'import/no-unused-modules': [
95
- 'error',
96
- {
97
- missingExports: true,
98
- src: ['.'],
99
- unusedExports: true,
100
- },
101
- ],
102
- 'import/order': 'off', // disabled due to conflict with eslint-plugin-perfectionist
103
- 'import/prefer-default-export': 'off',
104
-
105
- // Deactivated as TypeScript provides the same checks as part of standard type checking: https://typescript-eslint.io/linting/troubleshooting/performance-troubleshooting
106
- 'import/default': 'off',
107
- 'import/named': 'off',
108
- 'import/namespace': 'off',
109
- 'import/no-named-as-default-member': 'off',
110
-
111
- // eslint-plugin-perfectionist: https://github.com/azat-io/eslint-plugin-perfectionist
112
- 'perfectionist/sort-classes': [
113
- 'error',
114
- {
115
- ...eslintPluginPerfectionist.configs['recommended-natural-legacy'].rules['perfectionist/sort-classes'][1],
116
- groups: SORT_CLASSES_GROUPS,
117
- },
118
- ],
119
- 'perfectionist/sort-imports': [
120
- 'error',
121
- {
122
- ...eslintPluginPerfectionist.configs['recommended-natural-legacy'].rules['perfectionist/sort-imports'][1],
123
- groups: SORT_IMPORTS_GROUPS,
124
- newlinesBetween: 'ignore',
125
- },
126
- ],
127
- 'perfectionist/sort-intersection-types': [
128
- 'error',
129
- {
130
- ...eslintPluginPerfectionist.configs['recommended-natural-legacy'].rules[
131
- 'perfectionist/sort-intersection-types'
132
- ][1],
133
- groups: SORT_INTERSECTION_TYPES_GROUPS,
134
- },
135
- ],
136
- 'perfectionist/sort-named-imports': [
137
- 'error',
138
- {
139
- ...eslintPluginPerfectionist.configs['recommended-natural-legacy'].rules['perfectionist/sort-named-imports'][1],
140
- ignoreAlias: true,
141
- },
142
- ],
143
- 'perfectionist/sort-objects': [
144
- 'error',
145
- {
146
- ...eslintPluginPerfectionist.configs['recommended-natural-legacy'].rules['perfectionist/sort-objects'][1],
147
- partitionByComment: true,
148
- },
149
- ],
150
- },
151
- settings: {
152
- 'import/resolver': {
153
- typescript: true,
154
- },
155
- },
156
- };
package/base/local.js DELETED
@@ -1,20 +0,0 @@
1
- /**
2
- * Workaround to allow ESLint to resolve plugins that were installed
3
- * by an external config, see https://github.com/eslint/eslint/issues/3458.
4
- */
5
- require('@rushstack/eslint-patch/modern-module-resolution');
6
-
7
- const isCI = require('is-ci');
8
-
9
- /** @type {import('eslint').ESLint.ConfigData} */
10
- module.exports = {
11
- rules: isCI
12
- ? {}
13
- : {
14
- // Only activate in CI, as suggested here: https://typescript-eslint.io/linting/troubleshooting/performance-troubleshooting#eslint-plugin-import
15
- 'import/no-cycle': 'off',
16
- 'import/no-deprecated': 'off',
17
- 'import/no-named-as-default': 'off',
18
- 'import/no-unused-modules': 'off',
19
- },
20
- };
@@ -1,16 +0,0 @@
1
- /**
2
- * Workaround to allow ESLint to resolve plugins that were installed
3
- * by an external config, see https://github.com/eslint/eslint/issues/3458.
4
- */
5
- require('@rushstack/eslint-patch/modern-module-resolution');
6
-
7
- /** @type {import('eslint').ESLint.ConfigData} */
8
- module.exports = {
9
- extends: ['plugin:playwright/playwright-test'],
10
- rules: {
11
- // eslint-plugin-playwright: https://github.com/playwright-community/eslint-plugin-playwright
12
- 'playwright/prefer-to-be': 'error',
13
- 'playwright/prefer-to-have-length': 'error',
14
- 'playwright/require-top-level-describe': 'error',
15
- },
16
- };
@@ -1,13 +0,0 @@
1
- /**
2
- * Workaround to allow ESLint to resolve plugins that were installed
3
- * by an external config, see https://github.com/eslint/eslint/issues/3458.
4
- */
5
- require('@rushstack/eslint-patch/modern-module-resolution');
6
-
7
- /** @type {import('eslint').ESLint.ConfigData & { parserOptions: import('eslint').ESLint.ConfigData['parserOptions'] & import('@typescript-eslint/parser').ParserOptions } } */
8
- module.exports = {
9
- extends: ['prettier'],
10
- rules: {
11
- curly: 'error',
12
- },
13
- };
package/react/index.js DELETED
@@ -1,96 +0,0 @@
1
- const { SORT_IMPORTS_GROUPS } = require('../lib/eslint-plugin-perfectionist');
2
-
3
- /**
4
- * Workaround to allow ESLint to resolve plugins that were installed
5
- * by an external config, see https://github.com/eslint/eslint/issues/3458.
6
- */
7
- require('@rushstack/eslint-patch/modern-module-resolution');
8
-
9
- /** @type {import('eslint').ESLint.ConfigData & { parserOptions: import('eslint').ESLint.ConfigData['parserOptions'] & import('@typescript-eslint/parser').ParserOptions } } */
10
- module.exports = {
11
- env: {
12
- browser: true,
13
- },
14
- extends: [
15
- '../base/index.js',
16
- 'plugin:jsx-a11y/recommended',
17
- 'plugin:react/recommended',
18
- 'plugin:react/jsx-runtime',
19
- 'plugin:typescript-enum/recommended',
20
- ],
21
- parserOptions: {
22
- ecmaFeatures: {
23
- jsx: true,
24
- },
25
- ecmaVersion: 'latest',
26
- sourceType: 'module',
27
- },
28
- plugins: ['jsx-a11y', 'react', 'react-hooks', 'react-refresh', 'typescript-enum'],
29
- rules: {
30
- // @typescript-eslint: https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/eslint-plugin/docs/rules
31
- '@typescript-eslint/no-restricted-types': [
32
- 'error',
33
- {
34
- types: {
35
- 'React.FC': {
36
- message:
37
- 'Please use object type destructure declaration, see: https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/function_components',
38
- },
39
- 'React.FunctionalComponent': {
40
- message:
41
- 'Please use object type destructure declaration, see: https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/function_components',
42
- },
43
- },
44
- },
45
- ],
46
- '@typescript-eslint/consistent-type-definitions': ['error', 'type'],
47
-
48
- // eslint-plugin-react: https://github.com/jsx-eslint/eslint-plugin-react/tree/master/lib/rules
49
- 'react/jsx-pascal-case': 'error',
50
- 'react/jsx-sort-props': 'off', // disabled due to conflict with eslint-plugin-perfectionist
51
- 'react/sort-default-props': 'error',
52
-
53
- // eslint-plugin-react-hooks: https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/README.md
54
- 'react-hooks/exhaustive-deps': 'error',
55
- 'react-hooks/rules-of-hooks': 'error',
56
-
57
- // eslint-plugin-perfectionist: https://github.com/azat-io/eslint-plugin-perfectionist
58
- 'perfectionist/sort-imports': [
59
- 'error',
60
- {
61
- customGroups: {
62
- type: {
63
- react: ['react'],
64
- },
65
- value: {
66
- react: ['react'],
67
- },
68
- },
69
- groups: ['react', ...SORT_IMPORTS_GROUPS],
70
- ignoreCase: true,
71
- newlinesBetween: 'ignore',
72
- type: 'natural',
73
- },
74
- ],
75
- 'perfectionist/sort-jsx-props': [
76
- 'error',
77
- {
78
- customGroups: {
79
- callback: 'on*',
80
- 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
- },
82
- groups: ['reservedProps', 'unknown', 'callback'],
83
- ignoreCase: true,
84
- type: 'natural',
85
- },
86
- ],
87
-
88
- // eslint-plugin-react-refresh: https://github.com/ArnaudBarre/eslint-plugin-react-refresh
89
- 'react-refresh/only-export-components': 'warn',
90
- },
91
- settings: {
92
- react: {
93
- version: 'detect',
94
- },
95
- },
96
- };