Skip to content

display multiple suggestions when a config has an unknown feature #1062

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

Merged

Conversation

romainmenke
Copy link
Member

@romainmenke romainmenke commented Jul 28, 2023

fixes : #1061

We use a Levenshtein distance to find the most similar real feature but we also use the npm package names to find entries. This makes it possible to encounter this edge case :

  • user enters postcss-oklab-function
  • the package name is @csstools/postcss-oklab-function
  • the feature name is oklab-function
  • most similar result is postcss-lab-function

This is the most similar result because only two characters need to be altered.
Whereas the right result requires at least 8 changes.

user entry:
          postcss-oklab-function

candidates:
            postcss-lab-function
@csstools/postcss-oklab-function
                  oklab-function

This can not be fixed in a general, yet simple way.


Instead of showing only the top hit we will now show the 3 most likely features.

This makes it possible for users to pick the correct option even when a Levenshtein distance gives an unexpected result.

[postcss-preset-env]: Unknown feature: "postcss-oklab-function", did you mean one of: "lab-function", "oklab-function", "image-set-function"

@romainmenke romainmenke changed the title multiple suggestions display multiple suggestions when a config has an unknown feature Jul 28, 2023
@romainmenke romainmenke merged commit 2f80d77 into main Aug 5, 2023
@romainmenke romainmenke deleted the multiple-feature-suggestions--practical-yak-b93f43e225 branch August 5, 2023 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected Unknown feature warning
1 participant