Open
Description
ESLint config
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";
import * as pluginImportX from "eslint-plugin-import-x";
import svelteConfig from "./svelte.config.js";
const gitignorePath = fileURLToPath(new URL("./.gitignore", import.meta.url));
export default ts.config(
includeIgnoreFile(gitignorePath),
js.configs.recommended,
...ts.configs.recommended,
...svelte.configs.recommended,
pluginImportX.flatConfigs.recommended,
{
languageOptions: {
globals: { ...globals.browser, ...globals.node },
},
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",
},
},
{
settings: {
"import-x/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx", ".mts", ".mjs"],
},
"import-x/resolver": {
typescript: true,
},
},
},
{
files: ["**/*.svelte", "**/*.svelte.ts", "**/*.svelte.js"],
languageOptions: {
parserOptions: {
projectService: true,
extraFileExtensions: [".svelte"],
parser: ts.parser,
svelteConfig,
},
},
}
);
Code:
<script lang="ts">
import { onMount } from "svelte";
import { fly } from 'svelte/transition'
</script>
Eslint output:
/Users/bohdan/Development/eslint-import-no-dup/src/routes/+page.svelte
2:12 error 'onMount' is defined but never used @typescript-eslint/no-unused-vars
2:27 warning '/Users/bohdan/Development/eslint-import-no-dup/node_modules/.pnpm/[email protected]/node_modules/svelte/types/index.d.ts' imported multiple times import-x/no-duplicates
3:12 error 'fly' is defined but never used @typescript-eslint/no-unused-vars
3:23 warning '/Users/bohdan/Development/eslint-import-no-dup/node_modules/.pnpm/[email protected]/node_modules/svelte/types/index.d.ts' imported multiple times import-x/no-duplicates
Eslint autofix rewrites the imports to just import { onMount, fly } from "svelte";
however, svelte package does not export fly
.
Is there any way to configure import-x
plugin to not resolve by types
for svelte and its subpackages?
Metadata
Metadata
Assignees
Labels
No labels