@@ -480,6 +480,46 @@ def required_false_check(self, binding):
480
480
"'required: false' is redundant, please remove"
481
481
)
482
482
483
+ class DevicetreeLintingCheck (ComplianceTest ):
484
+ """
485
+ Checks if we are introducing syntax or formatting issues to devicetree files.
486
+ """
487
+ name = "DevicetreeLinting"
488
+ doc = "See https://docs.zephyrproject.org/latest/contribute/style/devicetree.html for more details."
489
+
490
+ def run (self ):
491
+ # Check if node is installed
492
+ if not shutil .which ("node" ):
493
+ self .skip ("Node.js is not installed or not in PATH" )
494
+
495
+ # Check if dts-linter is installed
496
+ if not shutil .which ("dts-linter" ):
497
+ self .skip ("dts-linter is not installed or not in PATH" )
498
+
499
+ # Get changed DTS files
500
+ dts_files = []
501
+ for file in get_files (filter = "d" ):
502
+ if file .endswith ((".dts" , ".dtsi" , ".overlay" )):
503
+ dts_files .append (file )
504
+
505
+ if not dts_files :
506
+ self .skip ('No DTS' )
507
+ return # No DTS files to check
508
+
509
+ # Build command: dts-linter --outFile diff --format --files file1 --files file2 ...
510
+ cmd = ["dts-linter" , "--format" , "--diagnostics" ]
511
+ for file in dts_files :
512
+ cmd .extend (["--files" , file ])
513
+
514
+ try :
515
+ result = subprocess .run (cmd , check = True , capture_output = True , cwd = GIT_TOP )
516
+ except subprocess .CalledProcessError as ex :
517
+ output = ex .output .decode ("utf-8" )
518
+ if output .strip ():
519
+ self .failure (f"dts-linter found issues:\n { output } " )
520
+ else :
521
+ self .failure ("dts-linter failed with no output" )
522
+
483
523
class KconfigCheck (ComplianceTest ):
484
524
"""
485
525
Checks is we are introducing any new warnings/errors with Kconfig,
0 commit comments