ts-reconf 0.4.5 → 0.4.6
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/dist/__tests__/rules/noEmitConflict.test.d.ts +1 -0
- package/dist/__tests__/rules/noEmitConflict.test.js +144 -0
- package/dist/__tests__/rules/noEmitConflict.test.js.map +1 -0
- package/dist/__tests__/rules/pathsWithoutBaseUrl.test.d.ts +1 -0
- package/dist/__tests__/rules/pathsWithoutBaseUrl.test.js +140 -0
- package/dist/__tests__/rules/pathsWithoutBaseUrl.test.js.map +1 -0
- package/dist/analyzer.js +4 -1
- package/dist/analyzer.js.map +1 -1
- package/dist/rules/index.d.ts +3 -0
- package/dist/rules/index.js +3 -0
- package/dist/rules/index.js.map +1 -1
- package/dist/rules/noEmitConflict.d.ts +9 -0
- package/dist/rules/noEmitConflict.js +58 -0
- package/dist/rules/noEmitConflict.js.map +1 -0
- package/dist/rules/outDirRootDirConflict.d.ts +8 -0
- package/dist/rules/outDirRootDirConflict.js +64 -0
- package/dist/rules/outDirRootDirConflict.js.map +1 -0
- package/dist/rules/pathsWithoutBaseUrl.d.ts +8 -0
- package/dist/rules/pathsWithoutBaseUrl.js +37 -0
- package/dist/rules/pathsWithoutBaseUrl.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { noEmitConflictRule } from '../../rules/noEmitConflict.js';
|
|
3
|
+
describe('noEmitConflict', () => {
|
|
4
|
+
it('should return no findings when noEmit is false', () => {
|
|
5
|
+
const config = {
|
|
6
|
+
compilerOptions: {
|
|
7
|
+
noEmit: false,
|
|
8
|
+
outDir: 'dist',
|
|
9
|
+
declaration: true,
|
|
10
|
+
},
|
|
11
|
+
rawConfig: {},
|
|
12
|
+
};
|
|
13
|
+
const findings = noEmitConflictRule.analyze(config);
|
|
14
|
+
expect(findings).toHaveLength(0);
|
|
15
|
+
});
|
|
16
|
+
it('should return no findings when noEmit is not set', () => {
|
|
17
|
+
const config = {
|
|
18
|
+
compilerOptions: {
|
|
19
|
+
outDir: 'dist',
|
|
20
|
+
},
|
|
21
|
+
rawConfig: {},
|
|
22
|
+
};
|
|
23
|
+
const findings = noEmitConflictRule.analyze(config);
|
|
24
|
+
expect(findings).toHaveLength(0);
|
|
25
|
+
});
|
|
26
|
+
it('should detect conflict when noEmit is true and outDir is set', () => {
|
|
27
|
+
const config = {
|
|
28
|
+
compilerOptions: {
|
|
29
|
+
noEmit: true,
|
|
30
|
+
outDir: 'dist',
|
|
31
|
+
},
|
|
32
|
+
rawConfig: {},
|
|
33
|
+
};
|
|
34
|
+
const findings = noEmitConflictRule.analyze(config);
|
|
35
|
+
expect(findings).toHaveLength(1);
|
|
36
|
+
expect(findings[0]?.severity).toBe('error');
|
|
37
|
+
expect(findings[0]?.message).toContain('noEmit');
|
|
38
|
+
expect(findings[0]?.message).toContain('outDir');
|
|
39
|
+
expect(findings[0]?.message).toContain('contradictory');
|
|
40
|
+
expect(findings[0]?.category).toBe('conflict');
|
|
41
|
+
});
|
|
42
|
+
it('should detect conflict when noEmit is true and outFile is set', () => {
|
|
43
|
+
const config = {
|
|
44
|
+
compilerOptions: {
|
|
45
|
+
noEmit: true,
|
|
46
|
+
outFile: 'bundle.js',
|
|
47
|
+
},
|
|
48
|
+
rawConfig: {},
|
|
49
|
+
};
|
|
50
|
+
const findings = noEmitConflictRule.analyze(config);
|
|
51
|
+
expect(findings).toHaveLength(1);
|
|
52
|
+
expect(findings[0]?.severity).toBe('error');
|
|
53
|
+
expect(findings[0]?.message).toContain('noEmit');
|
|
54
|
+
expect(findings[0]?.message).toContain('outFile');
|
|
55
|
+
});
|
|
56
|
+
it('should detect conflict when noEmit is true and declaration is true', () => {
|
|
57
|
+
const config = {
|
|
58
|
+
compilerOptions: {
|
|
59
|
+
noEmit: true,
|
|
60
|
+
declaration: true,
|
|
61
|
+
},
|
|
62
|
+
rawConfig: {},
|
|
63
|
+
};
|
|
64
|
+
const findings = noEmitConflictRule.analyze(config);
|
|
65
|
+
expect(findings).toHaveLength(1);
|
|
66
|
+
expect(findings[0]?.severity).toBe('error');
|
|
67
|
+
expect(findings[0]?.message).toContain('noEmit');
|
|
68
|
+
expect(findings[0]?.message).toContain('declaration');
|
|
69
|
+
});
|
|
70
|
+
it('should detect conflict when noEmit is true and declarationDir is set', () => {
|
|
71
|
+
const config = {
|
|
72
|
+
compilerOptions: {
|
|
73
|
+
noEmit: true,
|
|
74
|
+
declarationDir: 'types',
|
|
75
|
+
},
|
|
76
|
+
rawConfig: {},
|
|
77
|
+
};
|
|
78
|
+
const findings = noEmitConflictRule.analyze(config);
|
|
79
|
+
expect(findings).toHaveLength(1);
|
|
80
|
+
expect(findings[0]?.severity).toBe('warn');
|
|
81
|
+
expect(findings[0]?.message).toContain('noEmit');
|
|
82
|
+
expect(findings[0]?.message).toContain('declarationDir');
|
|
83
|
+
});
|
|
84
|
+
it('should detect multiple conflicts when noEmit is true with multiple conflicting options', () => {
|
|
85
|
+
const config = {
|
|
86
|
+
compilerOptions: {
|
|
87
|
+
noEmit: true,
|
|
88
|
+
outDir: 'dist',
|
|
89
|
+
declaration: true,
|
|
90
|
+
declarationDir: 'types',
|
|
91
|
+
},
|
|
92
|
+
rawConfig: {},
|
|
93
|
+
};
|
|
94
|
+
const findings = noEmitConflictRule.analyze(config);
|
|
95
|
+
expect(findings.length).toBeGreaterThan(1);
|
|
96
|
+
expect(findings.some(f => f.message.includes('outDir'))).toBe(true);
|
|
97
|
+
expect(findings.some(f => f.message.includes('declaration'))).toBe(true);
|
|
98
|
+
expect(findings.some(f => f.message.includes('declarationDir'))).toBe(true);
|
|
99
|
+
});
|
|
100
|
+
it('should have correct rule id', () => {
|
|
101
|
+
const config = {
|
|
102
|
+
compilerOptions: {
|
|
103
|
+
noEmit: true,
|
|
104
|
+
outDir: 'dist',
|
|
105
|
+
},
|
|
106
|
+
rawConfig: {},
|
|
107
|
+
};
|
|
108
|
+
const findings = noEmitConflictRule.analyze(config);
|
|
109
|
+
expect(findings[0]?.ruleId).toBe('ts.noemit.conflict');
|
|
110
|
+
});
|
|
111
|
+
it('should include specific file paths in error messages', () => {
|
|
112
|
+
const config = {
|
|
113
|
+
compilerOptions: {
|
|
114
|
+
noEmit: true,
|
|
115
|
+
outDir: 'custom/dist',
|
|
116
|
+
},
|
|
117
|
+
rawConfig: {},
|
|
118
|
+
};
|
|
119
|
+
const findings = noEmitConflictRule.analyze(config);
|
|
120
|
+
expect(findings[0]?.message).toContain('custom/dist');
|
|
121
|
+
});
|
|
122
|
+
it('should handle empty compilerOptions gracefully', () => {
|
|
123
|
+
const config = {
|
|
124
|
+
compilerOptions: {},
|
|
125
|
+
rawConfig: {},
|
|
126
|
+
};
|
|
127
|
+
const findings = noEmitConflictRule.analyze(config);
|
|
128
|
+
expect(findings).toHaveLength(0);
|
|
129
|
+
});
|
|
130
|
+
it('should detect conflict when both outDir and outFile are set with noEmit', () => {
|
|
131
|
+
const config = {
|
|
132
|
+
compilerOptions: {
|
|
133
|
+
noEmit: true,
|
|
134
|
+
outDir: 'dist',
|
|
135
|
+
outFile: 'bundle.js',
|
|
136
|
+
},
|
|
137
|
+
rawConfig: {},
|
|
138
|
+
};
|
|
139
|
+
const findings = noEmitConflictRule.analyze(config);
|
|
140
|
+
// Should have at least 2 findings (one for outDir, one for outFile)
|
|
141
|
+
expect(findings.length).toBeGreaterThanOrEqual(2);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
//# sourceMappingURL=noEmitConflict.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noEmitConflict.test.js","sourceRoot":"","sources":["../../../src/__tests__/rules/noEmitConflict.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,kBAAkB,E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S,EAAE,EAAE;SACd,CAAC;QAEF,MAAM,QAAQ,GAAG,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAEpD,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACxD,MAAM,MAAM,GAAoB;YAC9B,eAAe,EAAE,EAAE;YACnB,SAAS,EAAE,EAAE;SACd,CAAC;QAEF,MAAM,QAAQ,GAAG,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAEpD,MAAM,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yEAAyE,EAAE,GAAG,EAAE;QACjF,MAAM,MAAM,GAAoB;YAC9B,eAAe,EAAE;gBACf,MAAM,EAAE,IAAI;gBACZ,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,WAAW;aACrB;YACD,SAAS,EAAE,EAAE;SACd,CAAC;QAEF,MAAM,QAAQ,GAAG,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAEpD,oEAAoE;QACpE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { pathsWithoutBaseUrlRule } from '../../rules/pathsWithoutBaseUrl.js';
|
|
3
|
+
describe('pathsWithoutBaseUrl', () => {
|
|
4
|
+
it('should return no findings when neither paths nor baseUrl is set', () => {
|
|
5
|
+
const config = {
|
|
6
|
+
compilerOptions: {},
|
|
7
|
+
rawConfig: {},
|
|
8
|
+
};
|
|
9
|
+
const findings = pathsWithoutBaseUrlRule.analyze(config);
|
|
10
|
+
expect(findings).toHaveLength(0);
|
|
11
|
+
});
|
|
12
|
+
it('should return no findings when both paths and baseUrl are set', () => {
|
|
13
|
+
const config = {
|
|
14
|
+
compilerOptions: {
|
|
15
|
+
baseUrl: '.',
|
|
16
|
+
paths: {
|
|
17
|
+
'@/*': ['src/*'],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
rawConfig: {},
|
|
21
|
+
};
|
|
22
|
+
const findings = pathsWithoutBaseUrlRule.analyze(config);
|
|
23
|
+
expect(findings).toHaveLength(0);
|
|
24
|
+
});
|
|
25
|
+
it('should detect error when paths is set but baseUrl is not', () => {
|
|
26
|
+
const config = {
|
|
27
|
+
compilerOptions: {
|
|
28
|
+
paths: {
|
|
29
|
+
'@/*': ['src/*'],
|
|
30
|
+
'@components/*': ['src/components/*'],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
rawConfig: {},
|
|
34
|
+
};
|
|
35
|
+
const findings = pathsWithoutBaseUrlRule.analyze(config);
|
|
36
|
+
expect(findings).toHaveLength(1);
|
|
37
|
+
expect(findings[0]?.severity).toBe('error');
|
|
38
|
+
expect(findings[0]?.category).toBe('conflict');
|
|
39
|
+
});
|
|
40
|
+
it('should detect suggestion when baseUrl is set but paths is not', () => {
|
|
41
|
+
const config = {
|
|
42
|
+
compilerOptions: {
|
|
43
|
+
baseUrl: '.',
|
|
44
|
+
},
|
|
45
|
+
rawConfig: {},
|
|
46
|
+
};
|
|
47
|
+
const findings = pathsWithoutBaseUrlRule.analyze(config);
|
|
48
|
+
expect(findings).toHaveLength(1);
|
|
49
|
+
expect(findings[0]?.severity).toBe('info');
|
|
50
|
+
expect(findings[0]?.message).toContain('baseUrl is set to "."');
|
|
51
|
+
expect(findings[0]?.message).toContain('no paths are configured');
|
|
52
|
+
expect(findings[0]?.category).toBe('suggestion');
|
|
53
|
+
});
|
|
54
|
+
it('should detect suggestion when baseUrl is set but paths is empty', () => {
|
|
55
|
+
const config = {
|
|
56
|
+
compilerOptions: {
|
|
57
|
+
baseUrl: 'src',
|
|
58
|
+
paths: {},
|
|
59
|
+
},
|
|
60
|
+
rawConfig: {},
|
|
61
|
+
};
|
|
62
|
+
const findings = pathsWithoutBaseUrlRule.analyze(config);
|
|
63
|
+
expect(findings).toHaveLength(1);
|
|
64
|
+
expect(findings[0]?.severity).toBe('info');
|
|
65
|
+
expect(findings[0]?.message).toContain('baseUrl is set to "src"');
|
|
66
|
+
});
|
|
67
|
+
it('should have correct rule id', () => {
|
|
68
|
+
const config = {
|
|
69
|
+
compilerOptions: {
|
|
70
|
+
paths: {
|
|
71
|
+
'@/*': ['src/*'],
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
rawConfig: {},
|
|
75
|
+
};
|
|
76
|
+
const findings = pathsWithoutBaseUrlRule.analyze(config);
|
|
77
|
+
expect(findings[0]?.ruleId).toBe('ts.paths-baseurl.conflict');
|
|
78
|
+
});
|
|
79
|
+
it('should handle undefined compilerOptions gracefully', () => {
|
|
80
|
+
const config = {
|
|
81
|
+
compilerOptions: undefined,
|
|
82
|
+
rawConfig: {},
|
|
83
|
+
};
|
|
84
|
+
const findings = pathsWithoutBaseUrlRule.analyze(config);
|
|
85
|
+
expect(findings).toHaveLength(0);
|
|
86
|
+
});
|
|
87
|
+
it('should list multiple path aliases in error message', () => {
|
|
88
|
+
const config = {
|
|
89
|
+
compilerOptions: {
|
|
90
|
+
paths: {
|
|
91
|
+
'@/*': ['src/*'],
|
|
92
|
+
'@components/*': ['src/components/*'],
|
|
93
|
+
'@utils/*': ['src/utils/*'],
|
|
94
|
+
'@types/*': ['src/types/*'],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
rawConfig: {},
|
|
98
|
+
};
|
|
99
|
+
const findings = pathsWithoutBaseUrlRule.analyze(config);
|
|
100
|
+
expect(findings).toHaveLength(1);
|
|
101
|
+
});
|
|
102
|
+
it('should suggest adding baseUrl in error message', () => {
|
|
103
|
+
const config = {
|
|
104
|
+
compilerOptions: {
|
|
105
|
+
paths: {
|
|
106
|
+
'@/*': ['src/*'],
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
rawConfig: {},
|
|
110
|
+
};
|
|
111
|
+
const findings = pathsWithoutBaseUrlRule.analyze(config);
|
|
112
|
+
expect(findings[0]?.message).toContain('"baseUrl": "."');
|
|
113
|
+
});
|
|
114
|
+
it('should only suggest removing baseUrl if paths is truly empty', () => {
|
|
115
|
+
const config = {
|
|
116
|
+
compilerOptions: {
|
|
117
|
+
baseUrl: '.',
|
|
118
|
+
paths: {},
|
|
119
|
+
},
|
|
120
|
+
rawConfig: {},
|
|
121
|
+
};
|
|
122
|
+
const findings = pathsWithoutBaseUrlRule.analyze(config);
|
|
123
|
+
expect(findings).toHaveLength(1);
|
|
124
|
+
expect(findings[0]?.message).toContain('remove baseUrl to simplify');
|
|
125
|
+
});
|
|
126
|
+
it('should return error not suggestion when paths is set without baseUrl', () => {
|
|
127
|
+
const config = {
|
|
128
|
+
compilerOptions: {
|
|
129
|
+
baseUrl: '.',
|
|
130
|
+
paths: {
|
|
131
|
+
'@/*': ['src/*'],
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
rawConfig: {},
|
|
135
|
+
};
|
|
136
|
+
const findings = pathsWithoutBaseUrlRule.analyze(config);
|
|
137
|
+
expect(findings).toHaveLength(0);
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
//# sourceMappingURL=pathsWithoutBaseUrl.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pathsWithoutBaseUrl.test.js","sourceRoot":"","sources":["../../../src/__tests__/rules/pathsWithoutBaseUrl.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,o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CAAC,CAAC"}
|
package/dist/analyzer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { legacyOptionRule, strictRedundantRule, skipLibCheckRule, defaultRedundantRule, targetLibConflictRule, moduleKindCheckRule, allowJsCheckRule, noEmitOutDirCheckRule, noIncludeOrFilesCheckRule, moduleResolutionMismatchRule, declarationNoEmitCheckRule, verbatimModuleIsolatedModulesRule, verbatimModuleSyntaxCheckRule, allowSyntheticDefaultImportsRule, noUncheckedIndexedAccessRule, forceConsistentCasingInFileNamesRule, moduleResolutionOutdatedRule, emitDeclarationOnlyRule, legacyJsxTransformCheckRule, declarationMapCheckRule, } from "./rules/index.js";
|
|
1
|
+
import { legacyOptionRule, strictRedundantRule, skipLibCheckRule, defaultRedundantRule, targetLibConflictRule, moduleKindCheckRule, allowJsCheckRule, noEmitOutDirCheckRule, noIncludeOrFilesCheckRule, moduleResolutionMismatchRule, declarationNoEmitCheckRule, verbatimModuleIsolatedModulesRule, verbatimModuleSyntaxCheckRule, allowSyntheticDefaultImportsRule, noUncheckedIndexedAccessRule, forceConsistentCasingInFileNamesRule, moduleResolutionOutdatedRule, emitDeclarationOnlyRule, legacyJsxTransformCheckRule, declarationMapCheckRule, pathsWithoutBaseUrlRule, outDirRootDirConflictRule, noEmitConflictRule, } from "./rules/index.js";
|
|
2
2
|
const rules = [
|
|
3
3
|
legacyOptionRule,
|
|
4
4
|
strictRedundantRule,
|
|
@@ -20,6 +20,9 @@ const rules = [
|
|
|
20
20
|
emitDeclarationOnlyRule,
|
|
21
21
|
legacyJsxTransformCheckRule,
|
|
22
22
|
declarationMapCheckRule,
|
|
23
|
+
pathsWithoutBaseUrlRule,
|
|
24
|
+
outDirRootDirConflictRule,
|
|
25
|
+
noEmitConflictRule,
|
|
23
26
|
];
|
|
24
27
|
export function analyze(config) {
|
|
25
28
|
return rules.flatMap(rule => rule.analyze(config));
|
package/dist/analyzer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzer.js","sourceRoot":"","sources":["../src/analyzer.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,yBAAyB,EACzB,4BAA4B,EAC5B,0BAA0B,EAC1B,iCAAiC,EACjC,6BAA6B,EAC7B,gCAAgC,EAChC,4BAA4B,EAC5B,oCAAoC,EACpC,4BAA4B,EAC5B,uBAAuB,EACvB,2BAA2B,EAC3B,uBAAuB,
|
|
1
|
+
{"version":3,"file":"analyzer.js","sourceRoot":"","sources":["../src/analyzer.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,yBAAyB,EACzB,4BAA4B,EAC5B,0BAA0B,EAC1B,iCAAiC,EACjC,6BAA6B,EAC7B,gCAAgC,EAChC,4BAA4B,EAC5B,oCAAoC,EACpC,4BAA4B,EAC5B,uBAAuB,EACvB,2BAA2B,EAC3B,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,EACzB,kBAAkB,GACrB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,KAAK,GAAW;IAClB,gBAAgB;IAChB,mBAAmB;IACnB,gBAAgB;IAChB,oBAAoB;IACpB,qBAAqB;IACrB,mBAAmB;IACnB,gBAAgB;IAChB,qBAAqB;IACrB,yBAAyB;IACzB,4BAA4B;IAC5B,0BAA0B;IAC1B,iCAAiC;IACjC,6BAA6B;IAC7B,gCAAgC;IAChC,4BAA4B;IAC5B,oCAAoC;IACpC,4BAA4B;IAC5B,uBAAuB;IACvB,2BAA2B;IAC3B,uBAAuB;IACvB,uBAAuB;IACvB,yBAAyB;IACzB,kBAAkB;CACrB,CAAC;AAEF,MAAM,UAAU,OAAO,CAAC,MAAuB;IAC3C,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AACvD,CAAC"}
|
package/dist/rules/index.d.ts
CHANGED
|
@@ -18,3 +18,6 @@ export { moduleResolutionOutdatedRule } from "./moduleResolutionOutdated.js";
|
|
|
18
18
|
export { emitDeclarationOnlyRule } from "./emitDeclarationOnly.js";
|
|
19
19
|
export { legacyJsxTransformCheckRule } from "./legacyJsxTransformCheck.js";
|
|
20
20
|
export { declarationMapCheckRule } from "./declarationMapCheck.js";
|
|
21
|
+
export { pathsWithoutBaseUrlRule } from "./pathsWithoutBaseUrl.js";
|
|
22
|
+
export { noEmitConflictRule } from "./noEmitConflict.js";
|
|
23
|
+
export { outDirRootDirConflictRule } from "./outDirRootDirConflict.js";
|
package/dist/rules/index.js
CHANGED
|
@@ -18,4 +18,7 @@ export { moduleResolutionOutdatedRule } from "./moduleResolutionOutdated.js";
|
|
|
18
18
|
export { emitDeclarationOnlyRule } from "./emitDeclarationOnly.js";
|
|
19
19
|
export { legacyJsxTransformCheckRule } from "./legacyJsxTransformCheck.js";
|
|
20
20
|
export { declarationMapCheckRule } from "./declarationMapCheck.js";
|
|
21
|
+
export { pathsWithoutBaseUrlRule } from "./pathsWithoutBaseUrl.js";
|
|
22
|
+
export { noEmitConflictRule } from "./noEmitConflict.js";
|
|
23
|
+
export { outDirRootDirConflictRule } from "./outDirRootDirConflict.js";
|
|
21
24
|
//# sourceMappingURL=index.js.map
|
package/dist/rules/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5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AwB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,iCAAiC,EAAE,MAAM,oCAAoC,CAAC;AACvF,OAAO,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AACrF,OAAO,EAAE,gCAAgC,EAAE,MAAM,wCAAwC,CAAC;AAC1F,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,EAAE,oCAAoC,EAAE,MAAM,4BAA4B,CAAC;AAClF,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Rule } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Checks for contradictory noEmit settings:
|
|
4
|
+
* - Warns if noEmit is true but outDir is set (contradictory: can't emit AND not emit)
|
|
5
|
+
* - Warns if noEmit is true but declaration is true (pointless: can't generate .d.ts)
|
|
6
|
+
* - Warns if noEmit is true but declarationDir is set
|
|
7
|
+
* - Detects if outFile is set with noEmit (contradictory)
|
|
8
|
+
*/
|
|
9
|
+
export declare const noEmitConflictRule: Rule;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const ruleId = "ts.noemit.conflict";
|
|
2
|
+
/**
|
|
3
|
+
* Checks for contradictory noEmit settings:
|
|
4
|
+
* - Warns if noEmit is true but outDir is set (contradictory: can't emit AND not emit)
|
|
5
|
+
* - Warns if noEmit is true but declaration is true (pointless: can't generate .d.ts)
|
|
6
|
+
* - Warns if noEmit is true but declarationDir is set
|
|
7
|
+
* - Detects if outFile is set with noEmit (contradictory)
|
|
8
|
+
*/
|
|
9
|
+
export const noEmitConflictRule = {
|
|
10
|
+
id: ruleId,
|
|
11
|
+
analyze(config) {
|
|
12
|
+
const options = config.compilerOptions ?? {};
|
|
13
|
+
const noEmit = options.noEmit;
|
|
14
|
+
const findings = [];
|
|
15
|
+
// If noEmit is not true, no conflict possible
|
|
16
|
+
if (!noEmit) {
|
|
17
|
+
return findings;
|
|
18
|
+
}
|
|
19
|
+
// Check for noEmit with outDir
|
|
20
|
+
if (options.outDir) {
|
|
21
|
+
findings.push({
|
|
22
|
+
ruleId: ruleId,
|
|
23
|
+
severity: "error",
|
|
24
|
+
message: `noEmit is true but outDir is set to "${options.outDir}". These are contradictory: noEmit means "don't emit files", but outDir specifies where to emit them. Remove one of these options.`,
|
|
25
|
+
category: "conflict"
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
// Check for noEmit with outFile
|
|
29
|
+
if (options.outFile) {
|
|
30
|
+
findings.push({
|
|
31
|
+
ruleId: ruleId,
|
|
32
|
+
severity: "error",
|
|
33
|
+
message: `noEmit is true but outFile is set to "${options.outFile}". These are contradictory: noEmit means "don't emit files", but outFile specifies where to emit bundled output. Remove one of these options.`,
|
|
34
|
+
category: "conflict"
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
// Check for noEmit with declaration
|
|
38
|
+
if (options.declaration) {
|
|
39
|
+
findings.push({
|
|
40
|
+
ruleId: ruleId,
|
|
41
|
+
severity: "error",
|
|
42
|
+
message: `noEmit is true but declaration is true. These are contradictory: noEmit means "don't emit files", but declaration means "emit .d.ts files". Remove one of these options. If you need type checking only, use noEmit. If you need declarations, set noEmit to false.`,
|
|
43
|
+
category: "conflict"
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
// Check for noEmit with declarationDir
|
|
47
|
+
if (options.declarationDir) {
|
|
48
|
+
findings.push({
|
|
49
|
+
ruleId: ruleId,
|
|
50
|
+
severity: "warn",
|
|
51
|
+
message: `noEmit is true but declarationDir is set to "${options.declarationDir}". These are contradictory: noEmit means "don't emit files", but declarationDir specifies where to emit .d.ts files. Remove one of these options.`,
|
|
52
|
+
category: "conflict"
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return findings;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=noEmitConflict.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noEmitConflict.js","sourceRoot":"","sources":["../../src/rules/noEmitConflict.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAG,oBAAoB,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAS;IACpC,EAAE,EAAE,MAAM;IAEV,OAAO,CAAC,MAAuB;QAC3B,MAAM,OAAO,GAAG,MAAM,CAAC,eAAe,IAAI,EAAE,CAAC;QAC7C,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAE9B,MAAM,QAAQ,GAAc,EAAE,CAAC;QAE/B,8CAA8C;QAC9C,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,OAAO,QAAQ,CAAC;QACpB,CAAC;QAED,+BAA+B;QAC/B,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACjB,QAAQ,CAAC,IAAI,CAAC;gBACV,MAAM,EAAE,MAAM;gBACd,QAAQ,EAAE,OAAO;gBACjB,OAAO,EAAE,wCAAwC,OAAO,CAAC,MAAM,oIAAoI;gBACnM,QAAQ,EAAE,UAAU;aACvB,CAAC,CAAC;QACP,CAAC;QAED,gCAAgC;QAChC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YAClB,QAAQ,CAAC,IAAI,CAAC;gBACV,MAAM,EAAE,MAAM;gBACd,QAAQ,EAAE,OAAO;gBACjB,OAAO,EAAE,yCAAyC,OAAO,CAAC,OAAO,+IAA+I;gBAChN,QAAQ,EAAE,UAAU;aACvB,CAAC,CAAC;QACP,CAAC;QAED,oCAAoC;QACpC,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;YACtB,QAAQ,CAAC,IAAI,CAAC;gBACV,MAAM,EAAE,MAAM;gBACd,QAAQ,EAAE,OAAO;gBACjB,OAAO,EAAE,qQAAqQ;gBAC9Q,QAAQ,EAAE,UAAU;aACvB,CAAC,CAAC;QACP,CAAC;QAED,uCAAuC;QACvC,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;YACzB,QAAQ,CAAC,IAAI,CAAC;gBACV,MAAM,EAAE,MAAM;gBACd,QAAQ,EAAE,MAAM;gBAChB,OAAO,EAAE,gDAAgD,OAAO,CAAC,cAAc,mJAAmJ;gBAClO,QAAQ,EAAE,UAAU;aACvB,CAAC,CAAC;QACP,CAAC;QAED,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Rule } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Checks for conflicts between outDir and rootDir:
|
|
4
|
+
* - outDir should not be inside rootDir (creates circular paths)
|
|
5
|
+
* - outDir and rootDir should not be the same
|
|
6
|
+
* - Warns if outFile is used with conflicting outDir/rootDir
|
|
7
|
+
*/
|
|
8
|
+
export declare const outDirRootDirConflictRule: Rule;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const ruleId = "ts.outdir-rootdir.conflict";
|
|
2
|
+
/**
|
|
3
|
+
* Checks for conflicts between outDir and rootDir:
|
|
4
|
+
* - outDir should not be inside rootDir (creates circular paths)
|
|
5
|
+
* - outDir and rootDir should not be the same
|
|
6
|
+
* - Warns if outFile is used with conflicting outDir/rootDir
|
|
7
|
+
*/
|
|
8
|
+
export const outDirRootDirConflictRule = {
|
|
9
|
+
id: ruleId,
|
|
10
|
+
analyze(config) {
|
|
11
|
+
const options = config.compilerOptions ?? {};
|
|
12
|
+
const outDir = options.outDir;
|
|
13
|
+
const rootDir = options.rootDir;
|
|
14
|
+
const outFile = options.outFile;
|
|
15
|
+
const findings = [];
|
|
16
|
+
// If neither outDir nor rootDir is set, no conflict possible
|
|
17
|
+
if (!outDir && !rootDir) {
|
|
18
|
+
return findings;
|
|
19
|
+
}
|
|
20
|
+
// Check if outDir is inside rootDir
|
|
21
|
+
if (outDir && rootDir) {
|
|
22
|
+
const normalizedOutDir = outDir.replace(/\\/g, "/");
|
|
23
|
+
const normalizedRootDir = rootDir.replace(/\\/g, "/");
|
|
24
|
+
// Remove trailing slashes for comparison
|
|
25
|
+
const outDirClean = normalizedOutDir.endsWith("/")
|
|
26
|
+
? normalizedOutDir.slice(0, -1)
|
|
27
|
+
: normalizedOutDir;
|
|
28
|
+
const rootDirClean = normalizedRootDir.endsWith("/")
|
|
29
|
+
? normalizedRootDir.slice(0, -1)
|
|
30
|
+
: normalizedRootDir;
|
|
31
|
+
// Check if outDir equals rootDir
|
|
32
|
+
if (outDirClean === rootDirClean) {
|
|
33
|
+
findings.push({
|
|
34
|
+
ruleId: ruleId,
|
|
35
|
+
severity: "error",
|
|
36
|
+
message: `outDir and rootDir are the same ("${outDir}"). This will cause source files to be overwritten. Set outDir outside of rootDir.`,
|
|
37
|
+
category: "conflict"
|
|
38
|
+
});
|
|
39
|
+
return findings;
|
|
40
|
+
}
|
|
41
|
+
// Check if outDir is inside rootDir (e.g., rootDir: "src", outDir: "src/dist")
|
|
42
|
+
if (outDirClean.startsWith(rootDirClean + "/")) {
|
|
43
|
+
findings.push({
|
|
44
|
+
ruleId: ruleId,
|
|
45
|
+
severity: "error",
|
|
46
|
+
message: `outDir ("${outDir}") is inside rootDir ("${rootDir}"). This creates a circular path and can cause source files to be overwritten or deleted. Move outDir outside rootDir, e.g., "outDir": "dist"`,
|
|
47
|
+
category: "conflict"
|
|
48
|
+
});
|
|
49
|
+
return findings;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// Check if outFile conflicts with outDir
|
|
53
|
+
if (outFile && outDir) {
|
|
54
|
+
findings.push({
|
|
55
|
+
ruleId: ruleId,
|
|
56
|
+
severity: "warn",
|
|
57
|
+
message: `Both outFile ("${outFile}") and outDir ("${outDir}") are set. Typically, use either outFile (for bundled output) OR outDir (for distributed files), not both.`,
|
|
58
|
+
category: "conflict"
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return findings;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=outDirRootDirConflict.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outDirRootDirConflict.js","sourceRoot":"","sources":["../../src/rules/outDirRootDirConflict.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAG,4BAA4B,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAS;IAC3C,EAAE,EAAE,MAAM;IAEV,OAAO,CAAC,MAAuB;QAC3B,MAAM,OAAO,GAAG,MAAM,CAAC,eAAe,IAAI,EAAE,CAAC;QAC7C,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC9B,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAChC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAEhC,MAAM,QAAQ,GAAc,EAAE,CAAC;QAE/B,6DAA6D;QAC7D,IAAI,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;YACtB,OAAO,QAAQ,CAAC;QACpB,CAAC;QAED,oCAAoC;QACpC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;gBACV,MAAM,EAAE,MAAM;gBACd,QAAQ,EAAE,MAAM;gBAChB,OAAO,EAAE,kBAAkB,OAAO,mBAAmB,MAAM,6GAA6G;gBACxK,QAAQ,EAAE,UAAU;aACvB,CAAC,CAAC;QACP,CAAC;QAED,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Rule } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Checks for incomplete path configuration:
|
|
4
|
+
* - Warns if paths is set but baseUrl is not (paths require baseUrl to work)
|
|
5
|
+
* - Suggests setting baseUrl when paths is detected
|
|
6
|
+
* - Detects if baseUrl is set but paths is not (potentially unused baseUrl)
|
|
7
|
+
*/
|
|
8
|
+
export declare const pathsWithoutBaseUrlRule: Rule;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const ruleId = "ts.paths-baseurl.conflict";
|
|
2
|
+
/**
|
|
3
|
+
* Checks for incomplete path configuration:
|
|
4
|
+
* - Warns if paths is set but baseUrl is not (paths require baseUrl to work)
|
|
5
|
+
* - Suggests setting baseUrl when paths is detected
|
|
6
|
+
* - Detects if baseUrl is set but paths is not (potentially unused baseUrl)
|
|
7
|
+
*/
|
|
8
|
+
export const pathsWithoutBaseUrlRule = {
|
|
9
|
+
id: ruleId,
|
|
10
|
+
analyze(config) {
|
|
11
|
+
const options = config.compilerOptions ?? {};
|
|
12
|
+
const paths = options.paths;
|
|
13
|
+
const baseUrl = options.baseUrl;
|
|
14
|
+
const findings = [];
|
|
15
|
+
// Check if paths is set without baseUrl
|
|
16
|
+
if (paths && Object.keys(paths).length > 0 && !baseUrl) {
|
|
17
|
+
findings.push({
|
|
18
|
+
ruleId: ruleId,
|
|
19
|
+
severity: "error",
|
|
20
|
+
message: `paths is configured but baseUrl is not set. The paths option requires baseUrl to be set to work correctly. Add "baseUrl": "." to your compilerOptions.`,
|
|
21
|
+
category: "conflict"
|
|
22
|
+
});
|
|
23
|
+
return findings;
|
|
24
|
+
}
|
|
25
|
+
// Check if baseUrl is set without paths (softer suggestion)
|
|
26
|
+
if (baseUrl && (!paths || Object.keys(paths).length === 0)) {
|
|
27
|
+
findings.push({
|
|
28
|
+
ruleId: ruleId,
|
|
29
|
+
severity: "info",
|
|
30
|
+
message: `baseUrl is set to "${baseUrl}" but no paths are configured. If you're not using path aliases, you can remove baseUrl to simplify your config.`,
|
|
31
|
+
category: "suggestion"
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return findings;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=pathsWithoutBaseUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pathsWithoutBaseUrl.js","sourceRoot":"","sources":["../../src/rules/pathsWithoutBaseUrl.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAG,2BAA2B,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAS;IACzC,EAAE,EAAE,MAAM;IAEV,OAAO,CAAC,MAAuB;QAC3B,MAAM,OAAO,GAAG,MAAM,CAAC,eAAe,IAAI,EAAE,CAAC;QAC7C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC5B,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAEhC,MAAM,QAAQ,GAAc,EAAE,CAAC;QAE/B,wCAAwC;QACxC,IAAI,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YACrD,QAAQ,CAAC,IAAI,CAAC;gBACV,MAAM,EAAE,MAAM;gBACd,QAAQ,EAAE,OAAO;gBACjB,OAAO,EAAE,wJAAwJ;gBACjK,QAAQ,EAAE,UAAU;aACvB,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC;QACpB,CAAC;QAED,4DAA4D;QAC5D,IAAI,OAAO,IAAI,CAAC,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC;YACzD,QAAQ,CAAC,IAAI,CAAC;gBACV,MAAM,EAAE,MAAM;gBACd,QAAQ,EAAE,MAAM;gBAChB,OAAO,EAAE,sBAAsB,OAAO,kHAAkH;gBACxJ,QAAQ,EAAE,YAAY;aACzB,CAAC,CAAC;QACP,CAAC;QAED,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-reconf",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"description": "Understand and simplify (re-conf) your tsconfig.json",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"typescript": "6.0.3"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@types/node": "26.1.
|
|
44
|
+
"@types/node": "26.1.1",
|
|
45
45
|
"@vitest/coverage-v8": "4.1.10",
|
|
46
|
-
"tsx": "4.23.
|
|
46
|
+
"tsx": "4.23.1",
|
|
47
47
|
"vitest": "4.1.10"
|
|
48
48
|
}
|
|
49
49
|
}
|