[DEPRECATED] Prettier Swift Plugin - WARNING: The AST parser is not stable yet
prettier/plugin-swift
is deprecated. It hasn’t been updated since early 2018, and the Swift community seems to have moved towards Apple’s swift-format and Nick Lockwood’s SwiftFormat instead.
We hope to someday have plugins for one or both of these tools, but the Prettier team has no current plans to develop such an integration. If you do make something, let us know by opening an issue on the main Prettier repository, and we will consider adding a link to this README.
:warning: Warning :warning: This plugin might eat your homework in its early stage. It also depends on Swift's lib/Syntax which is in flux. Please stage or commit your code before performing any in-place formatting.
You can check out how it formatted Artsy's Eidolon.
You need one of the following:
master
, orAssuming you picked (1) please follow the
installation instructions,
which recommend updating your PATH
at the end:
TOOLCHAIN=swift-DEVELOPMENT-SNAPSHOT-2018-03-30-a.xctoolchain
export PATH=/Library/Developer/Toolchains/${TOOLCHAIN}/usr/bin/:"${PATH}"
Alternatively you can pass the full path to the swiftc
binary
via the environment variable PRETTIER_SWIFT_SWIFTC
:
TOOLCHAIN=swift-DEVELOPMENT-SNAPSHOT-2018-03-30-a.xctoolchain
export PRETTIER_SWIFT_SWIFTC=/Library/Developer/Toolchains/${TOOLCHAIN}/usr/bin/swiftc
If you're interested in contributing to the development of Prettier for Swift, you can follow the CONTRIBUTING guide from Prettier, as it all applies to this repository too.
To test it out on a Swift file:
yarn
.test.swift
.yarn prettier test.swift
to check the output.yarn add --dev --exact prettier prettier/plugin-swift
prettier --write "**/*.swift"
Marcel Jackwerth |