Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[@typescript-eslint/naming-convention] Less strict handling of merged declarations #2223

Closed
Labels
package: eslint-pluginIssues related to @typescript-eslint/eslint-pluginwontfixThis will not be worked on
@octogonz

Description

@octogonz

Repro

TypeScript allows two different declarations to use the same name; they getmerged into a single type. Besides a small handful of useful scenarios (e.g.namespace+enum), merged declarations generally arise as hacks in advanced abstractions (e.g. mixins) or retrofitted types for a legacy API. To avoid these complexities, I'll give somewhat contrived examples below.

The problem is that@typescript-eslint/naming-convention seems to check each declaration independently, whereas merged declarations must all have the same name. As a result, ESLint may reject every possible name.

{"rules": {"@typescript-eslint/naming-convention": ["error"]  }}

A couple example inputs:

exportclassSomeClass{}// ('typeLike' must have 'PascalCase')exporttypeExample=SomeClass;// ERROR: Variable name `Example` must match one of// the following formats: camelCase, UPPER_CASEexportconstExample=SomeClass;
// ('typeLike' must have 'PascalCase')exportinterfaceExample2{x:boolean;}// ERROR: Function name `Example2` must match one of the following formats: camelCaseexportfunctionExample2():Example2{return{x:false};}

Expected Result

Here's a better way to handle merged declarations: The@typescript-eslint/naming-convention rule should recognize merged declarations, and accept ANY applicable pattern, instead of applying ALL patterns.

For the sample declarationExample2 above, ESLint could accept EITHER 'PascalCase' OR 'camelCase' (whereas currently it requires BOTH).

Versions

packageversion
@typescript-eslint/eslint-plugin3.3.0
@typescript-eslint/parser3.3.0
TypeScript3.5.3
ESLint7.2.0
node12.17.0
npm6.14.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    package: eslint-pluginIssues related to @typescript-eslint/eslint-pluginwontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp