Skip to main content

key-spacing

danger
This rule will soon be moved to eslint-stylistic. See What About Formatting? for more information.

Enforce consistent spacing between property names and type annotations in types and interfaces.

🔧

Some problems reported by this rule are automatically fixable by the --fix ESLint command line option.

This rule extends the base eslint/key-spacing rule. It adds support for type annotations on interfaces, classes and type literals properties.

How to Use

.eslintrc.cjs
module.exports = {
"rules": {
// Note: you must disable the base rule as it can report incorrect errors
"key-spacing": "off",
"@typescript-eslint/key-spacing": "error"
}
};
Try this rule in the playground ↗

Options

See eslint/key-spacing options.

Resources

Taken with ❤️ from ESLint core