Skip to content

svelte/block-lang does not check <script context="module"> when a component script tag is present #507

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

Closed
2 tasks done
RubyTunaley opened this issue Jun 16, 2023 · 2 comments · Fixed by #511
Closed
2 tasks done

Comments

@RubyTunaley
Copy link

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.

What version of ESLint are you using?

v8.42.0

What version of eslint-plugin-svelte are you using?

v2.30.0

What did you do?

Configuration
const options = {
	env: {
		browser: true
	},
	parser: '@typescript-eslint/parser',
	parserOptions: {
		extraFileExtensions: ['.svelte'],
		ecmaVersion: 'latest',
		sourceType: 'module',
		project: true,
		tsconfigRootDir: __dirname
	},
	overrides: [
		{
			files: ['*.svelte'],
			parser: 'svelte-eslint-parser',
			parserOptions: {
				parser: '@typescript-eslint/parser',
				extraFileExtensions: ['.svelte'],
				tsconfigRootDir: __dirname
			}
		}
	],
	plugins: ['@typescript-eslint', 'eslint-plugin-svelte'],
	root: true,
	rules: {
		'svelte/block-lang': [2, {
			script: ['ts']
		}]
	},
	reportUnusedDisableDirectives: true
};

module.exports = options;
<script context="module"></script>
<script lang="ts"></script>

What did you expect to happen?

Linting error: error The lang attribute of the <script> block should be "ts" svelte/block-lang

What actually happened?

No linting error was raised.

Link to GitHub Repo with Minimal Reproducible Example

https://github.com/RubyTunaley/svelte-eslint-block-lang-bug

Additional comments

No response

@marekdedic
Copy link
Contributor

Hmm,
I tried adding tests for this and can't replicate - am I doing something wrong?

https://github.com/marekdedic/eslint-plugin-svelte/tree/block-lang-context-module

@RubyTunaley
Copy link
Author

RubyTunaley commented Jun 20, 2023

@marekdedic Yes - the error only occurs when there is both a regular script tag and a module script tag, like this:

<script context="module"></script>
<script lang="ts"></script>

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

Successfully merging a pull request may close this issue.

2 participants