You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm actually a bit surprised that not only is this not already a rule, I can't find any mention of anything close to it in any issue or PR - so I could be missing something really big, but in case I'm not here goes nothing...
Over in eslint-plugin-jest we have a rule called valid-title which does checks against it/test and describe descriptions (jest doesn't have context) for things like blank titles (similar to RSpec/ExampleWithoutDescription), duplicate titles (similar to RSpec/RepeatedExampleGroupDescription), and prefixing titles with the test method name (similar to RSpec/ExampleWording)
However, it also checks for accidental spaces in titles, which there doesn't seem to be any cop for!
Specifically, the rule looks for leading and trailing whitespace, and provides an autofix to remove them when found.
I can't think of a situation where you'd want to have this space, and so think this could a good addition for rubocop-rspec; maybe RSpec/ExampleSpacing, or as an extension to the existing RSpec/ExampleWording?
I actually think it would be fair to check for double spaces in titles too, but I think there's slightly higher chance of valid titles having that? (but tbh my go-to example of something like it 'treats " " as valid' would probably be better written as it 'treats multiple spaces as valid' anyway).
I'm happy to have a go at implementing this if people think it'd make a good cop :)
The text was updated successfully, but these errors were encountered:
This should apply to example group, shared group and example wording, right? I don't think that "docstring" is a commonly-used name for it, but AFAIR it is how RSpec calls it internally [1, 2]. Maybe RSpec/ExcessiveDocstringSpacing? See rubocop/rubocop#7077 for cop naming guidelines and practices.
I'm actually a bit surprised that not only is this not already a rule, I can't find any mention of anything close to it in any issue or PR - so I could be missing something really big, but in case I'm not here goes nothing...
Over in
eslint-plugin-jest
we have a rule calledvalid-title
which does checks againstit
/test
anddescribe
descriptions (jest
doesn't havecontext
) for things like blank titles (similar toRSpec/ExampleWithoutDescription
), duplicate titles (similar toRSpec/RepeatedExampleGroupDescription
), and prefixing titles with the test method name (similar toRSpec/ExampleWording
)However, it also checks for accidental spaces in titles, which there doesn't seem to be any cop for!
Specifically, the rule looks for leading and trailing whitespace, and provides an autofix to remove them when found.
I can't think of a situation where you'd want to have this space, and so think this could a good addition for
rubocop-rspec
; maybeRSpec/ExampleSpacing
, or as an extension to the existingRSpec/ExampleWording
?I actually think it would be fair to check for double spaces in titles too, but I think there's slightly higher chance of valid titles having that? (but tbh my go-to example of something like
it 'treats " " as valid'
would probably be better written asit 'treats multiple spaces as valid'
anyway).I'm happy to have a go at implementing this if people think it'd make a good cop :)
The text was updated successfully, but these errors were encountered: