zed icon indicating copy to clipboard operation
zed copied to clipboard

ESLint @typescript-eslint parser can’t find SvelteKit .svelte files in Zed

Open JustKira opened this issue 6 months ago • 3 comments

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:

  1. pnpm dlx sv create
  2. 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: Image

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

JustKira avatar May 15 '25 21:05 JustKira

Related: #29757

probably-neb avatar May 16 '25 10:05 probably-neb

Seems like it was the same error I had (I opened that issue)

Xyndra avatar May 16 '25 11:05 Xyndra

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
			}
		}
	}
];

JustKira avatar May 29 '25 12:05 JustKira

Closing in favor of:

  • https://github.com/zed-industries/zed/issues/29757

notpeter avatar Aug 19 '25 19:08 notpeter

I see this was closed as completed, but even with the suggested configs above, I'm still having this issue.

gchartier avatar Oct 03 '25 04:10 gchartier