-
Notifications
You must be signed in to change notification settings - Fork 73
feat: add allow options to no-empty-definitions #455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the no-empty-definitions
rule by adding two new allow lists and updating tests and docs to cover those options.
- Introduce
allowDefinitions
andallowFootnoteDefinitions
options, update schema and defaultOptions. - Modify rule logic to skip reporting for identifiers in the allow lists.
- Add new test cases and update documentation with examples for the new options.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
tests/rules/no-empty-definitions.test.js | Added valid/invalid cases to verify allowDefinitions and allowFootnoteDefinitions . |
src/rules/no-empty-definitions.js | Extended schema, defaultOptions, and rule logic to honor the new allow lists. |
docs/rules/no-empty-definitions.md | Documented the new options with configuration examples. |
Comments suppressed due to low confidence (1)
src/rules/no-empty-definitions.js:11
- The JSDoc tag
@import
is nonstandard. Consider using a proper@typedef
import syntax, e.g.:@typedef {import("../types.js").MarkdownRuleDefinition} NoEmptyDefinitionsRuleDefinition
.
* @import { MarkdownRuleDefinition } from "../types.js";
@@ -64,15 +78,28 @@ export default { | |||
}, | |||
], | |||
|
|||
defaultOptions: [{ checkFootnoteDefinitions: true }], | |||
defaultOptions: [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because ESLint does not deep-merge defaultOptions with a user-supplied options object, users who specify only one property will lose the defaults for the others. Consider destructuring context.options[0]
with in-function defaults (e.g., const { allowDefinitions = ["//"], allowFootnoteDefinitions = [], checkFootnoteDefinitions = true } = context.options[0] || {};
) to ensure all defaults apply even when partial options are provided.
Copilot uses AI. Check for mistakes.
src/rules/no-empty-definitions.js
Outdated
const allowDefinitions = new Set(context.options[0]?.allowDefinitions); | ||
const allowFootnoteDefinitions = new Set( | ||
context.options[0]?.allowFootnoteDefinitions, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using optional chaining here assumes allowDefinitions
is always provided via defaultOptions. If a user passes an empty object, this will be undefined
. You may want to explicitly default to an empty array to avoid unexpected behavior: new Set(context.options[0]?.allowDefinitions || [])
.
const allowDefinitions = new Set(context.options[0]?.allowDefinitions); | |
const allowFootnoteDefinitions = new Set( | |
context.options[0]?.allowFootnoteDefinitions, | |
const allowDefinitions = new Set(context.options[0]?.allowDefinitions || []); | |
const allowFootnoteDefinitions = new Set( | |
context.options[0]?.allowFootnoteDefinitions || [], |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM, just left one suggestion. Would like another review before merging.
Prerequisites checklist
What is the purpose of this pull request?
This pull request adds support for the
allowDefinitions
option to the no-empty-definitions rule, allowing users to specify definition identifiers that should be intentionally allowed to be empty. It also adds anallowFootnoteDefinitions
option to let users specify footnote identifiers that should be allowed to be empty.What changes did you make? (Give an overview)
Related Issues
Fixes #436
Is there anything you'd like reviewers to focus on?