mirror of
https://github.com/tc39/test262.git
synced 2025-07-27 07:54:41 +02:00
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
|
from ..check import Check
|
||||||
|
|
||||||
class CheckFeatures(Check):
|
class CheckFeatures(Check):
|
||||||
@ -11,8 +13,9 @@ class CheckFeatures(Check):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse(content):
|
def _parse(content):
|
||||||
features = []
|
features = []
|
||||||
for line in content.split():
|
for line in content.splitlines():
|
||||||
if not line or line.startswith('#'):
|
line = re.sub(r'\s*#.*', '', line)
|
||||||
|
if not line:
|
||||||
continue
|
continue
|
||||||
features.append(line)
|
features.append(line)
|
||||||
return features
|
return features
|
||||||
|
3
tools/lint/test/fixtures/features.txt
vendored
3
tools/lint/test/fixtures/features.txt
vendored
@ -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
|
object-spread
|
||||||
generators
|
generators
|
||||||
BigInt
|
BigInt
|
||||||
|
Loading…
x
Reference in New Issue
Block a user