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-no-type-assertion
Advanced tools
Disallow type assertions in TypeScript code. The rule will forbid both as
operator and the angle-bracketed syntax, unless used for const assertions.
The following code becomes invalid:
const foo: unknown = 42;
const notAString = <string>foo; // can't perform angle-bracketed type assertion
const alsoNotAString = foo as string; // can't use `as` operator for type assertion
const objectWithOptionalProperty: { a?: number } = {};
const notANumber = objectWithOptionalProperty.a! / 2; // can't use non-null assertion operator
Ensure you have ESLint and @typescript-eslint/parser
installed:
$ yarn add eslint @typescript-eslint/parser -D
Next, install this plugin:
$ yarn add eslint-plugin-no-type-assertion -D
In your ESLint configuratio, ensure you're using @typescript-eslint/parser
as a parser and it's set up correctly:
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018
}
}
Add eslint-plugin-no-type-assertion
to the plugin list:
{
"plugins": ["no-type-assertion"]
}
Enable the rule:
{
"rules": {
"no-type-assertion/no-type-assertion": "error"
}
}
1.2.0 - 2022-03-26
FAQs
Disallow type assertions in TypeScript code
We found that eslint-plugin-no-type-assertion demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.