-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Discuss] Lint rule to enforce I prefix for typescript interfaces #51674
Comments
Pinging @elastic/kibana-operations (Team:Operations) |
We can use the |
Will this also apply to interface representing (still) JavaScript classes? Like pure type definitions? Or just for real interfaces? Will it be used for all interfaces and interface-like types, or just interfaces? Are we planning to refactor the whole code base for that now (we already had 2 master breakages in the past week, because of type renaming). |
Yep, the idea is to apply the Ideally, everything would be refactored across the codebase, if it's too big of an effort to do in one chunk, we could split it up by folder. Though as our code base grows so do these style change efforts. I'm starting to think about how we can keep this kind of thing up as we grow. Forcing one team to modify every file in Kibana to conform to a new lint rule is a lot of work, as is manually setting it up to do it folder by folder. Maybe we need some kind of versioned, published lint/formatting rules, that each plugin can bump when they are ready. My main objective with this issue is to highlight the plan. E.g., you don't have to do this now, bc it's not yet a lint rule, but eventually, if you want to conform to Kibana's style guide, you'll have to do this. |
Could you perhaps also clarify on the reason for this decision? The initial description unfortunately doesn't go into detail why we now want to use interface names? I just remember we had some discussions in the past, where we made an explicit decision not to use it, so it would be nice to read a bit more about the backgrounds here of the decision, please. |
The benefits, imo, are to make the differentiation between what is a class and what is an interface clear and to enforce a consistent naming scheme. Embeddables export So if you are writing a function that takes in something, like a filter manager, you can first look for the Certainly open to arguments going the other way, especially since the original decision and discussion wasn't captured. There are quite a few arguments for the other side. Probably one of the strongest is that typescript/microsoft itself recommends against using this: microsoft/TypeScript-Handbook#121. You could also argue against my statement above and say that the plugin author should only export the interface and they should name it https://stackoverflow.com/questions/31876947/confused-about-the-interface-and-class-coding-guidelines-for-typescript/41967120#41967120 has some interesting info too. I don't know, I might actually be convincing myself out of this. If there is such a debate, why risk introducing a rule that we may eventually regret, when the effort to introduce the rule is large, and the benefit questionable. 🤔 |
Okay, so I finally found the slack discussion where this was loosely decided on back in July. Since slack is not a good place to track the reason for decisions, I would like to change this to a "discuss" topic, and give folks an opportunity to weigh in. cc @elastic/kibana-platform @elastic/kibana-app-arch @epixa I was originally for the rule, but after reading some of the reasons against, I'm starting to think it's not worth it to make this official. |
The platform teams decided on the |
I've worked on both types of TypeScript projects that explicitly prohibit prefixing interfaces with |
Thanks all for weighing in. Let's consider the matter closed with a decision of not moving forward with this as a linting rule, nor as a recommendation. |
We discussed using I prefix for typescript interfaces and decided to move forward with this as a convention. We just need to add a lint rule for it now.
The text was updated successfully, but these errors were encountered: