Skip to content

[naming-convention] Handle names that are a classish type #1485

@sindresorhus

Description

@sindresorhus
{
	rules: {
		'@typescript-eslint/naming-convention': [
			'error',
			{
				selector: 'default',
				format: [
					'strictCamelCase'
				],
				leadingUnderscore: 'allow',
				trailingUnderscore: 'allow'
			}
		}
	}
}
export interface Got extends GotFunctions {
	GotError: typeof errors.GotError;
	CacheError: typeof errors.CacheError;
	RequestError: typeof errors.RequestError;
	ReadError: typeof errors.ReadError;
	ParseError: typeof errors.ParseError;
	HTTPError: typeof errors.HTTPError;
	MaxRedirectsError: typeof errors.MaxRedirectsError;
	UnsupportedProtocolError: typeof errors.UnsupportedProtocolError;
	TimeoutError: typeof errors.TimeoutError;
	CancelError: typeof errors.CancelError;
}
export const Chalk: new (options?: Options) => ChalkInstance;

Expected Result

In the above example, errors.GotError and the other properties refers to a class, so GotError has to be PascalCase. However, I couldn't find a way to target properties that are classes.

Actual Result

  ✖   60:2   Property name GotError must match one of the following formats: strictCamelCase                         @typescript-eslint/naming-convention
  ✖   61:2   Property name CacheError must match one of the following formats: strictCamelCase                       @typescript-eslint/naming-convention
  ✖   62:2   Property name RequestError must match one of the following formats: strictCamelCase                     @typescript-eslint/naming-convention
  ✖   63:2   Property name ReadError must match one of the following formats: strictCamelCase                        @typescript-eslint/naming-convention
  ✖   64:2   Property name ParseError must match one of the following formats: strictCamelCase                       @typescript-eslint/naming-convention
  ✖   65:2   Property name HTTPError must match one of the following formats: strictCamelCase                        @typescript-eslint/naming-convention
  ✖   66:2   Property name MaxRedirectsError must match one of the following formats: strictCamelCase                @typescript-eslint/naming-convention
  ✖   67:2   Property name UnsupportedProtocolError must match one of the following formats: strictCamelCase         @typescript-eslint/naming-convention
  ✖   68:2   Property name TimeoutError must match one of the following formats: strictCamelCase                     @typescript-eslint/naming-convention
  ✖   69:2   Property name CancelError must match one of the following formats: strictCamelCase                      @typescript-eslint/naming-convention

Additional Info

Versions

package version
@typescript-eslint/eslint-plugin 2.17.0
@typescript-eslint/parser 2.17.0
TypeScript 3.7.5
ESLint 6.8.0
node 10.17.0
npm 6.13.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueenhancement: plugin rule optionNew rule option for an existing eslint-plugin rulelocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions