Gathering detailed insights and metrics for eslint-plugin-no-type-assertion
Gathering detailed insights and metrics for eslint-plugin-no-type-assertion
Gathering detailed insights and metrics for eslint-plugin-no-type-assertion
Gathering detailed insights and metrics for eslint-plugin-no-type-assertion
npm install eslint-plugin-no-type-assertion
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
29 Stars
17 Commits
1 Forks
3 Watching
1 Branches
1 Contributors
Updated on 13 Oct 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
29.7%
7,434
Compared to previous day
Last week
45.8%
38,810
Compared to previous week
Last month
4.7%
128,772
Compared to previous month
Last year
178.8%
1,028,134
Compared to previous year
1
5
Disallow type assertions in TypeScript code. The rule will forbid both as
operator and the angle-bracketed syntax, unless used for const assertions or with the unknown
type. The rule also forbids non-null assertions.
The following code becomes invalid:
1const foo: unknown = 42; 2 3const notAString = <string>foo; // can't perform angle-bracketed type assertion 4const alsoNotAString = foo as string; // can't use `as` operator for type assertion 5 6const objectWithOptionalProperty: { a?: number } = {}; 7 8const 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 configuration, ensure you're using @typescript-eslint/parser
as a parser and it's set up correctly:
1{ 2 "parser": "@typescript-eslint/parser", 3 "parserOptions": { 4 "ecmaVersion": 2018 5 } 6}
Add eslint-plugin-no-type-assertion
to the plugin list:
1{ 2 "plugins": ["no-type-assertion"] 3}
Enable the rule:
1{ 2 "rules": { 3 "no-type-assertion/no-type-assertion": "error" 4 } 5}
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/17 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
11 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More