Skip to content
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

Add support for Typed Linting in script tags #240

Open
wtchnm opened this issue Aug 20, 2023 · 2 comments
Open

Add support for Typed Linting in script tags #240

wtchnm opened this issue Aug 20, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@wtchnm
Copy link

wtchnm commented Aug 20, 2023

Description

Hey, it would be awesome if we can add support for @typescript-eslint/recommended-type-checked in script tag as follows:

{
	"files": ["**/*.astro/*.js", "*.astro/*.js"],
	"extends": ["plugin:@typescript-eslint/recommended-type-checked"],
	"parserOptions": {
		"project": true
	}
}

I will definitely make a PR if you can point me in the right direction!

@wtchnm wtchnm added the enhancement New feature or request label Aug 20, 2023
@ota-meshi
Copy link
Owner

Thanks for posting the issue.
We use the ESLint processor for linting client scripts. This assigns a virtual filename so TypeScript cannot get the type information.
I have no idea at the moment to work around this problem. If you have a good idea please let me know.

@morriq
Copy link

morriq commented Oct 11, 2023

I think my issue is related to it ...

I created repo to reproduce it - https://github.com/morriq/eslint-astro-issue/

npm install
npm run eslint

should cause

astro-eslint-issue/src/pages/index.astro
  7:8  error  Unsafe member access .then on an `any` value   @typescript-eslint/no-unsafe-member-access
  7:8  error  Unsafe call of an `any` typed value            @typescript-eslint/no-unsafe-call
  7:8  error  Unsafe member access .query on an `any` value  @typescript-eslint/no-unsafe-member-access
  7:8  error  Unsafe call of an `any` typed value            @typescript-eslint/no-unsafe-call

I have definition of it in https://github.com/morriq/eslint-astro-issue/blob/main/src/env.d.ts but somehow parser does not read it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants