-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
type-aware lints error with default generate eslint config #11209
Comments
Type-aware rules work fine in SvelteKit once you have it configured correctly. Maybe you just didn't show every command you typed throughout the process, but I didn't see that you ran Normally the tsconfig that's created by the new project CLI tool handles extending the generated tsconfig but I didn't see that happening in your tsconfig you pasted. https://kit.svelte.dev/docs/project-structure#project-files-tsconfig-json |
Ok, i can give that a go, thanks! Question tho, Can we change it to use the configs i define? Why use hidden configs? (Or .svelte-kit at all). This feels like a weirdness/departure from broader ecosystem convention |
Since v5.x.x (can't remember the exact version) TypeScript supports extending multiple tsconfigs at once. In my SvelteKit projects, from the tsconfig in the root project folder I extend both my own, custom tsconfig that's a package in my monorepo and the auto-generated tsconfig in the .svelte-kit folder and it works fine. As far as your question about why use the .svelte-kit folder at all - that I can't really say. I'm not involved in the development of SvelteKit in any way, just a fairly experienced Svelte dev that saw your post on Reddit and thought I might know the answer. I will say, though, that starting issues for problems that are (likely) easily solvable by having thoroughly read the docs (the .svelte-kit folder of auto-generated code is pretty fundamental to SvelteKit and isn't by any means an obscure feature) and then questioning core design decisions of the library as if that's the problem is a bit offputting from the perspective of someone trying to decide whether to devote some time to trying to help. 🤷♂️ |
I appreciate you taking the time to help! After running
I was able to successfully lint with type-aware rules, and I see these violations by default:
Time for some background -- first, I do appreciate all help, and I didn't mean to "question design decisions", it's just I'm genuinely curious, and type-aware linting is a hard problem to solve with custom file syntax (something I'm helping with in another corner of the broader JavaScript ecosystem) -- especially given responses from the TypeScript team like this:
And here:
which is a fine assumption, but the TS team also doesn't really give you sufficient APIs for pluggability if you dare not use JSX/TSX. And for Vue (also keep in mind I'm not very involved in that ecosystem), they're still working on figuring out ergonomic type-aware linting as they're regularly running in to problems with typescript-eslint. Naturally, one might want to look at ['@typescript-eslint/parser There is also this project: https://github.com/ota-meshi/typescript-eslint-parser-for-extra-files, but
I understand that reading docs is a bare minimum someone can do when starting a project, and I mean this is the most curious way possible, but I want to be clear about something, when I say
every ESLint-using project i've seen across many ecosystems runs on source files, and doesn't require first running I have since looked in the |
Describe the bug
Hello!!! I'm new to svelte, first issue:
type-aware lints, when enabled, are not supported out of the box.
I also posted about this in the Discord: https://discord.com/channels/457912077277855764/1182013829626986516/1182013829626986516
Reproduction
Project here: https://stackblitz.com/edit/stackblitz-starters-rvyx2s
npm create svelte@latest my-app
add to the lint config:
pnpm i
pnpm eslint .
Logs
System Info
Severity
blocking all usage of SvelteKit
Additional Information
Specifying the tsconfig.json,
whole file
const path = require('path');
/** @type { import("eslint").Linter.FlatConfig } /
module.exports = {
root: true,
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:svelte/recommended',
'prettier',
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020,
extraFileExtensions: ['.svelte'],
},
env: {
browser: true,
es2017: true,
node: true,
},
overrides: [
{
files: ['.svelte'],
parser: 'svelte-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
project: require.resolve(path.join(__dirname, 'tsconfig.json')),
},
rules: {
'@typescript-eslint/no-unsafe-argument': 'error',
'@typescript-eslint/no-unsafe-assignment': 'error',
'@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/no-unsafe-member-access': 'error',
'@typescript-eslint/no-unsafe-return': 'error',
},
},
],
};
then,
that
.svelte-kit
directory is super suspicious, like the CWD that eslint is running is incorrect.but adding a
..
to the tsconfig.json resolve, (as expected) errors earlier:So... is something going goofy with the svelte eslint plugin?
The text was updated successfully, but these errors were encountered: