Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Lintでレビューをラクにしよう/ Easing Code Review with Lint ...
Search
TATSUNO Yasuhiro
April 03, 2019
Programming
3
550
Lintでレビューをラクにしよう/ Easing Code Review with Lint for TypeScript
名古屋フロントエンドユーザーグループ TypeScript勉強会 での発表です。
https://nfug.connpass.com/event/123497/
TATSUNO Yasuhiro
April 03, 2019
Tweet
Share
More Decks by TATSUNO Yasuhiro
See All by TATSUNO Yasuhiro
Bun に LCOV 出力を実装した
exoego
2
75
terraform-provider-aws にプルリクして マージされるまで
exoego
2
320
ライブラリをパブリッシュせずにすばやく試す
exoego
2
190
esbuild 最適化芸人
exoego
3
1.5k
いい感じに AWS を組み合わせたビルディングブロックでアプリ開発を支援する / TdTechTalk 2022 11
exoego
0
570
Empowering App Dev by Nicely-Crafted High-Level AWS Components
exoego
0
30
月間数十億リクエストのマイクロサービスを支える JVM+AWS フルサーバーレス開発事例 / Now and Future of Fully Serverless development at Chatwork
exoego
1
660
Scala と AWS でフルサーバーレス開発事例 / How Chatworks uses Scala and Serverless
exoego
3
1.4k
忙しい Scala 開発者の超時間節約術 / Big Timesavers for Busy Scala Developers
exoego
1
1.1k
Other Decks in Programming
See All in Programming
Debugging: A Few Things You Should Know
jmatsu
1
130
知られざるNaNの世界
hole
3
1.1k
急速に利用拡大を続ける飲食店向けサービスで 店内端末同士のローカル通信を追加設定なしで実現した話
whatasoda
0
140
フロントエンドの現在地とこれから
koba04
10
4.7k
飲食業界向けマルチプロダクトを実現させる開発体制とリアルな現状
hiroya0601
1
210
個人開発で使ってるやつを紹介する回
yohfee
1
730
自分だけの世界を創るクリエイティブコーディング / Creative Coding: Creating Your Own World
chobishiba
2
2.1k
Going Staff - Keynote edition
pragtob
0
360
学生の時に開催したPerl入学式をきっかけにエンジニアが組織に馴染むために勉強会を主催や仲間と参加して職能間の境界を越えていく
ohmori_yusuke
2
330
Universal Linksの実装方法と陥りがちな罠
kaitokudou
1
140
App Store Connect APIで 作業時間を増やそう
mot_techtalk
3
140
ML-прайсинг_на_Lamoda__вошли_и_вышли__приключение_на_20_минут__Слава_Цыганков.pdf
lamodatech
0
400
Featured
See All Featured
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
327
21k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
23k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
5
130
Music & Morning Musume
bryan
46
6.1k
Adopting Sorbet at Scale
ufuk
73
9k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
92
16k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Code Reviewing Like a Champion
maltzj
519
39k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
37
1.8k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
How to Think Like a Performance Engineer
csswizardry
18
1k
Transcript
Lintでレビューをラクにしよう @exoego 2019-4-3 TypeScript勉強会 #nfug
twitter: @exoego 長野県の田舎でリモートワーク フロントエンドもバックエンドもプロダクトマネージメントもOSSもやるマン コミュニティ Vue i18n Japan AWS User
Group 名古屋支部 名古屋 Java User Group
TypeScriptの型検査 便利!
という話は誰かがして くれるはずなので 違う「検査」を紹介
Lint 使ってますか? 全員使ってたらLT終了
本日のお話 1. Lint の紹介 2. Lint があってよかった実体験 3. TypeScript で
Lint
1. Lint の紹介
重要だけど退屈なレビューに 時間をかけてませんか? コーディングスタイルに従ってる? 未使用コードが残ってる? 古い書き方しちゃってる?
重要だけど退屈なレビューに 時間をかけてませんか? コーディングスタイルに従ってる? 未使用コードが残ってる? 古い書き方しちゃってる? こういうレビューを自動で やってくれるのが Lint(er)
要するに Lint(またはLinter) とは プログラミングの支援ツール。ソースコードを分析し、 様々な問題を検査してくれる 検査は Warning(無視してよい)にもできるし、Error 扱 いにして見逃さず修正にしてもよい 最近の
Lint は、自動修正までやってくれる よくある修正は Lint に任せて 工数節約してコード品質アップ
色々な言語で使える Lint JavaScript: ESLint TypeScript: ESLint, TSLint CSS/altCSS: Stylelint HTML:
htmllint, tidy Markdown: markdownlint Ruby: RuboCop PHP: phplint, PHP_CodeSniffer Python: Pylint, Pycodestyle Java: Checkstyle, SpotBugs Scala: Scalafix
ESLint/TSLint で 見つけられる問題の例 ESLint: no-await-in-loop ルール ループ内の非効率かもしれない await を発見。非同期処理のレビューがラクに ESLint:
no-cond-assign ルール if (foo.bar = ‘message’”) を発見。たまにやらかす… TSLint: no-unsafe-any ルール any型での雑なメンバーアクセス、ダメ絶対。ちゃんとキャストかジェネリクス使って!!
様々な OSS が Pull Req に自動 Lint してレビューコストを下げてる →OSSメンテ続けやすくする仕組み Vue
i18n みんなも自動 Lint でレビューをラクに!
2. Lint があって よかった実体験
とある OSS に ESLint 導入→バグ発見 rules: function (field, rules) {
if (Array.isArray(field)) { $.each(fields, function (index, field) { module.remove.rule(field, rules); }); } else { module.remove.rule(field, rules); } 数年物のバグ、あなたはレビューで見つけられますか? テストがないのが問題だけど
3. TypeScript で Lint
導入デモ TypeScriptの著名レポジトリに Lint 導入して、 見つけた問題を修正 Pull Req してみた …をやろうとしたら、著名レポジトリでは あらかた導入済みだった!
著名レポジトリを参考にしよう!
TSLint派 angular/angular Microsoft/vscode nestjs/nest codercom/code-server grafana/grafana ESLint派 denoland/deno
現在 TypeScript では TSLint がメジャー が、Microsoft は ESLint を推してく らしい
ESLint/TSLint 設定多すぎて迷う? デファクトの設定に従うのがオススメ JavaScript Standard Styleベース https://www.npmjs.com/package/eslint-config-standard https://www.npmjs.com/package/tslint-config-standard 著名企業が公開した設定も広く使われてます https://www.npmjs.com/package/eslint-config-airbnb
https://www.npmjs.com/package/eslint-config-google https://www.npmjs.com/package/tslint-microsoft-contrib
まとめ 退屈なレビューは Lint に任せて、本質的な レビューに集中しよう! TypeScript では TSLint がデファクトだけど JS
にも対応した ESLint もいいよ! Lint の設定は、よく練られたデファクトに 乗っかるとラクだよ!