JSPM

tslint-whitespace-before-colon

0.2.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 101
  • Score
    100M100P100Q85548F
  • License MIT

TSLint rule for determining if a space is required or not before the colon in object literals and destructuring assignments

Package Exports

  • tslint-whitespace-before-colon

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tslint-whitespace-before-colon) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

TSLint Rule: whitespace-before-colon

TSLint provides no means of controlling spaces before colon in object literals and destructuring assignments. whitespace.check-type checks only for space after colon, and typedef-whitespace works only for type definitions.

This rules determines if a space is required or not before the colon in object literals and destructuring assignments.

Related to palantir/tslint#991.

Usage

Install with NPM or Yarn to your dev dependencies:

npm install --save-dev tslint-whitespace-before-colon

and include it in your project's tslint.json file. You can do it either by adding the package name to extends field:

  "extends": [
    "tslint-whitespace-before-colon"
  ]

or by adding the package location to rulesDirectory field:

  "rulesDirectory": [
    "node_modules/tslint-whitespace-before-colon"
  ]

Both approaches are equivalent, use whichever suits your project the most.

Configuration

Rule expects a single string option indicating the required number of spaces before colon:

  • "nospace" requires no space
  • "onespace" requires exactly one space
  • "space" requires one or more spaces

If none of the above is provided, the rule will have no effect.

Example configuration:

  "rules": {
    "whitespace-before-colon": [true, "nospace"]
  }

Note

If a newline character ("\n") is present, the rule validates regardless of the configured option, just as typedef-whitespace rule does.

License

MIT