@vortiquo/eslint-config 1.2.1 → 1.2.2-beta.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/base-typescript.js +40 -34
- package/base.js +16 -0
- package/package.json +1 -1
package/base-typescript.js
CHANGED
|
@@ -1,18 +1,52 @@
|
|
|
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
|
-
|
|
13
|
-
|
|
20
|
+
|
|
21
|
+
// Apply type-checked configs ONLY to TypeScript files
|
|
22
|
+
// We need to filter out configs that don't have rules (plugin definitions)
|
|
23
|
+
// and only add files restriction to configs that have rules
|
|
24
|
+
...tseslint.configs.strictTypeChecked.map((config) => {
|
|
25
|
+
// If this config has rules, scope it to TS files only
|
|
26
|
+
if (config.rules && Object.keys(config.rules).length > 0) {
|
|
27
|
+
return { ...config, files: TS_FILES };
|
|
28
|
+
}
|
|
29
|
+
// Plugin/parser configs stay global but we add files to scope parsing
|
|
30
|
+
if (config.languageOptions?.parser) {
|
|
31
|
+
return { ...config, files: TS_FILES };
|
|
32
|
+
}
|
|
33
|
+
// Plugin registration stays global (no files restriction)
|
|
34
|
+
return config;
|
|
35
|
+
}),
|
|
36
|
+
...tseslint.configs.stylisticTypeChecked.map((config) => {
|
|
37
|
+
if (config.rules && Object.keys(config.rules).length > 0) {
|
|
38
|
+
return { ...config, files: TS_FILES };
|
|
39
|
+
}
|
|
40
|
+
if (config.languageOptions?.parser) {
|
|
41
|
+
return { ...config, files: TS_FILES };
|
|
42
|
+
}
|
|
43
|
+
return config;
|
|
44
|
+
}),
|
|
45
|
+
|
|
46
|
+
// TypeScript-specific settings and rules (only for TS files)
|
|
14
47
|
{
|
|
15
48
|
name: 'vortiquo/typescript',
|
|
49
|
+
files: TS_FILES,
|
|
16
50
|
languageOptions: {
|
|
17
51
|
parserOptions: {
|
|
18
52
|
projectService: true,
|
|
@@ -99,41 +133,13 @@ export const baseTypescript = [
|
|
|
99
133
|
],
|
|
100
134
|
},
|
|
101
135
|
},
|
|
102
|
-
|
|
136
|
+
|
|
137
|
+
// Allow relative imports in config files (only applies to TS files since
|
|
138
|
+
// no-restricted-imports is only defined in base-typescript)
|
|
103
139
|
{
|
|
104
|
-
// Spread disableTypeChecked FIRST, then override with our settings
|
|
105
|
-
...tseslint.configs.disableTypeChecked,
|
|
106
140
|
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
|
-
},
|
|
141
|
+
files: ['**/*.config.ts', '**/*.config.mts', '**/*.config.cts'],
|
|
126
142
|
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
143
|
'no-restricted-imports': 'off',
|
|
138
144
|
},
|
|
139
145
|
},
|
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/package.json
CHANGED