Skip to content

Commit

Permalink
Merge pull request #1089 from elverytr/elverytr
Browse files Browse the repository at this point in the history
feat(back): #1087 enable custom rulesets for the lintMarkdown builtin
  • Loading branch information
dsalaza4 authored May 12, 2023
2 parents 039ffb5 + c296edb commit 726a521
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
7 changes: 6 additions & 1 deletion docs/src/api/builtins/lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,12 @@ Types:
- moduleType (`submodule`):
- config (`str`): Optional.
Path to the config file.
Defaults to [config.rb](/src/evaluator/modules/lint-markdown/config.rb).
Defaults to [config.rb](https://github.com/fluidattacks/makes/blob/main/src/evaluator/modules/lint-markdown/config.rb).
- targets (`listOf str`): Required.
paths to lint with `config`.
- rulesets (`str`): Optional.
Path to the custom rulesets file.
Defaults to [rulesets.rb](https://github.com/fluidattacks/makes/blob/main/src/evaluator/modules/lint-markdown/rulesets.rb).

Example:

Expand All @@ -175,6 +178,8 @@ Example:
all = {
# You can pass custom configs like this:
# config = "/src/config/markdown.rb";
# You can pass custom rules like this:
# rulesets = "/src/config/rulesets.rb";
targets = [ "/" ];
};
others = {
Expand Down
2 changes: 1 addition & 1 deletion src/args/lint-markdown/builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function main {
info Linting Markdown code \
&& for target in "${targets[@]}"; do
info Linting "${target}" \
&& mdl --ignore-front-matter --style "${envConfig}" "${target}" \
&& mdl --ignore-front-matter --style "${envConfig}" --rulesets "${envRulesets}" "${target}" \
|| return 1
done \
&& touch "${out}"
Expand Down
2 changes: 2 additions & 0 deletions src/args/lint-markdown/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
name,
config,
targets,
rulesets,
}:
makeDerivation {
env = {
envConfig = config;
envTargets = toBashArray targets;
envRulesets = rulesets;
};
name = "lint-markdown-for-${name}";
searchPaths = {
Expand Down
9 changes: 9 additions & 0 deletions src/evaluator/modules/lint-markdown/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
makeOutput = name: {
config,
targets,
rulesets,
}: {
name = "/lintMarkdown/${name}";
value = lintMarkdown {
Expand All @@ -20,6 +21,10 @@
then ./config.rb
else projectPath config;
targets = builtins.map projectPath targets;
rulesets =
if rulesets == null
then ./rulesets.rb
else projectPath rulesets;
};
};
in {
Expand All @@ -35,6 +40,10 @@ in {
targets = lib.mkOption {
type = lib.types.listOf lib.types.str;
};
rulesets = lib.mkOption {
default = null;
type = lib.types.nullOr lib.types.str;
};
};
}));
};
Expand Down
1 change: 1 addition & 0 deletions src/evaluator/modules/lint-markdown/rulesets.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Set custom rule sets here

0 comments on commit 726a521

Please sign in to comment.