Skip to content

[naming-convention] How to configure to forbid I prefix for interfaces #2065

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

Closed
simPod opened this issue May 22, 2020 · 2 comments · Fixed by #2070
Closed

[naming-convention] How to configure to forbid I prefix for interfaces #2065

simPod opened this issue May 22, 2020 · 2 comments · Fixed by #2070
Labels
documentation Documentation ("docs") that needs adding/updating package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@simPod
Copy link

simPod commented May 22, 2020

Repro

I have been using this config with v2

"@typescript-eslint/interface-name-prefix": [
    "error", {
        "prefixWithI": "never"
    }
],

The rule was removed in favor of naming-convention. I'm trying to configure the same

"@typescript-eslint/naming-convention": [
    "error",
    {
        "selector": "interface",
        "format": ["PascalCase"],
        "prefix": ["I"]
    }

which requires I prefix now. I did not find a way to invert the condition though.

Versions

package version
@typescript-eslint/eslint-plugin 3.0.0
@simPod simPod added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels May 22, 2020
@bradzacher
Copy link
Member

It should be as simple as:

"@typescript-eslint/naming-convention": [
    "error",
    {
        "selector": "interface",
        "format": ["PascalCase"],
        "custom": {
            "regex": "^I[A-Z]",
            "match": false,
        }
    }
]

I'll add this to the docs

@bradzacher bradzacher added documentation Documentation ("docs") that needs adding/updating and removed triage Waiting for team members to take a look labels May 22, 2020
@simPod
Copy link
Author

simPod commented May 23, 2020

Works like a charm, thanks, much appreciated!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Documentation ("docs") that needs adding/updating package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants