-
-
Notifications
You must be signed in to change notification settings - Fork 53
fix: eslint config error when using defineConfig #228
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
Conversation
Using the changed config import { defineConfig } from "eslint/config";
import pluginJs from "@eslint/js";
import pluginNode from "eslint-plugin-n";
import eslintPlugin from "eslint-plugin-eslint-plugin";
export default defineConfig([
{
name: "eslint/js",
plugins: {
js: pluginJs,
},
extends: ["js/recommended"],
},
{
name: "eslint/node",
plugins: {
n: pluginNode,
},
extends: ["n/flat/mixed-esm-and-cjs"],
},
{
name: "eslint/eslint-plugin",
plugins: {
"eslint-plugin": eslintPlugin,
},
extends: ["eslint-plugin/recommended"],
}
]); I'm getting a different error message from
Do you see this as well, or is it working for you? |
Yes, I noticed that, too. I will investigate. |
Both can solve the issue. 😂 |
16b8b3f
to
344bae9
Compare
Thanks for your actions! 👍🏻 This was much more complicated than I could understand and fix on my own! |
fixes #227 1. The `mixed-esm-and-cjs` configuration does not exist the eslintrc version, and config-helper does not seem to handle this scenario well. 2. use `eslint-plugin/flat/recommended`, as `recommended`is eslintrc-style.
344bae9
to
5ba95a0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I successfully ran https://github.com/eslint/generator-eslint/blob/aladdin-add-patch-2/plugin/templates/_eslint.config.mjs locally with npm run lint:js
, so that looks good to go!
Thank you very much!
extends: ["n/mixed-esm-and-cjs"], | ||
extends: ["n/flat/mixed-esm-and-cjs"], | ||
}, | ||
{ | ||
name: "eslint/eslint-plugin", | ||
plugins: { | ||
"eslint-plugin": eslintPlugin, | ||
}, | ||
extends: ["eslint-plugin/recommended"], | ||
extends: ["eslint-plugin/flat/recommended"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change necessary if eslint/rewrite#288 is accepted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it's necessary, that pr is only fixing the eslint-plugin-n
issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the cause is defineConfig()
simply check whether the property exists rather than determining its type to verify if it conforms to the eslintrc format:
https://github.com/eslint/rewrite/blob/4334e769be7cfe5b515d64058176571aab18ea5c/packages/config-helpers/src/define-config.js#L76-L84
const config = {plugins: ["eslint-plugin"]};
the config will be treated as flat config, while actually it's eslintrc format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see, both config formats have a plugins
property, but of different type. Maybe that could be another improvement in addition to eslint/rewrite#288. Either way, since there are multiple issues, I agree with this fix (even if it's temporary) in generator-eslint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Would like @mdjermanovic to verify before merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Prerequisites checklist
What is the purpose of this pull request?
when running
npx eslint .
, it output the errors:fixes #227
What changes did you make? (Give an overview)
Related Issues
Is there anything you'd like reviewers to focus on?
this is wrongly seen as flat config; we might need to fix it in
@eslint/config-helper
.