Jts contrib and linting fixes (#6494)
* feat(ci): improve linting configuration for instruction files - Add GitHub-flavored Markdown support with remark-gfm - Create generic Vale config (.vale-instructions.ini) for instruction files - Use pattern-based file inclusion instead of explicit file lists - Mount repository to /workdir in remark-lint container to preserve node_modules Changes: - Add remark-gfm to .ci/remark-lint/package.json - Create .remarkrc.yaml at repository root for instruction files - Update content/.remarkrc.yaml to include remark-gfm - Create .vale-instructions.ini for generic writing rules - Update compose.yaml: mount repo to /workdir (preserves /app/node_modules) - Update lefthook.yml: use glob patterns for uppercase .md files and .github/**/*.md - Update DOCS-CONTRIBUTING.md: remove empty CONTRIBUTING.md directory reference Benefits: - Automatic inclusion of new instruction files without config updates - Pattern matching for uppercase .md files (DOCS-*.md, CLAUDE.md, etc.) - Coverage for .github/, .claude/, api-docs/ directories - GFM features: tables, task lists, strikethrough, autolinks, footnotes - Separate linting rules for instruction files vs product documentation feat(lint): separate remark-lint auto-fix for instructions vs report-only for content - Split lint-markdown into two hooks: - lint-markdown-instructions: Auto-fixes README, DOCS-*.md, .github/**, .claude/** - lint-markdown-content: Reports issues in content/**, api-docs/** without modifying - Changed remark-lint volume mount from read_only: true to read_only: false - Instruction files now behave like Prettier (auto-fix + stage) - Content files report errors and block commits until manually fixed * chore(instructions): Add content/shared details, husky/lefthook updatespull/6486/head
parent
56c173ec33
commit
624c6ad0d8
|
|
@ -3,6 +3,7 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"remark-cli": "12.0.1",
|
"remark-cli": "12.0.1",
|
||||||
|
"remark-gfm": "4.0.1",
|
||||||
"remark-preset-lint-consistent": "6.0.0",
|
"remark-preset-lint-consistent": "6.0.0",
|
||||||
"remark-preset-lint-markdown-style-guide": "6.0.0",
|
"remark-preset-lint-markdown-style-guide": "6.0.0",
|
||||||
"remark-preset-lint-recommended": "7.0.0",
|
"remark-preset-lint-recommended": "7.0.0",
|
||||||
|
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
[*.md]
|
|
||||||
# Exclude `{{< ... >}}`, `{{% ... %}}`, [Who]({{< ... >}})
|
|
||||||
TokenIgnores = ({{[%<] .* [%>]}}.*?{{[%<] ?/.* [%>]}}), \
|
|
||||||
(\[.+\]\({{< .+ >}}\)), \
|
|
||||||
[^\S\r\n]({{[%<] \w+ .+ [%>]}})\s, \
|
|
||||||
[^\S\r\n]({{[%<](?:/\*) .* (?:\*/)[%>]}})\s
|
|
||||||
|
|
||||||
# Exclude `{{< myshortcode `This is some <b>HTML</b>, ... >}}`
|
|
||||||
BlockIgnores = (?sm)^({{[%<] \w+ [^{]*?\s[%>]}})\n$, \
|
|
||||||
(?s) *({{< highlight [^>]* ?>}}.*?{{< ?/ ?highlight >}})
|
|
||||||
|
|
@ -33,6 +33,9 @@ call_lefthook()
|
||||||
then
|
then
|
||||||
"$dir/node_modules/lefthook/bin/index.js" "$@"
|
"$dir/node_modules/lefthook/bin/index.js" "$@"
|
||||||
|
|
||||||
|
elif go tool lefthook -h >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
go tool lefthook "$@"
|
||||||
elif bundle exec lefthook -h >/dev/null 2>&1
|
elif bundle exec lefthook -h >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
bundle exec lefthook "$@"
|
bundle exec lefthook "$@"
|
||||||
|
|
@ -42,12 +45,21 @@ call_lefthook()
|
||||||
elif pnpm lefthook -h >/dev/null 2>&1
|
elif pnpm lefthook -h >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
pnpm lefthook "$@"
|
pnpm lefthook "$@"
|
||||||
elif swift package plugin lefthook >/dev/null 2>&1
|
elif swift package lefthook >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
swift package --disable-sandbox plugin lefthook "$@"
|
swift package --build-path .build/lefthook --disable-sandbox lefthook "$@"
|
||||||
elif command -v mint >/dev/null 2>&1
|
elif command -v mint >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
mint run csjones/lefthook-plugin "$@"
|
mint run csjones/lefthook-plugin "$@"
|
||||||
|
elif uv run lefthook -h >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
uv run lefthook "$@"
|
||||||
|
elif mise exec -- lefthook -h >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
mise exec -- lefthook "$@"
|
||||||
|
elif devbox run lefthook -h >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
devbox run lefthook "$@"
|
||||||
else
|
else
|
||||||
echo "Can't find lefthook in PATH"
|
echo "Can't find lefthook in PATH"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,9 @@ call_lefthook()
|
||||||
then
|
then
|
||||||
"$dir/node_modules/lefthook/bin/index.js" "$@"
|
"$dir/node_modules/lefthook/bin/index.js" "$@"
|
||||||
|
|
||||||
|
elif go tool lefthook -h >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
go tool lefthook "$@"
|
||||||
elif bundle exec lefthook -h >/dev/null 2>&1
|
elif bundle exec lefthook -h >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
bundle exec lefthook "$@"
|
bundle exec lefthook "$@"
|
||||||
|
|
@ -42,12 +45,21 @@ call_lefthook()
|
||||||
elif pnpm lefthook -h >/dev/null 2>&1
|
elif pnpm lefthook -h >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
pnpm lefthook "$@"
|
pnpm lefthook "$@"
|
||||||
elif swift package plugin lefthook >/dev/null 2>&1
|
elif swift package lefthook >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
swift package --disable-sandbox plugin lefthook "$@"
|
swift package --build-path .build/lefthook --disable-sandbox lefthook "$@"
|
||||||
elif command -v mint >/dev/null 2>&1
|
elif command -v mint >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
mint run csjones/lefthook-plugin "$@"
|
mint run csjones/lefthook-plugin "$@"
|
||||||
|
elif uv run lefthook -h >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
uv run lefthook "$@"
|
||||||
|
elif mise exec -- lefthook -h >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
mise exec -- lefthook "$@"
|
||||||
|
elif devbox run lefthook -h >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
devbox run lefthook "$@"
|
||||||
else
|
else
|
||||||
echo "Can't find lefthook in PATH"
|
echo "Can't find lefthook in PATH"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,9 @@ call_lefthook()
|
||||||
then
|
then
|
||||||
"$dir/node_modules/lefthook/bin/index.js" "$@"
|
"$dir/node_modules/lefthook/bin/index.js" "$@"
|
||||||
|
|
||||||
|
elif go tool lefthook -h >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
go tool lefthook "$@"
|
||||||
elif bundle exec lefthook -h >/dev/null 2>&1
|
elif bundle exec lefthook -h >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
bundle exec lefthook "$@"
|
bundle exec lefthook "$@"
|
||||||
|
|
@ -42,12 +45,21 @@ call_lefthook()
|
||||||
elif pnpm lefthook -h >/dev/null 2>&1
|
elif pnpm lefthook -h >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
pnpm lefthook "$@"
|
pnpm lefthook "$@"
|
||||||
elif swift package plugin lefthook >/dev/null 2>&1
|
elif swift package lefthook >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
swift package --disable-sandbox plugin lefthook "$@"
|
swift package --build-path .build/lefthook --disable-sandbox lefthook "$@"
|
||||||
elif command -v mint >/dev/null 2>&1
|
elif command -v mint >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
mint run csjones/lefthook-plugin "$@"
|
mint run csjones/lefthook-plugin "$@"
|
||||||
|
elif uv run lefthook -h >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
uv run lefthook "$@"
|
||||||
|
elif mise exec -- lefthook -h >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
mise exec -- lefthook "$@"
|
||||||
|
elif devbox run lefthook -h >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
devbox run lefthook "$@"
|
||||||
else
|
else
|
||||||
echo "Can't find lefthook in PATH"
|
echo "Can't find lefthook in PATH"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
settings:
|
||||||
|
bullet: "-"
|
||||||
|
|
||||||
|
plugins:
|
||||||
|
# GitHub-flavored Markdown support (tables, task lists, strikethrough, etc.)
|
||||||
|
- remark-gfm
|
||||||
|
- remark-frontmatter
|
||||||
|
# Check that markdown is consistent (list items have the same indentation)
|
||||||
|
- remark-preset-lint-consistent
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
StylesPath = .ci/vale/styles
|
||||||
|
|
||||||
|
MinAlertLevel = warning
|
||||||
|
|
||||||
|
# Use general technical writing packages
|
||||||
|
Packages = write-good
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
# Base styles focused on clarity and consistency
|
||||||
|
BasedOnStyles = Vale, write-good
|
||||||
|
|
||||||
|
# Disable style rules that are too opinionated for instruction files
|
||||||
|
Vale.Spelling = NO
|
||||||
|
|
@ -120,6 +120,10 @@ docs-v2 contains a `./.vscode/settings.json` that configures the following exten
|
||||||
|
|
||||||
### Style Guidelines
|
### Style Guidelines
|
||||||
|
|
||||||
|
#### Content Guidelines
|
||||||
|
|
||||||
|
Content follows Google Developer Documentation Style Guide and YouTube API documentation patterns with a few InfluxData-specific adaptations.
|
||||||
|
|
||||||
#### Markdown
|
#### Markdown
|
||||||
|
|
||||||
Most docs-v2 documentation content uses [Markdown](https://en.wikipedia.org/wiki/Markdown).
|
Most docs-v2 documentation content uses [Markdown](https://en.wikipedia.org/wiki/Markdown).
|
||||||
|
|
|
||||||
11
compose.yaml
11
compose.yaml
|
|
@ -516,12 +516,13 @@ services:
|
||||||
profiles:
|
profiles:
|
||||||
- lint
|
- lint
|
||||||
volumes:
|
volumes:
|
||||||
|
# Mount repository to /workdir to avoid overwriting /app/ node_modules
|
||||||
|
# Remark will receive paths like /workdir/content/file.md or /workdir/README.md
|
||||||
|
# Writable mount allows auto-fixing instruction files (README.md, DOCS-*.md, etc.)
|
||||||
- type: bind
|
- type: bind
|
||||||
source: ./content
|
source: .
|
||||||
target: /app/content
|
target: /workdir
|
||||||
- type: bind
|
read_only: false
|
||||||
source: ./CONTRIBUTING.md
|
|
||||||
target: /app/CONTRIBUTING.md
|
|
||||||
volumes:
|
volumes:
|
||||||
test-content:
|
test-content:
|
||||||
cloud-tmp:
|
cloud-tmp:
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ settings:
|
||||||
plugins:
|
plugins:
|
||||||
# Before you can configure plugins for remark here, you need to add them to
|
# Before you can configure plugins for remark here, you need to add them to
|
||||||
# the `devDependencies` in the `package.json` file--for CI: `/.ci/app/package.json`.
|
# the `devDependencies` in the `package.json` file--for CI: `/.ci/app/package.json`.
|
||||||
|
- remark-gfm
|
||||||
- remark-frontmatter
|
- remark-frontmatter
|
||||||
- remark-lint-frontmatter-schema
|
- remark-lint-frontmatter-schema
|
||||||
- remark-lint-no-shell-dollars
|
- remark-lint-no-shell-dollars
|
||||||
|
|
|
||||||
39
lefthook.yml
39
lefthook.yml
|
|
@ -12,12 +12,43 @@ pre-commit:
|
||||||
build-agent-instructions:
|
build-agent-instructions:
|
||||||
glob: "data/products.yml"
|
glob: "data/products.yml"
|
||||||
run: yarn build:agent:instructions
|
run: yarn build:agent:instructions
|
||||||
# Report linting warnings and errors, don't output files to stdout
|
# Auto-fix markdown formatting for instruction and README files (like prettier)
|
||||||
lint-markdown:
|
lint-markdown-instructions:
|
||||||
tags: lint
|
tags: lint
|
||||||
glob: "{README.md,DOCS-*.md,api-docs/README.md,content/*.md}"
|
glob: "{README.md,*[A-Z]*.md,.github/**/*.md,.claude/**/*.md}"
|
||||||
run: |
|
run: |
|
||||||
docker compose run --rm --name remark-lint remark-lint '{staged_files}'
|
# Prepend /workdir/ to staged files since repository is mounted at /workdir in container
|
||||||
|
files=$(echo '{staged_files}' | sed 's|^|/workdir/|g; s| | /workdir/|g')
|
||||||
|
docker compose run --rm --name remark-lint remark-lint $files --output --quiet || \
|
||||||
|
{ echo "⚠️ Remark found formatting issues in instruction files. Automatic formatting applied."; }
|
||||||
|
stage_fixed: true
|
||||||
|
# Report markdown formatting issues in content/api-docs without auto-fixing
|
||||||
|
lint-markdown-content:
|
||||||
|
tags: lint
|
||||||
|
glob: "{api-docs/**/*.md,content/**/*.md}"
|
||||||
|
run: |
|
||||||
|
# Prepend /workdir/ to staged files since repository is mounted at /workdir in container
|
||||||
|
files=$(echo '{staged_files}' | sed 's|^|/workdir/|g; s| | /workdir/|g')
|
||||||
|
# Run remark to check for formatting differences (without --output, shows diff in stdout)
|
||||||
|
# If output differs from input, fail the commit
|
||||||
|
for file in $files; do
|
||||||
|
original=$(cat "${file#/workdir/}")
|
||||||
|
formatted=$(docker compose run --rm --name remark-lint-content remark-lint "$file" 2>/dev/null | tail -n +2)
|
||||||
|
if [ "$original" != "$formatted" ]; then
|
||||||
|
echo "❌ Markdown formatting issues in ${file#/workdir/}"
|
||||||
|
echo " Run: docker compose run --rm remark-lint $file --output"
|
||||||
|
echo " Or manually fix the formatting to match remark style"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "✅ All content files are properly formatted"
|
||||||
|
# Lint instruction and repository documentation files with generic Vale config
|
||||||
|
lint-instructions:
|
||||||
|
tags: lint
|
||||||
|
glob: "{README.md,*[A-Z]*.md,.github/**/*.md,.claude/**/*.md,api-docs/README.md}"
|
||||||
|
run: '.ci/vale/vale.sh
|
||||||
|
--config=.vale-instructions.ini
|
||||||
|
--minAlertLevel=warning {staged_files}'
|
||||||
cloud-lint:
|
cloud-lint:
|
||||||
tags: lint,v2
|
tags: lint,v2
|
||||||
glob: 'content/influxdb/cloud/*.md'
|
glob: 'content/influxdb/cloud/*.md'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue