Module

Whine.Runner.Config

Package
purescript-whine-core
Repository
collegevine/purescript-whine

#PackageSpec Source

#Config Source

type Config :: (Type -> Type) -> Typetype Config m = { files :: Globs, rules :: RuleSet m }

#RuleSet Source

type RuleSet :: (Type -> Type) -> Typetype RuleSet m = Map RuleId { globs :: Globs, rule :: Rule m }

For every rule ID we have a rule implementation Rule m and some common config values that can be applied to any rule and are handled by the framework.

#ConfigJson Source

type ConfigJson = { exclude :: Maybe (Array NonEmptyString), include :: Maybe (Array NonEmptyString), rulePackages :: Map { package :: String } PackageSpec, rules :: Maybe (Map String JSON) }

#parseRuleConfigs Source

parseRuleConfigs :: forall m n. MonadWriter (Violations (WithRule + ())) m => RuleFactories n -> Map String JSON -> m (RuleSet n)

The config has the general shape of:

RuleId:
  include: ["one/file.purs", "many/**/*.purs"]
  exclude: ["same.purs"]
  enabled: true
  ruleSpecificSetting1: "foo"
  ruleSpecificSetting2: 42
  ruleSpecificSetting3: ["a", "b", "c"]

AnotherRuleId:
  ... samesies ...

This is what this function takes as parameter - a map of JS objects. The keys are rule IDs, the inner objects are rule-specific settings, plus common options of "include", "exclude", and "enable", all optional.

The other parameter is an array of rule factories, each a tuple of (ruleId /\ factoryFunction), where factoryFunction :: JSON -> Either String Rule

The result is a RuleSet value, which is a map of rule IDs to rule configs.

The whole thing runs in a writer monad to which it can report any errors while parsing the config. The errors doesn't stop the parsing, but erroneous rules do not make it into the resulting map.

#readConfig Source

readConfig :: forall m n. MonadEffect m => MonadWriter (Violations (WithRule + WithFile + ())) m => RuleFactories n -> FilePath -> m (Config n)

Reads config from a given file and parses it.

#packagesCodec Source