fix: align lint role-before-use check with siblings
supertensor lint.py now rejects role= used before \stsetrole, matching superfig and superderive lint behavior. Previously this was only caught at TeX compile time by \stcheckrole.
This commit is contained in:
@@ -68,6 +68,14 @@ def lint(path: Path) -> list[str]:
|
|||||||
dimensions = check_unique(source, DIM_RE, "axis", errors)
|
dimensions = check_unique(source, DIM_RE, "axis", errors)
|
||||||
roles = check_unique(source, ROLE_RE, "role", errors)
|
roles = check_unique(source, ROLE_RE, "role", errors)
|
||||||
|
|
||||||
|
for match in ROLE_KEY_RE.finditer(source):
|
||||||
|
role = match.group(1)
|
||||||
|
if role not in roles:
|
||||||
|
errors.append(
|
||||||
|
f"line {line_of(source, match.start())}: role {role!r} is used "
|
||||||
|
f"before \\stsetrole"
|
||||||
|
)
|
||||||
|
|
||||||
formula_positions = [m.start() for m in re.finditer(r"\\sttopformula\b", source)]
|
formula_positions = [m.start() for m in re.finditer(r"\\sttopformula\b", source)]
|
||||||
row_ends = [m.start() for m in re.finditer(r"\\strowend\b", source)]
|
row_ends = [m.start() for m in re.finditer(r"\\strowend\b", source)]
|
||||||
if not formula_positions and "allow-missing-formula" not in allowed:
|
if not formula_positions and "allow-missing-formula" not in allowed:
|
||||||
|
|||||||
Reference in New Issue
Block a user