Skip to content

Is jest really a peer (optional) dependency? It isn't because of the "'jest/no-deprecated-functions': Unable to detect Jest version" error. #1831

@stephen-carter-at-sf

Description

@stephen-carter-at-sf

Background - see salesforce/eslint-config-lwc#161

Should 'jest/no-deprecated-functions' really error if jest isn't installed?

This rule is causing other plugins and configs to not be used when jest isn't installed.

For example, https://github.com/salesforce/eslint-config-lwc is a popular eslint config that salesforce developers use to validate their salesforce lightning web components. But not all salesforce developers have jest installed. Some might have vitest, or a different test framework, or none at all. But the owners of @salesforce/eslint-config-lwc wanted to add in the jest rules into their recommended config just in case a user does have tests - jest tests in particular. But if they don't - it would be expected that these rules just wouldn't run or wouldn't produce violations or whatever.

But because eslint-plugin-jest is listed as a plugin within the @salesforce/eslint-config-lwc config, then it errors as shown in salesforce/eslint-config-lwc#161.

The reason why this seems wrong is because jest is listed as a "peerDependency" of eslint-plugin-jest - specifically with the "optional" true marker.

Image

So this seems like a bug with that rule.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions