Module

Whine.Runner.Config

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

#PackageSpec Source

#Config Source

type Config = { files :: Globs, rules :: RuleSet }

#RuleSet Source

type RuleSet = Map RuleId { globs :: Globs, rule :: Rule }

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. MonadRules (WithRule + ()) m => RuleFactories -> Map String JSON -> m RuleSet

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. MonadEffect m => RuleFactories -> FilePath -> WhineM (WithRule + WithFile + WithMuted + ()) m Config

Reads config from a given file and parses it.

#packagesCodec Source