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.
@node-ts/code-standards
Advanced tools
A sane and opinionated set of linting rules for TypeScript
An opinionated set of linting and build configurations for typescript projects to build modern, maintainable TypeScript projects.
The linting rules aim to produce terse, neat and consistent TypeScript code. This is valuable in any repo that has more than one contributor, but single author projects may also find it useful.
Below shows a small example of the code produced with this style:
// Enforce ES6 style imports
import { S3 } from 'aws-sdk' // single quotes, no semicolon on the end of lines
export class ObjectStorageService {
constructor ( // double-space indents
private readonly s3 = new S3()
) {
}
async upload (bucket: string, key: string, body: Buffer): Promise<void> { // enforce complete method signature
const putObjectRequest: S3.Types.PutObjectRequest = { // prefer const
Bucket: bucket,
Key: key,
Body: body
}
await this.s3.putObject(putObjectRequest).promise()
}
}
// All files end with a new line (LF)
TypeScript options have been set in tsconfig.json
that target Node v8 and up. These options can be overridden for web projects that target browsers.
Install into your project along with tslint
and typescript
npm i @node-ts/code-standards tslint typescript --save-dev
Copy .editorconfig
into the root of your project. This will let your code editor confirm to many of the whitespacing rules automatically. See Editor Config on setting up your code editor for the first time.
Create a tslint.json
file in the root of your project with the following contents:
{
"extends": "./node_modules/@node-ts/code-standards/tslint.json"
}
Create a tsconfig.json
file in the root of your project with the following contents. You may wish to extend this with further options
{
"extends": "./node_modules/@node-ts/code-standards/tsconfig.json"
}
Add the following to the scripts
block in your project's package.json
:
{
"lint": "tslint --project tsconfig.json 'src/**/*.ts'",
"lint:fix": "npm lint --fix"
}
IDE defaults for line spacing, whitespace etc can be set by placing an .editorconfig
file (like the one in this package) into the root of your project. This is used by the Editor Config plugin of your preferred browser to set such defaults for your project.
This helps ensure any characters inserted by your editor conforms to the linting rules in this package.
Individual rules can be overridden if they do not suit the particular project they're being imported into. This is common for web sites that need to transpile slightly differently to a regular node application.
Individual linting rules cna be overridden by specifying the updated rule in your local tslint.json
file as such:
{
"extends": "./node_modules/@node-ts/code-standards/tslint.json",
"rules": {
"semicolon": [true, "always"]
}
}
Similar to linting, TypeScript configuration options can be overridden by specifying the updated values in the local tsconfig.json
file.
For example:
{
"extends": "./node_modules/@node-ts/code-standards/tsconfig.json",
"compilerOptions": {
"target": "es6",
"lib": ["es7"]
}
}
FAQs
A sane and opinionated set of linting rules for TypeScript
The npm package @node-ts/code-standards receives a total of 730 weekly downloads. As such, @node-ts/code-standards popularity was classified as not popular.
We found that @node-ts/code-standards 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.