Skip to content

Disable no-navigation-without-resolve warning when all possible types are external links #1454

@aquagarced

Description

@aquagarced

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.39.1

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

3.4.1

What did you do?

Configuration
import globals from 'globals';
import ts from 'typescript-eslint';
import svelteConfig from './svelte.config.js';
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url));

export default defineConfig(
	includeIgnoreFile(gitignorePath),
	js.configs.recommended,
	...ts.configs.recommendedTypeChecked,
	...svelte.configs.all,
	prettier,
	...svelte.configs.prettier,
	eslintPluginUnicorn.configs.all,
	{
		languageOptions: { 
      globals: { ...globals.browser, ...globals.node },
      parserOptions: {
				projectService: true,
				extraFileExtensions: ['.svelte'],
				parser: ts.parser,
				svelteConfig
			},
    },

		rules: {
			// typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects.
			// see: https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
			'no-undef': 'off',
			'unicorn/better-regex': 'warn',
			'unicorn/filename-case': 'off',
			'unicorn/prevent-abbreviations': 'off',
			'unicorn/relative-url-style': 'off',
			'svelte/require-each-key': 'off',
			// We're using tailwind so basically none of our css classes will have a style defined locally
			'svelte/no-unused-class-name': 'off',
			'svelte/block-lang': [
				'error',
				{
					enforceScriptPresent: true,
					enforceStylePresent: false,
					script: ['ts'] // a list of languages or null to signify no language specified
				}
			],
      'svelte/sort-attributes': 'off',
      'svelte/no-navigation-without-base': 'off',
     // 'svelte/no-at-html-tags': 'warn',
		}
	},
	{
		files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],

		languageOptions: {
			parserOptions: {
				projectService: true,
				extraFileExtensions: ['.svelte'],
				parser: ts.parser,
				svelteConfig
			}
		}
	}
);

Right now when using the template syntax to put urls into a tags, the warning is added even if the type of the variable is a union consisting solely of external urls.

What did you expect to happen?

No warning to be thrown since all the possibilities are external links

What actually happened?

The warning is thrown regardless, meaning I have to put ignores in several places scattered across the code base

Link to GitHub Repo with Minimal Reproducible Example

Unfortunately in a private repo at the moment, this example is self contained though.

<script lang="ts">
    type testUrls = "https://google.com"  | "https://bing.com";
    const testUrlsList: testUrls[] = ["https://google.com", "https://bing.com"];
</script>

{each testUrlsList as url}
    <a href={url}>A random phrase</a>
{/each}

Additional comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions