@vijayhardaha/dev-config 2.0.4 → 2.1.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vijayhardaha/dev-config",
3
- "version": "2.0.4",
3
+ "version": "2.1.0",
4
4
  "description": "Reusable development configurations for Next.js + TypeScript projects",
5
5
  "scripts": {
6
6
  "lint": "eslint .",
@@ -1,5 +1,8 @@
1
+ import { existsSync } from 'node:fs';
2
+ import path from 'node:path';
3
+
1
4
  import { fixupPluginRules } from '@eslint/compat';
2
- import { defineConfig } from 'eslint/config';
5
+ import { defineConfig, includeIgnoreFile } from 'eslint/config';
3
6
  import { createNodeResolver, flatConfigs as importXFlatConfigs } from 'eslint-plugin-import-x';
4
7
  import jsdocPlugin from 'eslint-plugin-jsdoc';
5
8
  import prettierRecommended from 'eslint-plugin-prettier/recommended';
@@ -240,6 +243,9 @@ export const buildConfig = ({
240
243
  const parsedConfigs = typescript ? stripParser(strippedConfigs) : strippedConfigs;
241
244
  const mergedGlobalIgnores = mergeGlobalIgnores(opts.globalIgnores);
242
245
 
246
+ const gitignorePath = path.resolve(process.cwd(), '.gitignore');
247
+ const gitignoreConfig = existsSync(gitignorePath) ? includeIgnoreFile(gitignorePath) : null;
248
+
243
249
  const configObject = buildConfigObject({
244
250
  filePatterns,
245
251
  opts,
@@ -251,5 +257,10 @@ export const buildConfig = ({
251
257
  extraRules,
252
258
  });
253
259
 
254
- return defineConfig([...mergedGlobalIgnores, ...parsedConfigs, configObject]);
260
+ return defineConfig([
261
+ ...mergedGlobalIgnores,
262
+ ...(gitignoreConfig ? [gitignoreConfig] : []),
263
+ ...parsedConfigs,
264
+ configObject,
265
+ ]);
255
266
  };
@@ -77,4 +77,16 @@ describe('eslint/lib/build-config.js', () => {
77
77
  expect(configObject.settings).toBeDefined();
78
78
  expect(configObject.settings['import-x/resolver-next']).toBeUndefined();
79
79
  });
80
+
81
+ // Test that buildConfig includes .gitignore patterns via includeIgnoreFile.
82
+ it('should include .gitignore patterns from project root', async () => {
83
+ const module = await import('./build-config.js');
84
+ const { files } = await import('./files.js');
85
+
86
+ const result = module.buildConfig({ files: files.withoutTs, options: {} });
87
+
88
+ // When .gitignore exists at the project root, includeIgnoreFile adds a config with ignores.
89
+ const hasIgnoreConfig = result.some((config) => config.ignores && config.ignores.length > 0);
90
+ expect(hasIgnoreConfig).toBe(true);
91
+ });
80
92
  });
@@ -1,4 +1,4 @@
1
1
  {
2
- "compilerOptions": { "jsx": "react-jsx", "resolveJsonModule": true, "baseUrl": ".", "paths": { "@/*": ["./src/*"] } },
2
+ "compilerOptions": { "jsx": "react-jsx", "resolveJsonModule": true, "paths": { "@/*": ["./src/*"] } },
3
3
  "exclude": ["node_modules", ".next", "out"]
4
4
  }