@vijayhardaha/dev-config 2.2.0 → 2.2.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 +16 -0
- package/package.json +17 -17
- package/src/eslint/lib/build-config.js +8 -0
- package/src/next-sitemap/index.test.js +26 -0
package/README.md
CHANGED
|
@@ -116,6 +116,22 @@ import { createConfig } from "@vijayhardaha/dev-config/eslint/next";
|
|
|
116
116
|
export default createConfig();
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
+
#### ESLint Subpath Imports
|
|
120
|
+
|
|
121
|
+
Use subpath imports to load ESLint configs with optional integrations (TypeScript, React, Next.js). The root import only provides the base JavaScript config:
|
|
122
|
+
|
|
123
|
+
```javascript
|
|
124
|
+
// ✅ Correct: Use subpath imports for specialized configs
|
|
125
|
+
import { createConfig } from "@vijayhardaha/dev-config/eslint/ts"; // TypeScript
|
|
126
|
+
import { createConfig } from "@vijayhardaha/dev-config/eslint/react"; // React + TypeScript
|
|
127
|
+
import { createConfig } from "@vijayhardaha/dev-config/eslint/next"; // Next.js + React + TypeScript
|
|
128
|
+
|
|
129
|
+
// ❌ Incorrect: Root import only provides JavaScript config
|
|
130
|
+
// import { createEslintConfig } from "@vijayhardaha/dev-config"; // Won't export specialized createConfig
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
This design keeps the root import lightweight and prevents loading unnecessary optional dependencies.
|
|
134
|
+
|
|
119
135
|
### Prettier
|
|
120
136
|
|
|
121
137
|
Create `prettier.config.mjs` in your project root:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vijayhardaha/dev-config",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "Reusable development configurations for Next.js + TypeScript projects",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"lint": "eslint .",
|
|
@@ -67,30 +67,30 @@
|
|
|
67
67
|
],
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@eslint/js": "^10.0.1",
|
|
70
|
-
"@commitlint/cli": "^21.1
|
|
71
|
-
"@commitlint/config-conventional": "^21.
|
|
72
|
-
"@commitlint/types": "^21.
|
|
73
|
-
"@typescript-eslint/parser": "^8.
|
|
74
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
75
|
-
"@vitest/coverage-v8": "^4.1.
|
|
76
|
-
"eslint": "^10.
|
|
77
|
-
"eslint-config-next": "^16.2.
|
|
70
|
+
"@commitlint/cli": "^21.2.1",
|
|
71
|
+
"@commitlint/config-conventional": "^21.2.0",
|
|
72
|
+
"@commitlint/types": "^21.2.0",
|
|
73
|
+
"@typescript-eslint/parser": "^8.65.0",
|
|
74
|
+
"@typescript-eslint/eslint-plugin": "^8.65.0",
|
|
75
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
76
|
+
"eslint": "^10.8.0",
|
|
77
|
+
"eslint-config-next": "^16.2.12",
|
|
78
78
|
"eslint-config-prettier": "^10.1.8",
|
|
79
|
-
"eslint-plugin-import-x": "^4.17.
|
|
80
|
-
"eslint-plugin-jsdoc": "^63.
|
|
79
|
+
"eslint-plugin-import-x": "^4.17.1",
|
|
80
|
+
"eslint-plugin-jsdoc": "^63.3.2",
|
|
81
81
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
82
82
|
"eslint-plugin-prettier": "^5.5.6",
|
|
83
83
|
"eslint-plugin-react": "^7.37.5",
|
|
84
84
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
85
|
-
"globals": "^17.
|
|
85
|
+
"globals": "^17.9.0",
|
|
86
86
|
"husky": "^9.1.7",
|
|
87
|
-
"next": "^16.2.
|
|
88
|
-
"prettier": "^3.
|
|
87
|
+
"next": "^16.2.12",
|
|
88
|
+
"prettier": "^3.9.6",
|
|
89
89
|
"@prettier/plugin-xml": "^3.4.2",
|
|
90
|
-
"release-it": "^
|
|
90
|
+
"release-it": "^21.0.1",
|
|
91
91
|
"typescript": "^6.0.3",
|
|
92
|
-
"typescript-eslint": "^8.
|
|
93
|
-
"vitest": "^4.1.
|
|
92
|
+
"typescript-eslint": "^8.65.0",
|
|
93
|
+
"vitest": "^4.1.10"
|
|
94
94
|
},
|
|
95
95
|
"peerDependencies": {
|
|
96
96
|
"@commitlint/cli": ">=21",
|
|
@@ -17,6 +17,14 @@ try {
|
|
|
17
17
|
createTypeScriptImportResolver = (await import('eslint-import-resolver-typescript')).createTypeScriptImportResolver;
|
|
18
18
|
} catch {
|
|
19
19
|
createTypeScriptImportResolver = null;
|
|
20
|
+
// Debug logging for optional dependency failure
|
|
21
|
+
if (process.env.DEBUG?.includes('eslint') || process.env.DEBUG === '*') {
|
|
22
|
+
console.debug(
|
|
23
|
+
'[ESLint Config] Optional dependency "eslint-import-resolver-typescript" not found. '
|
|
24
|
+
+ 'TypeScript import resolution will be disabled. '
|
|
25
|
+
+ 'Install it with: npm install --save-dev eslint-import-resolver-typescript'
|
|
26
|
+
);
|
|
27
|
+
}
|
|
20
28
|
}
|
|
21
29
|
|
|
22
30
|
/**
|
|
@@ -56,4 +56,30 @@ describe('next-sitemap/index.js', () => {
|
|
|
56
56
|
// Verify that generateRobotsTxt is enabled by default.
|
|
57
57
|
expect(config.generateRobotsTxt).toBe(true);
|
|
58
58
|
});
|
|
59
|
+
|
|
60
|
+
// Test that transformRobotsTxt removes the Host header from generated robots.txt.
|
|
61
|
+
it('should remove Host header in transformRobotsTxt', async () => {
|
|
62
|
+
// Dynamically import the module to test its function.
|
|
63
|
+
const module = await import('./index.js');
|
|
64
|
+
|
|
65
|
+
// Call createSitemapConfig with a test siteUrl.
|
|
66
|
+
const config = module.createSitemapConfig({ siteUrl: 'https://example.com' });
|
|
67
|
+
|
|
68
|
+
// Verify that robotsTxtOptions has the transformRobotsTxt function.
|
|
69
|
+
expect(typeof config.robotsTxtOptions.transformRobotsTxt).toBe('function');
|
|
70
|
+
|
|
71
|
+
// Mock a robots.txt output with the Host header that next-sitemap generates.
|
|
72
|
+
const mockRobotsTxt = `# Host\nHost: https://example.com\n\nUser-agent: *\nAllow: /\n`;
|
|
73
|
+
|
|
74
|
+
// Call the transformRobotsTxt function with mock data.
|
|
75
|
+
const transformed = await config.robotsTxtOptions.transformRobotsTxt(config, mockRobotsTxt);
|
|
76
|
+
|
|
77
|
+
// Verify that the Host header has been removed from the output.
|
|
78
|
+
expect(transformed).not.toContain('# Host');
|
|
79
|
+
expect(transformed).not.toContain('Host: https://example.com');
|
|
80
|
+
|
|
81
|
+
// Verify that the rest of the robots.txt content is preserved.
|
|
82
|
+
expect(transformed).toContain('User-agent: *');
|
|
83
|
+
expect(transformed).toContain('Allow: /');
|
|
84
|
+
});
|
|
59
85
|
});
|