Scaling
Best practices With Syntax Trees

Will Klein

Best Practices

 

Knowledge

How do I code here

Testing

User

Experience

 

Developer

Experience

 

Documentation

Brown Bags

Code review

Convention Tests

Convention Tests, AKA

  • Linters
  • Code analyzers
  • Static analysis

Language

Conventions

What about     our project Conventions?

What about     our Framework Conventions?

What If We could write our own convention tests?

Convention Test "Frameworks"

  • Common tests included
  • Pluggable testing API
  • ESLint, for example
// Life, Universe, and Everything
var answer = 6 * 7;
// Life, Universe, and Everything
var answer = 6 * 7;
10111010001011011101000101

...

How does this work?

// Life, Universe, and Everything
var answer = 6 * 7;
[var] [answer] [=] [6] [*] [7][;]

...

Tokenize

// Life, Universe, and Everything
var answer = 6 * 7;
[var] [answer] [=] [6] [*] [7][;]

...

...

?

Parse

 

A Syntax Tree

Syntax Tree

  • Abstract syntax tree
  • AST
  • Syntax tree is easier to say

ESLint

  • Builds our syntax tree for us
  • Iterates over nodes in the tree
  • For each node, do we have a test?

ESLint: Rule boilerplate

ESLint: Rule boilerplate

ESLint: Rule boilerplate

ESLint: Rule boilerplate

Demo

Docs & Code

Go Forth and Test

  • Implement existing tools
  • Consider your project's conventions
  • Write your own convention tests

Go Forth and Test

  • Implement existing tools
  • Consider your project's conventions
  • Write your own convention tests
  • Improve your developer experience

programs must be written for people to read, and only incidentally for machines to execute

Donald Knuth

Structure and Interpretation of Computer Programs

http://willkle.in

will.klein@gmail.com

Thanks

@willslab

Scaling Best Practices with Syntax Trees - ReactJS Denver

By Will Klein

Scaling Best Practices with Syntax Trees - ReactJS Denver

The ReactJS edition

  • 479
Loading comments...

More from Will Klein