Giter Site home page Giter Site logo

tslint-config's Introduction

@carnesen/tslint-config Build Status

TSLint configurations for @carnesen projects

Install

These instructions assume that you're already using TypeScript and are now just adding tslint.

npm install --save-dev tslint @carnesen/tslint-config

Usage

Create a file tslint.json at the root of your project with contents:

{
  "extends": [
    "@carnesen/tslint-config"
  ]
}

That tells TSLint to use the "main" export of this package, its tslint.json file. Add these lines to your package.json's "scripts" field:

    "lint": "tslint --project .",
    "lint:fix": "npm run lint -- --fix",

Finally add && npm run lint to your package's "test" script to make sure you don't forget to lint! I strongly recommend setting up your editor to automatically fix lint errors on save. That makes it so that the linter mostly stays out of your way. In Visual Studio Code, this plugin works great.

Rules

This package's rules extend those espoused by by AirBnB, consumed as tslint-config-airbnb. Those rules are mostly concerned with syntax. For code formatting, this package uses tslint-config-prettier, which disables all rules that are unnecessary or might conflict with Prettier in conjunction with tslint-plugin-prettier, which "runs Prettier as a TSLint rule and reports differences as individual TSLint issues". I wrote up some thoughts here on why that's a much better approach than using tslint and prettier separately. Finally this configuration also enables the dtslint "expect" rule, which allows you to make type assertions that are checked at the same time as the lint rules:

// $ExpectType "foo"
'foo';

// $ExpectType string[]
['foo', 'bar', 'baz'];

These are a nice way of writing programmatic tests for types beyond what you can achieve with unit testing alone.

Here are some projects that make use of this one if you want to see some code looks like that adhere to these rules:

Related

More information

If you encounter any bugs or have any questions or feature requests, please don't hesitate to file an issue or submit a pull request on this project's repository on GitHub.

License

MIT © Chris Arnesen

tslint-config's People

Contributors

carnesen avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.