Skip to content

Commit d15b919

Browse files
committed
fix(phpcs): Remove support for CSS and JS files, remove deprecated MySource.Debug.DebugCode sniff, rename deprecated Squiz.WhiteSpace.LanguageConstructSpacing sniff
1 parent 92557b9 commit d15b919

19 files changed

+16
-800
lines changed

coder_sniffer/Drupal/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php

Lines changed: 0 additions & 141 deletions
This file was deleted.

coder_sniffer/Drupal/Sniffs/CSS/ColourDefinitionSniff.php

Lines changed: 0 additions & 77 deletions
This file was deleted.

coder_sniffer/Drupal/Sniffs/Commenting/DocCommentAlignmentSniff.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ public function process(File $phpcsFile, $stackPtr)
5454

5555
// We are only interested in function/class/interface doc block comments.
5656
$ignore = Tokens::$emptyTokens;
57-
if ($phpcsFile->tokenizerType === 'JS') {
58-
$ignore[] = T_EQUAL;
59-
$ignore[] = T_STRING;
60-
$ignore[] = T_OBJECT_OPERATOR;
61-
}
6257

6358
$nextToken = $phpcsFile->findNext($ignore, ($stackPtr + 1), null, true);
6459
$ignore = [

coder_sniffer/Drupal/Sniffs/Commenting/DocCommentSniff.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ public function process(File $phpcsFile, $stackPtr)
8383
}
8484

8585
// The first line of the comment should just be the /** code.
86-
// In JSDoc there are cases with @lends that are on the same line as code.
87-
if ($tokens[$short]['line'] === $tokens[$stackPtr]['line'] && $phpcsFile->tokenizerType !== 'JS') {
86+
if ($tokens[$short]['line'] === $tokens[$stackPtr]['line']) {
8887
$error = 'The open comment tag must be the only content on the line';
8988
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'ContentAfterOpen');
9089
if ($fix === true) {
@@ -137,12 +136,6 @@ public function process(File $phpcsFile, $stackPtr)
137136

138137
// Check for a comment description.
139138
if ($tokens[$short]['code'] !== T_DOC_COMMENT_STRING) {
140-
// JSDoc has many cases of @type declaration that don't have a
141-
// description.
142-
if ($phpcsFile->tokenizerType === 'JS') {
143-
return;
144-
}
145-
146139
// PHPUnit test methods are allowed to skip the short description and
147140
// only provide an @covers annotation.
148141
if ($tokens[$short]['content'] === '@covers') {
@@ -527,9 +520,6 @@ public function process(File $phpcsFile, $stackPtr)
527520
// of @code, @todo and link tags.
528521
if ($paramGroupid !== null && $paramGroupid !== 0
529522
&& in_array($tokens[$tokens[$commentStart]['comment_tags'][0]]['content'], ['@code', '@todo', '@link', '@endlink', '@codingStandardsIgnoreStart']) === false
530-
// In JSDoc we can have many other valid tags like @function or
531-
// tags like @constructor before the param tags.
532-
&& $phpcsFile->tokenizerType !== 'JS'
533523
) {
534524
$error = 'Parameter tags must be defined first in a doc comment';
535525
$phpcsFile->addError($error, $tagGroups[$paramGroupid][0], 'ParamNotFirst');

coder_sniffer/Drupal/Sniffs/Commenting/InlineCommentSniff.php

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -99,23 +99,6 @@ public function process(File $phpcsFile, $stackPtr)
9999
return;
100100
}
101101

102-
if ($phpcsFile->tokenizerType === 'JS') {
103-
// We allow block comments if a function or object
104-
// is being assigned to a variable.
105-
$ignore = Tokens::$emptyTokens;
106-
$ignore[] = T_EQUAL;
107-
$ignore[] = T_STRING;
108-
$ignore[] = T_OBJECT_OPERATOR;
109-
$nextToken = $phpcsFile->findNext($ignore, ($nextToken + 1), null, true);
110-
if ($tokens[$nextToken]['code'] === T_FUNCTION
111-
|| $tokens[$nextToken]['code'] === T_CLOSURE
112-
|| $tokens[$nextToken]['code'] === T_OBJECT
113-
|| $tokens[$nextToken]['code'] === T_PROTOTYPE
114-
) {
115-
return;
116-
}
117-
}
118-
119102
$prevToken = $phpcsFile->findPrevious(
120103
Tokens::$emptyTokens,
121104
($stackPtr - 1),
@@ -127,8 +110,7 @@ public function process(File $phpcsFile, $stackPtr)
127110
return;
128111
}
129112

130-
// Inline doc blocks are allowed in JSDoc.
131-
if ($tokens[$stackPtr]['content'] === '/**' && $phpcsFile->tokenizerType !== 'JS') {
113+
if ($tokens[$stackPtr]['content'] === '/**') {
132114
// The only exception to inline doc blocks is the /** @var */
133115
// declaration. Allow that in any form.
134116
$varTag = $phpcsFile->findNext([T_DOC_COMMENT_TAG], ($stackPtr + 1), $tokens[$stackPtr]['comment_closer'], false, '@var');
@@ -155,16 +137,6 @@ public function process(File $phpcsFile, $stackPtr)
155137
if ($tokens[$previousContent]['code'] === T_CLOSE_CURLY_BRACKET) {
156138
return;
157139
}
158-
159-
// Special case for JS files.
160-
if ($tokens[$previousContent]['code'] === T_COMMA
161-
|| $tokens[$previousContent]['code'] === T_SEMICOLON
162-
) {
163-
$lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($previousContent - 1), null, true);
164-
if ($tokens[$lastContent]['code'] === T_CLOSE_CURLY_BRACKET) {
165-
return;
166-
}
167-
}
168140
}
169141

170142
// Only want inline comments.

coder_sniffer/Drupal/Sniffs/Commenting/PostStatementCommentSniff.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,6 @@ public function process(File $phpcsFile, $stackPtr)
6565
return;
6666
}
6767

68-
// Special case for JS files.
69-
if ($tokens[$lastContent]['code'] === T_COMMA
70-
|| $tokens[$lastContent]['code'] === T_SEMICOLON
71-
) {
72-
$lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($lastContent - 1), null, true);
73-
if ($tokens[$lastContent]['code'] === T_CLOSE_CURLY_BRACKET) {
74-
return;
75-
}
76-
}
77-
7868
$error = 'Comments may not appear after statements';
7969
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'Found');
8070
if ($fix === true) {

coder_sniffer/Drupal/Sniffs/ControlStructures/ControlSignatureSniff.php

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -209,38 +209,6 @@ public function process(File $phpcsFile, $stackPtr)
209209
if (isset($tokens[$stackPtr]['scope_closer']) === true) {
210210
$closer = $tokens[$stackPtr]['scope_closer'];
211211
}
212-
213-
// Do-while loops should have curly braces. This is optional in
214-
// Javascript.
215-
if ($closer === false && $tokens[$stackPtr]['code'] === T_DO && $phpcsFile->tokenizerType === 'JS') {
216-
$error = 'The code block in a do-while loop should be surrounded by curly braces';
217-
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'DoWhileCurlyBraces');
218-
$closer = $phpcsFile->findNext(T_WHILE, $stackPtr);
219-
if ($fix === true) {
220-
$phpcsFile->fixer->beginChangeset();
221-
// Append an opening curly brace followed by a newline after
222-
// the DO.
223-
$next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
224-
if ($next !== ($stackPtr + 1)) {
225-
$phpcsFile->fixer->replaceToken(($stackPtr + 1), '');
226-
}
227-
228-
$phpcsFile->fixer->addContent($stackPtr, ' {'.$phpcsFile->eolChar);
229-
230-
// Prepend a closing curly brace before the WHILE and ensure
231-
// it is on a new line.
232-
$prepend = $phpcsFile->eolChar;
233-
if ($tokens[($closer - 1)]['code'] === T_WHITESPACE) {
234-
$prepend = '';
235-
if ($tokens[($closer - 1)]['content'] !== $phpcsFile->eolChar) {
236-
$phpcsFile->fixer->replaceToken(($closer - 1), $phpcsFile->eolChar);
237-
}
238-
}
239-
240-
$phpcsFile->fixer->addContentBefore($closer, $prepend.'} ');
241-
$phpcsFile->fixer->endChangeset();
242-
}//end if
243-
}//end if
244212
} else if ($tokens[$stackPtr]['code'] === T_ELSE
245213
|| $tokens[$stackPtr]['code'] === T_ELSEIF
246214
|| $tokens[$stackPtr]['code'] === T_CATCH

0 commit comments

Comments
 (0)