Skip to content

Commit f53adac

Browse files
Introduce purs-tidy formatter (#138)
* Add purs-tidy formatter * Run purs-tidy * review
1 parent 8f50d7e commit f53adac

22 files changed

+302
-199
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
1515

1616
- name: Set up a PureScript toolchain
1717
uses: purescript-contrib/setup-purescript@main
18+
with:
19+
purs-tidy: "latest"
1820

1921
- name: Cache PureScript dependencies
2022
uses: actions/cache@v2
@@ -32,3 +34,6 @@ jobs:
3234

3335
- name: Run tests
3436
run: spago test --no-install
37+
38+
- name: Check formatting
39+
run: purs-tidy check src test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
!.gitignore
33
!.github
44
!.editorconfig
5+
!.tidyrc.json
56

67
output
78
generated-docs

.tidyrc.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"importSort": "source",
3+
"importWrap": "source",
4+
"indent": 2,
5+
"operatorsFile": null,
6+
"ribbon": 1,
7+
"typeArrowPlacement": "first",
8+
"unicode": "never",
9+
"width": null
10+
}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ New features:
1313
Bugfixes:
1414

1515
Other improvements:
16+
- Added `purs-tidy` formatter (#138 by @thomashoneyman)
1617
- Remove ending space in css output (e.g. `padding: 1 2 3 4 `) (#135 by @chexxor and @JordanMartinez)
1718

1819
## [v5.0.1](https://github.com/purescript-contrib/purescript-css/releases/tag/v5.0.1) - 2021-04-19

packages.dhall

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
let upstream =
2-
https://github.com/purescript/package-sets/releases/download/psc-0.14.3-20210722/packages.dhall sha256:1ceb43aa59436bf5601bac45f6f3781c4e1f0e4c2b8458105b018e5ed8c30f8c
2+
https://github.com/purescript/package-sets/releases/download/psc-0.14.5-20211116/packages.dhall sha256:7ba810597a275e43c83411d2ab0d4b3c54d0b551436f4b1632e9ff3eb62e327a
33

44
in upstream

src/CSS/Background.purs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module CSS.Background
22
(
3-
-- * Generic background property.
3+
-- * Generic background property.
44
class Background
55
, background
66

@@ -18,16 +18,21 @@ module CSS.Background
1818
, BackgroundSize
1919
, backgroundSize
2020
, backgroundSizes
21-
, contain, cover
21+
, contain
22+
, cover
2223
, by
2324

2425
-- * The background-repeat.
2526
, BackgroundRepeat
2627
, backgroundRepeat
2728
, backgroundRepeats
28-
, repeat, space, round, noRepeat
29+
, repeat
30+
, space
31+
, round
32+
, noRepeat
2933
, xyRepeat
30-
, repeatX, repeatY
34+
, repeatX
35+
, repeatY
3136

3237
-- * The background-origin.
3338
, BackgroundOrigin
@@ -45,7 +50,8 @@ module CSS.Background
4550
, BackgroundAttachment
4651
, backgroundAttachment
4752
, backgroundAttachments
48-
, attachFixed, attachScroll
53+
, attachFixed
54+
, attachScroll
4955

5056
-- * The background-image.
5157
, BackgroundImage
@@ -70,8 +76,7 @@ module CSS.Background
7076
, Location
7177
, class Loc
7278
, location
73-
)
74-
where
79+
) where
7580

7681
import Prelude
7782

@@ -95,8 +100,7 @@ class Val a <= Background a where
95100
instance backgroundArray :: (Background a) => Background (Array a) where
96101
background = key $ fromString "background"
97102

98-
instance backgroundTuple
99-
:: (Background a, Background b) => Background (Tuple a b) where
103+
instance backgroundTuple :: (Background a, Background b) => Background (Tuple a b) where
100104
background = key $ fromString "background"
101105

102106
instance backgroundColor' :: Background Color where
@@ -118,7 +122,8 @@ instance backgroundBackgroundClip :: Background BackgroundClip where
118122
background = key $ fromString "background"
119123

120124
instance backgroundBackgroundAttachment :: Background BackgroundAttachment
121-
where background = key $ fromString "background"
125+
where
126+
background = key $ fromString "background"
122127

123128
instance backgroundBackgroundImage :: Background BackgroundImage where
124129
background = key $ fromString "background"

src/CSS/Box.purs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
module CSS.Box
22
( BoxType
3-
, paddingBox, borderBox, contentBox
3+
, paddingBox
4+
, borderBox
5+
, contentBox
46
, boxSizing
57
, boxShadow
68
, insetBoxShadow
7-
)
8-
where
9+
) where
910

1011
import Prelude
1112

@@ -56,6 +57,5 @@ boxShadow x y w c =
5657

5758
-------------------------------------------------------------------------------
5859

59-
insetBoxShadow ::
60-
forall a. Stroke -> Size a -> Size a -> Size a -> Color -> CSS
60+
insetBoxShadow :: forall a. Stroke -> Size a -> Size a -> Size a -> Color -> CSS
6161
insetBoxShadow x y w c z = prefixed (browsers <> fromString "box-shadow") (x ! y ! w ! c ! z)

src/CSS/Common.purs

Lines changed: 98 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,53 +12,114 @@ import Data.Tuple (Tuple(..))
1212
import CSS.Property (Prefixed(..), Value)
1313
import CSS.String (class IsString, fromString)
1414

15-
class All a where all :: a
16-
class Auto a where auto :: a
17-
class Baseline a where baseline :: a
18-
class Center a where center :: a
19-
class Inherit a where inherit :: a
20-
class None a where none :: a
21-
class Normal a where normal :: a
22-
class Visible a where visible :: a
23-
class Hidden a where hidden :: a
24-
class Initial a where initial :: a
25-
class Unset a where unset :: a
26-
class Top a where top :: a
27-
class Middle a where middle :: a
28-
class Bottom a where bottom :: a
29-
class URL a where url :: String -> a
15+
class All a where
16+
all :: a
17+
18+
class Auto a where
19+
auto :: a
20+
21+
class Baseline a where
22+
baseline :: a
23+
24+
class Center a where
25+
center :: a
26+
27+
class Inherit a where
28+
inherit :: a
29+
30+
class None a where
31+
none :: a
32+
33+
class Normal a where
34+
normal :: a
35+
36+
class Visible a where
37+
visible :: a
38+
39+
class Hidden a where
40+
hidden :: a
41+
42+
class Initial a where
43+
initial :: a
44+
45+
class Unset a where
46+
unset :: a
47+
48+
class Top a where
49+
top :: a
50+
51+
class Middle a where
52+
middle :: a
53+
54+
class Bottom a where
55+
bottom :: a
56+
57+
class URL a where
58+
url :: String -> a
3059

3160
-- | The other type class is used to escape from the type safety introduced by
3261
-- | embedding CSS properties into the typed world of purescript-css.
3362
-- | `Other` allows you to cast any `Value` to a specific value type.
34-
class Other a where other :: Value -> a
35-
36-
instance allValue :: All Value where all = fromString "all"
37-
instance autoValue :: Auto Value where auto = fromString "auto"
38-
instance baselineValue :: Baseline Value where baseline = fromString "baseline"
39-
instance centerValue :: Center Value where center = fromString "center"
40-
instance inheritValue :: Inherit Value where inherit = fromString "inherit"
41-
instance normalValue :: Normal Value where normal = fromString "normal"
42-
instance noneValue :: None Value where none = fromString "none"
43-
instance visibleValue :: Visible Value where visible = fromString "visible"
44-
instance hiddenValue :: Hidden Value where hidden = fromString "hidden"
45-
instance otherValue :: Other Value where other = identity
46-
instance initialValue :: Initial Value where initial = fromString "initial"
47-
instance unsetValue :: Unset Value where unset = fromString "unset"
48-
instance topValue :: Top Value where top = fromString "top"
49-
instance middleValue :: Middle Value where middle = fromString "middle"
50-
instance bottomValue :: Bottom Value where bottom = fromString "bottom"
51-
instance urlValue :: URL Value where url s = fromString ("url(\"" <> s <> "\")")
63+
class Other a where
64+
other :: Value -> a
65+
66+
instance allValue :: All Value where
67+
all = fromString "all"
68+
69+
instance autoValue :: Auto Value where
70+
auto = fromString "auto"
71+
72+
instance baselineValue :: Baseline Value where
73+
baseline = fromString "baseline"
74+
75+
instance centerValue :: Center Value where
76+
center = fromString "center"
77+
78+
instance inheritValue :: Inherit Value where
79+
inherit = fromString "inherit"
80+
81+
instance normalValue :: Normal Value where
82+
normal = fromString "normal"
83+
84+
instance noneValue :: None Value where
85+
none = fromString "none"
86+
87+
instance visibleValue :: Visible Value where
88+
visible = fromString "visible"
89+
90+
instance hiddenValue :: Hidden Value where
91+
hidden = fromString "hidden"
92+
93+
instance otherValue :: Other Value where
94+
other = identity
95+
96+
instance initialValue :: Initial Value where
97+
initial = fromString "initial"
98+
99+
instance unsetValue :: Unset Value where
100+
unset = fromString "unset"
101+
102+
instance topValue :: Top Value where
103+
top = fromString "top"
104+
105+
instance middleValue :: Middle Value where
106+
middle = fromString "middle"
107+
108+
instance bottomValue :: Bottom Value where
109+
bottom = fromString "bottom"
110+
111+
instance urlValue :: URL Value where
112+
url s = fromString ("url(\"" <> s <> "\")")
52113

53114
-- | Common list browser prefixes to make
54115
-- | experimental properties work in different browsers.
55116
browsers :: Prefixed
56117
browsers = Prefixed
57118
[ Tuple "-webkit-" ""
58-
, Tuple "-moz-" ""
59-
, Tuple "-ms-" ""
60-
, Tuple "-o-" ""
61-
, Tuple "" ""
119+
, Tuple "-moz-" ""
120+
, Tuple "-ms-" ""
121+
, Tuple "-o-" ""
122+
, Tuple "" ""
62123
]
63124

64125
-- | Syntax for CSS function call.

src/CSS/Cursor.purs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ data Cursor
1010
= Default
1111
| Help
1212
| Pointer
13-
| Progress
13+
| Progress
1414
| Wait
1515
| Cell
1616
| Crosshair
@@ -19,13 +19,13 @@ data Cursor
1919
| Alias
2020
| Copy
2121
| Move
22-
| NoDrop
22+
| NoDrop
2323
| NotAllowed
2424
| Grab
2525
| Grabbing
2626
| AllScroll
2727
| ColResize
28-
| RowResize
28+
| RowResize
2929
| NResize
3030
| EResize
3131
| SResize
@@ -45,29 +45,29 @@ derive instance eqCursor :: Eq Cursor
4545
derive instance ordCursor :: Ord Cursor
4646

4747
instance valCursor :: Val Cursor where
48-
value Default = fromString "default"
48+
value Default = fromString "default"
4949
value Help = fromString "help"
50-
value Pointer = fromString "pointer"
50+
value Pointer = fromString "pointer"
5151
value Progress = fromString "progress"
5252
value Wait = fromString "wait"
5353
value Cell = fromString "cell"
54-
value Crosshair = fromString "crosshair"
54+
value Crosshair = fromString "crosshair"
5555
value Text = fromString "text"
5656
value VerticalText = fromString "vertical-text"
57-
value Alias = fromString "alias"
57+
value Alias = fromString "alias"
5858
value Copy = fromString "copy"
5959
value Move = fromString "move"
6060
value NoDrop = fromString "no-drop"
6161
value NotAllowed = fromString "not-allowed"
6262
value Grab = fromString "grab"
6363
value Grabbing = fromString "grabbing"
64-
value AllScroll = fromString "all-scroll"
65-
value ColResize = fromString "col-resize"
66-
value RowResize = fromString "row-resize"
67-
value NResize = fromString "n-resize"
68-
value EResize = fromString "e-resize"
69-
value SResize = fromString "s-resize"
70-
value WResize = fromString "w-resize"
64+
value AllScroll = fromString "all-scroll"
65+
value ColResize = fromString "col-resize"
66+
value RowResize = fromString "row-resize"
67+
value NResize = fromString "n-resize"
68+
value EResize = fromString "e-resize"
69+
value SResize = fromString "s-resize"
70+
value WResize = fromString "w-resize"
7171
value NEResize = fromString "ne-resize"
7272
value NWResize = fromString "nw-resize"
7373
value SEResize = fromString "se-resize"
@@ -77,7 +77,7 @@ instance valCursor :: Val Cursor where
7777
value NESWResize = fromString "nesw-resize"
7878
value NWSEResize = fromString "nwse-resize"
7979
value ZoomIn = fromString "zoom-in"
80-
value ZoomOut = fromString "zoom-out"
80+
value ZoomOut = fromString "zoom-out"
8181

8282
cursor :: Cursor -> CSS
8383
cursor = key $ fromString "cursor"

0 commit comments

Comments
 (0)