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

usage in eslint flat config #13

Open
mesqueeb opened this issue May 2, 2024 · 5 comments
Open

usage in eslint flat config #13

mesqueeb opened this issue May 2, 2024 · 5 comments

Comments

@mesqueeb
Copy link

mesqueeb commented May 2, 2024

how to use it in the new eslint flat config

@electrovir
Copy link

It appears to not even be importable because it is built in CommonJS. I get No "exports" main defined errors when trying to import anything from this package into an ESLint v9 flat config.

@guoh27
Copy link

guoh27 commented Jun 19, 2024

+1

@electrovir
Copy link

electrovir commented Jul 21, 2024

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

Specifically, do this:

import {fileURLToPath} from 'node:url';
import {FlatCompat} from '@eslint/eslintrc';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const compat = new FlatCompat({
    baseDirectory: __dirname,
});

// ESM config export
export default [
    ...compat.plugins('require-extensions'),
    ...compat.extends('plugin:require-extensions/recommended'),
    // rest of your config
]

@SeanMcMillan
Copy link

The new @eslint/compat tool that's supposed to help migrate your .eslintrc incorrectly migrates this plugin, because it can't be imported.

You can still use compat.plugins, but you'll need to remove the import and fixupPluginRules call that is generated.

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

5 participants