
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
simplr-tslint
Advanced tools
A set of TSLint rules used in SimplrJS projects.
npm install simplr-tslint --save-dev
To get latest tslint config.
npm install simplr-tslint@next --save-dev
We recommend using this plugin tslint-language-service.
npm install tslint-language-service -D
tsconfig.json
{
"compilerOptions": {
"plugins": [
{
"name": "tslint-language-service",
"alwaysShowRuleFailuresAsWarnings": true,
"ignoreDefinitionFiles": true
}
]
}
}
Add this line in your tslint.json
file:
{
"extends": "simplr-tslint"
}
Or:
{
"extends": ["simplr-tslint"]
}
class-members-name
🔨Has Fixer ⚠️Requires Type info
Enforces consistent naming style in interface and class declarations.
Name | Type | Optional | Description |
---|---|---|---|
formatRules | FormatRule[] | Optional | Format rules for class and interface members. |
ignoreParentSuffixes | string[] | Optional | Ignores classes and interfaces with given suffix. |
Name | Type | Optional | Default |
---|---|---|---|
kind | "method", "property" | Required | |
modifier | "public", "private", "protected" | Optional | "public" |
format | "none", "camel-case", "pascal-case", "constant-case", "snake-case" | Optional | "none" |
isStatic | boolean | Optional | false |
allowedPrefixes | string[] | Optional |
"class-members-name": [
true,
{
"formatRules": [{ "kind": "property", "format": "camel-case", "allowedPrefixes": ["_"] }],
"ignoreParentSuffixes": ["Dto"]
}
]
Enforces all members naming to camel-case
format.
"class-members-name": true
Enforces all members naming to pascal-case
format.
"class-members-name": [true, "pascal-case"]
Enforces all members naming to pascal-case
format. Skips origin checking in heritage. Useful when migrating coding style.
"class-members-name": [true, "pascal-case", "skip-origin-checking"]
C# coding style example.
"class-members-name": [
true,
{
"formatRules": [
{ "kind": "method", "modifier": "public", "format": "pascal-case" },
{ "kind": "method", "modifier": "protected", "format": "pascal-case" },
{ "kind": "method", "modifier": "private", "format": "camel-case" },
{ "kind": "property", "modifier": "public", "format": "pascal-case" },
{ "kind": "property", "modifier": "protected", "format": "pascal-case" },
{ "kind": "property", "modifier": "private", "format": "camel-case" }
]
}
]
Ignoring parent suffix example.
"class-members-name": [
true,
{
"ignoreParentSuffixes": ["Dto"]
}
]
interface Foo {
_id: string;
// ~~~ [Declaration "_id" format is not correct (camel-case).]
full_name: string;
// ~~~~~~~~~ [Declaration "full_name" format is not correct (camel-case).]
}
interface FooDto {
_id: string;
full_name: string;
}
const-variable-name
🔨Has Fixer ⚠️Requires Type info
Const variables in source file or in module must have constant-case.
export const FOO_FOO = "Hello World!";
export const fooBar = "Hello World!";
// ~~~~~~ [Const variables in source file or in module declaration must have (constant-case) format.]
export namespace FooNamespace {
export const PACKAGE_VERSION: string = "v1.0.0";
export function test(): void {
const variableInFunctionScope: string = "Hello.";
}
}
"const-variable-name": true
This rule only will be applied to constants that has primitive value (e.g. string
, boolean
).
"const-variable-name": [true, "only-primitives"]
exported-namespace-member
🔨Has Fixer
All module members must be exported.
"exported-namespace-member": true
type-parameter-name
🔨Has Fixer
Type parameter's name must start with "T" prefix.
export type Foo<Value> = [string, Value];
// ~~~~~ [Type parameter's name must start with "T" prefix.]
export type Bar<TValue> = [string, TValue];
"type-parameter-name": true
backing-field
🔨Has Fixer
Backing fields are properties with _
prefix. They can ONLY be used in GetAccessor and SetAccessor declarations.
export class Foo {
constructor(private _foo: string) {}
public get foo(): string {
return this._foo;
}
public getFoo(): string {
return this._foo;
// ~~~~~~~~~ [Backing field can only be used in GetAccessor and SetAccessor.]
}
}
"type-parameter-name": true
Released under the MIT license.
FAQs
A set of TSLint rules used in SimplrJS projects.
The npm package simplr-tslint receives a total of 329 weekly downloads. As such, simplr-tslint popularity was classified as not popular.
We found that simplr-tslint demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.