Generic.PHP.UpperCaseConstant is being triggered for JS files

Created on 17 October 2022, over 2 years ago
Updated 3 June 2025, 2 days ago

Problem/Motivation

Setting up phpcs with Drupal coding standards flags js as needing uppercase FALSE,TRUE and NULL

Steps to reproduce

Setup the following phpcs.xml file

<?xml version="1.0"?>
<ruleset name="MyRules">
  <rule ref="Drupal">
  </rule>
  <rule ref="DrupalPractice">
  </rule>

  <exclude-pattern>*/node_modules/*</exclude-pattern>
  <exclude-pattern>*/dist/css/*</exclude-pattern>
  <exclude-pattern>*/dist/js/*</exclude-pattern>

  <file>docroot/modules/custom</file>
  <file>docroot/themes/custom</file>


</ruleset>

I added the following to fix it

<rule ref="Generic.PHP.UpperCaseConstant">
    <exclude-pattern>docroot/themes/custom/*/src/js</exclude-pattern>
 </rule>

It has been many years since I was setting up phpcs for a Drupal project but I don't remember needing this workaround. Why a php sniff would be scanning a js file? is there something wrong in my config?

Proposed resolution

No idea

Remaining tasks

User interface changes

API changes

Data model changes

💬 Support request
Status

Active

Version

8.3

Component

Coder Sniffer

Created by

🇪🇸Spain rodrigoaguilera Barcelona

Live updates comments and jobs are added and updated live.
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.

Production build 0.71.5 2024