
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
tslint-misc-rules
Advanced tools
Collection of miscellaneous TSLint rules
$ npm install tslint-misc-rules --save-dev
{
"rules": {
"sort-imports": true
},
"rulesDirectory": [
"tslint-misc-rules"
]
}
Fails:
import b from "b";
import a from "a";
Passes:
import a from "a";
import b from "b";
Blocks are grouped, so this also passes:
import a from "a";
import z from "z";
testSetup();
import c from "c";
import d from "d";
Precedence is essentially *
, {
, then alpha, so:
import * as a from "a";
import { b, c } from "bc";
import d from "d";
This rule has one option, whitespace-insensitive
, that collapses all whitespace spans (including line breaks) down to one space when sorting. This provides compatibility with formatters like Prettier, which may decide to turn a single-line import into a multi-line import when it grows too long. This could otherwise introduce a lint failure. Ex:
"sort-imports": [ true, "whitespace-insensitive" ]
Fails:
import {
x,
y,
} from "xy";
import { a } from "a";
Passes:
import { a } from "a";
import {
x,
y,
} from "xy";
With configuration (required):
{
"prefer-es6-imports": [
true,
"module-name"
]
}
Fails:
import mod = require("module-name");
import mod = require("path/to/module-name");
import mod = require("../module-name");
Ensure each method in class is preceded by a newline.
Fails:
class foo {
propertyOne: any;
propertyTwo: any;
one() {
}
two() {
}
}
Passes:
class foo {
propertyOne: any;
propertyTwo: any;
one() {
}
two() {
}
}
The first method is exempt, so this also passes:
class foo {
one() {
}
two() {
}
}
Fails:
<div prop = { value }/>
<div prop= { value }/>
<div prop ={ value }/>
Passes:
<div prop={ value }/>
Fails:
<div prop={value}/>
<div prop={ value}/>
<div prop={value }/>
<div>
{value}
{ value}
{value }
</div>
Passes:
<div prop={ value }/>
<div>
{ value }
</div>
Fails:
<a className="asdf"
href="/foo"
/>
<div
className="qwer"
name="asdf"
>
text
</div>
Passes:
<a className="asdf"
href="/foo" />
<div
className="qwer"
name="asdf">
text
</div>
Fails:
<div prop={ "value" }/>
Passes:
<div prop="value"/>
With configuration (optional):
{
"react-lifecycle-order": [
true,
"componentWillMount",
"render",
"componentWillUnmount"
]
}
Fails:
class extends React.Component {
componentWillMount() {
}
componentWillUnmount() {
}
render() {
}
}
Passes:
class extends React.Component {
componentWillMount() {
}
render() {
}
componentWillUnmount() {
}
}
If configuration is not specified, React's invocation order is used.
Fails:
const maybeFoo = foo ? foo : bar;
Passes:
const maybeFoo = foo || bar;
Fails:
class foo {
bar = 42;
}
Passes:
class foo {
bar: number;
}
Due to React's Stateless Functional Components, this rule checks callsites rather than declarations.
Fails:
import FooImport from 'foo';
function FooDeclaration() { }
FooImport();
FooDeclaration();
Passes:
import fooImport from 'foo';
function fooDeclaration() { }
function SomeSFC(props) { return null; }
fooImport();
fooDeclaration();
const el = </SomeSFC>;
Fails:
class foo {
bar() {
}
foo() {
this.bar();
}
}
Passes:
class foo {
foo() {
this.bar();
}
bar() {
}
}
Fails:
const add = (x, y) => { return x + y };
const btn = <button onClick={ e => { console.log(e); } } />;
Passes:
const add = (x, y) => x + y;
const btn = <button onClick={ e => console.log(e) } />;
Fails:
const log = (x) => console.log(x);
Passes:
const log = x => console.log(x);
FAQs
Collection of miscellaneous TSLint rules
The npm package tslint-misc-rules receives a total of 676 weekly downloads. As such, tslint-misc-rules popularity was classified as not popular.
We found that tslint-misc-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.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.