Slide 1

Slide 1 text

Lint, Laugh, Love

Slide 2

Slide 2 text

Josh Smith @joshingmachine

Slide 3

Slide 3 text

Problem

Slide 4

Slide 4 text

Developers care about

Slide 5

Slide 5 text

Developers care about ● Functionality

Slide 6

Slide 6 text

Developers care about ● Functionality ● Quality

Slide 7

Slide 7 text

Developers care about ● Functionality ● Quality ● Maintainability

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

Josh Smith Software Engineer circa 2015

Slide 10

Slide 10 text

Developers care about ● Functionality ● Quality ● Maintainability

Slide 11

Slide 11 text

Product owners care about

Slide 12

Slide 12 text

Product owners care about ● All of that

Slide 13

Slide 13 text

Product owners care about ● All of that ● But sooner

Slide 14

Slide 14 text

Solution

Slide 15

Slide 15 text

There’s not really a “silver bullet” that can entirely fix these issues. It’s a nuanced problem that involves all stakeholders coordinating with each other on the timeline of the product and how it fulfills business needs. It also requires developers with different skill levels and varying experiences in previous roles to work closely together, learn from each other, make compromises on personal views, and view projects in both the immediate and the long term. Hopefully your work environment includes management that can enable this kind of culture that empowers developers to take proactive measures and to voice concerns not only about their own area of expertise, but also address problems across silos and have an impact on the overall mission of the company.

Slide 16

Slide 16 text

Solution Something that Helps

Slide 17

Slide 17 text

Linting

Slide 18

Slide 18 text

Linting (what is it?)

Slide 19

Slide 19 text

Makes code better before you run it

Slide 20

Slide 20 text

Makes code better? before you run it

Slide 21

Slide 21 text

Makes code better? before you run it That’s pretty subjective

Slide 22

Slide 22 text

// simple-mistake.js function getHallAndOates() { var darylHall = 'vocals/keyboard' var johnOats = 'guitar/backup vocals' // return the greatest songwriting // duo of all time return darylHall + johnOates } getHallAndOates()

Slide 23

Slide 23 text

# CLI eslint --rule 'no-unused-vars: 2' ./simple-mistake.js

Slide 24

Slide 24 text

# CLI eslint --rule 'no-unused-vars: 2' ./simple-mistake.js # Output /simple-mistake.js 5:9 error 'johnOats' is assigned a value but never used no-unused-vars ✖ 1 problem (1 error, 0 warnings)

Slide 25

Slide 25 text

Keep things secure

Slide 26

Slide 26 text

// security-issue.js function blindTrust() { var superSafeText = prompt('Hello', '') if (superSafeText !== null) { // Some people just want to // watch the world burn eval(superSafeText) } } blindTrust()

Slide 27

Slide 27 text

# CLI eslint --rule 'no-eval: 2' ./security-issue.js

Slide 28

Slide 28 text

# CLI eslint --rule 'no-eval: 2' ./security-issue.js # Output /security-issue.js 8:9 error eval can be harmful no-eval ✖ 1 problem (1 error, 0 warnings)

Slide 29

Slide 29 text

Develop your style

Slide 30

Slide 30 text

// stylistic-issue.js // this is the same function as before, // but with tabs instead of spaces function getHallAndOates() { var darylHall = 'vocals/keyboard' var johnOats = 'guitar/backup vocals' // return the greatest songwriting // duo of all time return darylHall + johnOates } getHallAndOates()

Slide 31

Slide 31 text

# CLI eslint --rule 'no-tabs: 2' ./stylistic-issue.js # Output /stylistic-issue.js 5:9 error Unexpected tab character no-tabs ✖ 1 problem (1 error, 0 warnings)

Slide 32

Slide 32 text

Make code consistent

Slide 33

Slide 33 text

It’s a Match! Send Message Keep Playing You and Mark both prefer spaces over tabs.

Slide 34

Slide 34 text

Approach

Slide 35

Slide 35 text

Integration

Slide 36

Slide 36 text

● CLI ● Build Step ● Editors/IDEs ● Version control ● Tests ● etc.

Slide 37

Slide 37 text

● CLI ● Build Step ● Editors/IDEs ● Version control ● Tests ● etc.

Slide 38

Slide 38 text

Configuration

Slide 39

Slide 39 text

“I don’t want to configure every single rule.”

Slide 40

Slide 40 text

You don’t have to configure every single rule.

Slide 41

Slide 41 text

You don’t have to configure every single rule. Someone else already has.

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

teamwork

Slide 45

Slide 45 text

“I disagree with my team about a rule.”

Slide 46

Slide 46 text

“I disagree with my team about a rule.” Okay… ¯\_(ツ)_/¯

Slide 47

Slide 47 text

Implementation

Slide 48

Slide 48 text

“How should I lint a legacy project?”

Slide 49

Slide 49 text

One fell swoop

Slide 50

Slide 50 text

PRO: Immediate consistency

Slide 51

Slide 51 text

CON: You ruin everything for everyone

Slide 52

Slide 52 text

Base branch

Slide 53

Slide 53 text

Linting the entire codebase Base branch

Slide 54

Slide 54 text

Your coworkers, just trying to do their jobs Base branch Linting the entire codebase

Slide 55

Slide 55 text

The point of no return Your coworkers, just trying to do their jobs Base branch

Slide 56

Slide 56 text

The point of no return Your coworkers, just trying to do their jobs Base branch

Slide 57

Slide 57 text

The point of no return Your coworkers, just trying to do their jobs Base branch

Slide 58

Slide 58 text

Bit by bit

Slide 59

Slide 59 text

CON: Code is inconsistent

Slide 60

Slide 60 text

PRO: Everyone makes it out alive

Slide 61

Slide 61 text

ADVICE: Add linting as early as possible

Slide 62

Slide 62 text

Tools

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

No content

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

● Functionality ● Quality ● Maintainability

Slide 69

Slide 69 text

Thanks

Slide 70

Slide 70 text

https://speakerdeck.com/joshingmachine/lint-laugh-love