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

import-x/no-default-export does not work in typescript #144

Closed
M-51 opened this issue Aug 31, 2024 · 4 comments · Fixed by #181 or #182
Closed

import-x/no-default-export does not work in typescript #144

M-51 opened this issue Aug 31, 2024 · 4 comments · Fixed by #181 or #182

Comments

@M-51
Copy link

M-51 commented Aug 31, 2024

Lets say we have simple (flat) config file eslint.config.js with only one rule 'import-x/no-default-export': 'error',

import eslintPluginImportX from 'eslint-plugin-import-x'
import tsParser from '@typescript-eslint/parser'

export default [
    {
        files: ['**/*.js'],
        languageOptions: {
            ecmaVersion: 'latest',
            sourceType: 'module',
        },
        plugins: {
            'import-x': eslintPluginImportX,
        },
        ignores: ['eslint.config.js'],
        rules: {
            'import-x/no-default-export': 'error',
        },
    },
    {
        files: ['**/*.ts'],
        languageOptions: {
            parser: tsParser,
            ecmaVersion: 'latest',
            sourceType: 'module',
        },
        plugins: {
            'import-x': eslintPluginImportX,
        },
        rules: {
            'import-x/no-default-export': 'error',
        },
        settings: {
            'import-x/resolver': {
                typescript: true,
            },
        },
    },
];

and two files with identical content:

foo.js foo.ts
function foo() {
return 'foo';
}

export default foo;
function foo() {
return 'foo';
}

export default foo;

eslint shows correctly 'import-x/no-default-export': 'error' in foo.js file
js

while in foo.ts it shows nothing:
ts

Here is a repo with replicated problem https://github.com/M-51/default-export-bug


Worth mentioning, other rules, for example opposite rule - import-x/prefer-default-export works correctly (when added) in the same environment in both JavaScript and Typescript.
named
So it seems, it is only problem with import-x/no-default-export'

@hellpirat
Copy link

hellpirat commented Oct 1, 2024

Yeah I got the same error. no-default-export does not work in my project as well but import-x/prefer-default-export works correctly

@jleider
Copy link

jleider commented Oct 2, 2024

Just ran into this issue yesterday as well after converting from the forked import plugin to import-x.

@SukkaW
Copy link
Collaborator

SukkaW commented Nov 11, 2024

@hellpirat @jleider @M-51

I am to re-produce the issue w/ the minimum re-production, but I can't re-produce within the unit test cases.

@SukkaW SukkaW added help wanted Extra attention is needed and removed help wanted Extra attention is needed labels Nov 11, 2024
@SukkaW
Copy link
Collaborator

SukkaW commented Nov 11, 2024

Update: I have located the issue, I will create a PR to fix this.

SukkaW added a commit to SukkaW/eslint-plugin-import-x that referenced this issue Nov 11, 2024
renovate bot added a commit to mmkal/eslint-plugin-mmkal that referenced this issue Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants