tslint-rules-line-before-tests
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

tslint-rules-line-before-tests

TSLint rule to check and fix the minimum number of lines before test cases.
i.e. describe(), xdescribe(), it(), xit(), test(), xtest().

Install

Install the package using NPM:

npm install tslint-rules-line-before-tests --save-dev

Update your tslint.json file to extend this package:

{
  "rulesDirectory": [
    "tslint-rules-line-before-tests"
  ],
  "rules": {
    "line-before-tests": true
  }
}

Rules

line-before-tests

Checks minimum number of lines before test cases.

Has Fixer

Yes

Config

Takes optional object with following optional properties:

  • "beforeDescribe" minimum number of blank lines before describe(), xdescribe(). Default value = 2. To disable, set to -1.
  • "beforeIt" minimum number of blank lines before it(), xit(), test(), xtest(). Default value = 1. To disable, set to -1.
Config examples
"line-before-tests": true
"line-before-tests": [true, {beforeDescribe: 2, beforeIt: 1}]
"line-before-tests": [true, {beforeDescribe: 2}]
"line-before-tests": [true, {beforeIt: 1}]
"line-before-tests": [true, {beforeDescribe: 2, beforeIt: -1}]
"line-before-tests": [true, {beforeDescribe: -1, beforeIt: 1}]

Test files

If you are interested to see exactly where it will throw error, you can take a look at tests:


For below configuration, check test file here.

"line-before-tests": [true, {beforeDescribe: 2, beforeIt: -1}]

For below configuration, check test file here.

"line-before-tests": [true, {beforeDescribe: -1, beforeIt: 1}]

Development

# build
yarn build

# test
yarn test

Package Sidebar

Install

npm i tslint-rules-line-before-tests

Weekly Downloads

2

Version

2.0.0

License

MIT

Unpacked Size

12.7 kB

Total Files

13

Last publish

Collaborators

  • omkar.sheral.1989