Truly independent web browser
Meta: Lint the fetch engine's includes
Luke Wildeaf7af866d80c
diff --git a/Meta/Linters/check_fetch_engine_includes.py b/Meta/Linters/check_fetch_engine_includes.pynew file mode 100755index 00000000000..061bca0fd2b--- /dev/null+++ b/Meta/Linters/check_fetch_engine_includes.py@@ -0,0 +1,33 @@+#!/usr/bin/env python3++import pathlib+import re+import sys++REPO_ROOT = pathlib.Path(__file__).resolve().parents[2]+ENGINE_ROOT = pathlib.Path("Libraries/LibWeb/Fetch/Engine")+FORBIDDEN_INCLUDE = re.compile(r'^\s*#\s*include\s*[<"](LibJS|LibGC)/')++CHECKED_SUFFIXES = {".cpp", ".h"}+++def main() -> int:+ offenders = []+ for path in sorted((REPO_ROOT / ENGINE_ROOT).rglob("*")):+ if path.suffix not in CHECKED_SUFFIXES:+ continue+ for line_number, line in enumerate(path.read_text(encoding="utf-8").splitlines(), start=1):+ if FORBIDDEN_INCLUDE.match(line):+ offenders.append(f"{path.relative_to(REPO_ROOT)}:{line_number}: {line.strip()}")++ if not offenders:+ return 0++ print(f"{ENGINE_ROOT} must not include LibJS or LibGC:", file=sys.stderr)+ for offender in offenders:+ print(f" {offender}", file=sys.stderr)+ return 1+++if __name__ == "__main__":+ sys.exit(main())diff --git a/Meta/lint-ci.sh b/Meta/lint-ci.shindex 26426f53f82..3862137f197 100755--- a/Meta/lint-ci.sh+++ b/Meta/lint-ci.sh@@ -32,6 +32,7 @@ set +efor cmd in \Meta/Linters/check_debug_flags.sh \+ Meta/Linters/check_fetch_engine_includes.py \Meta/Linters/check_flatpak.py \Meta/Linters/check_html_doctype.py \Meta/Linters/check_idl_files.py \