43081j / eslint-plugin-lit

lit-html support for ESLint
115 stars 20 forks source link

Flat config support & improvements for `d.ts` #194

Closed what1s1ove closed 3 months ago

what1s1ove commented 4 months ago

Hey guys! First of all, thank you for such a cool plugin!

Since ESLint 9 is soon to be released, are there any plans to add a Flat config and, equally importantly, improve the d.ts files of the plugin?

eslint.config.js:17:3 - error TS2322: Type 'typeof import("node_modules/eslint-plugin-lit/lib/index")' is not assignable to type 'Plugin'.
  Types of property 'configs' are incompatible.
    Type '{ all: { plugins: string[]; rules: { 'lit/attribute-value-entities': string; 'lit/binding-positions': string; 'lit/lifecycle-super': string; 'lit/no-duplicate-template-bindings': string; 'lit/no-invalid-escape-sequences': string; ... 15 more ...; 'lit/value-after-constraints': string; }; }; recommended: { ...; }; }' is not assignable to type 'Record<string, FlatConfig | ConfigData<RulesRecord> | FlatConfig[]>'.
      Property 'all' is incompatible with index signature.
        Type '{ plugins: string[]; rules: { 'lit/attribute-value-entities': string; 'lit/binding-positions': string; 'lit/lifecycle-super': string; 'lit/no-duplicate-template-bindings': string; 'lit/no-invalid-escape-sequences': string; ... 15 more ...; 'lit/value-after-constraints': string; }; }' is not assignable to type 'FlatConfig | ConfigData<RulesRecord> | FlatConfig[]'.
          Type '{ plugins: string[]; rules: { 'lit/attribute-value-entities': string; 'lit/binding-positions': string; 'lit/lifecycle-super': string; 'lit/no-duplicate-template-bindings': string; 'lit/no-invalid-escape-sequences': string; ... 15 more ...; 'lit/value-after-constraints': string; }; }' is not assignable to type 'ConfigData<RulesRecord>'.
            Types of property 'rules' are incompatible.
              Type '{ 'lit/attribute-value-entities': string; 'lit/binding-positions': string; 'lit/lifecycle-super': string; 'lit/no-duplicate-template-bindings': string; 'lit/no-invalid-escape-sequences': string; ... 15 more ...; 'lit/value-after-constraints': string; }' is not assignable to type 'Partial<RulesRecord>'.
                Property ''lit/attribute-value-entities'' is incompatible with index signature.
                  Type 'string' is not assignable to type 'RuleEntry<any[]> | undefined'.

17   lit,
     ~~~

eslint.config.js:19:2 - error TS2322: Type '{ 'lit/attribute-value-entities': string; 'lit/binding-positions': string; 'lit/lifecycle-super': string; 'lit/no-duplicate-template-bindings': string; 'lit/no-invalid-escape-sequences': string; ... 15 more ...; 'lit/value-after-constraints': string; }' is not assignable to type 'RulesRecord'.
  Property ''lit/attribute-value-entities'' is incompatible with index signature.
    Type 'string' is not assignable to type 'RuleEntry<any[]>'.

19  rules: lit.configs.all.rules,
    ~~~~~

  ../../node_modules/@types/eslint/index.d.ts:1116:9
    1116         rules?: RulesRecord;
                 ~~~~~
    The expected type comes from property 'rules' which is declared here on type 'FlatConfig'
43081j commented 4 months ago

would love to add support for flat config, just haven't had chance yet to fully understand how to have "dual" support (i.e. support flag config and rc files)

ill ask around but i think we would need to have two exported config sets

a flat config needs the plugin as a reference afaik, while an rc config needs it as a string

what1s1ove commented 4 months ago

would love to add support for flat config, just haven't had chance yet to fully understand how to have "dual" support (i.e. support flag config and rc files)

ill ask around but i think we would need to have two exported config sets

a flat config needs the plugin as a reference afaik, while an rc config needs it as a string

Recently, several plugins have migrated to similar support. You might find it interesting to take a look.

By the way, here in the issue of my personal project https://github.com/what1s1ove/whatislove.dev/issues/270 where I track the migration progress of my favorite plugins. You can find issues of some other well-known plugins that are in the process of migration.