1. tslint-no-unused-expression-chai
Custom tslint no-unused-expression rule supports chai's expect assertion
tslint-no-unused-expression-chai
Package: tslint-no-unused-expression-chai
Created by: kwonoj
Last modified: Mon, 27 Jun 2022 22:41:49 GMT
Version: 0.1.4
License: MIT
Downloads: 47,614
Repository: https://github.com/kwonoj/tslint-no-unused-expression-chai

Install

npm install tslint-no-unused-expression-chai
yarn add tslint-no-unused-expression-chai

Build Status
npm

tslint-no-unused-expression-chai

From tslint 5, lint applies no-unused-expression more strictly. This affects
test assertion written via chai, as its expect assertion is form of expression caught by lint. tslint-no-unused-expression-chai provides drop-in replacement of rule no-unused-expression to loosen lint checker for chai's assertion.

This module supports chai's expect based assertion (i.e expect(x).to.be....).
When adding "should" to the rule configuration, it also supports those assertios.
Other type of property based assertion still may not work.

Install

This has a peer dependencies of tslint@5.*.* and implicit dependency of typescript, which will have to be installed as well

 npm install --save-dev tslint-no-unused-expression-chai

Usage

You can configure tslint rules by replacing existing no-unused-expression rule.

 "rules": {
  //accepts all options of https://palantir.github.io/tslint/rules/no-unused-expression/
  "no-unused-expression-chai": true
  ...
},
"rulesDirectory": [
  "tslint-no-unused-expression-chai"
  ...
]

Alternatively you can just extend the configuration preset provided by this package. It disables no-unused-expression and enables no-unused-expression-chai.

 "extends": [
  ...
  "tslint-no-unused-expression-chai"
]

Building / Testing

Few npm scripts are supported for build / test code. As this rule is simple override to default rules, it doesn't have own unit test coverage but borrows test fixture from original rule.

  • build: Transpiles code to ES5 commonjs to rules.
  • test: Run tests.
  • lint: Run lint over all codebases
  • lint:staged: Run lint only for staged changes. This'll be executed automatically with precommit hook.
  • commit: Commit wizard to write commit message

Dependencies

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code