feat: add jsdoc-example-eslint ESLint rule#11101
Draft
Planeshifter wants to merge 1 commit intodevelopfrom
Draft
feat: add jsdoc-example-eslint ESLint rule#11101Planeshifter wants to merge 1 commit intodevelopfrom
jsdoc-example-eslint ESLint rule#11101Planeshifter wants to merge 1 commit intodevelopfrom
Conversation
|
No dependency changes detected. Learn more about Socket for GitHub. 👍 No dependency changes detected in pull request |
8fce0dc to
33e0f6e
Compare
Add a new custom ESLint rule that extracts JavaScript code from
JSDoc `@example` blocks and lints it using ESLint's synchronous
`Linter` API. The rule is a pure mechanism: it accepts a `rules`
object and lints example code with those rules, reporting violations
mapped back to the correct source file lines.
The rule is configured in `.eslintrc.overrides.js`, where the
examples ESLint config is loaded (avoiding a circular dependency
with `stdlib.js`), filtered to exclude plugin rules and rules
incompatible with code snippets, and passed to the rule.
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: passed
- task: lint_package_json
status: passed
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: passed
- task: lint_javascript_tests
status: passed
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
33e0f6e to
9dbe8eb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves stdlib-js/metr-issue-tracker#57.
Description
This pull request:
jsdoc-example-eslintthat extracts JavaScript code from JSDoc@exampleblocks and lints it using ESLint's synchronousLinterAPI.eslintrc.overrides.jsusing the existing examples ESLint config, keeping JSDoc example linting rules in sync with standalone example file linting--external eslintto the Browserify build for the ESLint plugin to avoid bundling ESLint inside itselfRelated Issues
Questions
No.
Other
The rule is a pure mechanism: it accepts a
rulesobject and lints example code with those rules, reporting violations mapped back to the correct source file lines. It has no built-in opinions about which rules to apply.The rule is configured in
.eslintrc.overrides.js(rather thanstdlib.js) to avoid a circular dependency:stdlib.js→.eslintrc.examples.js→.eslintrc.js→rules/index.js→stdlib.js. The overrides file loads after the base config resolves, so it can safely require the examples config.Rules from the examples config are filtered to exclude plugin rules (which the internal
Linterinstance doesn't have registered) and rules incompatible with code snippets (no-undef,no-unused-vars,strict,no-var,eol-last,indent,no-restricted-syntax).Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was written primarily by Claude Code following my instructions.
@stdlib-js/reviewers