Skip to main content

init-declarations

Require or disallow initialization in variable declarations.

🧱

This is an "extension" rule that replaces a core ESLint rule to work with TypeScript. See Rules > Extension Rules.

This rule extends the base init-declarations rule from ESLint core. It adds support for TypeScript's declare variables.

Options

See eslint/init-declarations's options.

How to Use

eslint.config.mjs
export default tseslint.config({
rules: {
// Note: you must disable the base rule as it can report incorrect errors
"init-declarations": "off",
"@typescript-eslint/init-declarations": "error"
}
});

Try this rule in the playground ↗

Resources

Taken with ❤️ from ESLint core.