Skip to content

Instantly share code, notes, and snippets.

@wshihadeh
Created April 24, 2020 20:15
Show Gist options
  • Save wshihadeh/07b71b7a289d4cb3df6cb2d8373081f6 to your computer and use it in GitHub Desktop.
Save wshihadeh/07b71b7a289d4cb3df6cb2d8373081f6 to your computer and use it in GitHub Desktop.
Linting
{
"no-hard-tabs": false,
"MD007": { "indent": 4 },
"MD009": false,
"MD013": false,
"MD024": false,
"MD026": false,
"MD033": false,
"MD034": false,
"MD036": false,
"MD046": false
}
#!/bin/sh -eu
# This script will run a couple of linter on the documentation
EXIT_CODE=0
readonly BASE_DIR=/app
echo "== Linting Markdown"
# Uses the file ".markdownlint.json" for setup
cd "${BASE_DIR}" || exit 1
LINTER_EXCLUSIONS="$(find "${BASE_DIR}/docs" -type f -name '.markdownlint.json')" \
GLOBAL_LINT_OPTIONS="--config ${BASE_DIR}/.markdownlint.json"
# Lint the specific folders (containing linter specific rulesets)
for LINTER_EXCLUSION in ${LINTER_EXCLUSIONS}
do
markdownlint --config "${LINTER_EXCLUSION}" "$(dirname "${LINTER_EXCLUSION}")" || EXIT_CODE=1
# Add folder to the ignore list for global lint
GLOBAL_LINT_OPTIONS="${GLOBAL_LINT_OPTIONS} --ignore=$(dirname "${LINTER_EXCLUSION}")"
done
# Lint all the docs, excluding the previously done`
eval markdownlint "${GLOBAL_LINT_OPTIONS}" "${BASE_DIR}/docs/**/*.md" || EXIT_CODE=1
exit "${EXIT_CODE}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment