Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type checking fails in index.js #2394

Closed
ericbn opened this issue Jun 29, 2024 · 2 comments
Closed

Type checking fails in index.js #2394

ericbn opened this issue Jun 29, 2024 · 2 comments
Labels

Comments

@ericbn
Copy link

ericbn commented Jun 29, 2024

Type checking fails in eslint.config.js containing:

// @ts-check
"use strict";
const eslintPluginUnicorn = require("eslint-plugin-unicorn");
const tseslint = require("typescript-eslint");

module.exports = tseslint.config(
	...tseslint.configs.recommended,
	eslintPluginUnicorn.configs["flat/recommended"],
//	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	{
		rules: {
			"@typescript-eslint/no-var-requires": "off",
			"unicorn/prefer-module": "off",
			"unicorn/prefer-top-level-await": "off",
		},
	},
);

First error is:

Argument of type '{ rules: any; name: true; plugins: { unicorn: { meta: { name: string; version: string; }; rules: { [x: string]: RuleModule; }; }; }; languageOptions: { globals: any; }; } | { rules: any; plugins: string[]; env: { ...; }; parserOptions: { ...; }; }' is not assignable to parameter of type 'ConfigWithExtends'.
  Type '{ rules: any; name: true; plugins: { unicorn: { meta: { name: string; version: string; }; rules: { [x: string]: Rule.RuleModule; }; }; }; languageOptions: { globals: any; }; }' is not assignable to type 'ConfigWithExtends'.
    Types of property 'name' are incompatible.
      Type 'boolean' is not assignable to type 'string'.ts(2345)

which can be fixed by the following change in index.js:

-const createConfig = (rules, flatConfigName = false) => ({
+const createConfig = (rules, flatConfigName = '') => ({

The following error is:

Argument of type '{ rules: any; name: string; plugins: { unicorn: { meta: { name: string; version: string; }; rules: { [x: string]: RuleModule; }; }; }; languageOptions: { globals: any; }; } | { rules: any; plugins: string[]; env: { ...; }; parserOptions: { ...; }; }' is not assignable to parameter of type 'ConfigWithExtends'.
  Type '{ rules: any; plugins: string[]; env: { es2024: boolean; }; parserOptions: { ecmaVersion: string; sourceType: string; }; }' is not assignable to type 'ConfigWithExtends'.
    Types of property 'plugins' are incompatible.
      Type 'string[]' is not assignable to type 'Plugins'.
        Index signature for type 'string' is missing in type 'string[]'.ts(2345)

Not sure if this is valid change in index.js:

-			: {...legacyConfigBase, plugins: ['unicorn']}
+			: {...legacyConfigBase, plugins: {unicorn}}
@ericbn ericbn added the bug label Jun 29, 2024
@johanbook
Copy link

I also bumped into this type error when installing the latest of eslint-plugin-unicorn

@ericbn
Copy link
Author

ericbn commented Jun 30, 2024

Looks like this is going to be fixed with the next version, with #2382.

@ericbn ericbn closed this as completed Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants