Skip to content

Flat config with ESM modules doesn’t work #791

Closed
@cherryblossom000

Description

@cherryblossom000

Bug Report

Rules such as functional/type-declaration-immutability don’t work when using the flat config with ESM modules.

test.ts:

type Test = readonly string[]

eslint.config.js:

import tseslint from 'typescript-eslint'
import functional from 'eslint-plugin-functional/flat'

export default tseslint.config(
	{
		files: ['**/*.ts'],
		languageOptions: {
			ecmaVersion: 2022,
			parserOptions: {
				project: true,
				tsconfigRootDir: import.meta.dirname,
			},
		},
	},
	tseslint.configs.base,
	functional.configs.strict,
	{
		rules: {
			'functional/type-declaration-immutability': 'error',
		},
	},
)

Expected behavior

No errors.

Actual behavior

/path/to/file/test.ts
  1:1  error  This type is declare to have an immutability of at least "Immutable" (actual: "Unknown")  functional/type-declaration-immutability

Steps to reproduce

  1. Install [email protected]
  2. Run eslint test.ts

Proposed changes

export default (() => {
try {
return require("typescript") as typeof ts;
} catch {
return undefined;
}
})();

typescript can’t be imported in an ESM module as require is not defined.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: ReleasedIt's now live.Type: BugInconsistencies or issues which will cause a problem for users or implementors.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions