mirror of https://github.com/tc39/test262.git
linter: Fix parsing features.txt
Previously, split() would split on whitespace, then the if-condition would remove `#` - interpreting every word in every comment in the file as a potential valid feature flag. We want splitlines() here. Partial-line comments were inadvertently "supported" before, because of this bug. Instead, support them explicitly by chopping off a `#` character, anything after it, and any whitespace immediately preceding it.
This commit is contained in:
parent
6e1b737357
commit
a58ae41ea7
|
@ -1,3 +1,5 @@
|
|||
import re
|
||||
|
||||
from ..check import Check
|
||||
|
||||
class CheckFeatures(Check):
|
||||
|
@ -11,8 +13,9 @@ class CheckFeatures(Check):
|
|||
@staticmethod
|
||||
def _parse(content):
|
||||
features = []
|
||||
for line in content.split():
|
||||
if not line or line.startswith('#'):
|
||||
for line in content.splitlines():
|
||||
line = re.sub(r'\s*#.*', '', line)
|
||||
if not line:
|
||||
continue
|
||||
features.append(line)
|
||||
return features
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
async-functions
|
||||
# Here is a full-line comment: not-a-valid-feature
|
||||
async-functions # This is a partial-line comment
|
||||
object-spread
|
||||
generators
|
||||
BigInt
|
||||
|
|
Loading…
Reference in New Issue