Skip to content
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

no-duplicates false positive without prefer-inline #167

Closed
hyoban opened this issue Oct 12, 2024 · 1 comment · Fixed by #168 or #172
Closed

no-duplicates false positive without prefer-inline #167

hyoban opened this issue Oct 12, 2024 · 1 comment · Fixed by #168 or #172

Comments

@hyoban
Copy link

hyoban commented Oct 12, 2024

import type * as React from "react"
import type { JSX, PropsWithChildren, ReactNode } from "react"
@hyoban hyoban closed this as not planned Won't fix, can't repro, duplicate, stale Oct 12, 2024
@hyoban hyoban changed the title no-duplicates false positive no-duplicates false positive without prefer-inline Oct 12, 2024
@hyoban hyoban reopened this Oct 12, 2024
@ocavue
Copy link

ocavue commented Oct 13, 2024

Another example:

Given the following file:

// test.ts

import { onMount } from 'svelte';
import { readable, type Readable } from 'svelte/store';

export function main() {
	console.log(onMount);
	console.log(readable);
	let variable: Readable<number> | number = 1;
	variable = 2;
	console.log(variable);
}

and the following config:

import * as importPlugin from 'eslint-plugin-import-x';
import tseslint from 'typescript-eslint';

const config = [
	{
		files: ['test.ts'],
		plugins: { import: importPlugin },
		settings: { 'import-x/resolver': { typescript: true, node: true } },
		rules: {
			'import/no-duplicates': ['warn', { 'prefer-inline': true }]
		}
	}
];

export default tseslint.config(...tseslint.configs.recommended, ...config);

Running eslint --fix test.ts will produce the follow incorrect file:

import { onMount , readable, type Readable } from 'svelte';
...

Reproduction:

renovate bot added a commit to mmkal/eslint-plugin-mmkal that referenced this issue Oct 30, 2024
##### [v4.4.0](https://github.com/un-ts/eslint-plugin-import-x/blob/HEAD/CHANGELOG.md#440)

##### Minor Changes

-   [#169](un-ts/eslint-plugin-import-x#169) [`9c58269`](un-ts/eslint-plugin-import-x@9c58269) Thanks [@teidesu](https://github.com/teidesu)! - Add new rule option `checkTypedImports` for `extensions`, backports import-js/eslint-plugin-import#2817

##### Patch Changes

-   [#171](un-ts/eslint-plugin-import-x#171) [`9715220`](un-ts/eslint-plugin-import-x@9715220) Thanks [@SukkaW](https://github.com/SukkaW)! - Perf: avoid regexp during parser choosing

-   [#171](un-ts/eslint-plugin-import-x#171) [`9715220`](un-ts/eslint-plugin-import-x@9715220) Thanks [@SukkaW](https://github.com/SukkaW)! - Add extra guard for rule `no-named-as-default`. A few guards are borrowed from import-js/eslint-plugin-import#3032, but we don't sync the rest of changes from upstream since we have already implemented a way more performant check.

-   [#171](un-ts/eslint-plugin-import-x#171) [`9715220`](un-ts/eslint-plugin-import-x@9715220) Thanks [@SukkaW](https://github.com/SukkaW)! - More test cases for `no-named-export` and `no-defualt-export` rule specifically with non-module `sourceType`

-   [#171](un-ts/eslint-plugin-import-x#171) [`9715220`](un-ts/eslint-plugin-import-x@9715220) Thanks [@SukkaW](https://github.com/SukkaW)! - Fix `export` when there is only one `TSDeclareFunction` (import-js/eslint-plugin-import#3065)

-   [#171](un-ts/eslint-plugin-import-x#171) [`9715220`](un-ts/eslint-plugin-import-x@9715220) Thanks [@SukkaW](https://github.com/SukkaW)! - Prevent `ExportMap`'s cache is being tainted by incompatible parser (e.g. old `babel-eslint`). The cache is now skipped w/ incompatible parsers, which might introduce performance impacts only for those who are using incompatible parsers. (import-js/eslint-plugin-import#3062)

-   [#171](un-ts/eslint-plugin-import-x#171) [`9715220`](un-ts/eslint-plugin-import-x@9715220) Thanks [@SukkaW](https://github.com/SukkaW)! - Docs: fix a few typos here and there

-   [#168](un-ts/eslint-plugin-import-x#168) [`5de039c`](un-ts/eslint-plugin-import-x@5de039c) Thanks [@hyoban](https://github.com/hyoban)! - Fixes un-ts/eslint-plugin-import-x#167, the `no-duplicates` rule now allows co-existing inline type imports and namespace imports.

-   [#171](un-ts/eslint-plugin-import-x#171) [`9715220`](un-ts/eslint-plugin-import-x@9715220) Thanks [@SukkaW](https://github.com/SukkaW)! - Properly fix espree parser w/ ESLint Flat Config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants