feat(linter/plugins): add defineRule
API
#13945
Draft
+64
−3
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.
Add
defineRule
method for defining rules. This is the 2nd part of the "alternative API" mentioned in #9905 (comment).or, using the alternative
createOnce
API:When using
createOnce
,defineRule
creates acreate
method and adds it to the rule object. So the rule remains ESLint-compatible, while getting a potential speed boost when the rule is used with Oxlint.Incomplete. Needs tests, and we need to export TS type defs, so the type checking benefit of this API is realized.
This method is intended to be used when defining JS plugins, so we should move it into a separate NPM package (
oxlint-tools
?), so that someone publishing a plugin to NPM doesn't need their plugin to have a dependency onoxlint
itself, which includes large binaries.But for now, for simplicity, just include it in
oxlint
package.