Skip to content

No Implicit Any, not being flagged #1191

Open
@jamesthemullet

Description

@jamesthemullet

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions