Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
Better detect unformatted markdown files (#422)
Browse files Browse the repository at this point in the history
This change splits the `lint` NPM run script into its component parts
and then calls then with `run-p`. It also adds a CI job to explicitly
check our documentation for formatting errors. This will better detect
unformatted Markdown files and no longer block application deployments
if unformatted Markdown slips into the codebase.

Closes #420
  • Loading branch information
ian-noaa authored Oct 23, 2023
2 parents 540b91c + 8cc8abf commit 0d46dab
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 5 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "Format Docs"
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+-rc[0-9]+"
branches: [main]
# Path filters aren't evaluated for tags - https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onpushpull_requestpull_request_targetpathspaths-ignore
paths:
- "**/*.md"
pull_request:
paths:
- "**/*.md"
workflow_dispatch: # Manually

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Install dependencies
run: npm install prettier
- name: Lint
run: npx prettier --check **/*.md
2 changes: 1 addition & 1 deletion .github/workflows/ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
run: npm run lint:code
# test:
# runs-on: ubuntu-latest
# permissions:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ repos:
rev: v2.7.1
hooks:
- id: prettier
types_or: [css, javascript, json, yaml]
types_or: [css, javascript, json, yaml, markdown]
exclude: .github/workflows/.*\.yaml
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ service is as simple as:

```
npm run vendor && npm run build
npm test
npm run lint
npm run format
```

## Coding Style
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
"build:assets": "mkdir -p build && cp -r src/unified_graphics/static/geo build/geo && cp src/unified_graphics/static/*icon.* build",
"clean": "del build/",
"test": "echo 'No tests' && exit 1",
"lint": "prettier --check --plugin-search-dir=. . && eslint . --ignore-pattern '**/*.min.js' --ignore-pattern '**/htmlcov/**' --ignore-pattern '**/vendor/*' && stylelint src/**/*.css",
"format": "prettier --write --plugin-search-dir=. . && stylelint --fix src/**/*.css",
"lint": "run-p lint:prettier:docs lint:prettier:code lint:eslint lint:css",
"lint:code": "run-p lint:prettier:code lint:eslint lint:css",
"lint:css": "stylelint src/**/*.css",
"lint:eslint": "eslint . --ignore-pattern '**/*.min.js' --ignore-pattern '**/htmlcov/**' --ignore-pattern '**/vendor/*'",
"lint:prettier:docs": "prettier --check '**/*.md'",
"lint:prettier:code": "prettier --check '.' '!**/*.md'",
"format": "prettier --write . && stylelint --fix src/**/*.css",
"vendor": "run-p vendor:*",
"vendor:lodash": "echo 'export * from \"lodash-es\"' | rollup --plugin @rollup/plugin-node-resolve --file src/unified_graphics/static/js/vendor/lodash.js --format es",
"vendor:d3": "echo 'export * from \"d3\"' | rollup --plugin @rollup/plugin-node-resolve --file src/unified_graphics/static/js/vendor/d3.js --format es"
Expand Down

0 comments on commit 0d46dab

Please sign in to comment.