From c58e5a0c44c0010bbc8a91fc468f4667e177b976 Mon Sep 17 00:00:00 2001 From: Klaus Purer Date: Sun, 22 Sep 2024 21:02:16 +0200 Subject: [PATCH] fix(InlineCommen): Allow spellchecker keyword (#3424914) --- coder_sniffer/Drupal/Sniffs/Commenting/InlineCommentSniff.php | 2 +- tests/Drupal/Commenting/InlineCommentUnitTest.inc | 3 +++ tests/Drupal/Commenting/InlineCommentUnitTest.inc.fixed | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/InlineCommentSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/InlineCommentSniff.php index 3fdb4049..f226d61f 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/InlineCommentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/InlineCommentSniff.php @@ -351,7 +351,7 @@ public function process(File $phpcsFile, $stackPtr) // Also, when the comment starts with cspell: don't check the end of the // comment. if (preg_match('/^\p{L}/u', $commentText) === 1 - && preg_match('/(cspell|spell\-checker):/i', $commentText) === 0 + && preg_match('/(cspell|spell\-checker|spellchecker):/i', $commentText) === 0 ) { $commentCloser = $commentText[(strlen($commentText) - 1)]; $acceptedClosers = [ diff --git a/tests/Drupal/Commenting/InlineCommentUnitTest.inc b/tests/Drupal/Commenting/InlineCommentUnitTest.inc index 401d02fc..5755af9f 100644 --- a/tests/Drupal/Commenting/InlineCommentUnitTest.inc +++ b/tests/Drupal/Commenting/InlineCommentUnitTest.inc @@ -126,3 +126,6 @@ $x = 2; // And here as well. // spell-checker:ignore bananarama $x = 3; +// Different keword. +// spellchecker:disable-next-line +$x = 4; diff --git a/tests/Drupal/Commenting/InlineCommentUnitTest.inc.fixed b/tests/Drupal/Commenting/InlineCommentUnitTest.inc.fixed index fabc368f..16297513 100644 --- a/tests/Drupal/Commenting/InlineCommentUnitTest.inc.fixed +++ b/tests/Drupal/Commenting/InlineCommentUnitTest.inc.fixed @@ -125,3 +125,6 @@ $x = 2; // And here as well. // spell-checker:ignore bananarama $x = 3; +// Different keword. +// spellchecker:disable-next-line +$x = 4;