@gv-tech/eslint-config 0.1.6 → 0.1.7

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.7](https://github.com/Garcia-Ventures/eslint-config/compare/eslint-config-v0.1.6...eslint-config-v0.1.7) (2026-02-08)
4
+
5
+
6
+ ### Features
7
+
8
+ * Add blackbox tests for various ESLint configurations and integrate them into CI/CD workflows. ([005ebc7](https://github.com/Garcia-Ventures/eslint-config/commit/005ebc74fc40a11c4fb6eba1b3e7326dbde29d2a))
9
+ * Dynamically import the Next.js ESLint plugin to make it optional and consolidate Next.js configurations into the main package exports. ([01cb660](https://github.com/Garcia-Ventures/eslint-config/commit/01cb660e2307e56b373a8620972991f335e8a5fd))
10
+ * Introduce unit tests for ESLint configurations and update package scripts and CI workflow to include them. ([da749c0](https://github.com/Garcia-Ventures/eslint-config/commit/da749c02489c70ce472e8c2e926e9941c4a74326))
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * Enhance ESLint configurations to robustly handle array-based recommended configs and remove a JSDoc example. ([4d0de8e](https://github.com/Garcia-Ventures/eslint-config/commit/4d0de8e66cd01698e999eb3bcf9f01714fefa17e))
16
+
3
17
  ## [0.1.6](https://github.com/Garcia-Ventures/eslint-config/compare/eslint-config-v0.1.5...eslint-config-v0.1.6) (2026-02-08)
4
18
 
5
19
 
package/README.md CHANGED
@@ -69,8 +69,7 @@ export default [...typescript, ...prettier];
69
69
  ### Next.js Project
70
70
 
71
71
  ```js
72
- import { next } from '@gv-tech/eslint-config/next';
73
- import { prettier } from '@gv-tech/eslint-config/prettier';
72
+ import { next, prettier } from '@gv-tech/eslint-config';
74
73
 
75
74
  export default [...next, ...prettier];
76
75
  ```
@@ -85,7 +84,7 @@ import { recommended } from '@gv-tech/eslint-config';
85
84
  export default [...recommended];
86
85
 
87
86
  // Next.js + TypeScript + Prettier
88
- import { nextjs } from '@gv-tech/eslint-config/next';
87
+ import { nextjs } from '@gv-tech/eslint-config';
89
88
  export default [...nextjs];
90
89
  ```
91
90
 
@@ -115,14 +114,14 @@ export default [
115
114
 
116
115
  ## Available Configurations
117
116
 
118
- | Export | Description |
119
- | ------------- | ------------------------------------------- |
120
- | `base` | Core JavaScript rules |
121
- | `typescript` | TypeScript support (includes base) |
122
- | `next` | Next.js rules (requires `next` import) |
123
- | `prettier` | Prettier formatting integration |
124
- | `recommended` | TypeScript + Prettier |
125
- | `nextjs` | Next.js + Prettier (requires `next` import) |
117
+ | Export | Description |
118
+ | ------------- | ----------------------------------- |
119
+ | `base` | Core JavaScript rules |
120
+ | `typescript` | TypeScript support (includes base) |
121
+ | `next` | Next.js rules (includes TypeScript) |
122
+ | `prettier` | Prettier formatting integration |
123
+ | `recommended` | TypeScript + Prettier |
124
+ | `nextjs` | Next.js + Prettier |
126
125
 
127
126
  ## Exported Utilities
128
127
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gv-tech/eslint-config",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Shareable ESLint configuration for Garcia Ventures projects - ESLint v9 flat config",
5
5
  "keywords": [
6
6
  "eslint",
@@ -37,9 +37,12 @@
37
37
  "format": "prettier --write .",
38
38
  "format:ci": "prettier --check .",
39
39
  "lint": "eslint . --cache",
40
- "lint:fix": "eslint . --cache --fix",
40
+ "lint:fix": "yarn lint --fix",
41
41
  "lint:report": "eslint . --cache -o ./eslintReport.html -f html",
42
- "prepare": "husky"
42
+ "prepare": "husky",
43
+ "test": "yarn test:unit && node test/verify.mjs",
44
+ "test:unit": "node test/unit.test.mjs",
45
+ "validate": "yarn lint && yarn test && publint"
43
46
  },
44
47
  "lint-staged": {
45
48
  "*.(js|ts|mjs|cjs)?(x)": [
package/src/base.mjs CHANGED
@@ -13,27 +13,22 @@ export const jsFiles = ['**/*.js', '**/*.jsx', '**/*.mjs', '**/*.cjs'];
13
13
  /** Common ignore patterns */
14
14
  export const commonIgnores = ['**/node_modules/**', '**/dist/**', '**/build/**', '**/coverage/**', '**/.git/**'];
15
15
 
16
- /**
17
- * Base ESLint configuration for JavaScript projects.
18
- *
19
- * @example
20
- *
21
- * ```js
22
- * // eslint.config.mjs
23
- * import { base } from '@gv-tech/eslint-config';
24
- *
25
- * export default [...base];
26
- * ```
27
- */
16
+ // Helper to ensure we have an array of configs
17
+ const ensureArray = (config) => (Array.isArray(config) ? config : [config]);
18
+
19
+ /** Base ESLint configuration for JavaScript projects. */
28
20
  export const base = [
29
21
  // Global ignores
30
22
  {
31
23
  ignores: commonIgnores,
32
24
  },
33
- // Base configuration for all JS files
25
+ // Base configuration for all JS files (properly handling array-based recommended configs)
26
+ ...ensureArray(js.configs.recommended).map((config) => ({
27
+ ...config,
28
+ files: jsFiles,
29
+ })),
34
30
  {
35
31
  files: jsFiles,
36
- ...js.configs.recommended,
37
32
  languageOptions: {
38
33
  ecmaVersion: 'latest',
39
34
  sourceType: 'module',
package/src/index.mjs CHANGED
@@ -2,36 +2,16 @@
2
2
  * @gv-tech/eslint-config
3
3
  *
4
4
  * Shareable ESLint configuration for Garcia Ventures projects. Supports ESLint v9+ flat config format.
5
- *
6
- * @example Basic JavaScript
7
- *
8
- * ```js
9
- * import { base } from '@gv-tech/eslint-config';
10
- * export default [...base];
11
- * ```
12
- *
13
- * @example TypeScript
14
- *
15
- * ```js
16
- * import { typescript, prettier } from '@gv-tech/eslint-config';
17
- * export default [...typescript, ...prettier];
18
- * ```
19
- *
20
- * @example Next.js
21
- *
22
- * ```js
23
- * import { next, prettier } from '@gv-tech/eslint-config';
24
- * export default [...next, ...prettier];
25
- * ```
26
5
  */
27
6
 
28
7
  // Import for creating combined presets
29
8
  import { base, commonIgnores, jsFiles } from './base.mjs';
9
+ import { next, nextIgnores, nextjs } from './next.mjs';
30
10
  import { prettier } from './prettier.mjs';
31
11
  import { allJsTsFiles, tsFiles, typescript } from './typescript.mjs';
32
12
 
33
13
  // Re-export individual configurations
34
- export { allJsTsFiles, base, commonIgnores, jsFiles, prettier, tsFiles, typescript };
14
+ export { allJsTsFiles, base, commonIgnores, jsFiles, next, nextIgnores, nextjs, prettier, tsFiles, typescript };
35
15
 
36
16
  /** Recommended configuration for TypeScript projects with Prettier. Combines TypeScript and Prettier configurations. */
37
17
  export const recommended = [...typescript, ...prettier];
package/src/next.mjs CHANGED
@@ -4,46 +4,67 @@
4
4
  * Next.js 15+ ESLint configuration with Core Web Vitals. Uses ESLint v9 flat config format.
5
5
  */
6
6
 
7
- import nextPlugin from '@next/eslint-plugin-next';
8
7
  import { commonIgnores } from './base.mjs';
9
8
  import { prettier } from './prettier.mjs';
10
9
  import { allJsTsFiles, typescript } from './typescript.mjs';
11
10
 
11
+ // Try to load the Next.js plugin dynamically to avoid crashing if it's not installed
12
+ let nextPlugin;
13
+ try {
14
+ // Allow forcing missing state for tests
15
+ if (process.env.ESLINT_CONFIG_FORCE_MISSING_NEXT === 'true') {
16
+ throw new Error('Forced missing state for testing');
17
+ }
18
+ const mod = await import('@next/eslint-plugin-next');
19
+ nextPlugin = mod.default;
20
+ } catch {
21
+ if (process.env.ESLINT_CONFIG_FORCE_MISSING_NEXT !== 'true') {
22
+ console.warn("Next.js plugin not found. It's optional.");
23
+ }
24
+ }
25
+
12
26
  /** Next.js specific ignore patterns */
13
27
  export const nextIgnores = [...commonIgnores, '.next/**', 'out/**', 'next-env.d.ts'];
14
28
 
15
- /**
16
- * Next.js ESLint configuration. Extends TypeScript configuration and adds Next.js-specific rules.
17
- *
18
- * @example
19
- *
20
- * ```js
21
- * // eslint.config.mjs
22
- * import { next } from '@gv-tech/eslint-config/next';
23
- *
24
- * export default [...next];
25
- * ```
26
- */
27
- export const next = [
28
- // Global ignores including Next.js specific
29
- {
30
- ignores: nextIgnores,
31
- },
32
- // Extend TypeScript config
33
- ...typescript.filter((config) => !config.ignores),
34
- // Next.js plugin configuration
35
- {
36
- files: allJsTsFiles,
37
- plugins: {
38
- '@next/next': nextPlugin,
39
- },
40
- rules: {
41
- // Core Web Vitals rules
42
- ...nextPlugin.configs.recommended.rules,
43
- ...nextPlugin.configs['core-web-vitals'].rules,
44
- },
45
- },
46
- ];
29
+ /** Next.js ESLint configuration. Extends TypeScript configuration and adds Next.js-specific rules. */
30
+ export const next = nextPlugin
31
+ ? [
32
+ // Global ignores including Next.js specific
33
+ {
34
+ ignores: nextIgnores,
35
+ },
36
+ // Extend TypeScript config
37
+ ...typescript.filter((config) => !config.ignores),
38
+ // Next.js plugin configuration
39
+ {
40
+ files: allJsTsFiles,
41
+ plugins: {
42
+ '@next/next': nextPlugin,
43
+ },
44
+ rules: {
45
+ // Core Web Vitals rules
46
+ ...nextPlugin.configs.recommended.rules,
47
+ ...nextPlugin.configs['core-web-vitals'].rules,
48
+ },
49
+ },
50
+ ]
51
+ : [
52
+ {
53
+ // If the plugin is missing, we provide a placeholder that informs the user
54
+ // but doesn't crash the entire linting process unless this specific config is used.
55
+ files: allJsTsFiles,
56
+ rules: {
57
+ 'no-restricted-syntax': [
58
+ 'error',
59
+ {
60
+ selector: 'Program',
61
+ message:
62
+ "Next.js ESLint configuration was requested but '@next/eslint-plugin-next' is not installed. Please install it to enable Next.js rules.",
63
+ },
64
+ ],
65
+ },
66
+ },
67
+ ];
47
68
 
48
69
  /**
49
70
  * Recommended configuration for Next.js projects with Prettier. Combines Next.js (which includes TypeScript) and
package/src/prettier.mjs CHANGED
@@ -24,7 +24,8 @@ import { allJsTsFiles } from './typescript.mjs';
24
24
  */
25
25
  export const prettier = [
26
26
  // Disable ESLint rules that conflict with Prettier
27
- prettierConfig,
27
+ // Handle case where prettierConfig might be an array in future versions
28
+ ...(Array.isArray(prettierConfig) ? prettierConfig : [prettierConfig]),
28
29
  // Run Prettier as an ESLint rule with @eng618/prettier-config
29
30
  {
30
31
  files: allJsTsFiles,