Skip to content

feat: add claude md rules - #63

Open
darkmavis1980 wants to merge 17 commits into
mainfrom
feature/WTI-787--add-claude-md-rules
Open

feat: add claude md rules#63
darkmavis1980 wants to merge 17 commits into
mainfrom
feature/WTI-787--add-claude-md-rules

Conversation

@darkmavis1980

Copy link
Copy Markdown
Contributor

Add CLAUDE.md linting rules

Summary of Changes 📋

  • feat: Add CLAUDE.md ESLint plugin with max-lines rule to enforce line count limits
  • feat: Add claude-md.config.js with dedicated ESLint configuration for linting CLAUDE.md files
  • feat: Integrate CLAUDE.md linting into both index.js (Node) and browser.js (Browser/React) ESLint configurations
  • feat: Add tests for CLAUDE.md linting rules and max-lines rule
  • docs: Add ADR (docs/adr/0001-lint-claude-md-with-eslint.md) documenting the decision to lint CLAUDE.md with ESLint
  • docs: Add examples/claude-md-usage.md with usage documentation for the new linting rules
  • fix: Update test script to run Node.js tests instead of echo error
  • chore: Add @eslint/markdown dependency
  • chore: Update version to 4.3.0-next.1

Notes

This PR introduces a new ESLint plugin (plugins/claude-md/) that enforces a maximum line count on CLAUDE.md files, helping keep AI context files concise and maintainable. The plugin is automatically included in both the Node and Browser ESLint configurations exported by this package.

denisolvr
denisolvr previously approved these changes Aug 24, 2026
craigayre
craigayre previously approved these changes Aug 24, 2026
…int-node into feature/WTI-787--add-claude-md-rules
@darkmavis1980
darkmavis1980 dismissed stale reviews from craigayre and denisolvr via 1fc81a6 August 24, 2026 11:24

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Since the rule itself doesn't distinguish the file it is being run on - should we just use the built in https://eslint.org/docs/latest/rules/max-lines rule instead (and target CLAUDE.md with it)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point, let me see if we can use that

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Claude:

Good question — I looked into this. The built-in max-lines won't work here: CLAUDE.md is linted with language: 'markdown/gfm' (otherwise ESLint parses the Markdown as JS and errors), and the built-in rule listens on Program:exit while the Markdown AST's root node is root. So it would silently never fire, and it also calls JS-only SourceCode APIs (getAllComments, etc.) that the Markdown language doesn't provide. That's why this custom rule hooks root(). The "doesn't distinguish the file" point is true but harmless since files: ['**/CLAUDE.md'] already scopes it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I ummed and arred about leaving a similar comment - I think it does need to be a unique rule but there's potentially a mismatch between max-lines and it specifically mentioning CLAUDE.md. We could use this for SKILL.md with a different threshold etc so maybe the wording being generic would help?

You'd know what file from the output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants