39

When I add the rule,

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

give the following error message:

Definition for rule '@typescript-eslint/interface-name-prefix' was not found.eslint(@typescript-eslint/interface-name-prefix)

2 Answers 2

100

The rule @typescript-eslint/interface-name-prefix has been removed as you can see here.

You can achieve the same effect of [ "error", { "prefixWithI": "always" }] with the following:

{
  "@typescript-eslint/naming-convention": [
    "error",
    {
      "selector": "interface",
      "format": ["PascalCase"],
      "custom": {
        "regex": "^I[A-Z]",
        "match": true
      }
    }
  ]
}
Sign up to request clarification or add additional context in comments.

3 Comments

I've just updated my libraries and was getting the same error -- thanks for the answer :)
After I did update packages with the command (yarn upgrade-interactive --latest) the error occurred, thank you very much, your answer helped me.
Hi, where I should put this code?
5

The accepted answer is great, though it looks like you can also simply specify a prefix:

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

2 Comments

Hi, where I should put this code?
This goes under "rules" in your .eslintrc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.