From f3ddfde201072263b8ca36388a89b4b5913c8b59 Mon Sep 17 00:00:00 2001 From: Orion Kindel Date: Sat, 28 Oct 2023 14:47:41 -0500 Subject: [PATCH] chore: fmt --- .prettierrc.cjs | 2 +- bun.lockb | Bin 58040 -> 58040 bytes package.json | 2 +- src/Cheerio.js | 43 +++++++++++++++++----------------- src/Cheerio.purs | 12 ++++++---- src/Cheerio/Static.js | 8 +++---- src/Cheerio/Static.purs | 5 ++-- test/Test/Cheerio.purs | 17 +++++++------- test/Test/Cheerio/Static.purs | 2 +- test/Test/HtmlEx.purs | 3 ++- 10 files changed, 49 insertions(+), 45 deletions(-) diff --git a/.prettierrc.cjs b/.prettierrc.cjs index 3a11283..b8e1fd1 100644 --- a/.prettierrc.cjs +++ b/.prettierrc.cjs @@ -4,5 +4,5 @@ module.exports = { singleQuote: true, semi: false, arrowParens: 'avoid', - plugins: ['prettier-plugin-sh'], + plugins: [], } diff --git a/bun.lockb b/bun.lockb index c7c423732748020c37fe312c203d2ec5072b12b8..ff1ebabd312984a7357fe3f7b9a9ba1ef04a3a9d 100755 GIT binary patch delta 23 fcmdmSlzGQd<_(66IT+&%^b8I33^rRXuD1sOZ8Hc~ delta 23 acmdmSlzGQd<_(66IhYtAV6)}odV2t0VFug) diff --git a/package.json b/package.json index ab46c49..d27b3f2 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "test": "test" }, "scripts": { - "fmt": "bun fmt", + "fmt": "bun bun/fmt.js", "build": "bun x spago build", "test": "bun x spago test" }, diff --git a/src/Cheerio.js b/src/Cheerio.js index db9825a..574487e 100644 --- a/src/Cheerio.js +++ b/src/Cheerio.js @@ -1,67 +1,66 @@ import cheerio from 'cheerio' // Attributes -export const attrImpl = function(nothing, just, name, cheerioInst) { - +export const attrImpl = function (nothing, just, name, cheerioInst) { if (cheerioInst.length > 0) { - const value = cheerioInst.attr(name); - return value != null ? just(value) : nothing; + const value = cheerioInst.attr(name) + return value != null ? just(value) : nothing } - return nothing; + return nothing } -export const hasClassImpl = function(className, cheerioInst) { - return cheerioInst.hasClass(className); +export const hasClassImpl = function (className, cheerioInst) { + return cheerioInst.hasClass(className) } // Traversing -export const findImpl = function(selector, cheerioInst) { - return cheerioInst.find(selector); +export const findImpl = function (selector, cheerioInst) { + return cheerioInst.find(selector) } -export const parent = function(cheerioInst) { +export const parent = function (cheerioInst) { return cheerioInst.parent() } -export const next = function(cheerioInst) { +export const next = function (cheerioInst) { return cheerioInst.next() } -export const prev = function(cheerioInst) { +export const prev = function (cheerioInst) { return cheerioInst.prev() } -export const siblings = function(cheerioInst) { +export const siblings = function (cheerioInst) { return cheerioInst.siblings() } -export const children = function(cheerioInst) { +export const children = function (cheerioInst) { return cheerioInst.children() } -export const first = function(cheerioInst) { +export const first = function (cheerioInst) { return cheerioInst.first() } -export const last = function(cheerioInst) { +export const last = function (cheerioInst) { return cheerioInst.last() } -export const eqImpl = function(index, cheerioInst) { +export const eqImpl = function (index, cheerioInst) { return cheerioInst.eq(index) } // Rendering -export const htmlImpl = function(nothing, just, cheerioInst) { - return cheerioInst.length ? just(cheerioInst.html()) : nothing; +export const htmlImpl = function (nothing, just, cheerioInst) { + return cheerioInst.length ? just(cheerioInst.html()) : nothing } -export const text = function(cheerioInst) { +export const text = function (cheerioInst) { return cheerioInst.text() } // Miscellaneous -export const length = function(cheerioInst) { - return cheerioInst.length; +export const length = function (cheerioInst) { + return cheerioInst.length } diff --git a/src/Cheerio.purs b/src/Cheerio.purs index 175cfa0..791e045 100644 --- a/src/Cheerio.purs +++ b/src/Cheerio.purs @@ -26,8 +26,9 @@ import Data.Maybe (Maybe(..)) foreign import data Cheerio :: Type -- Attributes -foreign import attrImpl :: forall a. - Fn4 (Maybe a) (a -> Maybe a) String Cheerio (Maybe String) +foreign import attrImpl + :: forall a + . Fn4 (Maybe a) (a -> Maybe a) String Cheerio (Maybe String) -- | Gets an attribute value from the first selected element, returning -- | Nothing when there are no selected elements, or when the first selected @@ -60,8 +61,9 @@ eq :: Int -> Cheerio -> Cheerio eq = runFn2 eqImpl -- Rendering -foreign import htmlImpl :: forall a. - Fn3 (Maybe a) (a -> Maybe a) Cheerio (Maybe String) +foreign import htmlImpl + :: forall a + . Fn3 (Maybe a) (a -> Maybe a) Cheerio (Maybe String) -- | Gets an html content string from the first selected element, returning -- | Nothing when there are no selected elements. @@ -79,4 +81,4 @@ foreign import length :: Cheerio -> Int toArray :: Cheerio -> Array Cheerio toArray c | length c == 0 = [] - | otherwise = map (\i -> eq i c) (0 .. (length c - 1)) + | otherwise = map (\i -> eq i c) (0 .. (length c - 1)) diff --git a/src/Cheerio/Static.js b/src/Cheerio/Static.js index 0ad4d1a..d8787db 100644 --- a/src/Cheerio/Static.js +++ b/src/Cheerio/Static.js @@ -4,21 +4,21 @@ import cheerio from 'cheerio' export const load = cheerio.load // Selecting -export const selectImpl = function(str, cheerioStatic) { +export const selectImpl = function (str, cheerioStatic) { return cheerioStatic(str) } -export const selectDeepImpl = function(strArr, cheerioStatic) { +export const selectDeepImpl = function (strArr, cheerioStatic) { return cheerioStatic.apply(cheerioStatic, strArr) } // Rendering -export const htmlImpl = function(nothing, just, cheerioInst) { +export const htmlImpl = function (nothing, just, cheerioInst) { const ret = cheerio.html(cheerioInst) return ret != null ? just(ret) : nothing } // Utilities -export const root = function(cheerioStatic) { +export const root = function (cheerioStatic) { return cheerio.root.call(cheerioStatic) } diff --git a/src/Cheerio/Static.purs b/src/Cheerio/Static.purs index ac0b4bb..8264743 100644 --- a/src/Cheerio/Static.purs +++ b/src/Cheerio/Static.purs @@ -30,8 +30,9 @@ selectDeep :: Array String -> CheerioStatic -> Cheerio selectDeep = runFn2 selectDeepImpl -- Rendering -foreign import htmlImpl :: forall a. - Fn3 (Maybe a) (a -> Maybe a) Cheerio (Maybe String) +foreign import htmlImpl + :: forall a + . Fn3 (Maybe a) (a -> Maybe a) Cheerio (Maybe String) html :: Cheerio -> Maybe String html = runFn3 htmlImpl Nothing Just diff --git a/test/Test/Cheerio.purs b/test/Test/Cheerio.purs index 437bd2d..a89b877 100644 --- a/test/Test/Cheerio.purs +++ b/test/Test/Cheerio.purs @@ -155,7 +155,7 @@ suites = do (emptyCheerio # toArray # map (attr "class")) Assert.equal - (map Just ["apple", "orange", "pear"]) + (map Just [ "apple", "orange", "pear" ]) (loadRoot htmlEx # find "li" # toArray # map (attr "class")) suite "More" do @@ -163,10 +163,11 @@ suites = do Assert.equal "Apple" ( loadRoot htmlEx - # find ".apple" - # siblings - # eq 1 - # parent - # children - # first - # text) + # find ".apple" + # siblings + # eq 1 + # parent + # children + # first + # text + ) diff --git a/test/Test/Cheerio/Static.purs b/test/Test/Cheerio/Static.purs index 3060ae1..dd2f0f4 100644 --- a/test/Test/Cheerio/Static.purs +++ b/test/Test/Cheerio/Static.purs @@ -41,7 +41,7 @@ suites = do test "selectDeep" do Assert.equal "Apple" - (load htmlEx # selectDeep [".apple", "#fruits"] # text) + (load htmlEx # selectDeep [ ".apple", "#fruits" ] # text) suite "Rendering" do test "html" do diff --git a/test/Test/HtmlEx.purs b/test/Test/HtmlEx.purs index d239233..50cc797 100644 --- a/test/Test/HtmlEx.purs +++ b/test/Test/HtmlEx.purs @@ -1,7 +1,8 @@ module Test.HtmlEx where htmlEx :: String -htmlEx = """ +htmlEx = + """