
Product
Introducing Module Reachability: Focus on the Vulnerabilities That Matter
Module Reachability filters out unreachable CVEs so you can focus on vulnerabilities that actually matter to your application.
vrsource-tslint-rules
Advanced tools
This project includes a variety of tslint rules we have found useful for our projects.
Install from npm to your devDependencies (https://www.npmjs.com/package/vrsource-tslint-rules)
npm install --save-dev vrsource-tslint-rules
Configure tslint to use the vrsource-tslint-rules folder:
Add "vrsource-tslint-rules"
to the extends
array of your tslint.json
file:
{
"rulesDirectory": ["vrsource-tslint-rules/rules"]
"rules": {
...
}
}
Now configure some of the new rules.
Rule to enforce the use of parentheses each clause of a conditional when they are not simple expressions of a single indentifier or calling expression.
"conditional-expression-parens": true
This rule provides extensive support for customizing allowable variable names for a wide variety of variable tags. The rule is configured by setting up a list of sub-rules that specify the tags of variables to check and the checks to perform on the variable's name. The sub-rules are checked in order and the first one that matches the tags of variable being checked is the only one that is used.
An example set of sub-rules for an example coding standard is shown below.
"ext-variable-name": [
true,
["class", "pascal"],
["interface", "pascal", {"regex": "^I.*$"}],
["parameter", "camel"],
["property", "static", "camel", {"regex": "^s.*$"}],
["property", "private", "camel", "require-leading-underscore"],
["property", "protected", "camel", "allow-leading-underscore"],
["variable", "local", "snake"],
["variable", "const", "upper"],
["variable", "camel", {"regex": "^g.*$"}],
["method", "private", "camel", "require-leading-underscore"],
["method", "protected", "camel", "allow-leading-underscore"],
["function", "camel"],
["default", "camel"]
]
Allowed tags for variables:
note: If any tags is added to a sub-rule then all must match the variable.
Checks allowed:
Rule to enforce consistent spacing inside array and object literals.
See: eslint: object-curly-spacing and array-bracket-spacing
"literal-spacing": [
true,
{
"array": ["always"],
"object": ["never"],
"import": ["always"]
}
]
Rule to enforce a maximum number of parameters for functions and methods.
"max-params": [
true,
3
]
Rule to enforce various checks arrow functions that span multiple lines.
"multiline-arrow": [
true,
"require-parens",
"require-block"
]
This rule checks to make sure that all case clauses use a block around the statements of the case. This helps to protect against issues with lexcical declarations that would become visible to the entire switch statement.
To maintain consistency, the rule requires a block in all cases.
"prefer-case-blocks": true
Flags locations where code calls "new Object()", "new Array()", "new Function()""
"prefer-literal": [
true,
"object",
"function",
"array"
]
prefer-const
rule as tslint now supports itContributions are greatly appreciated. Please fork the repository and submit a pull request.
The command npm run test
will run tests locally.
To add a new rule:
Notes for how to build new rules and tests:
FAQs
Extension rules for tslint
We found that vrsource-tslint-rules 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.
Product
Module Reachability filters out unreachable CVEs so you can focus on vulnerabilities that actually matter to your application.
Product
Socket is introducing a new way to organize repositories and apply repository-specific security policies.
Research
Security News
Socket researchers uncovered malicious npm and PyPI packages that steal crypto wallet credentials using Google Analytics and Telegram for exfiltration.