flat config doesn't work using re-export custom module #978
Replies: 2 comments
|
What version of the plugin are you using? |
0 replies
|
I think the issue is the shallow merge here: {
files: ["**/test/**/*.test.{ts,tsx}"],
...testingLibrary.configs["flat/react"],
...jestdom.configs["flat/recommended"],
}Both flat configs define top-level keys like Use separate config objects instead: export default tseslint.config(
{ ignores: ["dist"] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ["**/*.{ts,tsx}"],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
"react-hooks": reactHooks,
"react-refresh": reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
},
},
{
files: ["**/test/**/*.test.{ts,tsx}"],
...testingLibrary.configs["flat/react"],
},
{
files: ["**/test/**/*.test.{ts,tsx}"],
...jestdom.configs["flat/recommended"],
},
eslintConfigPrettier,
);If you really want one object, you need to deep-merge const testingLibraryReact = testingLibrary.configs["flat/react"];
const jestDomRecommended = jestdom.configs["flat/recommended"];
{
files: ["**/test/**/*.test.{ts,tsx}"],
plugins: {
...testingLibraryReact.plugins,
...jestDomRecommended.plugins,
},
rules: {
...testingLibraryReact.rules,
...jestDomRecommended.rules,
},
}I would prefer the separate-config-object version because it follows the way flat config composition is intended to work and avoids accidentally dropping nested config keys. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
pnpm exec npx eslint --print-config ./src/test/unit/app.test.tsxresult:All reactions