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

jsdoc/recommend error when using Flat Config #1131

Closed
snebjorn opened this issue Jul 7, 2023 · 4 comments · Fixed by #1147
Closed

jsdoc/recommend error when using Flat Config #1131

snebjorn opened this issue Jul 7, 2023 · 4 comments · Fixed by #1147

Comments

@snebjorn
Copy link

snebjorn commented Jul 7, 2023

Expected behavior

Recommended config works.

This is actually the official ESLint docs https://eslint.org/docs/latest/use/configure/configuration-files-new#using-configurations-included-in-plugins

Using configurations included in plugins

You can use a configuration included in a plugin by adding that configuration directly to the eslint.config.js configurations array. Often, you do this for a plugin’s recommended configuration. Here’s an example:

import jsdoc from "eslint-plugin-jsdoc";

export default [
    // configuration included in plugin
    jsdoc.configs.recommended,
    // other configuration objects...
    {
        files: ["**/*.js"],
        plugins: {
            jsdoc: jsdoc
        },
        rules: {
            "jsdoc/require-description": "warn",
        }
    }
];

Actual behavior

Oops! Something went wrong! :(

ESLint: 8.44.0

TypeError: Key "plugins": Key "0": Expected an object.
at Object.validate (myrepo\node_modules\eslint\lib\config\flat-config-schema.js:315:23)
at ObjectSchema.validate (myrepo\node_modules@humanwhocodes\object-schema\src\object-schema.js:218:35)
at myrepo\node_modules@humanwhocodes\object-schema\src\object-schema.js:171:18
at Array.reduce ()
at ObjectSchema.merge (myrepo\node_modules@humanwhocodes\object-schema\src\object-schema.js:169:24)
at myrepo\node_modules@humanwhocodes\config-array\api.js:916:42
at Array.reduce ()
at FlatConfigArray.getConfig (myrepo\node_modules@humanwhocodes\config-array\api.js:915:39)
at FlatConfigArray.isFileIgnored (myrepo\node_modules@humanwhocodes\config-array\api.js:943:15)
at myrepo\node_modules\eslint\lib\eslint\eslint-helpers.js:312:49

ESLint Config

Flat config

import jsdoc from "eslint-plugin-jsdoc";

export default [
  jsdoc.configs.recommended,
  // omitted...
];

ESLint sample

It's a problem with the config. So running eslint should trigger the error.

$ eslint .

Environment

  • Node version: v18.13.0
  • ESLint version v8.44.0
  • eslint-plugin-jsdoc version: 46.4.3

Workaround

I got it working using this workaround

import jsdoc from "eslint-plugin-jsdoc";

export default [
  {
    ...jsdoc.configs.recommended,
    plugins: {
      jsdoc,
    },
  },
  // omitted...
];
@kkmuffme
Copy link

kkmuffme commented Jul 15, 2023

Same for me.

Also reported in eslint to improve their error message for those case eslint/eslint#17369

@kkmuffme
Copy link

See eslint/eslint#17355

brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Aug 18, 2023
@brettz9
Copy link
Collaborator

brettz9 commented Aug 18, 2023

I've posted #1147 if anyone might take a look.

@github-actions
Copy link

🎉 This issue has been resolved in version 46.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants