Skip to content

Bug: TypeError when using defineConfig with recommended preset #175

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

Closed
andrew-pledge-io opened this issue Apr 16, 2025 · 3 comments
Closed
Labels

Comments

@andrew-pledge-io
Copy link

andrew-pledge-io commented Apr 16, 2025

What version of eslint-plugin-security are you using?

3.0.1

ESLint Environment

Node version: v22.14.0
npm version: 10.9.2
Local ESLint version: v9.23.0
Global ESLint version: N/A
Operating System: MacOS

What did you do?

Using the recommended config as an element in defineConfig causes the following TypeScript error:

Type 'FlatConfig' is not assignable to type 'InfiniteArray<ConfigWithExtends>'.

Using the recommended config as an element in extends causes the following TypeScript error:

Type 'FlatConfig' is not assignable to type 'ExtendsElement'.

Config:

// @ts-check

import { defineConfig } from 'eslint/config';
import pluginSecurity from 'eslint-plugin-security';

export default defineConfig([
  pluginSecurity.configs.recommended,
  {
    extends: [
      pluginSecurity.configs.recommended,
    ],
  }
]);
@nzakas
Copy link
Contributor

nzakas commented Apr 16, 2025

Thanks for the report. I think this is just because this plugin is referencing an older version of ESLint.

@nzakas
Copy link
Contributor

nzakas commented Apr 16, 2025

I'm having some trouble reproducing this. Can you please create a repro case on StackBlitz?

@andrew-pledge-io
Copy link
Author

Thanks for taking the time to look into it.

After digging in I've narrowed down the issue to my environment, so I'll close this.

The problem was that TypeScript was referencing global versions of @types/eslint-plugin-security and @types/eslint that had incorrect/mismatching versions (on MacOS these were installed at /Users/<user>/Library/Caches/typescript/5.8/node_modules/@types/eslint/index.d.ts)

I assume VSCode did this instead of just erroring since eslint.config.mjs isn't included in the TypeScript project in tsconfig.json but that's just a guess.

The fix was to install @types/eslint-plugin-security in my project which caused the correct versions of the types to be used.

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

No branches or pull requests

2 participants