Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Lint, Laugh, Love

Lint, Laugh, Love

6250928fb645dda17e083ef0b009c268?s=128

Josh Smith

June 02, 2018
Tweet

Other Decks in Programming

Transcript

  1. Lint, Laugh, Love

  2. Josh Smith @joshingmachine

  3. Problem

  4. Developers care about

  5. Developers care about • Functionality

  6. Developers care about • Functionality • Quality

  7. Developers care about • Functionality • Quality • Maintainability

  8. None
  9. Josh Smith Software Engineer circa 2015

  10. Developers care about • Functionality • Quality • Maintainability

  11. Product owners care about

  12. Product owners care about • All of that

  13. Product owners care about • All of that • But

    sooner
  14. Solution

  15. 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.
  16. Solution Something that Helps

  17. Linting

  18. Linting (what is it?)

  19. Makes code better before you run it

  20. Makes code better? before you run it

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

  22. // 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()
  23. # CLI eslint --rule 'no-unused-vars: 2' ./simple-mistake.js

  24. # 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)
  25. Keep things secure

  26. // security-issue.js function blindTrust() { var superSafeText = prompt('Hello', '')

    if (superSafeText !== null) { // Some people just want to // watch the world burn eval(superSafeText) } } blindTrust()
  27. # CLI eslint --rule 'no-eval: 2' ./security-issue.js

  28. # 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)
  29. Develop your style

  30. // 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()
  31. # 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)
  32. Make code consistent

  33. It’s a Match! Send Message Keep Playing You and Mark

    both prefer spaces over tabs.
  34. Approach

  35. Integration

  36. • CLI • Build Step • Editors/IDEs • Version control

    • Tests • etc.
  37. • CLI • Build Step • Editors/IDEs • Version control

    • Tests • etc.
  38. Configuration

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

  40. You don’t have to configure every single rule.

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

    already has.
  42. None
  43. None
  44. teamwork

  45. “I disagree with my team about a rule.”

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

  47. Implementation

  48. “How should I lint a legacy project?”

  49. One fell swoop

  50. PRO: Immediate consistency

  51. CON: You ruin everything for everyone

  52. Base branch

  53. Linting the entire codebase Base branch

  54. Your coworkers, just trying to do their jobs Base branch

    Linting the entire codebase
  55. The point of no return Your coworkers, just trying to

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

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

    do their jobs Base branch
  58. Bit by bit

  59. CON: Code is inconsistent

  60. PRO: Everyone makes it out alive

  61. ADVICE: Add linting as early as possible

  62. Tools

  63. None
  64. None
  65. None
  66. None
  67. None
  68. • Functionality • Quality • Maintainability

  69. Thanks

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