Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sake92/kalem
Scalafix rules for generating Withers
https://github.com/sake92/kalem
scala scalafix-rule scalajs
Last synced: 22 days ago
JSON representation
Scalafix rules for generating Withers
- Host: GitHub
- URL: https://github.com/sake92/kalem
- Owner: sake92
- License: apache-2.0
- Created: 2021-04-02T15:42:49.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-04-02T16:48:20.000Z (over 3 years ago)
- Last Synced: 2024-10-04T20:43:49.064Z (about 1 month ago)
- Topics: scala, scalafix-rule, scalajs
- Language: Scala
- Homepage:
- Size: 16.6 KB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Scalafix rules for Wither
---
## @WitherRun scalafix to turn this:
```scala
import ba.sake.kalem.Wither@Wither
case class MyClass(x: Int, opt: Option[String])
```
into this:
```scala
@Wither
case class MyClass(x: Int, opt: Option[String], lst: List[String]){
def withX(x: Int): MyClass = new MyClass(x = x, opt = opt, lst = lst)def withOpt(opt: Option[String]): MyClass = MyClass(x = x, opt = opt, lst = lst)
def withOpt(opt: String): MyClass = new MyClass(x = x, opt = Option(opt), lst = lst)def withLst(lst: List[String]): MyClass = new MyClass(x = x, opt = opt, lst = lst)
def withLst(lst: String*): MyClass = new MyClass(x = x, opt = opt, lst = lst.toList)
}
```Why ?
- more readable than named args
- autocomplete is nicer
- additional goodies for Options and ListsHow ?
Install scalafix as usual.
Add this to your `build.sbt`:
```scala
libraryDependencies += "ba.sake" %% "kalem-core" % "0.0.1"ThisBuild / scalafixDependencies += "ba.sake" %% "kalem-rules" % "0.0.1"
```and this to `.scalafix.conf`:
```
rules = [
Wither
]
```---
### Develop
To develop rule:
```
sbt ~tests/test
# edit rules/src/main/scala/fix/Wither.scala
```