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

Error using flat config #989

Closed
fractionalJoe opened this issue Feb 26, 2023 · 6 comments · Fixed by #993
Closed

Error using flat config #989

fractionalJoe opened this issue Feb 26, 2023 · 6 comments · Fixed by #993

Comments

@fractionalJoe
Copy link

Expected behavior

Enforce the check-access rule. Same issue occurs for any rule I've tried, not just check-access. This is just an example.

Actual behavior

Throws this exception:

> eslint .


Oops! Something went wrong! :(

ESLint: 8.35.0

TypeError: Error while loading rule 'jsdoc/check-access': Cannot read properties of undefined (reading 'includes')
Occurred while linting /home/joe/repos/ndevr.core/packages/eslint.config.js
    at getSettings (/home/joe/repos/ndevr.core/node_modules/.pnpm/eslint-plugin-jsdoc@40.0.0_eslint@8.35.0/node_modules/eslint-plugin-jsdoc/dist/iterateJsdoc.js:678:174)
    at Object.create (/home/joe/repos/ndevr.core/node_modules/.pnpm/eslint-plugin-jsdoc@40.0.0_eslint@8.35.0/node_modules/eslint-plugin-jsdoc/dist/iterateJsdoc.js:906:18)
    at createRuleListeners (/home/joe/repos/ndevr.core/node_modules/.pnpm/eslint@8.35.0/node_modules/eslint/lib/linter/linter.js:926:21)
    at /home/joe/repos/ndevr.core/node_modules/.pnpm/eslint@8.35.0/node_modules/eslint/lib/linter/linter.js:1108:110
    at Array.forEach (<anonymous>)
    at runRules (/home/joe/repos/ndevr.core/node_modules/.pnpm/eslint@8.35.0/node_modules/eslint/lib/linter/linter.js:1045:34)
    at Linter._verifyWithFlatConfigArrayAndWithoutProcessors (/home/joe/repos/ndevr.core/node_modules/.pnpm/eslint@8.35.0/node_modules/eslint/lib/linter/linter.js:1696:31)
    at Linter._verifyWithFlatConfigArray (/home/joe/repos/ndevr.core/node_modules/.pnpm/eslint@8.35.0/node_modules/eslint/lib/linter/linter.js:1825:21)
    at Linter.verify (/home/joe/repos/ndevr.core/node_modules/.pnpm/eslint@8.35.0/node_modules/eslint/lib/linter/linter.js:1475:65)
    at Linter.verifyAndFix (/home/joe/repos/ndevr.core/node_modules/.pnpm/eslint@8.35.0/node_modules/eslint/lib/linter/linter.js:2031:29)
/home/joe/repos/ndevr.core/packages:
 ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  ndevr.core.packages@ lint: `eslint .`
Exit status 2
 ELIFECYCLE  Command failed with exit code 1.

ESLint Config

// eslint.config.js New Flat Config
import ts from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
import jsdoc from "eslint-plugin-jsdoc";

export default [
  {
    files: [
      "**/*.ts",
      "**/*.js",
    ],
    ignores: [
      "**/build/**",
    ],
    languageOptions: {
      parser: tsParser,
      parserOptions: {
        ecmaVersion: 2020,
        sourceType: "module",
      },
    },
    plugins: {
      "@typescript-eslint": ts,
      jsdoc
    },
    rules: {
      "jsdoc/check-access": 1,
    },
  },
];

ESLint sample

/**
 * Strip all non-word characters out of string
 * @param {string} value The string value to be stripped
 * @returns {string} Stripped value
 */
const stripString = function(value: string): string {
  return value.replace(/(^\w)/, "");
};

Environment

  • Node version: 18.14.2
  • ESLint version 8.35.0
  • eslint-plugin-jsdoc version: 40.0.0
@brettz9
Copy link
Collaborator

brettz9 commented Mar 1, 2023

Since we can't get at the parserPath (per eslint/eslint#16878 ) (and since context.languageOptions?.parser doesn't currently have a property to expose the parser name), we are unable to auto-detect the name of the parser (e.g., as being @typescript-eslint/parser) and auto-entering our own TypeScript mode when flat config is used.

I could fix the immediate error, but we'll want to see about whether @typescript-eslint/parser is willing to add a name property to their parser so we could really get things working without the user needing to manually set settings.jsdoc.mode.

@brettz9 brettz9 changed the title Error while loading rule 'jsdoc/.....': Cannot read properties of undefined (reading 'includes') Error using flat config Mar 1, 2023
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Mar 2, 2023
Also:
- chore: update lock file
brettz9 added a commit that referenced this issue Mar 2, 2023
Also:
- chore: update lock file
@brettz9
Copy link
Collaborator

brettz9 commented Mar 10, 2023

Blocked by typescript-eslint/typescript-eslint#6541

@somebody1234
Copy link

@brettz9 looks like should now be available in v5.55.0?

@github-actions
Copy link

🎉 This issue has been resolved in version 40.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@brettz9
Copy link
Collaborator

brettz9 commented Mar 14, 2023

The latest eslint-plugin-jsdoc should now be ok with @typescript-eslint/parser v5.55.0+ and eslint v8.36.0.

@fractionalJoe
Copy link
Author

Thanks!

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