Skip to content

No Implicit Any, not being flagged #1191

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

Open
2 tasks done
jamesthemullet opened this issue Apr 6, 2025 · 0 comments
Open
2 tasks done

No Implicit Any, not being flagged #1191

jamesthemullet opened this issue Apr 6, 2025 · 0 comments

Comments

@jamesthemullet
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?

9.24.0

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

3.5.1

What did you do?

Configuration
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';
const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url));
import svelteConfig from './svelte.config.js';
import { parser as tsEslintParser } from 'typescript-eslint';

export default ts.config(
	includeIgnoreFile(gitignorePath),
	js.configs.recommended,
	...ts.configs.recommended,
	...svelte.configs['flat/recommended'],
	prettier,
	...svelte.configs['flat/prettier'],
	{
		languageOptions: {
			globals: {
				...globals.browser,
				...globals.node
			}
		}
	},
	{
		files: ['**/*.ts', '**/*.svelte'],
		languageOptions: {
			parserOptions: {
				extraFileExtensions: ['.svelte'],
				parser: tsEslintParser,
				svelteConfig
			}
		},
		rules: {
			...ts.configs.recommended.rules,
			...ts.configs.recommendedTypeChecked[0].rules,
			'@typescript-eslint/no-explicit-any': 'error',
			'@typescript-eslint/explicit-module-boundary-types': 'error'
		}
	}
);

<script lang="ts">
	import '../../styles/index.css';
	import AddComment from '$lib/components/AddComment.svelte';
	import Comments from '$lib/components/Comments.svelte';
	import type { PageProps } from '../[slug]/$types';
	import { showAddComment } from '$lib/stores/commentState';

	let { data }: PageProps = $props();

	const x: number = 'not a number';

	const organiseComments = (comments) => {
		const commentMap = new Map();
		const y: number = 'not a number';

		comments.forEach((comment) => {
			comment.replies = [];
			commentMap.set(comment.id, comment);
		});

		const topLevelComments = [];
		comments.forEach((comment) => {
			if (comment.parentId) {
				const parent = commentMap.get(comment.parentId);
				if (parent) {
					parent.replies.push(comment);
				}
			} else {
				topLevelComments.push(comment);
			}
		});

		return topLevelComments;
	};
</script>

What did you expect to happen?

Eslint should add errors for 'Parameter 'comments' implicitly has an 'any' type.' (and similar issues).

What actually happened?

It does not error on such issues.

It will error on const x: number = 'not a number';

Link to GitHub Repo with Minimal Reproducible Example

https://github.com/jamesthemullet/readingweather

Additional comments

Possibly an issue with my set-up? Have tried a few different examples from other issues posted.

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