ember-cli / eslint-plugin-ember

An ESLint plugin that provides set of rules for Ember applications based on commonly known good practices.
MIT License
262 stars 204 forks source link

Issues with the "flat" config exports #2190

Closed Windvis closed 1 week ago

Windvis commented 2 weeks ago

I was trying out the new eslint v9 setup (https://github.com/ember-cli/ember-cli/pull/10516) in our app, but I ran into some issues and one of the issues is related to the "flat" recommended config exports.

Since they are exported as arrays, they don't work as expected when used as in that PR. The example in the readme also doesn't work as intended.

I've been able to work around the issues by flattening the exported array and then spreading the .rules prop where needed.

(I'll try to add more details later, just creating a new issue before I forget)

NullVoxPopuli commented 2 weeks ago

I think we should add a `import { gjs, gts } from 'eslint-plugin-ember/configs';

where gjs is this object:

{
    plugins: { ember: plugin },
    files: ['**/*.gjs'],
    languageOptions: {
      parser: emberEslintParser,
    },
    processor: 'ember/noop',
    rules: gjsRules,
}

and gts is this object:

{
    plugins: { ember: plugin },
    files: ['**/*.gts'],
    languageOptions: {
      parser: emberEslintParser,
    },
    processor: 'ember/noop',
    rules: gtsRules,
}

that way folks can chose to do something like:

import { gjs, gts } from 'eslint-plugin-ember/configs';

export default [
  gjs,
  gts,
  {
    files: ['**/*.{js,gjs}'],
    /* ... */
    rules: {
      ...etc,
      ...gjs.rules,
    }
  },
  {
    files: ['**/*.{js,gjs}'],
    /* ... */
    rules: {
      ...etc,
      ...gts.rules,
    }
  }
]
NullVoxPopuli commented 1 week ago

I opened #2191 to help out here