A-Shleifman / eslint-plugin-export-scope

Disallows importing scoped exports outside their scope
https://www.npmjs.com/package/eslint-plugin-export-scope
110 stars 0 forks source link

Not working with flat config #6

Closed sergei-dyshel closed 3 months ago

sergei-dyshel commented 4 months ago

I'm using the following eslint.config.mjs:

import eslintPluginExportScope from 'eslint-plugin-export-scope';
import tseslint from 'typescript-eslint';

export default tseslint.config({
  plugins: {
    'export-scope': eslintPluginExportScope,
  },
...

but getting runtime error when running eslint:

ESLint: 8.57.0

Error: Key "plugins": Key "export-scope": Expected an object.
    at ObjectSchema.validate (/local/home/sergei/workplace/sergei-js-workspace/src/SergeiJsAll/node_modules/@humanwhocodes/object-schema/src/object-schema.js:287:23)
    at /local/home/sergei/workplace/sergei-js-workspace/src/SergeiJsAll/node_modules/@humanwhocodes/object-schema/src/object-schema.js:239:18
    at Array.reduce (<anonymous>)
    at ObjectSchema.merge (/local/home/sergei/workplace/sergei-js-workspace/src/SergeiJsAll/node_modules/@humanwhocodes/object-schema/src/object-schema.js:237:24)
    at /local/home/sergei/workplace/sergei-js-workspace/src/SergeiJsAll/node_modules/@humanwhocodes/config-array/api.js:935:42
    at Array.reduce (<anonymous>)
    at FlatConfigArray.getConfig (/local/home/sergei/workplace/sergei-js-workspace/src/SergeiJsAll/node_modules/@humanwhocodes/config-array/api.js:934:39)
    at FlatConfigArray.isFileIgnored (/local/home/sergei/workplace/sergei-js-workspace/src/SergeiJsAll/node_modules/@humanwhocodes/config-array/api.js:962:15)
    at /local/home/sergei/workplace/sergei-js-workspace/src/SergeiJsAll/node_modules/eslint/lib/eslint/eslint-helpers.js:312:49
    at Array.reduce (<anonymous>)
A-Shleifman commented 4 months ago

@sergei-dyshel, if I'm not mistaken, tseslint.config is only used for the new Flat Config which became the default only in eslint v9. Do you have flat config enabled? If not, you need to create a legacy eslint config and use the examples from README to configure it.

I haven't tested the plugin with the flat config yet. I will do it in the next few days.

sergei-dyshel commented 4 months ago

I've migrated my monorepo (with common sharable config) to flat config, so using legacy is not an option. Let's keep this issue to track flat config support.

A-Shleifman commented 4 months ago

@sergei-dyshel, v2.4.0 adds support for Flat Config. Please let me know if you experience any issues.