-
Notifications
You must be signed in to change notification settings - Fork 40
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
Incorrect validTitle error flag #312
Comments
The rule doesn't do semantic analysis, and doesn't have type information, so this is expected. |
This doesn't make sense. The rule says title must be a string... the title is a string... and it's calling an error. That is by every definition a bug. What's the intention behind this rule? If the rule only sees string-literals as valid, that's poor coding practices. Why is a linter advocating for it? Even still, if this is expected behaviour, it should say that in the rule/documentation. https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/valid-title.md => Nowhere does it indicate developers storing strings in variables for titles is invalid. This is an extremely common practice whereas using string literals generally frowned upon.
|
@toduyemi It's not a bug, this plugin does not use type information and thus cannot in all circumstances determine the type of the variable. We could add some amount of logic to make that work in the current file, but it's such a rare thing its not worth the effort. The rule was ported from the Jest ESLint plugin as part of our effort to provide compatibility and feature completeness between the two. I do think it's a fine rule, test titles with a variable instead of a string literal is a super rare case, so I don't really care to handle most of the rare exceptions to this rule. |
Fixes #295 Fixes #243 Fixes #312 Fixes #320 I give in, I've got enough reports of this from users I'm tired of dealing with it and decided to just support basic semantic analysis. No doubt at some point someone is going to expect it to work with full type information cause they'll have some weird use case where they import some title string function from a util or something dumb like that, but at least this will quell the nonsense for most simple cases.
🎉 This issue has been resolved in version 1.8.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Example =>
Title is a string yet an error is thrown.
The text was updated successfully, but these errors were encountered: