From 7e9941bf90644120b3627d0f0f66204fed9efb2a Mon Sep 17 00:00:00 2001 From: stuebinm Date: Mon, 4 Apr 2022 00:10:56 +0200 Subject: linter: collect content warnings --- lib/Properties.hs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/Properties.hs') 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 -- cgit v1.2.3