Skip to content

Commit 14fb328

Browse files
fix: several bugs
1 parent 46b2773 commit 14fb328

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

docs/pages/project/roadmap.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
- social image for docs and launch
1313
- twitter thread
1414
- public launch! 🚀
15+
- fix confusing rules with empty config
16+
- fix cache being in `.gptlint`
17+
- fix dry-run should never be cached
1518

1619
## Post-MVP
1720

src/cache.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export class LinterCache<
1818
TValue extends object = types.LintResult
1919
> {
2020
noCache: boolean
21+
dryRun: boolean
2122
cacheDir?: string
2223
cacheFile?: string
2324
cache?: Record<string, string>
@@ -27,14 +28,17 @@ export class LinterCache<
2728
constructor({
2829
cacheDir,
2930
cacheFileName = 'cache.json',
30-
noCache = false
31+
noCache = false,
32+
dryRun = false
3133
}: {
3234
cacheDir?: string
3335
cacheFileName?: string
3436
noCache?: boolean
37+
dryRun?: boolean
3538
}) {
3639
this.cacheDir = cacheDir
3740
this.noCache = !!noCache
41+
this.dryRun = !!dryRun
3842
this.cacheFile = this.cacheDir
3943
? path.join(this.cacheDir, cacheFileName)
4044
: undefined
@@ -112,7 +116,7 @@ export class LinterCache<
112116
}
113117

114118
async flush() {
115-
if (!this.cache) return
119+
if (!this.cache || this.dryRun) return
116120

117121
const cacheFile = this.cacheFile
118122
if (cacheFile) {
@@ -132,7 +136,8 @@ export async function createLinterCache<
132136
>(config: types.ResolvedLinterConfig): Promise<LinterCache<TKey, TValue>> {
133137
const cache = new LinterCache<TKey, TValue>({
134138
cacheDir: config.linterOptions.cacheDir,
135-
noCache: config.linterOptions.noCache
139+
noCache: config.linterOptions.noCache,
140+
dryRun: config.linterOptions.dryRun
136141
})
137142
await cache.init()
138143
return cache

src/config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import path from 'node:path'
2+
13
import type { MergeDeep, SetRequired, Simplify } from 'type-fest'
24
import type { SimplifyDeep } from 'type-fest/source/merge-deep.js'
35
import findCacheDirectory from 'find-cache-dir'
@@ -27,7 +29,7 @@ export type LinterConfigRuleSettings = z.infer<
2729
>
2830

2931
export const defaultCacheDir =
30-
findCacheDirectory({ name: 'gptlint' }) ?? '.gptlint'
32+
findCacheDirectory({ name: 'gptlint' }) ?? path.join('.gptlint', 'cache')
3133

3234
export const LLMOptionsSchema = z
3335
.object({

src/utils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,9 @@ export function validateLinterInputs({
456456
console.error(
457457
`\n${chalk.bold('Error: no rules enabled')} (${chalk.italic('run with --print-config to debug')})\n`
458458
)
459+
console.error(
460+
'\nNote: If you want to use the built-in rules with a custom config file, you must enable tem explicitly: https://gptlint.dev/guide/config#config-file\n'
461+
)
459462
gracefulExit(1)
460463
return false
461464
}

0 commit comments

Comments
 (0)