@rcrsr/rill-cli 0.7.2 → 0.8.0

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 (57) hide show
  1. package/dist/cli-shared.d.ts.map +1 -1
  2. package/dist/cli-shared.js +3 -1
  3. package/dist/cli-shared.js.map +1 -1
  4. package/package.json +16 -1
  5. package/src/check/config.ts +0 -202
  6. package/src/check/fixer.ts +0 -174
  7. package/src/check/index.ts +0 -39
  8. package/src/check/rules/anti-patterns.ts +0 -585
  9. package/src/check/rules/closures.ts +0 -445
  10. package/src/check/rules/collections.ts +0 -437
  11. package/src/check/rules/conditionals.ts +0 -155
  12. package/src/check/rules/flow.ts +0 -262
  13. package/src/check/rules/formatting.ts +0 -811
  14. package/src/check/rules/helpers.ts +0 -89
  15. package/src/check/rules/index.ts +0 -140
  16. package/src/check/rules/loops.ts +0 -372
  17. package/src/check/rules/naming.ts +0 -242
  18. package/src/check/rules/strings.ts +0 -104
  19. package/src/check/rules/types.ts +0 -213
  20. package/src/check/types.ts +0 -163
  21. package/src/check/validator.ts +0 -136
  22. package/src/check/visitor.ts +0 -338
  23. package/src/cli-check.ts +0 -456
  24. package/src/cli-error-enrichment.ts +0 -274
  25. package/src/cli-error-formatter.ts +0 -313
  26. package/src/cli-eval.ts +0 -145
  27. package/src/cli-exec.ts +0 -408
  28. package/src/cli-explain.ts +0 -76
  29. package/src/cli-lsp-diagnostic.ts +0 -132
  30. package/src/cli-module-loader.ts +0 -101
  31. package/src/cli-shared.ts +0 -187
  32. package/tests/check/cli-check.test.ts +0 -189
  33. package/tests/check/config.test.ts +0 -350
  34. package/tests/check/fixer.test.ts +0 -373
  35. package/tests/check/format-diagnostics.test.ts +0 -327
  36. package/tests/check/rules/anti-patterns.test.ts +0 -467
  37. package/tests/check/rules/closures.test.ts +0 -192
  38. package/tests/check/rules/collections.test.ts +0 -380
  39. package/tests/check/rules/conditionals.test.ts +0 -185
  40. package/tests/check/rules/flow.test.ts +0 -250
  41. package/tests/check/rules/formatting.test.ts +0 -755
  42. package/tests/check/rules/loops.test.ts +0 -334
  43. package/tests/check/rules/naming.test.ts +0 -336
  44. package/tests/check/rules/strings.test.ts +0 -129
  45. package/tests/check/rules/types.test.ts +0 -233
  46. package/tests/check/validator.test.ts +0 -444
  47. package/tests/check/visitor.test.ts +0 -171
  48. package/tests/cli/check.test.ts +0 -801
  49. package/tests/cli/error-enrichment.test.ts +0 -510
  50. package/tests/cli/error-formatter.test.ts +0 -631
  51. package/tests/cli/eval.test.ts +0 -85
  52. package/tests/cli/exec.test.ts +0 -537
  53. package/tests/cli-explain.test.ts +0 -249
  54. package/tests/cli-lsp-diagnostic.test.ts +0 -202
  55. package/tests/cli-shared.test.ts +0 -439
  56. package/tsconfig.json +0 -9
  57. package/tsconfig.tsbuildinfo +0 -1
@@ -1,350 +0,0 @@
1
- /**
2
- * Configuration Loader Tests
3
- * Tests for .rill-check.json loading and validation.
4
- */
5
-
6
- import { describe, it, expect, beforeEach, afterEach } from 'vitest';
7
- import { mkdirSync, writeFileSync, rmSync, existsSync } from 'node:fs';
8
- import { join } from 'node:path';
9
- import { loadConfig, createDefaultConfig } from '../../src/check/index.js';
10
-
11
- // ============================================================
12
- // TEST FIXTURES
13
- // ============================================================
14
-
15
- const TEST_DIR = join(process.cwd(), 'tests', 'fixtures', 'check-config');
16
- const CONFIG_FILE = '.rill-check.json';
17
-
18
- /**
19
- * Create test directory and configuration file.
20
- */
21
- function setupTestConfig(config: unknown): string {
22
- // Create test directory if it doesn't exist
23
- if (!existsSync(TEST_DIR)) {
24
- mkdirSync(TEST_DIR, { recursive: true });
25
- }
26
-
27
- const configPath = join(TEST_DIR, CONFIG_FILE);
28
- writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf-8');
29
- return TEST_DIR;
30
- }
31
-
32
- /**
33
- * Clean up test directory after each test.
34
- */
35
- function cleanupTestConfig(): void {
36
- if (existsSync(TEST_DIR)) {
37
- rmSync(TEST_DIR, { recursive: true, force: true });
38
- }
39
- }
40
-
41
- // ============================================================
42
- // DEFAULT CONFIGURATION
43
- // ============================================================
44
-
45
- describe('createDefaultConfig', () => {
46
- it('returns configuration with all rules enabled', () => {
47
- const config = createDefaultConfig();
48
-
49
- expect(config.rules).toBeDefined();
50
- expect(config.severity).toBeDefined();
51
- });
52
-
53
- it('returns configuration with all registered rules enabled', () => {
54
- // VALIDATION_RULES contains registered rules
55
- const config = createDefaultConfig();
56
-
57
- // Should have at least NAMING_SNAKE_CASE rule
58
- expect(Object.keys(config.rules).length).toBeGreaterThan(0);
59
- expect(config.rules.NAMING_SNAKE_CASE).toBe('on');
60
- });
61
- });
62
-
63
- // ============================================================
64
- // FILE NOT FOUND
65
- // ============================================================
66
-
67
- describe('loadConfig - file not found', () => {
68
- beforeEach(() => {
69
- cleanupTestConfig();
70
- });
71
-
72
- it('returns null when config file does not exist', () => {
73
- const result = loadConfig(TEST_DIR);
74
- expect(result).toBeNull();
75
- });
76
-
77
- it('returns null for non-existent directory', () => {
78
- const result = loadConfig('/nonexistent/directory');
79
- expect(result).toBeNull();
80
- });
81
- });
82
-
83
- // ============================================================
84
- // VALID CONFIGURATION
85
- // ============================================================
86
-
87
- describe('loadConfig - valid configuration', () => {
88
- afterEach(() => {
89
- cleanupTestConfig();
90
- });
91
-
92
- it('loads empty configuration file', () => {
93
- setupTestConfig({});
94
- const result = loadConfig(TEST_DIR);
95
-
96
- expect(result).not.toBeNull();
97
- expect(result?.rules).toBeDefined();
98
- expect(result?.severity).toBeDefined();
99
- });
100
-
101
- it('loads configuration with rules field', () => {
102
- setupTestConfig({
103
- rules: {},
104
- });
105
-
106
- const result = loadConfig(TEST_DIR);
107
- expect(result).not.toBeNull();
108
- });
109
-
110
- it('loads configuration with severity field', () => {
111
- setupTestConfig({
112
- severity: {},
113
- });
114
-
115
- const result = loadConfig(TEST_DIR);
116
- expect(result).not.toBeNull();
117
- });
118
-
119
- it('loads configuration with both fields', () => {
120
- setupTestConfig({
121
- rules: {},
122
- severity: {},
123
- });
124
-
125
- const result = loadConfig(TEST_DIR);
126
- expect(result).not.toBeNull();
127
- expect(result?.rules).toBeDefined();
128
- expect(result?.severity).toBeDefined();
129
- });
130
-
131
- it('merges config with defaults', () => {
132
- setupTestConfig({
133
- rules: {},
134
- severity: {},
135
- });
136
-
137
- const defaults = createDefaultConfig();
138
- const result = loadConfig(TEST_DIR);
139
-
140
- expect(result).not.toBeNull();
141
- expect(result?.rules).toEqual(defaults.rules);
142
- expect(result?.severity).toEqual(defaults.severity);
143
- });
144
- });
145
-
146
- // ============================================================
147
- // INVALID JSON [EC-3]
148
- // ============================================================
149
-
150
- describe('loadConfig - invalid JSON [EC-3]', () => {
151
- afterEach(() => {
152
- cleanupTestConfig();
153
- });
154
-
155
- it('throws for malformed JSON', () => {
156
- if (!existsSync(TEST_DIR)) {
157
- mkdirSync(TEST_DIR, { recursive: true });
158
- }
159
- const configPath = join(TEST_DIR, CONFIG_FILE);
160
- writeFileSync(configPath, '{ invalid json }', 'utf-8');
161
-
162
- expect(() => loadConfig(TEST_DIR)).toThrow('Invalid configuration:');
163
- expect(() => loadConfig(TEST_DIR)).toThrow('invalid JSON');
164
- });
165
-
166
- it('throws for non-object JSON', () => {
167
- setupTestConfig('string value');
168
-
169
- expect(() => loadConfig(TEST_DIR)).toThrow('Invalid configuration:');
170
- expect(() => loadConfig(TEST_DIR)).toThrow('must be an object');
171
- });
172
-
173
- it('throws for array JSON', () => {
174
- setupTestConfig([1, 2, 3]);
175
-
176
- expect(() => loadConfig(TEST_DIR)).toThrow('Invalid configuration:');
177
- expect(() => loadConfig(TEST_DIR)).toThrow('must be an object');
178
- });
179
-
180
- it('throws for null JSON', () => {
181
- setupTestConfig(null);
182
-
183
- expect(() => loadConfig(TEST_DIR)).toThrow('Invalid configuration:');
184
- expect(() => loadConfig(TEST_DIR)).toThrow('must be an object');
185
- });
186
-
187
- it('throws when rules field is not an object', () => {
188
- setupTestConfig({
189
- rules: 'invalid',
190
- });
191
-
192
- expect(() => loadConfig(TEST_DIR)).toThrow('Invalid configuration:');
193
- expect(() => loadConfig(TEST_DIR)).toThrow('rules must be an object');
194
- });
195
-
196
- it('throws when severity field is not an object', () => {
197
- setupTestConfig({
198
- severity: 'invalid',
199
- });
200
-
201
- expect(() => loadConfig(TEST_DIR)).toThrow('Invalid configuration:');
202
- expect(() => loadConfig(TEST_DIR)).toThrow('severity must be an object');
203
- });
204
-
205
- it('throws when rule state is invalid', () => {
206
- setupTestConfig({
207
- rules: {
208
- SOME_RULE: 'invalid_state',
209
- },
210
- });
211
-
212
- expect(() => loadConfig(TEST_DIR)).toThrow('Invalid configuration:');
213
- expect(() => loadConfig(TEST_DIR)).toThrow('invalid state');
214
- expect(() => loadConfig(TEST_DIR)).toThrow(
215
- "must be 'on', 'off', or 'warn'"
216
- );
217
- });
218
-
219
- it('throws when severity value is invalid', () => {
220
- setupTestConfig({
221
- severity: {
222
- SOME_RULE: 'critical',
223
- },
224
- });
225
-
226
- expect(() => loadConfig(TEST_DIR)).toThrow('Invalid configuration:');
227
- expect(() => loadConfig(TEST_DIR)).toThrow('invalid severity');
228
- expect(() => loadConfig(TEST_DIR)).toThrow(
229
- "must be 'error', 'warning', or 'info'"
230
- );
231
- });
232
- });
233
-
234
- // ============================================================
235
- // UNKNOWN RULES [EC-4]
236
- // ============================================================
237
-
238
- describe('loadConfig - unknown rules [EC-4]', () => {
239
- afterEach(() => {
240
- cleanupTestConfig();
241
- });
242
-
243
- it('throws for unknown rule in rules field', () => {
244
- setupTestConfig({
245
- rules: {
246
- UNKNOWN_RULE: 'on',
247
- },
248
- });
249
-
250
- expect(() => loadConfig(TEST_DIR)).toThrow('Invalid configuration:');
251
- expect(() => loadConfig(TEST_DIR)).toThrow('unknown rule UNKNOWN_RULE');
252
- });
253
-
254
- it('throws for unknown rule in severity field', () => {
255
- setupTestConfig({
256
- severity: {
257
- UNKNOWN_RULE: 'error',
258
- },
259
- });
260
-
261
- expect(() => loadConfig(TEST_DIR)).toThrow('Invalid configuration:');
262
- expect(() => loadConfig(TEST_DIR)).toThrow('unknown rule UNKNOWN_RULE');
263
- });
264
-
265
- it('throws for multiple unknown rules', () => {
266
- setupTestConfig({
267
- rules: {
268
- UNKNOWN_ONE: 'on',
269
- UNKNOWN_TWO: 'off',
270
- },
271
- });
272
-
273
- expect(() => loadConfig(TEST_DIR)).toThrow('Invalid configuration:');
274
- expect(() => loadConfig(TEST_DIR)).toThrow('unknown rule');
275
- });
276
- });
277
-
278
- // ============================================================
279
- // VALID RULE STATES
280
- // ============================================================
281
-
282
- describe('loadConfig - valid rule states', () => {
283
- afterEach(() => {
284
- cleanupTestConfig();
285
- });
286
-
287
- it('accepts "on" state', () => {
288
- setupTestConfig({
289
- rules: {},
290
- });
291
-
292
- const result = loadConfig(TEST_DIR);
293
- expect(result).not.toBeNull();
294
- });
295
-
296
- it('accepts "off" state', () => {
297
- setupTestConfig({
298
- rules: {},
299
- });
300
-
301
- const result = loadConfig(TEST_DIR);
302
- expect(result).not.toBeNull();
303
- });
304
-
305
- it('accepts "warn" state', () => {
306
- setupTestConfig({
307
- rules: {},
308
- });
309
-
310
- const result = loadConfig(TEST_DIR);
311
- expect(result).not.toBeNull();
312
- });
313
- });
314
-
315
- // ============================================================
316
- // VALID SEVERITY VALUES
317
- // ============================================================
318
-
319
- describe('loadConfig - valid severity values', () => {
320
- afterEach(() => {
321
- cleanupTestConfig();
322
- });
323
-
324
- it('accepts "error" severity', () => {
325
- setupTestConfig({
326
- severity: {},
327
- });
328
-
329
- const result = loadConfig(TEST_DIR);
330
- expect(result).not.toBeNull();
331
- });
332
-
333
- it('accepts "warning" severity', () => {
334
- setupTestConfig({
335
- severity: {},
336
- });
337
-
338
- const result = loadConfig(TEST_DIR);
339
- expect(result).not.toBeNull();
340
- });
341
-
342
- it('accepts "info" severity', () => {
343
- setupTestConfig({
344
- severity: {},
345
- });
346
-
347
- const result = loadConfig(TEST_DIR);
348
- expect(result).not.toBeNull();
349
- });
350
- });