Personally, I am a strong fan of this rule. There is currently a similar rule provided by PHP_CodeSniffer.
Details
- Reviewers
epriestley - Group Reviewers
Blessed Reviewers - Commits
- rARC35a26718d861: Add a linter rule for determining when single quotes should be used over double…
Wrote and executed unit tests.
Diff Detail
- Repository
- rARC Arcanist
- Lint
Lint Skipped - Unit
Tests Skipped
Event Timeline
What does it do in this case?
return pht( "This string requires \x12\x34 double quotes, but ". "this string does not. Here, they are used for consistency.");
I think there's some code in the analysis of pht() and such that can merge string literals together if you fish around a bit. That use-the-less-preferred-quotes-for-consistency case is the only one I can think of where this gets the rule wrong.
Sure, I'll take a look. Thanks.
Off topic, but I have given thought to extending the ArcanistXHPASTLinter and generally making it more customisable to (possibly) allow for more widespread use. One point of concern, however, is that the source code is getting a tad large.
src/lint/linter/ArcanistXHPASTLinter.php | ||
---|---|---|
2416 | I think we could remove escapes on double quotes here? But that's complicated and probably not worthwhile. | |
2425 | I'm going to tweak this message slightly to emphasize that the motivation here is style consistency, to something like this: String does not require double quotes; for consistency, prefer single quotes. (Long ago, at Facebook, there was a wiki page which advised you to use this quote style for performance, which has no basis in reality.) |
Closed by commit rARC35a26718d861 (authored by @joshuaspence, committed by @epriestley).