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

Add Eslint Flat-File support for ReDos Eslint plugin #1293

Open
ThomasTrepanier opened this issue Jul 5, 2024 · 1 comment
Open

Add Eslint Flat-File support for ReDos Eslint plugin #1293

ThomasTrepanier opened this issue Jul 5, 2024 · 1 comment

Comments

@ThomasTrepanier
Copy link

ThomasTrepanier commented Jul 5, 2024

What is the problem?

Since [email protected], eslint now support a new type of configuration file: the flat-file format.

When migrating our config files to this new format, we realized that the ReDos eslint plugin does not yet support this new file format.
More specifically, the rules attribute now has to be a JS object instead of an array of strings (see error below).

A config object has a "plugins" key defined as an array of strings.

Flat config requires "plugins" to be an object in this form:

    {
        plugins: {
            redos: pluginObject
        }
    }

Would you be able to add support for this file format?

How to fix the problem?

eslint released a migration guide for eslint plugins to add support for flat-file configs

@ThomasTrepanier
Copy link
Author

ThomasTrepanier commented Jul 5, 2024

For anyone stumbling upon this problem, until flat-file config support is added, you can use the ReDos plugin in your flat-file config like this:

import { FlatCompat } from "@eslint/eslintrc";

const compat = new FlatCompat({
  baseDirectory: import.meta.dirname,
});

const esConfigs = [
  // Rest of your config
  ...compat.extends("plugin:eslint-plugin-redos/recommended"),
  // Rest of your config
]

Source: https://eslint.org/docs/latest/use/configure/migration-guide#using-eslintrc-configs-in-flat-config

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

No branches or pull requests

1 participant