mirror of https://github.com/tc39/test262.git
set lint rules to avoid leading or trailing empty lines in frontmatter string values
Fix #2034 Ref #1997
This commit is contained in:
parent
b4e15b3d5c
commit
e7092eacc4
|
@ -0,0 +1,21 @@
|
|||
from ..check import Check
|
||||
import re
|
||||
|
||||
class CheckNoPadding(Check):
|
||||
'''Ensure frontmatter string tags doesn't contain leading empty lines'''
|
||||
ID = 'NOPADDING'
|
||||
|
||||
def __init__(self):
|
||||
self.noPadding = re.compile(r"^(?![\r\n])[\s\S]*")
|
||||
|
||||
def run(self, name, meta, source):
|
||||
if not meta:
|
||||
return
|
||||
|
||||
if 'description' in meta:
|
||||
if self.noPadding.match(meta['description']) == None:
|
||||
return 'The `description` tag should not have leading empty lines'
|
||||
|
||||
if 'info' in meta:
|
||||
if self.noPadding.match(meta['info']) == None:
|
||||
return 'The `info` tag should not have leading empty lines'
|
|
@ -37,6 +37,7 @@ from lib.checks.harness import CheckHarness
|
|||
from lib.checks.license import CheckLicense
|
||||
from lib.checks.negative import CheckNegative
|
||||
from lib.checks.filename import CheckFileName
|
||||
from lib.checks.nopadding import CheckNoPadding
|
||||
from lib.eprint import eprint
|
||||
import lib.frontmatter
|
||||
import lib.exceptions
|
||||
|
@ -57,7 +58,8 @@ checks = [
|
|||
CheckHarnessFeatures(),
|
||||
CheckHarness(),
|
||||
CheckLicense(),
|
||||
CheckNegative()
|
||||
CheckNegative(),
|
||||
CheckNoPadding()
|
||||
]
|
||||
|
||||
def lint(file_names):
|
||||
|
|
Loading…
Reference in New Issue