uhyo / eslint-plugin-import-access

https://www.npmjs.com/package/eslint-plugin-import-access
MIT License
346 stars 10 forks source link

Flat config fails typescript type check #49

Closed sergei-dyshel closed 1 week ago

sergei-dyshel commented 1 month ago

pluugin version: 2.2.1 eslint version: 8.57.0

I'm using the following config

// @ts-check

import eslintPluginImportAccess from 'eslint-plugin-import-access/flat-config';
import tseslint from 'typescript-eslint';

const warn = 'warn';

export default tseslint.config({
  plugins: {
    'import-access': eslintPluginImportAccess,
    ^^^^^^^^^^^^^^^
  },
  rules: {
    'import-access/jsdoc': [warn],
  },
});

And getting the following error from tsc:

Type '{ rules: { jsdoc: unknown; }; }' is not assignable to type 'Omit<Plugin, "configs">'.
  Types of property 'rules' are incompatible.
    Type '{ jsdoc: unknown; }' is not assignable to type 'Record<string, LooseRuleDefinition>'.
      Property 'jsdoc' is incompatible with index signature.
        Type 'unknown' is not assignable to type 'LooseRuleDefinition'.

looks like the rule mistakingly has unknown type and TS complains abot it:

/**
 * ESLint Plugin object of eslint-plugin-import-access.
 */
declare const eslintPlugin: {
    rules: {
        jsdoc: unknown;
    };
};
export = eslintPlugin;
uhyo commented 1 week ago

Hello, sorry for taking a month or this. 😢 It should be fixed in v2.2.2.