-
-
Notifications
You must be signed in to change notification settings - Fork 73
Remove CSS/JS support (HUGE PR, reviews welcome!) #983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Removes the following sniffs: - Generic.Debug.CSSLint - Squiz.CSS.ClassDefinitionClosingBraceSpace - Squiz.CSS.ClassDefinitionNameSpacing - Squiz.CSS.ClassDefinitionOpeningBraceSpace - Squiz.CSS.ColonSpacing - Squiz.CSS.ColourDefinition - Squiz.CSS.DisallowMultipleStyleDefinitions - Squiz.CSS.DuplicateClassDefinition - Squiz.CSS.DuplicateStyleDefinition - Squiz.CSS.EmptyClassDefinition - Squiz.CSS.EmptyStyleDefinition - Squiz.CSS.ForbiddenStyles - Squiz.CSS.Indentation - Squiz.CSS.LowercaseStyleDefinition - Squiz.CSS.MissingColon - Squiz.CSS.NamedColours - Squiz.CSS.Opacity - Squiz.CSS.SemicolonSpacing - Squiz.CSS.ShorthandSize Ref: * squizlabs/PHP_CodeSniffer 2448 Co-authored-by: jrfnl <[email protected]>
Removes the following sniffs: - Generic.Debug.ClosureLinter - Generic.Debug.JSHint - Generic.Debug.ESLint - Squiz.Classes.DuplicateProperty - Squiz.Debug.JavaScriptLint - Squiz.Debug.JSLint - Squiz.Objects.DisallowObjectStringIndex - Squiz.Objects.ObjectMemberComma - Squiz.WhiteSpace.PropertyLabelSpacing Includes removing two `<exclude name="Generic.Debug"/>` directives from tests for the Filter and Ruleset components. These excludes were only introduced temporarily to bypass the deprecation notice for sniffing JS/CSS files with the `Generic.Debug.*` sniffs. Ref: * squizlabs/PHP_CodeSniffer 2448 Co-authored-by: jrfnl <[email protected]>
Removes the JS/CSS support from the following sniffs: - Generic.Commenting.DocComment - Generic.Commenting.Fixme - Generic.Commenting.Todo - Generic.ControlStructures.InlineControlStructure - Generic.Files.EndFileNewline - Generic.Files.EndFileNoNewline - Generic.Files.LineEndings - Generic.Formatting.MultipleStatementAlignment - Generic.Formatting.SpaceAfterNot - Generic.PHP.LowerCaseConstant - Generic.Strings.UnnecessaryStringConcat - Generic.VersionControl.GitMergeConflict - Generic.WhiteSpace.DisallowTabIndent - Generic.WhiteSpace.DisallowSpaceIndent - Generic.WhiteSpace.IncrementDecrementSpacing - Generic.WhiteSpace.ScopeIndent - PEAR.ControlStructures.MultiLineCondition - PEAR.Functions.FunctionCallSignature - PEAR.Functions.FunctionDeclaration - Squiz.Commenting.DocCommentAlignment - Squiz.Commenting.FileComment - Squiz.Commenting.InlineComment - Squiz.Commenting.LongConditionClosingComment - Squiz.Commenting.PostStatementComment - Squiz.Formatting.OperatorBracket - Squiz.ControlStructures.ControlSignature - Squiz.ControlStructures.ForLoopDeclaration - Squiz.ControlStructures.SwitchDeclaration - Squiz.Functions.MultiLineFunctionDeclaration - Squiz.Operators.ComparisonOperatorUsage - Squiz.PHP.CommentedOutCode - Squiz.PHP.DisallowInlineIf - Squiz.PHP.DisallowSizeFunctionsInLoops - Squiz.WhiteSpace.ControlStructureSpacing - Squiz.WhiteSpace.FunctionClosingBraceSpace - Squiz.WhiteSpace.FunctionOpeningBraceSpace - Squiz.WhiteSpace.LogicalOperatorSpacing - Squiz.WhiteSpace.OperatorSpacing - Squiz.WhiteSpace.SemicolonSpacing - Squiz.WhiteSpace.SuperfluousWhitespace Ref: * squizlabs/PHP_CodeSniffer 2448 Co-authored-by: jrfnl <[email protected]>
Ref: * squizlabs/PHP_CodeSniffer 2448
This has been implemented slightly differently from the original PHPCS 4.0 branch implementation. 1. The array format of the `Config::$extensions` property has not been changed. The format is an associative array with the extensions as keys and the tokenizer type as the value. Originally, the format was changed to a list with the extensions as values. While information on the tokenizer type now no longer has any value as the only supported tokenizer is PHP, changing the array format could break integrations in unexpected ways, so I have decided against this. 2. I have also elected to throw an error when the passed extensions contain the `/tokenizer` switch, but only if the tokenizer is set to something other than PHP. In the original implementation, no information was provided to the user and all extensions values would be accepted and expected to be acceptable, including values which contained the `/tokenizer` switch. Note: users can still pass extensions for unsupported file types. This is no different than before, either in the previous implementation or in PHPCS 3.x. I mean, users could already pass `html` as an extension and it would be scanned as if it were PHP. Whether the results of such scans would be useful is doubtful, but that's the user's responsibility. So if the user passes `--extensions=php,js`, as of PHPCS 4.0, javascript files will be scanned as if they were PHP. Ref: * squizlabs/PHP_CodeSniffer 2448 Co-authored-by: Greg Sherwood <[email protected]>
…roperty Ref: * squizlabs/PHP_CodeSniffer 2448 Co-authored-by: Greg Sherwood <[email protected]>
Ref: * squizlabs/PHP_CodeSniffer 2448 Co-authored-by: Greg Sherwood <[email protected]>
The `T_DOC_COMMENT` token is a PHP native token. For PHP files, however, all `T_DOC_COMMENT` tokens are split up and re-tokenized via the `PHP_CodeSniffer\Tokenizer\Comment` class to more "sniffable" smaller tokens, so the `T_DOC_COMMENT` token should not exist in PHP files after the PHPCS tokenizer has finished processing the file. By the looks of it, this may not have been the same for JS files. Then again, references to `T_DOC_COMMENT` - outside of the Tokenizer classes + the `Tokens` class - may also have been from long forgotten times before the `Comment` class existed. Either way, now the JS and CSS tokenizers have been removed, it seems safe enough to remove references to `T_DOC_COMMENT` (outside of the Tokenizer context).
Closes squizlabs/PHP_CodeSniffer 2448 Related to 6
e665d60
to
182f87a
Compare
Rebased without changes to hopefully get Coveralls to report 🤞🏻 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Remove all CSS-specific sniffs
Removes the following sniffs:
Ref:
Remove all JS-specific sniffs
Removes the following sniffs:
Includes removing two
<exclude name="Generic.Debug"/>
directives from tests for the Filter and Ruleset components.These excludes were only introduced temporarily to bypass the deprecation notice for sniffing JS/CSS files with the
Generic.Debug.*
sniffs.Ref:
Remove all JS/CSS specific code from mixed sniffs
Removes the JS/CSS support from the following sniffs:
Ref:
File::getDeclarationName(): remove support for JS functions
Ref:
Config: drop support for setting language via --extensions CLI arg
This has been implemented slightly differently from the original PHPCS 4.0 branch implementation.
Config::$extensions
property has not been changed.The format is an associative array with the extensions as keys and the tokenizer type as the value.
Originally, the format was changed to a list with the extensions as values.
While information on the tokenizer type now no longer has any value as the only supported tokenizer is PHP, changing the array format could break integrations in unexpected ways, so I have decided against this.
/tokenizer
switch, but only if the tokenizer is set to something other than PHP.In the original implementation, no information was provided to the user and all extensions values would be accepted and expected to be acceptable, including values which contained the
/tokenizer
switch.Note: users can still pass extensions for unsupported file types. This is no different than before, either in the previous implementation or in PHPCS 3.x. I mean, users could already pass
html
as an extension and it would be scanned as if it were PHP. Whether the results of such scans would be useful is doubtful, but that's the user's responsibility.So if the user passes
--extensions=php,js
, as of PHPCS 4.0, javascript files will be scanned as if they were PHP.Ref:
Ruleset: drop support for sniffs setting the $supportedTokenizers property
Ref:
Tokenizers: drop JS/CSS tokenizers and associated tokens
Ref:
File/utility methods: minor clean up
The
T_DOC_COMMENT
token is a PHP native token.For PHP files, however, all
T_DOC_COMMENT
tokens are split up and re-tokenized via thePHP_CodeSniffer\Tokenizer\Comment
class to more "sniffable" smaller tokens, so theT_DOC_COMMENT
token should not exist in PHP files after the PHPCS tokenizer has finished processing the file.By the looks of it, this may not have been the same for JS files. Then again, references to
T_DOC_COMMENT
- outside of the Tokenizer classes + theTokens
class - may also have been from long forgotten times before theComment
class existed.Either way, now the JS and CSS tokenizers have been removed, it seems safe enough to remove references to
T_DOC_COMMENT
(outside of the Tokenizer context).Miscellaneous other changes after dropping JS/CSS support
Closes squizlabs/PHP_CodeSniffer#2448
Related to #6
Suggested changelog entry
Changes:
--extensions
command line argument no longer accepts the tokenizer along with the extension..module
files as PHP files using--extensions=module/php
.--extensions=module
.Removed:
Generic.Debug.ClosureLinter
sniff.Generic.Debug.CSSLint
sniff.Generic.Debug.ESLint
sniff.Generic.Debug.JSHint
sniff.Squiz.Classes.DuplicateProperty
sniff.Squiz.Debug.JavaScriptLint
sniff.Squiz.Debug.JSLint
sniff.Squiz.Objects.DisallowObjectStringIndex
sniff.Squiz.Objects.ObjectMemberComment
sniff.Squiz.WhiteSpace.PropertyLabelSpacing
sniff.Squiz.CSS
category, and all sniffs within.