eslint-config-algolia icon indicating copy to clipboard operation
eslint-config-algolia copied to clipboard

feat: introduce flat config

Open sbellone opened this issue 1 year ago • 0 comments

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:

  • plugins now moved at the top level
  • overrides is moved as an entry of the flat config

Changes

  • new flat configs in the flat/ dir
  • new eslint.config.js files
  • tests are run with both legacy and flat configs
  • new dependencies required: @eslint/js and global

Refs

  • env moved to languageOptions: 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
  • parser moved to languageOptions: https://eslint.org/docs/latest/use/configure/migration-guide#custom-parsers

SFCC-391

sbellone avatar Oct 02 '24 17:10 sbellone