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

Linting for svetle file with lang="ts" not matching typescript file linting #206

Open
AutomateAaron opened this issue Apr 25, 2023 · 0 comments

Comments

@AutomateAaron
Copy link

I have the following two files:

+page.svelte:

<script lang="ts">
  var test = 'test';
</script>

and

+page.ts:

var test = 'test';

However, when I run eslint I get different results for the files:

[...]\+page.svelte
  2:6  warning  'test' is assigned a value but never used  @typescript-eslint/no-unused-vars

[...]\+page.ts
  1:1  error    Unexpected var, use let or const instead   no-var
  1:5  warning  'test' is assigned a value but never used  @typescript-eslint/no-unused-vars

Notably the ts(no-var) is being applied to the typescript file, however it isn't being applied to the svelte file. I'd like to have this handled consistently across svelte and typescript files?

For context, here are my config files (let me know if you need to see any other files):

.eslintrc.cjs
module.exports = {
	root: true,
	parser: '@typescript-eslint/parser',
	extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
	plugins: ['svelte3', '@typescript-eslint'],
	ignorePatterns: ['*.cjs'],
	overrides: [
		{
			files: ['*.svelte'],
			processor: 'svelte3/svelte3'
		}
	],
	settings: {
		'svelte3/typescript': () => require('typescript')
	},
	parserOptions: {
		sourceType: 'module',
		ecmaVersion: 2020
	},
	env: {
		browser: true,
		es2017: true,
		node: true
	}
};
tsconfig.json
{
	"extends": "./.svelte-kit/tsconfig.json",
	"compilerOptions": {
		"allowJs": true,
		"checkJs": true,
		"esModuleInterop": true,
		"forceConsistentCasingInFileNames": true,
		"resolveJsonModule": true,
		"skipLibCheck": true,
		"sourceMap": true,
		"strict": true,
		"outDir": "dist",
		"types": ["unplugin-icons/types/svelte"]
	}
	// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
	//
	// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
	// from the referenced tsconfig.json - TypeScript does not merge them in
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant