Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make @typescript-eslint/naming-convention ignore non alphanumeric keys #54

Closed
wants to merge 1 commit into from

Conversation

GauBen
Copy link

@GauBen GauBen commented Mar 24, 2022

Please see #53 for context

\W means [^a-zA-Z0-9_], making keys containing symbols (and thus quoted) ignored by the rule.

Fixes #53

@sindresorhus
Copy link
Member

$ is a valid character in a JS identifier.

I guess you could borrow the regex from here: https://github.com/yeoman/stringify-object/blob/e6ef8e2aa276f79b86a04398df273d45e838a254/index.js#L111

@GauBen
Copy link
Author

GauBen commented Mar 27, 2022

That's true, but I don't know how to capitalize "$lib", maybe it would make more sense to restrict the regex to "sentence-like" keys ([^a-zA-Z_]), without numbers and symbols.

@GauBen
Copy link
Author

GauBen commented Mar 27, 2022

I'm back with a crazier edge-case:

export default class Ping {
  @Get()
  ''(): string {
//^^ Class Method name `` must match...
    return 'pong'
  }
}

@sindresorhus
Copy link
Member

@GauBen
Copy link
Author

GauBen commented May 8, 2022

Disclaimer: not tested

// Ignore `{'Retry-After': retryAfter}` type properties.
selector: ['classProperty', 'objectLiteralProperty', 'classMethod', 'objectLiteralMethod', 'typeMethod'],
format: null,
modifiers: ["requiresQuotes"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
modifiers: ["requiresQuotes"]
modifiers: [
'requiresQuotes'
]

@sindresorhus
Copy link
Member

It needs to be tested for it to be merged.

@gutenye
Copy link

gutenye commented May 9, 2022

// Allow these in non-camel-case when quoted.
{
selector: [
'classProperty',
'objectLiteralProperty'
],
format: null,
modifiers: [
'requiresQuotes'
]
}
Should be removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@typescript-eslint/naming-convention should ignore all exotic keys
3 participants