gajus / eslint-config-canonical

The most comprehensive ES code style guide.
Other
598 stars 30 forks source link

Support "Flat Config" (ESLint 9) #80

Closed JoshuaKGoldberg closed 5 months ago

JoshuaKGoldberg commented 8 months ago

👋 Coming over from https://github.com/eslint/eslint/issues/18093: ESLint is migrating to a new "flat config" format that will be the default in ESLint v9.

It doesn't look like eslint-config-canonical has support yet. Just for fun, I tried it out in a repository with the new eslint.config.js:

// eslint.config.js

import eslint from "@eslint/js";
import canonical from "eslint-config-canonical";

export default [eslint.configs.recommended, canonical];

...and got an error from @rushstack/eslint-patch (https://github.com/microsoft/rushstack/issues/4372):

$ npx eslint .
Error: Failed to patch ESLint because the calling module was not recognized.
If you are using a newer ESLint version that may be unsupported, please create a GitHub issue:
https://github.com/microsoft/rushstack/issues
    at Object.<anonymous> (/Users/josh/repos/repros/node_modules/@rushstack/eslint-patch/lib/_patch-base.js:166:19)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (/Users/josh/repos/repros/node_modules/@rushstack/eslint-patch/lib/modern-module-resolution.js:11:23)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)

Does that mean eslint-config-canonical is blocked on https://github.com/microsoft/rushstack/issues/4372 for supporting flat config?

I'm posting this issue here as a reference & cross-linking it to the table in https://github.com/eslint/eslint/issues/18093. If there's anything blocking the extension from supporting flat configs, please let us know - we'd be happy to try to help! 💜

Additional resources:

gajus commented 8 months ago

Pretty sure @rushstack/eslint-patch will need to be removed in order to support flat config.

gajus commented 5 months ago

Canonical now supports v9

Razunter commented 5 months ago

I think README has a bug:

export default [
  auto
];

Should be

export default [
  ...auto
];
gajus commented 5 months ago

Yeah, README is still WIP, and so is the API. Learning new tips and tricks as I am rolling it out to the projects that I work with.

Should be stable by the end of the day.