eslint-community / eslint-plugin-eslint-comments

Additional ESLint rules for directive comments of ESLint.
https://eslint-community.github.io/eslint-plugin-eslint-comments
MIT License
44 stars 6 forks source link

Export flat config plugin for standalone use #215

Open Zamiell opened 2 months ago

Zamiell commented 2 months ago

The getting started page shows how to import the recommended config into a flat config. But I don't want to use the recommended config. I just want to import the plugin and then choose for myself what rules to turn on. The documentation does not cover this. Is this possible?

I did some digging and it looks like the index.js file does not even export the plugin (??), so I am very confused.

voxpelli commented 1 month ago

Agree. The plugin itself should also be exported, which it isn't today: https://github.com/eslint-community/eslint-plugin-eslint-comments/blob/main/configs.js

Zamiell commented 1 month ago

For now, VoxPelli helped me work around the issue with this code:

// @ts-expect-error https://github.com/eslint-community/eslint-plugin-eslint-comments/issues/214
import ESLintPluginESLintCommentsConfigs from "@eslint-community/eslint-plugin-eslint-comments/configs";
import tseslint from "typescript-eslint";

// The plugin is not currently exported from the root, so we have to get the plugin from the config.
// https://github.com/eslint-community/eslint-plugin-eslint-comments/issues/215
const ESLintPluginESLintComments =
  ESLintPluginESLintCommentsConfigs.recommended.plugins[
    "@eslint-community/eslint-comments"
  ];

export const configFoo = tseslint.config({
  plugins: {
    "@eslint-community/eslint-comments": ESLintPluginESLintComments,
  },
});

But this is really confusing and weird so hopefully it is exported from the root in the next version of the plugin.