Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tslint-immutable

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tslint-immutable

TSLint rules to disable all mutation in TypeScript.

  • 0.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19K
decreased by-4.56%
Maintainers
1
Weekly downloads
 
Created
Source

tslint-immutable

This repo contains a TSLint version of the eslint-plugin-immutable .

This goal of these TSLint rules are to disable all mutation in TypeScript. Please see the eslint-plugin-immutable version for the rationale beind this.

Installing

npm install tslint-immutable --save-dev

TSLint Rules

There following rules are availavle:

no-let

See eslint version for documentation.

no-this

See eslint version for documentation.

no-mutation

See eslint version for documentation.

no-expression-statement

When you call a function and don’t use it’s return value, chances are high that it is being called for its side effect. e.g.

array.push(1)
alert('Hello world!')

This rule checks that the value of an expression is assigned to a variable. However it will still be possible to perform mutations, eg. this rule will not catch these expressions:

const namesWithBar = names.concat([' bar ']) // ok, bound to another variable
return namesWithBar // ok, returned
const newSize = names.push('baz') // maybe `no-unused-vars` can catch this
const newObject = Object.assign(oldObject, { foo: 'bar' }) // tough luck

Supplementary TSLint Rules to Enable

The rules in this package alone can not eliminate mutation in your TypeScript programs. To go the distance I suggest you also enable the following built-in TSLint rules:

  • no-var-keyword (self-explanatory)

Sample Configuration File

Here's a sample TSLint configuration file (tslint.json) that activates all the recommended rules:

{
  "rulesDirectory": "path/to/tslint-immutable/rules",
  "rules": {
    "no-let": true,
    "no-this": true,
    "no-mutation": true,
    "no-expression-statement": true,
    "no-var-keyword": true
  }
}

Keywords

FAQs

Package last updated on 03 Nov 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc