Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
eslint-plugin-expect-type
Advanced tools
ESLint plugin with ^? Twoslash, $ExpectError, and $ExpectType type assertions. 🧩
ESLint plugin with `^?` Twoslash, `$ExpectError`, and `$ExpectType` type assertions. 🧩
let value = 9001;
// ^? let value: number
// $ExpectError
value = "over nine thousand";
// $ExpectType number
9001;
Make sure you have TypeScript and @typescript-eslint/parser installed, then install the plugin:
npm i -D eslint-plugin-expect-type
See typescript-eslint's Getting Started docs for how to run ESLint on TypeScript files.
Add the following options to your ESLint configuration file:
import expectType from "eslint-plugin-expect-type/configs/recommended";
export default [
// your other ESLint configurations
expectType,
];
Then, you'll be able to use ^?
, $ExpectError
, $ExpectType
, and $ExpectTypeSnapshot
comments in code assert on types.
If you're still using the legacy ESLint configuration file format:
{
"extends": ["plugin:expect-type/recommended"],
"plugins": ["expect-type"]
}
💼 Configurations enabled in.
✅ Set in the recommended
configuration.
🔧 Automatically fixable by the --fix
CLI option.
💭 Requires type information.
Name | Description | 💼 | 🔧 | 💭 |
---|---|---|---|---|
expect | Expects type error, type snapshot, or type. | ✅ | 🔧 | 💭 |
You might consider using other popular type assertion libraries in the TypeScript ecosystem:
expectTypeOf('abc').toMatchTypeOf<string>()
.expectType<string>('abc')()
..d.ts
definition files.assertType
and expectTypeOf
assertions.eslint-plugin-expect-type
mirrors the DefinitelyTyped TypeScript Support Window.
Roughly, that's major versions of TypeScript less than 2 years old.
Many thanks to @ibezkrovnyi for creating the initial version and core infrastructure of this package! 💖
Batuhan Wilhelm 🐛 💻 | Colin 🐛 | Dan Vanderkam 💻 🚧 | Daniel Nagy 🐛 | Dominik Dorfmeister 📖 | Francesco Trotta 💻 | Igor Bezkrovnyi 🐛 💻 📖 🚧 |
Josh Goldberg ✨ 🐛 💻 📖 🚧 🚇 🤔 | Russell Davis 💻 | detachhead 🤔 | nirtamir2 📖 |
💙 This package was templated with create-typescript-app.
FAQs
ESLint plugin with ^? Twoslash, $ExpectError, and $ExpectType type assertions. 🧩
We found that eslint-plugin-expect-type demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.