CSS At-rule should be allowed on its own line. For example @CHARSET "UTF-8";

Created on 5 October 2018, over 5 years ago
Updated 12 October 2023, 9 months ago

Problem/Motivation

Recently I was reviewing an issue and noticed that PHPCS throws an error if @CHARSET "UTF-8"; is declared on its own line. This same applies to other CSS At-rule.

In a CSS file below code is being used and PHPCS throws an error.

File: modules/contrib/autocomplete_deluxe/assets/css/autocomplete_deluxe.css

@CHARSET "UTF-8";

ul.ui-autocomplete {
  max-height: 240px;
  overflow-x: hidden;
  overflow-y: scroll;
  padding: 3px;
}
❯ autocomplete_deluxe 8.x-1.x* phpcs --standard=Drupal .

FILE: modules/contrib/autocomplete_deluxe/assets/css/autocomplete_deluxe.css
--------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 3 LINES
--------------------------------------------------------------------------------------------------------------
   1 | ERROR | [x] Selectors must be on a single line
   2 | ERROR | [x] Blank lines are not allowed between class names
--------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------

Time: 405ms; Memory: 10Mb

This is allowed:

@CHARSET "UTF-8"; ul.ui-autocomplete {
  max-height: 240px;
  overflow-x: hidden;
  overflow-y: scroll;
  padding: 3px;
}

Proposed resolution

Allow At-rules to be on its own line.

Remaining tasks

- Discussion
- Write a patch
- Commit

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Closed: outdated

Version

3.0

Component

Coder Sniffer

Created by

🇮🇳India msankhala Bikaner, Rajasthan

Live updates comments and jobs are added and updated live.
  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇩🇪Germany sleitner

    In GitLab CI css is not tested with phpcs anymore, stylelint is used in GitLab CI.
    https://git.drupalcode.org/project/gitlab_templates/-/blob/1.0.x/scripts/phpcs.xml.dist

Production build 0.69.0 2024