Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
eslint-flat-config
Search
てけし
April 01, 2023
Programming
1.1k
5
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
eslint-flat-config
ESLint Flat Configで誰もが簡単に Lintを設定できる時代へ。
新しいESLintの設定方法、ESLint Flat Configを紹介します。
てけし
April 01, 2023
More Decks by てけし
See All by てけし
フロントエンドで 良いコードを書くために
t_keshi
7
2.5k
Other Decks in Programming
See All in Programming
Crash Auto Pipelines
veronikapj
1
240
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
300
當我們開始不讀 Code - AI Agent 時代,Code Review 與 Clean Code 還剩下什麼?
jame2408
1
350
コードで差別化できない時代の ソフトウェアエンジニアリング / Software Engineering in an Era Where Code Doesn’t Differentiate
kishida
2
220
Railsのためのパスキー実践入門 〜マルチテナントSaaSでの意思決定〜
utakaha
3
2k
続・コーディングルールの鮮度を保ちたい / keep-fresh-go-internal-conventions-again
handlename
0
160
sbt 2.0: takeoff
eed3si9n
0
180
Seven New Principles of Software Engineering
yegor256
0
400
AI時代のFlutter品質設計 — アプリ品質を守るQuality Layers
omatty198
0
330
クラウドエージェントは、 何がそんなに便利なのか / what makes cloud agents so useful
rkaga
3
640
そのデザイントークン、Flutterでも同じ見た目になりますか?
nakamizu
0
140
SODA - FACT BOOK(JP)
sodainc
1
40k
Featured
See All Featured
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
510
Facilitating Awesome Meetings
lara
57
7.2k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
610
エンジニアに許された特別な時間の終わり
watany
109
250k
sira's awesome portfolio website redesign presentation
elsirapls
0
480
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
390
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
570
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
340
Building a Scalable Design System with Sketch
lauravandoore
464
34k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
So, you think you're a good person
axbom
PRO
2
2.2k
Transcript
ESLint Flat Configで 誰もが簡単に Lintを設定できる時代へ🥳 2023/04/01 CREATED BY t-keshi
t-keshi Web / TypeScript / React / Kotlin http://zenn.dev/t_keshi
本日はESLint Flat Configの話
None
- デフォルトでsourceTypeがesmoduleになった - デフォルトで.mjsや.cjsも対象とするようになった - ecmaVersionの指定が"latest"になった - extendsプロパティが無くなった などなど。 ☞
キャッチアップする
/) ///) /,.=゙''"/ / i f ,.r='"-‐'つ____こまけぇこたぁいいんだよ!! / / _,.-‐'~/⌒ ⌒\
/ ,i ,二ニ⊃( •). (•)\ / ノ il゙フ::::::⌒(__人__)⌒::::: \ ,イ「ト、 ,!,!| |r┬-| | / iトヾヽ_/ィ"\ `ー'´ / ひとことでまとめると、、
誰でも簡単にLintの設定が 書けるようになった
そ れ っ て 最 高 じ ゃ な い
で す か 最高である!!!
駆け足で振り返るLintの歴史
Q.以下のconsole.logの出力は? console.log(isNaN(true)); TRUE FALSE
最 高 じ ゃ な い で す か ありがとうLint!!!
ブラウザで動く(ほぼ)唯一のプログラミング言語 ⇨ 後方互換性を捨てられない ⇨ 理解不能な仕様が永遠に残り続ける LintなしでJavaScriptを書くなんて、 命綱なしでバンジージャンプするようなもの JavaScriptはLintがないと駄目な子
JavaScriptを陰で守ってきた 立役者たち... そこで JSHint / TSLint / ESLint
選ばれたのはΕSLintでした https://npmtrends.com/eslint-vs-jshint-vs-tslint
そして、ESLintは JSの未来を一身に背負ってきた...
しかし、 だからこそ複雑になりすぎてしまった extends… 独自シンタクス... 暗黙の了解...
そんな中、 彗星のごとく現れた救世主 それが、、
ESLint Flat Config
JavaScriptさえわかればOK グッバイ、ESLint独自構文👋 それは誰でもLintが設定できる技術
import customConfig from "eslint-config-custom"; export default [ customConfig, { files:
["**/*.js", "**/*.cjs"], rules: { "semi": "error", "no-unused-vars": "error" } }, { files: ["**/*.js"], rules: { "no-undef": "error", "semi": "warn" } } ]; JavaScriptと同じように、 直感的にわかりやすい構文 例えば、 Override!
そろそろ Flat Conigが書きたくて うずうずしてきましたか? では早速、
Let's Lint
でもちょっと待って 改めて考えたいLintの意義 慌 て る な
🤬口うるさい教師 ✨最も低コストで運用できるテスト メンタルモデルを変えよう!
NG例)ぼくのかんがえたさいきょうのりんと 時代は関数型プログラミングなんや...! わいはeslint-plugin-lodash-fp入れるんや...! Lintはみんなのもの。
Lintミニマリズムのすゝめ Marie Kondo Your Lint Config
今度こそ本当にLet's Lint
Flat Configは2023年4月現在、 Experimental Featureになっています。 導入はあくまでも自己責任でお願いします。 また、設定ノウハウの蓄積もWeb上に少ないので 場合によっては難しいと感じる部分もあるかもしれません。 ※注意事項
基本は3STEP 1 ベースとなる 設定集を選ぶ 2 環境に合わせて Pluginを入れる 3 必要に応じて 独自設定を足す
ESLintには200〜300ほどの ルールの設定項目がある(!!) 自分で一から設定するのは超困難 ⇨ベースとなる設定集を選ぼう! STEP1: ベースとなる設定集を選ぶ
選択肢は大きく3つ airbnb / standard / google (どれを選べばいいんだッ?!)
一番人気はairbnb https://npmtrends.com/eslint-config-airbnb-vs-eslint-config-google-vs-eslint-config-standard
airbnbはモリモリの設定 standardはシンプルな設定 IMO: 最初はシンプルな設定にして 少しずつ足していくのがおすすめ airbnb vs standard https://zenn.dev/tapioca/articles/5685d794f6452b
// .eslintrc { "extends": ["standard"] } // eslint.config.js import {
FlatCompat } from '@eslint/eslintrc' const compat = new FlatCompat() export default [ ...compat.extends('eslint-config-standard'), ] config形式がflat configに対応しきれ てない関係上、ここは少しややこしい 設定サンプル
STEP2: 環境に合わせてPluginを入れる 多種多様なPluginがある pluggableなところがESLintの思想であり魅力でもある 一例) • eslint-plugin-import • eslint-plugin-react •
eslint-plugin-jest • eslint-plugin-storybook
import ts from "@typescript-eslint/eslint-plugin" import tsParser from "@typescript-eslint/parser" export default
[{ files: ["src/**/*.ts", "src/**/*.tsx"], languageOptions: { parser: tsParser, }, plugins: { "@typescript-eslint": ts, }, rules: { ...ts.configs["recommended"].rules, ...ts.configs["eslint-recommended"].rules, } }]; TypeScript環境に TypeScript用のLintを入れる 例えば、 https://www.sunapro.com/eslint-flat-config/
ただ一つの完璧なLintの設定なんて存在しない 今の自分たちの状況に最もフィットするベストなLintにしよう STEP3: 必要に応じて独自設定を足す ESLint Flat Configは スタマイズしやすい...
import jsdoc from "eslint-plugin-jsdoc"; export default [ { files: ["**/*.js"],
plugins: { jsd: jsdoc } rules: { "jsd/require-description": "error", "jsd/check-values": "error" } } ]; せめてJSDocを書きたい TypeScript化が間に合わないチーム 右のようなlintConfigを置くことで JSDocの記述を強制できる 例えば、 https://eslint.org/blog/2022/08/new-config-system-part-2/
ということで 新しいESLintの設定方法、 かなり直感的ではないでしょうか? Lint 職人は もう 要らねぇ
Enjoy Your Lint Life!!!
ご清聴ありがとうございました!
• ESLint's new config system, Part 2: Introduction to flat
config • Config File Simplification • Flat Config導入完了! 新しいESLintの設定フォーマットを使ってみた • eslintをflat configで書き換える • ESLintのconfigがどのように変わり得るか(flat configとは何か) 参考資料
• 『ブラックジャックによろしく』マンガデータ • Azusa 3大体いい感じのスライドを作るための無料テンプレート 利用素材