summaryrefslogtreecommitdiff
path: root/lib/Properties.hs
diff options
context:
space:
mode:
authorstuebinm2022-04-04 00:10:56 +0200
committerstuebinm2022-04-04 00:10:56 +0200
commit7e9941bf90644120b3627d0f0f66204fed9efb2a (patch)
tree6189ca6d4f2baab04a6759c9ba934295aa06def9 /lib/Properties.hs
parent1db21885df2bd99d65a5aac43bd7fc35ea0ff767 (diff)
linter: collect content warnings
Diffstat (limited to 'lib/Properties.hs')
-rw-r--r--lib/Properties.hs11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/Properties.hs b/lib/Properties.hs
index 035b76a..faa6db0 100644
--- a/lib/Properties.hs
+++ b/lib/Properties.hs
@@ -38,7 +38,7 @@ import LintConfig (LintConfig (..))
import LintWriter (LintWriter, adjust, askContext,
askFileDepth, complain, dependsOn, forbid,
lintConfig, offersBadge, offersEntrypoint,
- suggest, warn, zoom)
+ suggest, warn, zoom, offersCWs)
import Paths (PathResult (..), RelPath (..),
getExtension, isOldStyle, parsePath)
import Types (Dep (Link, Local, LocalMap, MapLink))
@@ -47,7 +47,8 @@ import Uris (SubstError (..), applySubsts)
knownMapProperties :: Vector Text
knownMapProperties = V.fromList
- [ "mapName", "mapDescription", "mapCopyright", "mapLink", "script" ]
+ [ "mapName", "mapDescription", "mapCopyright", "mapLink", "script"
+ , "contentWarnings" ]
knownTilesetProperties :: Vector Text
knownTilesetProperties = V.fromList
@@ -106,6 +107,9 @@ checkMap = do
unlessHasProperty "mapCopyright"
$ suggest "document the map's copyright via the \"mapCopyright\" property."
+ unlessHasProperty "contentWarnings"
+ $ suggest "set content warnings for your map via the \"contentWarnings\" property."
+
-- TODO: this doesn't catch collisions with the default start layer!
whenLayerCollisions layers (\(Property name _) -> name == "exitUrl" || name == "startLayer")
$ \cols -> warn $ "collisions between entry and / or exit layers: " <> prettyprint cols
@@ -134,6 +138,9 @@ checkMapProperty p@(Property name _) = case name of
"mapDescription" -> naiveEscapeProperty p
"mapCopyright" -> naiveEscapeProperty p
"mapLink" -> pure ()
+ "contentWarnings" ->
+ unwrapString p $ \str -> do
+ offersCWs (T.splitOn "," str)
-- usually the linter will complain if names aren't in their
-- "canonical" form, but allowing that here so that multiple
-- scripts can be used by one map