Interface Rules
All rules regarding interface declarations
Rules that govern how standalone interface files are written. Every rule is
enabled by the recommended config and applies to .ts / .tsx files
inside a /interfaces/ folder of your project.
interface-name-pascal-case
Require interface names to use PascalCase — a leading uppercase letter followed by alphanumeric characters only.
Do
export default interface UserData {
id: string
}Don't
export default interface userData {
id: string
}Underscores and dashes are not allowed in interface names — only alphanumeric characters, with the first character uppercase.
interface-filename-matches-name
Require interface file names to match interface names (excluding extension).
Do
export default interface CustomerProfile {
customerId: string
}Don't
export default interface CustomerProfile {
customerId: string
}A matching file name keeps the import path and the type name in lockstep, which matters when the interface is consumed across many files.
interface-one-per-file
Require exactly one interface declaration per interface file.
Do
export default interface ApiResult {
success: boolean
}Don't
export default interface BillingAddress {
street: string
}
interface ShippingAddress {
street: string
}
If you need a second interface, move it to its own file under
src/interfaces/. This keeps each type easy to find and keeps the
file-name / interface-name contract enforceable.
interface-require-default-export
Require the interface in an interface file to be the default export.
Do
export default interface InvoiceData {
invoiceId: string
}Don't
export interface InvoiceData {
invoiceId: string
}The rule also accepts the equivalent export { Name as default } form:
interface ReceiptData {
receiptId: string
}
export { ReceiptData as default }A default export lets the importer rename the interface to fit the surrounding
context (e.g. InvoiceData as Invoice) without having to know the original
file-level export name.
interface-no-i-prefix
Disallow interface names that start with an I prefix (Hungarian-style
notation).
Do
export default interface UserProfile {
name: string
}Don't
export default interface IUserProfile {
name: string
}The rule only flags names that start with a capital I followed by another
uppercase letter (e.g. IUser, IUserProfile). Identifiers like index or
item are not affected.
TypeScript types and interfaces are structurally typed, so the I prefix no
longer communicates information that the compiler cannot infer. Drop it and
let the name describe the data, not the declaration kind.