Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

TypeScript coding guidelines say to not prefix interface with I #3265

Closed
bdparrish opened this issue Sep 30, 2017 · 15 comments
Closed

TypeScript coding guidelines say to not prefix interface with I #3265

bdparrish opened this issue Sep 30, 2017 · 15 comments

Comments

@bdparrish
Copy link

Bug Report

  • TSLint version: 3.15.1
  • TypeScript version: 2.5.3
  • Running TSLint via: (pick one) CLI

TypeScript code being linted

// code snippet
interface TypeConfig { }

Actual behavior

[tslint] interface name must start with a capitalized I (interface-name)

Microsoft suggests interface names to not be prefixed with an I - https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines#names

@ajafff
Copy link
Contributor

ajafff commented Sep 30, 2017

Note that these are the guidelines for writing the typescript compiler itself. It's not meant to be a style guide for any other typescript project out there.
If you want to adopt this style guide for your projects, you can just change the rule's config in your tslint.json to "interface-name" : [true, "never"]

@kachkaev
Copy link

kachkaev commented Feb 2, 2018

50 cent from a passer-by:
"interface-name" : [true, "never-prefix"] instead of
"interface-name" : [true, "never"]
🙌

rule docs

@mraible
Copy link

mraible commented May 16, 2018

I tried turning off the "I" prefix by adding interface-name to the default tslint.json that's generated by Create React App. However, it doesn't seem to work. Maybe I'm putting it in the wrong location?

{
  "extends": [
    "tslint:recommended",
    "tslint-react",
    "tslint-config-prettier"
  ],
  "linterOptions": {
    "exclude": [
      "config/**/*.js",
      "node_modules/**/*.ts"
    ]
  },
  "interface-name" : [true, "never-prefix"]
}

@mraible
Copy link

mraible commented May 16, 2018

Nevermind, I figured it out:

{
  "extends": [
    "tslint:recommended",
    "tslint-react",
    "tslint-config-prettier"
  ],
  "linterOptions": {
    "exclude": [
      "config/**/*.js",
      "node_modules/**/*.ts"
    ]
  },
  "rules": {
    "interface-name" : [true, "never-prefix"]
  }
}

@vasilev-alex
Copy link

For some reason "interface-name": [true, "never"] doesn't work for me. But "interface-name": false works fine

@aaronjameslang
Copy link

@vasilev-alex "interface-name": [true, "never-prefix"] empasis on never-prefix

@JacobWeisenburger
Copy link

I'm still getting "interface name must start with a capitalized I"

this is my tslint.json:

{
  "rules": {
    "interface-name": [
      true,
      "never-prefix"
    ]
  },
  "extends": [
    "tslint:recommended",
    "tslint-react",
    "tslint-config-prettier"
  ],
  "linterOptions": {
    "exclude": [
      "config/**/*.js",
      "node_modules/**/*.ts",
      "coverage/lcov-report/*.js"
    ]
  }
}

What am I doing wrong?

@aaronjameslang
Copy link

@offg777 Nothing obvious. Link to repo?

@johnwiseheart
Copy link
Contributor

The config looks correct to me - are you sure theres nothing else overriding it? The rule is definitely working properly for me

@stevenvanc
Copy link

@offg777

"interface name must start with a capitalized I"

From where do you get this error? From your IDE or when running a CLI?
And I don't know about the exact cascading rules of tslint, but have you tried putting the "rules" block underneath "extends"?

@DDDenial
Copy link

厉害

@ackvf
Copy link

ackvf commented Apr 14, 2019

Does eslint support that already?

@hyvyys
Copy link

hyvyys commented Mar 8, 2020

Setting

"rules": {
    "interface-name": [
      true,
      "never-prefix"
    ]
  },

results in
Configuration for rule "interface-name" is invalid

Maybe this rule exists for a reason? Should every interface have a meaningful name obviously different from an implementing class?

@sergeych
Copy link

This is bloody annoying idea of forcing the rest of the world following your preferences outside the your own project. Obtrusion of your own naming conventions in programming tools is a bug of the product developer neural network ;)

@JoshuaKGoldberg
Copy link
Contributor

Good thing TSLint is deprecated and this issue is no longer relevant, then! #4534

@palantir palantir locked and limited conversation to collaborators Nov 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests