Force commits to pass TSLint


I was recently working on a project and multiple collaborators started to contribute to. All seemed fine until one day, I synced up with the master branch and had 100 warnings pop up in VSCode. I thought about buying my hot dog cart and moving to a beach area finally.



Being totally honest, that cart near the beach looks way more fun than sitting behind a desk staring at a beam of light sucking my soul away sometimes, but that’s just me. You are different and still love programming, because you’re young and full of energy. You’ll mature once you realize you attend meetings that could have been emails for years.

At any rate, lets get back to the issue.

So here I was staring at 100+ warnings all related to TSLint. At first, I thought, “Damn, I’m gonna Macho Man Randy Savage elbow drop someone.”


I then started thinking “how could they commit with these warnings?”, it turned out I had the TSLint extension for VSCode installed and they did not, so they never seen the warnings as they worked on the project. Worse yet, nothing was in place to warn them or prevent the code from being committed.

The Solution

We already use a precommit hook that runs Prettier against files so it was a simple step to add tslint to run during the precommit hook we have in our project.

"lint-staged": {
    "*.ts": [
      "prettier --write",
      "git add"

The above basically runs on all the TypeScript files and runs `tslint` then `prettier` and last `git add`.

As for how this gets executed I have a brief write up on adding a precommit hook for Prettier. Which outlines the dependencies on `husky` and `lint-staged`. If you don’t want to look at that, then add the following as a script in your package.json `scripts` section:

    "precommit": "lint-staged",

Be sure to add the dependencies to your project as well under the `devDependencies`: `lint-staged` and `husky`.

Now when someone tries to commit files to the repo their files will be ran against `tslint` (at this point I shouldn’t have to tell you that you need it inside your project). If all the tslint checks pass then the commit works, if not you’ll have errors with your git logs.

Use Camera Plus in a NativeScript Project


What is Camera Plus?

Camera Plus is a NativeScript plugin recently open sourced from the team at nStudio. Prior to being open sourced the plugin was developed privately with the support of LiveShopper. This plugin allows you to embed a UI component into your layouts. So you can create applications with custom camera layouts. The plugin provides a lot of functionality out of the box. For this guide we’ll stick to the core functionality of installing and using the plugin to take a picture.

Continue reading “Use Camera Plus in a NativeScript Project”