feat: introduce flat config
Introduce flat configs (blog, doc), required to migrate to ESLint 9 (#342). Migration guide: https://eslint.org/docs/latest/use/configure/migration-guide
To keep our config compatible with legacy versions, I've created new configs in a separate flat/ directory.
You can see the new usage in the updated README or in the packages/test/eslint.config.js files:
// eslint.config.js
const algolia = require('eslint-config-algolia/flat/base');
module.exports = [
...algolia,
];
Notes
I've tried to keep changes minimal, configs in the flat/ dir are meant to be a simple port.
A lot of plugins already expose ways to work with flat configs, I simply followed their doc, for example:
- https://github.com/prettier/eslint-plugin-prettier?tab=readme-ov-file#configuration-new-eslintconfigjs
- https://github.com/jsx-eslint/eslint-plugin-react?tab=readme-ov-file#flat-configs
Only the import plugin is not fully compatible and I had to disable import/no-named-as-default for now.
I've been able to reuse the rules in rules/ by just deleting the deprecated properties:
pluginsnow moved at the top leveloverridesis moved as an entry of the flat config
Changes
- new flat configs in the
flat/dir - new
eslint.config.jsfiles - tests are run with both legacy and flat configs
- new dependencies required:
@eslint/jsandglobal
Refs
envmoved tolanguageOptions: https://eslint.org/docs/latest/use/configure/migration-guide#configuring-language-options- plugins: https://eslint.org/docs/latest/use/configure/migration-guide#importing-plugins-and-custom-parsers
parsermoved tolanguageOptions: https://eslint.org/docs/latest/use/configure/migration-guide#custom-parsers
SFCC-391