zed
zed copied to clipboard
ESLint @typescript-eslint parser can’t find SvelteKit .svelte files in Zed
Summary
Description
When opening a SvelteKit project with ESLint configured for type-aware linting of .svelte files, Zed reports a “file not found by the project service” parsing error, even though the file is included in my tsconfig.json.
Note the issue is only in .svelte files .ts files works just fine it seems.
Steps to reproduce:
- pnpm dlx sv create
- open any +page.svelte +layout.svelte
im not sure that even I think issue is related to my machine only i would assume
Expected Behavior:
ESLint should parse and lint +layout.svelte without errors.
Actual Behavior:
Parsing error: Z:\pixelscortex\uni-fied\src\routes\+layout.svelte
was not found by the project service. Consider either including it
in the tsconfig.json or including it in allowDefaultProject.
// Zed settings
//
// For information on how to configure Zed, see the Zed
// documentation: https://zed.dev/docs/configuring-zed
//
// To see all of Zed's default settings without changing your
// custom settings, run `zed: open default settings` from the
// command palette (cmd-shift-p / ctrl-shift-p)
{
"icon_theme": "Catppuccin Macchiato",
"ui_font_size": 15,
"buffer_font_size": 15,
"terminal": {
"font_size": 14
},
"theme": {
"mode": "system",
"light": "One Light",
"dark": "Tokyo Night"
},
"buffer_line_height": { "custom": 1.5 },
"cursor_blink": true,
"cursor_shape": "block"
}
tsconfig.json
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"types": ["unplugin-icons/types/svelte"],
"moduleResolution": "bundler"
},
"include": [
"src/**/*.ts",
"src/**/*.js",
"src/**/*.svelte",
".svelte-kit/ambient.d.ts",
".svelte-kit/types/**/$types.d.ts"
]
}
eslint.config.mjs
import prettier from 'eslint-config-prettier';
import js from '@eslint/js';
import { includeIgnoreFile } from '@eslint/compat';
import svelte from 'eslint-plugin-svelte';
import globals from 'globals';
import { fileURLToPath } from 'node:url';
import ts from 'typescript-eslint';
import svelteConfig from './svelte.config.js';
const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url));
export default ts.config(
{
ignores: ['dist/**/*.ts', 'dist/**', '**/*.mjs', 'eslint.config.mjs', '**/*.js'],
files: ['src/**/*.ts', 'src/**/*.svelte', 'src/**/*.svelte.ts', 'src/**/*.svelte.js']
},
includeIgnoreFile(gitignorePath),
js.configs.recommended,
...ts.configs.recommended,
...svelte.configs.recommended,
prettier,
...svelte.configs.prettier,
{
languageOptions: {
globals: { ...globals.browser, ...globals.node }
},
rules: { 'no-undef': 'off' }
},
{
files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],
languageOptions: {
parserOptions: {
projectService: true,
allowDefaultProject: true,
extraFileExtensions: ['.svelte'],
parser: ts.parser,
svelteConfig
}
}
}
);
Zed Version and System Specs
VERSION: zed: 0.186.8 OS: windows 11 CPU: ryzen 5600x GPU: radeon 6600xt
Related: #29757
Seems like it was the same error I had (I opened that issue)
For anyone with Similar issue maybe try this config
import prettier from 'eslint-config-prettier';
import js from '@eslint/js';
import { includeIgnoreFile } from '@eslint/compat';
import svelte from 'eslint-plugin-svelte';
import globals from 'globals';
import { fileURLToPath } from 'node:url';
import ts from 'typescript-eslint';
import svelteConfig from './svelte.config.js';
/*eslint no-undef: "error"*/
const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url));
export default [
includeIgnoreFile(gitignorePath),
js.configs.recommended,
...ts.configs.recommended,
...svelte.configs.recommended,
prettier,
...svelte.configs.prettier,
{
languageOptions: {
globals: { ...globals.browser, ...globals.node }
},
rules: { 'no-undef': 'off' }
},
{
files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],
languageOptions: {
parserOptions: {
svelteConfig
}
}
}
];
Closing in favor of:
- https://github.com/zed-industries/zed/issues/29757
I see this was closed as completed, but even with the suggested configs above, I'm still having this issue.