Description
What version of Oxlint are you using?
1.1.0
What command did you run?
yarn lint:oxlint
What does your .oxlintrc.json
config file look like?
What happened?
Svelte allows use of Runes ($state, $derived, $props) in svelte files (*.svelte
, *.svelte.ts
, and *.svelte.js
). Outside of these, Runes are not defined/accessible. So use of them should trigger the no-undef lint rule. But it isn't doing so consistently.
Repo:
- Checkout this repo: https://github.com/KieranP/Github-Releases-Feed
- Add
const _hello = $state(0)
at the bottom of allsrc/*.ts
files - Run
yarn lint:oxlint
I'm getting the following output. Note that $state is not defined in any of the 5 non-svelte ts files, but only 2 of the non-svelte files report eslint(no-undef): '$state' is not defined.
. The rest think runes are available there, when they are not.
› yarn lint:oxlint
× eslint(no-undef): '$state' is not defined.
╭─[src/db.ts:23:16]
22 │
23 │ const _hello = $state(0)
· ──────
╰────
× eslint(no-undef): '$state' is not defined.
╭─[src/main.ts:12:16]
11 │
12 │ const _hello = $state(0)
· ──────
╰────
Found 0 warnings and 2 errors.
Finished in 19ms on 13 files using 12 threads.
Something is causing oxlint to think that svelte runes are available in some of the TS files but not others. I thought maybe it was because most of the TS files are being included in App.svelte where runes are available, and so therefore oxlint thinks they are available in all usages of those included files. The include tree looks like this:
- main.ts
- App.svelte
- db.ts
- components/release.svelte
- helpers.ts
- github.ts
But if that were the case, then shouldn't no-undef not show up at all except in main.ts? Further, why is it showing up in db.ts, which is included under App.svelte, where runes are accessible.
Also, if I then include helpers.ts in main.ts, where runes aren't accessible, shouldn't oxlint then throw no-undef for helpers.ts? But its not doing so.
And types.d.ts is a types file for TypeScript, which isn't included anywhere, so Svelte runes are most definitely not available there, but oxlint lets them through.
Weird inconsistencies it seems.