@boehringer-ingelheim/eslint-config 7.2.0 → 7.3.0-include-ignore-file.2

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
@@ -35,7 +35,7 @@ export default boehringer.config(
35
35
 
36
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
37
 
38
- #### Extend or Override configuration
38
+ ##### Extend or Override configuration
39
39
 
40
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:
41
41
 
@@ -52,6 +52,33 @@ export default boehringer.config(
52
52
  );
53
53
  ```
54
54
 
55
+ #### `boehringer.includeIgnoreFile()`
56
+
57
+ The `includeIgnoreFile` function allows you to include `.gitignore` files in your ESLint configuration using a relative path.
58
+ This is an adjusted version of the same function from ESLint ([Ignore Files](https://eslint.org/docs/latest/use/configure/ignore#including-gitignore-files)).
59
+ It is recommended to use this function to ensure that your `.gitignore` file is properly included in your ESLint setup.
60
+
61
+ ```js
62
+ import boehringer from '@boehringer-ingelheim/eslint-config';
63
+
64
+ export default boehringer.config(
65
+ boehringer.includeIgnoreFile(), // default value '.gitignore'
66
+ boehringer.configs.strict,
67
+ );
68
+ ```
69
+
70
+ or in case you have a different paths to your `.gitignore` file(s):
71
+
72
+ ```js
73
+ import boehringer from '@boehringer-ingelheim/eslint-config';
74
+
75
+ export default boehringer.config(
76
+ boehringer.includeIgnoreFile('./backend/.gitignore'),
77
+ boehringer.includeIgnoreFile('./frontend/.gitignore'),
78
+ boehringer.configs.strict,
79
+ );
80
+ ```
81
+
55
82
  More Information: [ESLint - Configuration Files](https://eslint.org/docs/latest/use/configure/configuration-files#extending-configuration-files)
56
83
 
57
84
  ### Run
package/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { FlatConfig } from '@eslint/compat';
1
2
  import { Config } from 'typescript-eslint';
2
3
 
3
4
  type Configs =
@@ -13,6 +14,15 @@ type Configs =
13
14
  declare module './index' {
14
15
  const config: typeof import('typescript-eslint').config;
15
16
  const configs: Record<Configs, Config>;
17
+ /**
18
+ * Reads an ignore file (e.g. `.gitignore`) and returns an object with the ignore patterns.
19
+ *
20
+ * @param {string} [ignoreFilePath='.gitignore'] - The path to the ignore file. Defaults to `.gitignore`.
21
+ * @throws {TypeError} If the provided path is not a string.
22
+ * @throws {Error} If the provided path is an empty string.
23
+ * @returns {FlatConfig} The result of including the ignore file at the resolved absolute path.
24
+ */
25
+ const includeIgnoreFile: (ignoreFilePath = '.gitignore') => FlatConfig;
16
26
 
17
- export { config, configs };
27
+ export { config, configs, includeIgnoreFile };
18
28
  }
package/index.js CHANGED
@@ -8,6 +8,7 @@ const playwright = require('./configs/playwright.js');
8
8
  const prettierDisable = require('./configs/prettier-disable.js');
9
9
  const react = require('./configs/react.js');
10
10
  const strict = require('./configs/strict.js');
11
+ const { includeIgnoreFile } = require('./lib/include-ignore-file.js');
11
12
 
12
13
  module.exports = {
13
14
  config: tseslint.config,
@@ -21,4 +22,5 @@ module.exports = {
21
22
  react,
22
23
  strict,
23
24
  },
25
+ includeIgnoreFile,
24
26
  };
@@ -0,0 +1,28 @@
1
+ const { includeIgnoreFile: includeIgnoreFileAbsolute } = require('@eslint/compat');
2
+ const path = require('node:path');
3
+ const { cwd } = require('node:process');
4
+
5
+ /**
6
+ * Reads an ignore file (e.g. `.gitignore`) and returns an object with the ignore patterns.
7
+ *
8
+ * @param {string} [ignoreFilePath='.gitignore'] - The path to the ignore file. Defaults to `.gitignore`.
9
+ * @throws {TypeError} If the provided path is not a string.
10
+ * @throws {Error} If the provided path is an empty string.
11
+ * @returns {import('@eslint/compat').FlatConfig} The result of including the ignore file at the resolved absolute path.
12
+ */
13
+ const includeIgnoreFile = (ignoreFilePath = '.gitignore') => {
14
+ if (typeof ignoreFilePath !== 'string') {
15
+ throw new TypeError('Expected a string');
16
+ }
17
+
18
+ if (ignoreFilePath === '') {
19
+ throw new Error('Expected a non-empty string');
20
+ }
21
+
22
+ const absolutePath = path.resolve(cwd(), ignoreFilePath);
23
+ return includeIgnoreFileAbsolute(absolutePath);
24
+ };
25
+
26
+ module.exports = {
27
+ includeIgnoreFile,
28
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boehringer-ingelheim/eslint-config",
3
- "version": "7.2.0",
3
+ "version": "7.3.0-include-ignore-file.2",
4
4
  "description": "Shared eslint configuration used at Boehringer Ingelheim for code styling",
5
5
  "keywords": [
6
6
  "boehringer",
@@ -32,21 +32,22 @@
32
32
  "eslint": ">= 8"
33
33
  },
34
34
  "dependencies": {
35
- "@eslint/js": "^9.19.0",
36
- "@next/eslint-plugin-next": "^15.1.6",
35
+ "@eslint/compat": "^1.2.6",
36
+ "@eslint/js": "^9.20.0",
37
+ "@next/eslint-plugin-next": "^15.1.7",
37
38
  "eslint-config-prettier": "^10.0.1",
38
- "eslint-import-resolver-typescript": "^3.7.0",
39
+ "eslint-import-resolver-typescript": "^3.8.1",
39
40
  "eslint-plugin-import": "^2.31.0",
40
41
  "eslint-plugin-jsx-a11y": "^6.10.2",
41
- "eslint-plugin-perfectionist": "^4.8.0",
42
+ "eslint-plugin-perfectionist": "^4.9.0",
42
43
  "eslint-plugin-playwright": "^2.2.0",
43
44
  "eslint-plugin-react": "^7.37.4",
44
45
  "eslint-plugin-react-hooks": "^5.1.0",
45
- "eslint-plugin-react-refresh": "^0.4.18",
46
+ "eslint-plugin-react-refresh": "^0.4.19",
46
47
  "eslint-plugin-sonarjs": "^1.0.4",
47
- "globals": "^15.14.0",
48
+ "globals": "^15.15.0",
48
49
  "is-ci": "^4.1.0",
49
- "typescript-eslint": "^8.23.0"
50
+ "typescript-eslint": "^8.24.1"
50
51
  },
51
52
  "devDependencies": {
52
53
  "@boehringer-ingelheim/prettier-config": "2.0.0",
@@ -57,7 +58,7 @@
57
58
  "@semantic-release/git": "10.0.1",
58
59
  "dotenv-cli": "8.0.0",
59
60
  "husky": "9.1.7",
60
- "prettier": "3.4.2",
61
- "semantic-release": "24.2.1"
61
+ "prettier": "3.5.1",
62
+ "semantic-release": "24.2.3"
62
63
  }
63
64
  }