-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[Bug]: The latest version is giving a ESLint error (No default export found in imported module) #3837
Comments
cc @voxpelli |
I kind of object to the phrasing of this issue title. It does not cause an ESLint error. It fails the So anyone that doesn't use that rule is not affected, right? That limits the scope and urgency a lot |
From the description of the
Not sure why it got triggered now and didn't trigger before though. The types are generated by TypeScript and I see no issues when consuming it through TypeScript, so this seems like an incorrect error? Or are you having actual issues with the types? |
Replacing the module.exports = Object.assign(plugin, {
configs: Object.assign(plugin.configs, {
flat,
}),
}); I'm not able to spend more time on this right now though. I have to focus fully on a freelance project. An alternative strategy could be to just not publish the exact details on any of the types and simply publish a type like what import type {ESLint, Linter} from 'eslint';
declare const eslintPluginUnicorn: ESLint.Plugin & {
configs: {
recommended: Linter.Config;
all: Linter.Config;
'flat/all': Linter.FlatConfig;
'flat/recommended': Linter.FlatConfig;
};
};
export = eslintPluginUnicorn; @ljharb I would be okay with either solution. Thinking about it some more the Maintaining and testing ten lines of code is easier than an autogenerated type setup by an outdated typescript. But now you know the autogenerated one is an alternative and the benefit of the source maps with that approach at least 🙈 |
#3838 might be related/duplicate |
It'd be great if someone could take a look at the types that https://github.com/jsx-eslint/eslint-plugin-react/tree/types generates (you'll have to clone it) and confirm if that solves the issues discussed here. |
Is there an existing issue for this?
Description Overview
Hi team!
First, thanks a lot for the hard work on this library.
The latest version of
eslint-plugin-react
includes the types for the project, but unfortunately, the types seem to be incorrect.We're using the plugin
eslint-plugin-import-x
, which we're also using to validate our ESLint configuration, and this plugin is giving us the following error:The complete output:
The error occurs on the following line:
I then tried to use a named export instead of the default export, as the ESLint rule suggests, but this doesn't seem to work as I'm getting the following error:
The JavaScript is using a
module.exports
statement, as shown here:https://github.com/jsx-eslint/eslint-plugin-react/blob/master/index.js#L109
However, the
index.d.ts
exports a singleconfigs
namespace that doesn't reflect the code specified in theindex.js
-file. You can see this by inspecting theindex.d.ts
file on npmjs.comhttps://www.npmjs.com/package/eslint-plugin-react?activeTab=code
Expected Behavior
I'd expect that the TypeScript types reflect the
module.exports
statement of theindex.js
file 1:1eslint-plugin-react version
v7.37.1
eslint version
v9.11.1
node version
v20.17.0
The text was updated successfully, but these errors were encountered: