COSCUP 2025

Tommy Han

自我介紹

你好,我是湯米。
本職是 APP 軟體工程師 (iOS + Android),在大學年代開始接觸開源軟體及開發。
在工餘時間是香港不同科技社群的主持 (Pythont User Group HK, Codeaholics),有空的時候會做一些 Swift/Kotlin 相關的興趣開發/研究。
熱愛攝影,會在不同科技社群活動擔任攝影師。
曾經在 HKOSCon (2023-2024) 參與 HKOSCon 議程組相關時宜。

Hello, this is Tommy from Hong Kong.
My current Job is Mobile Engineer, mainly on iOS and Android Native, do know some cross-platform stuff.
My first time in open-source and open-source development was in my Year 1 at the University.
Apart from my work, I am also a host of different technical communities (Python User Group HK, OSHK, Codeaholic), to get developers/programmers/engineers together and meet up.
I might do some hobby development and proposal/feature study about Swift/Kotlin during my extra time.
Loves Photography, been the photo guy in different technical and non-technical events.
Work as a member of Program Team of HKOSCon (2023-2024)

年度期待

作爲一個2018年開始參加的會衆和擺攤人,希望可以回饋一些東西。
認識不同的人!
希望讓參加的會衆可以帶一些東西回去。


Session

08/10
10:40
30min
How to build a Custom Linter, using SwiftSyntax
Tommy Han

Linting is an important part of the software development process lifecycle. For many years, Swift has had different 3rd party libraries for developers to provide linting, and one of the most famous libraries is SwiftLint.

A few years ago, Apple announced SwiftSyntax as an Open-Source package. It provides a better possibility for developers to work on the syntax tree of the code. Although Apple has used this package for implementing Swift Macros, more possibilities could be found.

Sometimes, in different conditions, we might want some more custom linting(e.g. sync with coding style, company linting requirements, for fun, etc.). Apart from building custom rules of SwiftLint, we can try to do it in a more intuitive way, using Swift to build on our own.

This time, we will try to use SwiftSyntax to integrate with SwiftLint, and from scratch, to build a simple custom linter.

Linting 是軟體開發流程中非常重要的一環。多年來,Swift 一直有各種第三方函式庫協助開發者進行程式碼檢查,其中最知名的之一就是 SwiftLint。

幾年前,Apple 推出了 SwiftSyntax 這個開源套件。它讓開發者能更深入地操作程式碼的語法樹。雖然 Apple 目前主要用 SwiftSyntax 來實作 Swift Macros,但這個套件其實還有更多潛在的應用可能。

在某些情況下,我們可能需要更客製化的 linting(例如:配合團隊的程式風格、公司內部規範,或單純好玩)。除了在 SwiftLint 上建立自訂規則之外,其實也可以直接用 Swift,利用 SwiftSyntax 以更直觀的方式自行打造 lint 工具。

這次,我們將嘗試用 SwiftSyntax 結合 SwiftLint,並從零開始建立一個簡單的自訂 Linter。

Open Source Swift
TR211