Skip to content

Bug: [naming-convention] PascalCase format matches single word in UPPER_CASE #11465

@FabienDehopre

Description

@FabienDehopre

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Playground Link

https://typescript-eslint.io/play/#ts=5.8.2&fileType=.tsx&code=GYVwdgxgLglg9mABACQKIBl0HkAUBKRAbwChFEIEBnOAGwFMA6GuAcxwHJk6bn28BuYgF8gA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6JgQwFtmBzWsgHsmAN0QtKw9GADa4bDkTRog6JAA08hVgXZIyREjL5V0yABNEAMw4J8GrbshXVXDvYxzdTst0MBhDgNIRwUAXU1vHCQOcz4AVSZLaGQhaEQzF2gAI0pzByiofGgOSkYmXkTk1NUMjGdVXPzQsABfSN0db31DRGNTeqtYJmNJJgKohug3D1kWhUhfLgCgjI7CyAAFIN94QOD5sDCW1sdjiFPWoA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eFYDArugDTg2RYBDEgIBGGAMoBPIngEAPbEVSTWHdLwC%2BIDUA&tokens=false

Repro Code

function HELLO() {
  console.log('Hello');
}

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    "@typescript-eslint/naming-convention": [
      "error",
      {
        selector: 'default',
        format: ['camelCase'],
        leadingUnderscore: 'forbid',
        trailingUnderscore: 'forbid'
      },
      {
        selector: 'function',
        format: ['camelCase', 'PascalCase'
        ]
      }
    ]
  },
};

tsconfig

{
  "compilerOptions": {
    "strict": true,
    "erasableSyntaxOnly": true
  }
}

Expected Result

I expect that the function cannot be named HELLO. Acceptable names are either hello or Hello.

Actual Result

The function is allowed to be named HELLO.

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    package: eslint-pluginIssues related to @typescript-eslint/eslint-pluginquestionQuestions! (i.e. not a bug / enhancment / documentation)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions