
Product
Introducing Pull Request Stories to Help Security Teams Track Supply Chain Risks
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
smart-tslint-rules
Advanced tools
Human-friendly tslint rules
smart-tslint-rules
is set of TSLint rules to:
Install the package using NPM:
npm install smart-tslint-rules --save-dev
smart-tslint-rules has peer dependencies on TSLint and TypeScript.
To use these lint rules with the default preset, use configuration inheritance via the extends
keyword.
Here's a sample configuration where tslint.json
lives adjacent to your node_modules
folder:
{
"extends": ["tslint:latest", "smart-tslint-rules"],
"rules": {
"quotemark-smart": true,
"restrict-literal-concat": true
}
}
To lint your .ts
and .tsx
files you can simply run tslint -c tslint.json 'src/**/*.{ts,tsx}'
.
Requires single or double quotes for string literals based on literal content.
Configuration object may be optionally provided (defaults listed):
{
default: "'",
// allow both single or double but not \`tagged\`
jsx: "'\"",
empty: "'\"",
singleChar: "'",
startsWithDot: "\"",
startsWithDigit: "\"",
multiWord: "\"",
longLiteral: "\"",
longLimit: 30,
shortLiteral: "'",
shortLimit: 10,
avoidEscape: true,
avoidTemplate: true,
}
For example, `[true, "singleChar": ""'" ]` would not report a failure on the string literals "a" or 'a'.`,
Individual rules can be enabled and configured to express preference and smooth the transitions. E.g. start with allowing both kinds of quotes for all but long words and then gradually restrict the ruleset.
Prefer template literals to string concatenation.
Short literal can be allowed with setting [true, { "allow-length": 5 }]
Setting allow-length
to relatively high limit enables baby steps for removing '+' concatenation in a codebase.
FAQs
Human-friendly tslint rules
We found that smart-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
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.