Skip to main content

no-invalid-this

Disallows this keywords outside of classes or class-like objects.

Attributes

  • Included in configs
    • ✅ Recommended
    • 🔒 Strict
  • Fixable
    • 🔧 Automated Fixer
    • 🛠 Suggestion Fixer
  • 💭 Requires type information

Rule Details

This rule extends the base eslint/no-invalid-this rule. It adds support for TypeScript's this parameters.

How to Use

{
// note you must disable the base rule as it can report incorrect errors
"no-invalid-this": "off",
"@typescript-eslint/no-invalid-this": ["error"]
}

Options

See eslint/no-invalid-this options.

When Not To Use It

When you are indifferent as to how your variables are initialized.

Taken with ❤️ from ESLint core