@vijayhardaha/dev-config 1.0.12 → 1.1.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.
Files changed (36) hide show
  1. package/README.md +79 -13
  2. package/package.json +60 -97
  3. package/src/commitlint/index.js +3 -3
  4. package/src/commitlint/index.test.js +49 -0
  5. package/src/eslint/index.js +17 -53
  6. package/src/eslint/index.test.js +22 -0
  7. package/src/eslint/lib/build-config.js +85 -0
  8. package/src/eslint/lib/build-config.test.js +30 -0
  9. package/src/eslint/lib/files.js +6 -0
  10. package/src/eslint/lib/files.test.js +31 -0
  11. package/src/eslint/lib/ignores.js +184 -0
  12. package/src/eslint/lib/ignores.test.js +37 -0
  13. package/src/eslint/lib/index.js +3 -0
  14. package/src/eslint/lib/index.test.js +37 -0
  15. package/src/eslint/lib/language-options.js +13 -0
  16. package/src/eslint/lib/language-options.test.js +28 -0
  17. package/src/eslint/{common.js → lib/rules.js} +4 -103
  18. package/src/eslint/lib/rules.test.js +73 -0
  19. package/src/eslint/lib/setup.js +29 -0
  20. package/src/eslint/lib/setup.test.js +25 -0
  21. package/src/eslint/next.js +30 -59
  22. package/src/eslint/next.test.js +32 -0
  23. package/src/eslint/react.js +27 -55
  24. package/src/eslint/react.test.js +22 -0
  25. package/src/eslint/typescript.js +19 -43
  26. package/src/eslint/typescript.test.js +22 -0
  27. package/src/index.js +3 -3
  28. package/src/index.test.js +36 -0
  29. package/src/jsconfig/index.test.js +34 -0
  30. package/src/next-sitemap/index.js +3 -3
  31. package/src/next-sitemap/index.test.js +59 -0
  32. package/src/prettier/index.js +12 -3
  33. package/src/prettier/index.test.js +39 -0
  34. package/src/stylelint/index.js +3 -3
  35. package/src/stylelint/index.test.js +52 -0
  36. package/src/tsconfig/index.test.js +52 -0
@@ -1,17 +1,15 @@
1
1
  /**
2
- * =====================================================================.
2
+ * =====================================================================
3
3
  * Eslint Configuration (Flat)
4
- * =====================================================================.
4
+ * =====================================================================
5
5
  * Purpose: Project-wide ESLint configuration for Next.js, TypeScript, and
6
6
  * React. Enforces code quality, accessibility, and consistent styling.
7
7
  * Docs: https://eslint.org/docs/latest/use/configure/configuration-files-new
8
8
  * Usage: npx eslint .
9
- * =====================================================================.
9
+ * =====================================================================
10
10
  */
11
11
 
12
- import { defineConfig } from 'eslint/config';
13
-
14
- import { setup, commonIgnores, commonParser, commonRules, commonLanguageOptions, files } from './common.js';
12
+ import { setup, buildConfig, files } from './lib/index.js';
15
13
 
16
14
  const { compat } = setup();
17
15
 
@@ -25,66 +23,39 @@ const { compat } = setup();
25
23
  * @param {boolean} [options.a11y] - Enable accessibility rules.
26
24
  * @param {boolean} [options.importOrder] - Enable import order rules.
27
25
  * @param {boolean} [options.jsdoc] - Enable JSDoc rules for public/exported APIs.
26
+ * @param {string[]} [options.ignores] - Additional ignore patterns.
27
+ * @param {object} [options.rules] - Additional or overridden rules.
28
+ * @param {object} [options.settings] - Additional settings.
29
+ * @param {string[]} [options.files] - Additional file patterns to lint.
30
+ * @param {object} [options.languageOptions] - Additional language options.
31
+ * @param {string[]} [options.plugins] - Additional plugin configs to extend.
32
+ * @param {string[]} [options.globalIgnores] - Additional global ignore patterns.
33
+ * @param {object} [options.extend] - Additional config properties to extend.
28
34
  *
29
35
  * @returns {import('eslint').Linter.Config[]} ESLint configuration array.
30
36
  */
31
37
  export const createConfig = (options = {}) => {
32
38
  const { prettier = true, react = true, a11y = true, importOrder = true, jsdoc = true } = options;
33
39
 
34
- // ---- Extends Configs ----
35
- // Build the extends array based on enabled features
36
- const extendsConfigs = [
37
- 'next/core-web-vitals',
38
- 'next/typescript',
39
- react && 'plugin:react/recommended',
40
- react && 'plugin:react-hooks/recommended',
41
- 'plugin:@typescript-eslint/recommended',
42
- 'plugin:import/recommended',
43
- a11y && 'plugin:jsx-a11y/recommended',
44
- jsdoc && 'plugin:jsdoc/recommended',
45
- prettier && 'plugin:prettier/recommended',
46
- ].filter(Boolean);
47
-
48
- return defineConfig([
49
- // ---- Global Ignores ----
50
- ...commonIgnores,
51
-
52
- // ---- Extends Configs ----
53
- ...compat.extends(...extendsConfigs),
54
-
55
- {
56
- // ---- TypeScript Files Configuration ----
57
- // Apply to TypeScript files
58
- files: files.withTs,
59
-
60
- // ---- Language Options ----
61
- languageOptions: {
62
- ...commonLanguageOptions,
63
- ...commonParser,
64
- // ---- Parser Options ----
65
- // Configure TypeScript parser with React JSX support
66
- parserOptions: { ecmaFeatures: { jsx: true }, tsconfigRootDir: process.cwd() },
67
- },
68
-
69
- // ---- Settings ----
70
- settings: {
71
- ...(react && { react: { version: 'detect' } }),
72
- ...(importOrder && { 'import/resolver': { typescript: {} } }),
73
- },
74
-
75
- // ---- Rules ----
76
- rules: {
77
- // ---- React Rules ----
78
- // Disable React import requirement (Next.js handles this)
79
- ...(react && { 'react/react-in-jsx-scope': 'off' }),
80
- // Allow JSX and global attributes
81
- ...(react && { 'react/no-unknown-property': ['error', { ignore: ['jsx', 'global'] }] }),
82
- // ---- Common Rules ----
83
- // Apply shared rules
84
- ...commonRules({ prettier, importOrder, jsdoc }),
85
- },
40
+ return buildConfig({
41
+ compat,
42
+ files: files.withTs,
43
+ builtinPlugins: ['next/core-web-vitals', 'next/typescript', 'plugin:@typescript-eslint/recommended'],
44
+ conditionalPlugins: {
45
+ react: ['plugin:react/recommended', 'plugin:react-hooks/recommended'],
46
+ a11y: 'plugin:jsx-a11y/recommended',
47
+ },
48
+ parserOptions: { ecmaFeatures: { jsx: true } },
49
+ settings: { react: { version: 'detect' } },
50
+ rules: {
51
+ ...(react && {
52
+ 'react/react-in-jsx-scope': 'off',
53
+ 'react/no-unknown-property': ['error', { ignore: ['jsx', 'global'] }],
54
+ }),
86
55
  },
87
- ]);
56
+ typescript: true,
57
+ options: { ...options, prettier, react, a11y, importOrder, jsdoc },
58
+ });
88
59
  };
89
60
 
90
61
  export default createConfig();
@@ -0,0 +1,32 @@
1
+ import { describe, it, expect } from 'vitest';
2
+
3
+ // Test suite for the ESLint Next.js configuration module.
4
+ describe('eslint/next.js', () => {
5
+ // Test that the module exports the createConfig function.
6
+ it('should export createConfig function', async () => {
7
+ try {
8
+ // Dynamically import the next.js module to test its exports.
9
+ const module = await import('./next.js');
10
+
11
+ // Verify that createConfig is a function (used to create ESLint config for Next.js).
12
+ expect(typeof module.createConfig).toBe('function');
13
+ } catch (error) {
14
+ // If import fails, expect an error to be defined.
15
+ expect(error).toBeDefined();
16
+ }
17
+ });
18
+
19
+ // Test that the module exports a default configuration object.
20
+ it('should export default config', async () => {
21
+ try {
22
+ // Dynamically import the next.js module to test its exports.
23
+ const module = await import('./next.js');
24
+
25
+ // Verify that the default export is defined (should be an ESLint config object).
26
+ expect(module.default).toBeDefined();
27
+ } catch (error) {
28
+ // If import fails, expect an error to be defined.
29
+ expect(error).toBeDefined();
30
+ }
31
+ });
32
+ });
@@ -1,17 +1,15 @@
1
1
  /**
2
- * =====================================================================.
2
+ * =====================================================================
3
3
  * Eslint Configuration (Flat)
4
- * =====================================================================.
4
+ * =====================================================================
5
5
  * Purpose: Project-wide ESLint configuration for React with TypeScript.
6
6
  * Enforces code quality, accessibility, and consistent styling.
7
7
  * Docs: https://eslint.org/docs/latest/use/configure/configuration-files-new
8
8
  * Usage: npx eslint .
9
- * =====================================================================.
9
+ * =====================================================================
10
10
  */
11
11
 
12
- import { defineConfig } from 'eslint/config';
13
-
14
- import { setup, commonIgnores, commonParser, commonRules, commonLanguageOptions, files } from './common.js';
12
+ import { setup, buildConfig, files } from './lib/index.js';
15
13
 
16
14
  const { compat } = setup();
17
15
 
@@ -24,61 +22,35 @@ const { compat } = setup();
24
22
  * @param {boolean} [options.a11y] - Enable accessibility rules.
25
23
  * @param {boolean} [options.importOrder] - Enable import order rules.
26
24
  * @param {boolean} [options.jsdoc] - Enable JSDoc rules for public/exported APIs.
25
+ * @param {string[]} [options.ignores] - Additional ignore patterns.
26
+ * @param {object} [options.rules] - Additional or overridden rules.
27
+ * @param {object} [options.settings] - Additional settings.
28
+ * @param {string[]} [options.files] - Additional file patterns to lint.
29
+ * @param {object} [options.languageOptions] - Additional language options.
30
+ * @param {string[]} [options.plugins] - Additional plugin configs to extend.
31
+ * @param {string[]} [options.globalIgnores] - Additional global ignore patterns.
32
+ * @param {object} [options.extend] - Additional config properties to extend.
27
33
  *
28
34
  * @returns {import('eslint').Linter.Config[]} ESLint configuration array.
29
35
  */
30
36
  export const createConfig = (options = {}) => {
31
37
  const { prettier = true, a11y = true, importOrder = true, jsdoc = true } = options;
32
38
 
33
- // ---- Extends Configs ----
34
- // Build the extends array based on enabled features
35
- const extendsConfigs = [
36
- 'plugin:react/recommended',
37
- 'plugin:react-hooks/recommended',
38
- 'plugin:@typescript-eslint/recommended',
39
- 'plugin:import/recommended',
40
- a11y && 'plugin:jsx-a11y/recommended',
41
- jsdoc && 'plugin:jsdoc/recommended',
42
- prettier && 'plugin:prettier/recommended',
43
- ].filter(Boolean);
44
-
45
- return defineConfig([
46
- // ---- Global Ignores ----
47
- ...commonIgnores,
48
-
49
- // ---- Extends Configs ----
50
- ...compat.extends(...extendsConfigs),
51
-
52
- {
53
- // ---- TypeScript Files Configuration ----
54
- // Apply to TypeScript files
55
- files: files.withTs,
56
-
57
- // ---- Language Options ----
58
- languageOptions: {
59
- ...commonLanguageOptions,
60
- ...commonParser,
61
- // ---- Parser Options ----
62
- // Configure TypeScript parser with React JSX support
63
- parserOptions: { ecmaFeatures: { jsx: true }, tsconfigRootDir: process.cwd() },
64
- },
65
-
66
- // ---- Settings ----
67
- settings: { react: { version: 'detect' }, ...(importOrder && { 'import/resolver': { typescript: {} } }) },
68
-
69
- // ---- Rules ----
70
- rules: {
71
- // ---- React Rules ----
72
- // Disable React import requirement (Next.js handles this)
73
- 'react/react-in-jsx-scope': 'off',
74
- // Allow JSX and global attributes
75
- 'react/no-unknown-property': ['error', { ignore: ['jsx', 'global'] }],
76
- // ---- Common Rules ----
77
- // Apply shared rules
78
- ...commonRules({ prettier, importOrder, jsdoc }),
79
- },
80
- },
81
- ]);
39
+ return buildConfig({
40
+ compat,
41
+ files: files.withTs,
42
+ builtinPlugins: [
43
+ 'plugin:react/recommended',
44
+ 'plugin:react-hooks/recommended',
45
+ 'plugin:@typescript-eslint/recommended',
46
+ ],
47
+ conditionalPlugins: { a11y: 'plugin:jsx-a11y/recommended' },
48
+ parserOptions: { ecmaFeatures: { jsx: true } },
49
+ settings: { react: { version: 'detect' } },
50
+ rules: { 'react/react-in-jsx-scope': 'off', 'react/no-unknown-property': ['error', { ignore: ['jsx', 'global'] }] },
51
+ typescript: true,
52
+ options: { ...options, prettier, a11y, importOrder, jsdoc },
53
+ });
82
54
  };
83
55
 
84
56
  export default createConfig();
@@ -0,0 +1,22 @@
1
+ import { describe, it, expect } from 'vitest';
2
+
3
+ // Test suite for the ESLint React configuration module.
4
+ describe('eslint/react.js', () => {
5
+ // Test that the module exports the createConfig function.
6
+ it('should export createConfig function', async () => {
7
+ // Dynamically import the react.js module to test its exports.
8
+ const module = await import('./react.js');
9
+
10
+ // Verify that createConfig is a function (used to create ESLint config for React).
11
+ expect(typeof module.createConfig).toBe('function');
12
+ });
13
+
14
+ // Test that the module exports a default configuration object.
15
+ it('should export default config', async () => {
16
+ // Dynamically import the react.js module to test its exports.
17
+ const module = await import('./react.js');
18
+
19
+ // Verify that the default export is defined (should be an ESLint config object).
20
+ expect(module.default).toBeDefined();
21
+ });
22
+ });
@@ -1,17 +1,15 @@
1
1
  /**
2
- * =====================================================================.
2
+ * =====================================================================
3
3
  * Eslint Configuration (Flat)
4
- * =====================================================================.
4
+ * =====================================================================
5
5
  * Purpose: Project-wide ESLint configuration for TypeScript.
6
6
  * Enforces code quality and consistent styling.
7
7
  * Docs: https://eslint.org/docs/latest/use/configure/configuration-files-new
8
8
  * Usage: npx eslint .
9
- * =====================================================================.
9
+ * =====================================================================
10
10
  */
11
11
 
12
- import { defineConfig } from 'eslint/config';
13
-
14
- import { setup, commonIgnores, commonParser, commonRules, commonLanguageOptions, files } from './common.js';
12
+ import { setup, buildConfig, files } from './lib/index.js';
15
13
 
16
14
  const { compat } = setup();
17
15
 
@@ -22,49 +20,27 @@ const { compat } = setup();
22
20
  * @param {boolean} [options.prettier] - Enable Prettier integration.
23
21
  * @param {boolean} [options.importOrder] - Enable import order rules.
24
22
  * @param {boolean} [options.jsdoc] - Enable JSDoc rules for public/exported APIs.
23
+ * @param {string[]} [options.ignores] - Additional ignore patterns.
24
+ * @param {object} [options.rules] - Additional or overridden rules.
25
+ * @param {object} [options.settings] - Additional settings.
26
+ * @param {string[]} [options.files] - Additional file patterns to lint.
27
+ * @param {object} [options.languageOptions] - Additional language options.
28
+ * @param {string[]} [options.plugins] - Additional plugin configs to extend.
29
+ * @param {string[]} [options.globalIgnores] - Additional global ignore patterns.
30
+ * @param {object} [options.extend] - Additional config properties to extend.
25
31
  *
26
32
  * @returns {import('eslint').Linter.Config[]} ESLint configuration array.
27
33
  */
28
34
  export const createConfig = (options = {}) => {
29
35
  const { prettier = true, importOrder = true, jsdoc = true } = options;
30
36
 
31
- // ---- Extends Configs ----
32
- // Build the extends array based on enabled features
33
- const extendsConfigs = [
34
- 'plugin:@typescript-eslint/recommended',
35
- importOrder && 'plugin:import/recommended',
36
- jsdoc && 'plugin:jsdoc/recommended',
37
- prettier && 'plugin:prettier/recommended',
38
- ].filter(Boolean);
39
-
40
- return defineConfig([
41
- // ---- Global Ignores ----
42
- ...commonIgnores,
43
-
44
- // ---- Extends Configs ----
45
- ...compat.extends(...extendsConfigs),
46
-
47
- {
48
- // ---- TypeScript Files Configuration ----
49
- // Apply to TypeScript files
50
- files: files.withTs,
51
-
52
- // ---- Language Options ----
53
- languageOptions: {
54
- ...commonLanguageOptions,
55
- ...commonParser,
56
- // ---- Parser Options ----
57
- // Configure TypeScript parser
58
- parserOptions: { tsconfigRootDir: process.cwd() },
59
- },
60
-
61
- // ---- Settings ----
62
- settings: { ...(importOrder && { 'import/resolver': { typescript: {} } }) },
63
-
64
- // ---- Rules ----
65
- rules: commonRules({ prettier, importOrder, jsdoc }),
66
- },
67
- ]);
37
+ return buildConfig({
38
+ compat,
39
+ files: files.withTs,
40
+ builtinPlugins: ['plugin:@typescript-eslint/recommended'],
41
+ typescript: true,
42
+ options: { ...options, prettier, importOrder, jsdoc },
43
+ });
68
44
  };
69
45
 
70
46
  export default createConfig();
@@ -0,0 +1,22 @@
1
+ import { describe, it, expect } from 'vitest';
2
+
3
+ // Test suite for the ESLint TypeScript configuration module.
4
+ describe('eslint/typescript.js', () => {
5
+ // Test that the module exports the createConfig function.
6
+ it('should export createConfig function', async () => {
7
+ // Dynamically import the typescript.js module to test its exports.
8
+ const module = await import('./typescript.js');
9
+
10
+ // Verify that createConfig is a function (used to create ESLint config for TypeScript).
11
+ expect(typeof module.createConfig).toBe('function');
12
+ });
13
+
14
+ // Test that the module exports a default configuration object.
15
+ it('should export default config', async () => {
16
+ // Dynamically import the typescript.js module to test its exports.
17
+ const module = await import('./typescript.js');
18
+
19
+ // Verify that the default export is defined (should be an ESLint config object).
20
+ expect(module.default).toBeDefined();
21
+ });
22
+ });
package/src/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  /**
2
- * =====================================================================.
2
+ * =====================================================================
3
3
  * Dev Configurations Index
4
- * =====================================================================.
4
+ * =====================================================================
5
5
  * Purpose: Central index file that re-exports all configuration presets
6
6
  * for easy consumption by root-level config files.
7
7
  * Docs: https://github.com/vijay/repositories/projects/dev-config
8
- * =====================================================================.
8
+ * =====================================================================
9
9
  */
10
10
 
11
11
  /**
@@ -0,0 +1,36 @@
1
+ import { describe, it, expect } from 'vitest';
2
+
3
+ // Test suite for the main index.js exports.
4
+ describe('index.js exports', () => {
5
+ // Test that all expected functions and objects are exported from the module.
6
+ it('should export functions', async () => {
7
+ try {
8
+ // Dynamically import the module to test its exports.
9
+ const module = await import('./index.js');
10
+
11
+ // Verify ESLint-related exports are functions.
12
+ expect(typeof module.eslint).toBe('function');
13
+ expect(typeof module.createEslintConfig).toBe('function');
14
+ expect(typeof module.eslintTs).toBe('function');
15
+ expect(typeof module.createEslintTsConfig).toBe('function');
16
+ expect(typeof module.eslintReact).toBe('function');
17
+ expect(typeof module.createEslintReactConfig).toBe('function');
18
+ expect(typeof module.eslintNext).toBe('function');
19
+ expect(typeof module.createEslintNextConfig).toBe('function');
20
+
21
+ // Verify config objects are exported.
22
+ expect(typeof module.prettier).toBe('object');
23
+ expect(typeof module.commitlint).toBe('object');
24
+ expect(typeof module.nextSitemap).toBe('object');
25
+
26
+ // Verify sitemap config function is exported.
27
+ expect(typeof module.createSitemapConfig).toBe('function');
28
+
29
+ // Verify Stylelint config object is exported.
30
+ expect(typeof module.stylelint).toBe('object');
31
+ } catch (error) {
32
+ // If import fails, expect an error to be defined.
33
+ expect(error).toBeDefined();
34
+ }
35
+ });
36
+ });
@@ -0,0 +1,34 @@
1
+ import { describe, it, expect } from 'vitest';
2
+
3
+ // Test suite for the JavaScript base configuration file.
4
+ describe('jsconfig/index.json', () => {
5
+ // Test that the jsconfig file is valid JSON and exports an object.
6
+ it('should be a valid JSON file', async () => {
7
+ // Dynamically import the JSON file with JSON assertion.
8
+ const module = await import('./index.json', { assert: { type: 'json' } });
9
+
10
+ // Verify that the default export is an object (valid JSON object).
11
+ expect(typeof module.default).toBe('object');
12
+ });
13
+
14
+ // Test that the jsconfig contains compilerOptions.
15
+ it('should have compilerOptions', async () => {
16
+ // Dynamically import the JSON file with JSON assertion.
17
+ const module = await import('./index.json', { assert: { type: 'json' } });
18
+
19
+ // Verify that compilerOptions property exists on the config object.
20
+ expect(module.default.compilerOptions).toBeDefined();
21
+
22
+ // Verify that compilerOptions is an object.
23
+ expect(typeof module.default.compilerOptions).toBe('object');
24
+ });
25
+
26
+ // Test that the jsconfig has exclude patterns defined as an array.
27
+ it('should have exclude patterns', async () => {
28
+ // Dynamically import the JSON file with JSON assertion.
29
+ const module = await import('./index.json', { assert: { type: 'json' } });
30
+
31
+ // Verify that exclude property exists and is an array (list of file patterns to exclude).
32
+ expect(Array.isArray(module.default.exclude)).toBe(true);
33
+ });
34
+ });
@@ -1,11 +1,11 @@
1
1
  /**
2
- * =====================================================================.
2
+ * =====================================================================
3
3
  * Next Sitemap Configuration
4
- * =====================================================================.
4
+ * =====================================================================
5
5
  * Purpose: Next.js sitemap configuration for generating SEO-friendly
6
6
  * sitemaps with robots.txt support.
7
7
  * Docs: https://github.com/iamvishnusankar/next-sitemap
8
- * =====================================================================.
8
+ * =====================================================================
9
9
  */
10
10
 
11
11
  /**
@@ -0,0 +1,59 @@
1
+ import { describe, it, expect } from 'vitest';
2
+
3
+ // Test suite for next-sitemap module's main entry point.
4
+ describe('next-sitemap/index.js', () => {
5
+ // Test that the module exports the createSitemapConfig function.
6
+ it('should export createSitemapConfig function', async () => {
7
+ // Dynamically import the module to test its exports.
8
+ const module = await import('./index.js');
9
+
10
+ // Verify that createSitemapConfig is a function.
11
+ expect(typeof module.createSitemapConfig).toBe('function');
12
+ });
13
+
14
+ // Test that the module exports a default config object.
15
+ it('should export default config object', async () => {
16
+ // Dynamically import the module to test its exports.
17
+ const module = await import('./index.js');
18
+
19
+ // Verify that the default export is an object.
20
+ expect(typeof module.default).toBe('object');
21
+ });
22
+
23
+ // Test that createSitemapConfig returns config with provided siteUrl.
24
+ it('should return config with siteUrl', async () => {
25
+ // Dynamically import the module to test its function.
26
+ const module = await import('./index.js');
27
+
28
+ // Call createSitemapConfig with a siteUrl parameter.
29
+ const config = module.createSitemapConfig({ siteUrl: 'https://example.com' });
30
+
31
+ // Verify that the returned config contains the provided siteUrl.
32
+ expect(config.siteUrl).toBe('https://example.com');
33
+ });
34
+
35
+ // Test that createSitemapConfig returns config with default values when no params provided.
36
+ it('should return config with default values', async () => {
37
+ // Dynamically import the module to test its function.
38
+ const module = await import('./index.js');
39
+
40
+ // Call createSitemapConfig without parameters to get defaults.
41
+ const config = module.createSitemapConfig();
42
+
43
+ // Verify default siteUrl and outDir values.
44
+ expect(config.siteUrl).toBe('https://example.com');
45
+ expect(config.outDir).toBe('./public');
46
+ });
47
+
48
+ // Test that generateRobotsTxt is enabled by default in the config.
49
+ it('should have generateRobotsTxt enabled', async () => {
50
+ // Dynamically import the module to test its function.
51
+ const module = await import('./index.js');
52
+
53
+ // Call createSitemapConfig to get default config.
54
+ const config = module.createSitemapConfig();
55
+
56
+ // Verify that generateRobotsTxt is enabled by default.
57
+ expect(config.generateRobotsTxt).toBe(true);
58
+ });
59
+ });
@@ -1,12 +1,12 @@
1
1
  /**
2
- * =====================================================================.
2
+ * =====================================================================
3
3
  * Prettier Configuration
4
- * =====================================================================.
4
+ * =====================================================================
5
5
  * Purpose: Code formatting configuration for consistent style across
6
6
  * the project.
7
7
  * Docs: https://prettier.io/docs/en/configuration.html
8
8
  * Usage: npx prettier --write .
9
- * =====================================================================.
9
+ * =====================================================================
10
10
  */
11
11
 
12
12
  /** @type {import("prettier").Config} */
@@ -38,6 +38,11 @@ const config = {
38
38
  experimentalOperatorPosition: 'start',
39
39
  // Collapse object literals
40
40
  objectWrap: 'collapse',
41
+ // Ensures that whitespace in XML is preserved as-is
42
+ xmlWhitespaceSensitivity: 'strict',
43
+
44
+ // ---- Plugins ----
45
+ plugins: ['@prettier/plugin-xml'],
41
46
 
42
47
  // ---- Overrides ----
43
48
  // Different formatting rules for different file types
@@ -63,6 +68,10 @@ const config = {
63
68
  // ---- YAML ----
64
69
  // Use yaml parser with 2-space indentation
65
70
  { files: ['*.yml', '*.yaml'], options: { parser: 'yaml', tabWidth: 2 } },
71
+
72
+ // ---- XML ----
73
+ // Use 2-space indentation for XML files
74
+ { files: ['.xml', '.xsd', '.xsl', '.xslt'], options: { tabWidth: 2 } },
66
75
  ],
67
76
  };
68
77
 
@@ -0,0 +1,39 @@
1
+ import { describe, it, expect } from 'vitest';
2
+
3
+ // Test suite for the Prettier configuration.
4
+ describe('prettier/index.js', () => {
5
+ // Test that the module exports a default config object.
6
+ it('should export default config object', async () => {
7
+ // Dynamically import the rules module to test its function.
8
+ const module = await import('./index.js');
9
+
10
+ // Verify default export is an object.
11
+ expect(typeof module.default).toBe('object');
12
+ });
13
+
14
+ // Test that the config has the correct Prettier properties.
15
+ it('should have correct Prettier configuration properties', async () => {
16
+ // Dynamically import the rules module to test its function.
17
+ const module = await import('./index.js');
18
+ const config = module.default;
19
+
20
+ // Verify basic formatting options.
21
+ expect(config.printWidth).toBe(120);
22
+ expect(config.tabWidth).toBe(2);
23
+ expect(config.useTabs).toBe(false);
24
+ expect(config.semi).toBe(true);
25
+ expect(config.singleQuote).toBe(false);
26
+ expect(config.trailingComma).toBe('es5');
27
+ });
28
+
29
+ // Test that the config has overrides for different file types.
30
+ it('should have overrides for different file types', async () => {
31
+ // Dynamically import the rules module to test its function.
32
+ const module = await import('./index.js');
33
+ const config = module.default;
34
+
35
+ // Verify overrides array exists and has entries.
36
+ expect(Array.isArray(config.overrides)).toBe(true);
37
+ expect(config.overrides.length).toBeGreaterThan(0);
38
+ });
39
+ });
@@ -1,12 +1,12 @@
1
1
  /**
2
- * =====================================================================.
2
+ * =====================================================================
3
3
  * Stylelint Configuration
4
- * =====================================================================.
4
+ * =====================================================================
5
5
  * Purpose: CSS/SCSS linting configuration for consistent styling and
6
6
  * proper property ordering.
7
7
  * Docs: https://stylelint.io/user-guide/configure
8
8
  * Usage: npx stylelint .
9
- * =====================================================================.
9
+ * =====================================================================
10
10
  */
11
11
 
12
12
  /** @type {import("stylelint").Config} */