@vortiquo/eslint-config 1.2.1 → 1.2.2-beta.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.
@@ -1,18 +1,57 @@
1
1
  import tseslint from 'typescript-eslint';
2
2
  import { base } from './base.js';
3
3
 
4
+ /**
5
+ * TypeScript file patterns - type-aware rules only apply to these
6
+ */
7
+ const TS_FILES = ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'];
8
+
4
9
  /**
5
10
  * Base TypeScript ESLint configuration.
6
11
  * Extends base config with TypeScript-specific rules.
7
12
  *
13
+ * Type-aware rules are ONLY applied to TypeScript files (.ts, .tsx, .mts, .cts).
14
+ * JavaScript files (including config files like eslint.config.js) are not affected.
15
+ *
8
16
  * @type {import("eslint").Linter.Config[]}
9
17
  */
10
18
  export const baseTypescript = [
11
19
  ...base,
12
- ...tseslint.configs.strictTypeChecked,
13
- ...tseslint.configs.stylisticTypeChecked,
20
+
21
+ // Global TypeScript plugin registration (plugins must be defined globally)
22
+ {
23
+ name: 'vortiquo/typescript-plugins',
24
+ plugins: {
25
+ '@typescript-eslint': tseslint.plugin,
26
+ },
27
+ },
28
+
29
+ // TypeScript parser and language options (scoped to TS files)
30
+ {
31
+ name: 'vortiquo/typescript-parser',
32
+ files: TS_FILES,
33
+ languageOptions: {
34
+ parser: tseslint.parser,
35
+ parserOptions: {
36
+ projectService: true,
37
+ },
38
+ },
39
+ },
40
+
41
+ // Apply type-checked rules ONLY to TypeScript files
42
+ // Use the recommended approach from typescript-eslint docs
43
+ ...tseslint.config({
44
+ files: TS_FILES,
45
+ extends: [
46
+ tseslint.configs.strictTypeChecked,
47
+ tseslint.configs.stylisticTypeChecked,
48
+ ],
49
+ }),
50
+
51
+ // TypeScript-specific settings and rules (only for TS files)
14
52
  {
15
53
  name: 'vortiquo/typescript',
54
+ files: TS_FILES,
16
55
  languageOptions: {
17
56
  parserOptions: {
18
57
  projectService: true,
@@ -99,41 +138,13 @@ export const baseTypescript = [
99
138
  ],
100
139
  },
101
140
  },
102
- // Disable type-aware linting for config files (typically not in tsconfig)
141
+
142
+ // Allow relative imports in config files (only applies to TS files since
143
+ // no-restricted-imports is only defined in base-typescript)
103
144
  {
104
- // Spread disableTypeChecked FIRST, then override with our settings
105
- ...tseslint.configs.disableTypeChecked,
106
145
  name: 'vortiquo/typescript/config-files',
107
- files: [
108
- '**/*.config.{js,ts,mjs,cjs}',
109
- '**/.*rc.{js,ts,mjs,cjs}',
110
- 'eslint.config.*',
111
- '.lintstagedrc.*',
112
- 'tsup.config.*',
113
- 'vitest.config.*',
114
- 'jest.config.*',
115
- 'tailwind.config.*',
116
- 'postcss.config.*',
117
- 'next.config.*',
118
- 'commitlint.config.*',
119
- 'prettier.config.*',
120
- ],
121
- languageOptions: {
122
- parserOptions: {
123
- projectService: false,
124
- },
125
- },
146
+ files: ['**/*.config.ts', '**/*.config.mts', '**/*.config.cts'],
126
147
  rules: {
127
- // Spread the disableTypeChecked rules first, then add our overrides
128
- ...tseslint.configs.disableTypeChecked.rules,
129
- // Relax strictness for config files
130
- '@typescript-eslint/explicit-function-return-type': 'off',
131
- '@typescript-eslint/explicit-module-boundary-types': 'off',
132
- // Config files require default exports
133
- 'import/no-default-export': 'off',
134
- // Allow console in config files
135
- 'no-console': 'off',
136
- // Allow relative imports in config files (they often need it)
137
148
  'no-restricted-imports': 'off',
138
149
  },
139
150
  },
package/base.js CHANGED
@@ -69,6 +69,22 @@ export const base = [
69
69
  '**/public/**',
70
70
  ],
71
71
  },
72
+ // Relaxations for config files
73
+ {
74
+ name: 'vortiquo/base/config-files',
75
+ files: [
76
+ '**/*.config.{js,ts,mjs,cjs}',
77
+ '**/.*rc.{js,ts,mjs,cjs}',
78
+ 'eslint.config.*',
79
+ '.lintstagedrc.*',
80
+ ],
81
+ rules: {
82
+ // Config files require default exports
83
+ 'import/no-default-export': 'off',
84
+ // Allow console in config files
85
+ 'no-console': 'off',
86
+ },
87
+ },
72
88
  ];
73
89
 
74
90
  export default base;
package/node-library.js CHANGED
@@ -1,6 +1,11 @@
1
1
  import globals from 'globals';
2
2
  import { baseTypescript } from './base-typescript.js';
3
3
 
4
+ /**
5
+ * TypeScript file patterns - type-aware rules only apply to these
6
+ */
7
+ const TS_FILES = ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'];
8
+
4
9
  /**
5
10
  * ESLint configuration for Node.js libraries/packages.
6
11
  * Extends TypeScript config for shared backend packages.
@@ -16,14 +21,19 @@ export const nodeLibrary = [
16
21
  ...globals.node,
17
22
  },
18
23
  },
24
+ rules: {
25
+ // No console in libraries (consumers should handle logging)
26
+ 'no-console': 'error',
27
+ },
28
+ },
29
+ {
30
+ name: 'vortiquo/node-library/typescript',
31
+ files: TS_FILES,
19
32
  rules: {
20
33
  // Libraries should be strict
21
34
  '@typescript-eslint/explicit-function-return-type': 'error',
22
35
  '@typescript-eslint/explicit-module-boundary-types': 'error',
23
36
 
24
- // No console in libraries (consumers should handle logging)
25
- 'no-console': 'error',
26
-
27
37
  // Async handling
28
38
  '@typescript-eslint/no-floating-promises': 'error',
29
39
  '@typescript-eslint/require-await': 'error',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vortiquo/eslint-config",
3
- "version": "1.2.1",
3
+ "version": "1.2.2-beta.2",
4
4
  "description": "Modern ESLint v9 flat configurations with TypeScript, React, Next.js, and Node.js support",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -14,8 +14,9 @@
14
14
  "lint": "ls-lint",
15
15
  "format": "prettier --write .",
16
16
  "format:check": "prettier --check .",
17
- "test": "node scripts/validate-configs.js",
18
- "prepack": "node scripts/validate-configs.js",
17
+ "test": "node scripts/validate-configs.js && node tests/test-configs.js",
18
+ "test:configs": "node tests/test-configs.js",
19
+ "prepack": "npm run test",
19
20
  "commit": "cz",
20
21
  "prepare": "husky"
21
22
  },
package/react-library.js CHANGED
@@ -1,5 +1,10 @@
1
1
  import { react } from './react.js';
2
2
 
3
+ /**
4
+ * TypeScript file patterns - type-aware rules only apply to these
5
+ */
6
+ const TS_FILES = ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'];
7
+
3
8
  /**
4
9
  * ESLint configuration for React component libraries.
5
10
  * Extends React config with library-specific rules.
@@ -11,9 +16,6 @@ export const reactLibrary = [
11
16
  {
12
17
  name: 'vortiquo/react-library',
13
18
  rules: {
14
- // Libraries should be stricter about exports
15
- '@typescript-eslint/explicit-module-boundary-types': 'error',
16
-
17
19
  // No console in libraries
18
20
  'no-console': 'error',
19
21
 
@@ -21,6 +23,14 @@ export const reactLibrary = [
21
23
  'import/no-default-export': 'error',
22
24
  },
23
25
  },
26
+ {
27
+ name: 'vortiquo/react-library/typescript',
28
+ files: TS_FILES,
29
+ rules: {
30
+ // Libraries should be stricter about exports
31
+ '@typescript-eslint/explicit-module-boundary-types': 'error',
32
+ },
33
+ },
24
34
  {
25
35
  name: 'vortiquo/react-library/config-files',
26
36
  files: ['**/*.config.{js,ts,mjs}', '**/tsup.config.ts'],
package/server.js CHANGED
@@ -1,6 +1,11 @@
1
1
  import globals from 'globals';
2
2
  import { baseTypescript } from './base-typescript.js';
3
3
 
4
+ /**
5
+ * TypeScript file patterns - type-aware rules only apply to these
6
+ */
7
+ const TS_FILES = ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'];
8
+
4
9
  /**
5
10
  * ESLint configuration for backend APIs (Fastify, Express, Hono).
6
11
  * Extends TypeScript config with Node.js-specific rules.
@@ -22,7 +27,12 @@ export const server = [
22
27
 
23
28
  // Backend-specific rules
24
29
  'no-process-exit': 'off',
25
-
30
+ },
31
+ },
32
+ {
33
+ name: 'vortiquo/server/typescript',
34
+ files: TS_FILES,
35
+ rules: {
26
36
  // Stricter for backend code
27
37
  '@typescript-eslint/explicit-function-return-type': 'error',
28
38
  '@typescript-eslint/explicit-module-boundary-types': 'error',