Slide 1

Slide 1 text

Building Custom TSLint Rules Ash Furrow, Artsy

Slide 2

Slide 2 text

whoami - Hi I’m Ash - Artsy - Canadian - Recovering iOS developer - Photography - Guitar - Likes type systems - Really likes developer tooling

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

TSLint - Checks (“lints”) your code for problems - There are a bunch of built-in rules - Line length - Alphabetically ordered imports - Variable name consistency - Prevent unnecessary type assertions - etc - And you can build your own!

Slide 6

Slide 6 text

Custom TSLint Rules - Rules are just code - Rules provide details of what’s wrong - Optionally, rules can fix the code automatically ✨ - Two types of rules: - String-based rules - AST-based rules - So what’s an AST?

Slide 7

Slide 7 text

Abstract Syntax Trees - Compiler data type - Machine-readable representation of your code if (user.isAdmin) { return "Hello, Admin." } else { return "401 lol" } if user.isAdmin return return "Hello, Admin" "401 lol"

Slide 8

Slide 8 text

astexplorer.net

Slide 9

Slide 9 text

Demo - Okay time for code now please

Slide 10

Slide 10 text

Resources - github.com/ashfurrow/tsnyc-tslint-rules (see: STEPS.md) - github.com/ashfurrow/tslint-playground (more resources linked to from here)