gajus / eslint-plugin-canonical

ESLint rules for Canonical ruleset.
Other
121 stars 7 forks source link

ESlint 9 and flat config compatibility #37

Closed rzschoch closed 3 weeks ago

rzschoch commented 4 weeks ago

I would like to use the plugin with ESlint 9. To achieve this, the configuration must be written in flat config format. My attempts to get the plugin to work have unfortunately failed.

Is it officially compatible with ESlint 9 and the flat config? Would it be possible to provide an example of the configuration in this format?

gajus commented 3 weeks ago

It is being used in https://github.com/gajus/eslint-config-canonical, so you can use that as a reference.

FruityLeo commented 1 week ago

I have the same problem.

Thanks for the link, unfortunately I still have no idea how to adjust the configuration. Would you also have a practical example for me or help me out?

I am trying to use the "no-unused-exports" rule.

I tried the following in my eslint.config.js:

const canonical = require("eslint-plugin-canonical");

module.exports = tseslint.config(
  {
    plugins: {
      canoncial,
    },
    extends: [
      ... // only other rule sets
    ],
    rules: {
      "canonical/no-unused-exports": "error",
    }
  }
);

But I get the following error (even when I only add the require statement at the top):

An unhandled exception occurred: Cannot find module 'doctrine'
Require stack:
- /Users/project/node_modules/eslint-plugin-canonical/dist/src/rules/ExportMap.js
- /Users/project/node_modules/eslint-plugin-canonical/dist/src/rules/noBarrelImport.js
- /Users/project/node_modules/eslint-plugin-canonical/dist/src/index.js
- /Users/project/eslint.config.js
See ".../angular-errors.log" for further details.

Additionally, I wonder if an updated documentation for the flat configuration is useful for other users in the future?