Bug 165453
Summary: | check-webkit-style: false positive caused by regex literal matching in SingleQuoteChecker | ||
---|---|---|---|
Product: | WebKit | Reporter: | Matt Baker <mattbaker> |
Component: | Tools / Tests | Assignee: | Nobody <webkit-unassigned> |
Status: | NEW | ||
Severity: | Normal | CC: | joepeck, lforschler, ross.kirsling, webkit-bug-importer |
Priority: | P2 | Keywords: | InRadar |
Version: | WebKit Nightly Build | ||
Hardware: | Unspecified | ||
OS: | Unspecified |
Matt Baker
SingleQuoteChecker strips out regex literals before checking for single quotes, which is a good thing. Unfortunately, the regex that does this matches the wrong thing when a regex contains a forward slash:
Tools/Scripts/webkitpy/style/checkers/js.py: 88:
line = re.sub('/.+?/', '//', line)
Input: /[/'"]/
Expect: ^-----^
Actual: ^-^
Output: //'"]/
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Matt Baker
Forward slash should be escaped:
Input: /[\/'"]/
Expect: ^------^
Actual: ^--^
Ross Kirsling
This checker has many other problems too -- it doesn't support template strings, it doesn't allow multiline strings to share a line with actual code, and it doesn't allow you to start a line with (whitespace and) a multiplication operator.
Given that ESLint does this properly with an actual parser, it would seem advisable to drop this checker altogether.
Ross Kirsling
To be clearer:
> return `'${foo}'`;
is viewed as an error, while
> return 'foo'; /* bar */
is not.
Radar WebKit Bug Importer
<rdar://problem/33440119>