Commit Graph

58 Commits

Author SHA1 Message Date
renovate aece7e5112 chore(deps): update dependency oxlint to v1.64.0 (#22362)
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Adoption](https://docs.renovatebot.com/merge-confidence/) | [Passing](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|---|---|
| [oxlint](https://oxc.rs/docs/guide/usage/linter) ([source](https://redirect.github.com/oxc-project/oxc/tree/HEAD/npm/oxlint)) | [`1.63.0` → `1.64.0`](https://renovatebot.com/diffs/npm/oxlint/1.63.0/1.64.0) | ![age](https://developer.mend.io/api/mc/badges/age/npm/oxlint/1.64.0?slim=true) | ![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/oxlint/1.64.0?slim=true) | ![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/oxlint/1.63.0/1.64.0?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/oxlint/1.63.0/1.64.0?slim=true) |

---

### Release Notes

<details>
<summary>oxc-project/oxc (oxlint)</summary>

### [`v1.64.0`](https://redirect.github.com/oxc-project/oxc/blob/HEAD/npm/oxlint/CHANGELOG.md#1640---2026-05-11)

[Compare Source](https://redirect.github.com/oxc-project/oxc/compare/oxlint_v1.63.0...oxlint_v1.64.0)

##### 🚀 Features

- [`fbb8f22`](https://redirect.github.com/oxc-project/oxc/commit/fbb8f22) linter: Support `ignores` in overrides ([#&#8203;22148](https://redirect.github.com/oxc-project/oxc/issues/22148)) (camc314)

##### 🐛 Bug Fixes

- [`25b7017`](https://redirect.github.com/oxc-project/oxc/commit/25b7017) linter: Undocument override `ignores` option ([#&#8203;22213](https://redirect.github.com/oxc-project/oxc/issues/22213)) (camc314)

</details>

---

### Configuration

📅 **Schedule**: (in timezone Asia/Shanghai)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/oxc-project/oxc).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xNzMuNiIsInVwZGF0ZWRJblZlciI6IjQzLjE3My42IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
2026-05-12 19:16:14 +00:00
camc314 1392ec860b test(linter): retry flaky napi tests on windows (#19460)
The goal here is hopefully to make our CI a bit greener.

9/10 times, the failure of windows napi CI is due to memory failing to allocate. This PR retries the test, (hopefully) making it less flaky).

We should remove this once https://github.com/oxc-project/oxc/issues/19395 is fixed
2026-02-17 12:32:45 +00:00
camc314 400d9e135a test(linter): add option to pass custom arguments (#19284) 2026-02-12 15:55:12 +00:00
overlookmotel 86047f9eaf test(linter/plugins): add ability to fix suggestions in JS plugins tests (#18961)
Add ability to run `oxlint` with `--fix-suggestions` flag in tests.
2026-02-05 02:24:16 +00:00
overlookmotel cae8e956fc test(linter/plugins): reduce repetition in runFixture (#18960)
Pure refactor of tests. Reduce repetition in code.
2026-02-05 02:24:15 +00:00
overlookmotel 9d6520e63c test(linter/plugins): add ability to lint files in deterministic order (#17205)
In JS plugins tests, it's sometimes required to ensure that files are linted in deterministic order.

For example, #17207 fixes a bug where some internal global state was not reset correctly after an error is thrown during visiting the AST. This affects what happens when linting the *next* file.

In order to write a test for this, and produces deterministic output in the snapshot file, the order files are linted in needs to be deterministic.

This PR provides this determinism by:

1. Adding a `force_deterministic_order` cargo feature which is enabled in test build.
2. When this feature is enabled *and* Oxlint is run with `--threads 1`, file paths are sorted before linting.
3. Adding an option for test fixtures `singleThread`. When `true`, the fixture is run with `--threads 1`.

Aim is to only enable deterministic ordering in test fixtures which *need* determinism, so that most test fixtures are still testing Oxlint running as it does usually for a user.
2025-12-21 14:33:13 +00:00
camc314 78242041de test(linter): disable running vitest in parellel on windows (#16711)
CI is currently failing due to memory allication failures:

https://github.com/oxc-project/oxc/actions/runs/20105836018/job/57689305978

This is only a problem on windows https://github.com/oxc-project/oxc/issues/14375
2025-12-10 18:46:17 +00:00
camc314 a5dc4c6ab6 perf(oxlint): run e2e tests concurrently (#16651)
Tests in the same file typically run in sequence. we can improve the performance by running these in parallel:

https://vitest.dev/guide/parallelism.html#test-parallelism

 - Before (sequential): ~5.2s total, e2e.test.ts ~5000ms
 - After (concurrent):  ~1.50s total, e2e.test.ts ~1200ms

~3.5x faster
2025-12-10 15:06:46 +00:00
overlookmotel 3f3d646280 refactor(linter/plugins): imports use .ts extension (#16390)
Pure refactor. Use `.ts` extension when importing `.ts` files.
2025-12-02 14:08:49 +00:00
Boshen 523a30a016 style(all): apply oxfmt default options (#16091)
Embrace the defaults!

---------

Co-authored-by: Yuji Sugiura <y.sugiura.0316@gmail.com>
2025-11-25 15:56:24 +09:00
overlookmotel 80fe39d696 build(linter/plugins): build either release or debug version, not both (#15949)
#15921 added a debug build for Oxlint, and various PRs since have tweaked it. However, I now realize there's little point in generating *both* a release build and debug build.

Just create one build, and use env var `DEBUG` to control whether it has debug assertions included in it or not.

`pnpm run build` produces release build with no debug assertions, `pnpm run build-test` includes the asserts. I've verified that both do what they're meant to.
2025-11-23 12:11:29 +00:00
overlookmotel 325af3273b test(linter/plugins): debug build for tests (#15921)
Generate a debug build, in addition to the normal release build.

In the debug build, `DEBUG` global is defined as `true` and `assertIsNonNull` does a runtime assertion. In release build, `DEBUG === false` and minifier removes debug-only code.

Run the tests in debug mode.

Debug build is generated in a separate directory from `dist`, so is *not* included in NPM package.
2025-11-21 13:40:31 +00:00
overlookmotel ca7a6d3d79 test(linter/plugins): automate testing all fixtures (#15911)
Remove the need to list every fixture in `e2e.test.ts` file by automatically running tests on every fixture in `test/fixtures` directory.

Running Oxlint with `--fix` and running fixtures with ESLint is now controlled by adding an `options.json` file to the fixture directory contining e.g. `{ "fix": true }` or `{ "eslint": true }`.

Now we can add a new fixture just by creating a new directory in `fixtures`.
2025-11-21 11:38:01 +00:00
overlookmotel 102037372f ci(linter/plugins): lint apps/oxlint with oxlint (#15887)
2nd try at #14573. Run oxlint on oxlint. Linter inception.
2025-11-20 15:52:49 +00:00
overlookmotel 6ce2f7a371 test(linter/plugins): rename dirs in nested tests (#15888)
Rename the directories containing files to lint in the nested config tests from `nested` to `files`, to match the rest, and only lint the `files` directories.

I don't think this has any effect on the operation of the tests, but makes it easier to lint these directories as part of the repo (#15887).

This also removes the need for `overrideFiles` property in `testFixture` function's options, so remove it.
2025-11-20 15:52:49 +00:00
overlookmotel 7ed871b4a0 test(linter/plugins): remove pointless options to testFixture (#15902)
Default for `args` option passed to `testFixture` is an empty array, so no point passing an empty array explicitly.
2025-11-20 10:36:44 +00:00
overlookmotel 37a44d04e3 test(linter/plugins): rename test fixture (#15502)
Pure refactor of tests. Rename test fixture dir to snake_case, for consistency with the others.
2025-11-08 19:43:23 +00:00
overlookmotel 222a8f015a feat(linter/plugins): implement SourceCode#isSpaceBetween (#15498)
Implement `sourceCode.isSpaceBetween`. Implementation is not quite correct, because we don't have tokens yet. But it's better than no implementation at all. We can correct it once we have tokens.

The reason it's not correct is explained in comment on `isSpaceBetween` implementation, and the incorrect behavior is demonstrated in the test fixture.
2025-11-08 19:14:50 +00:00
overlookmotel 2f9735dcd8 feat(linter/plugins): implement context.languageOptions (#15486)
Implement `Context#languageOptions`.
2025-11-08 14:18:54 +00:00
overlookmotel a17ca32399 fix(linter/plugins): replace Context class (#15448)
Fix #15325.

Some ESLint rules create a wrapped copy of `context`, in order to patch `report` and pass that wrapped context object to another rule.

Some rules also rely on unspecified details of ESLint's implementation - that `context` is formed of 2 layers - top layer being `RuleContext` (`id`, `report` etc), and bottom layer being `FileContext` (`filename`, `sourceText` etc).

This usage was broken in our implementation because:

1. We collapsed the 2 layers into 1.
2. We used a `Context` class which stored its internal data in a private property. When `context.report` was called with a different `this`, it failed because the private property couldn't be accessed from an object which isn't an instance of the class.

Fix this problem by:

1. Splitting `Context` into 2 layers like ESLint does.
2. Not using classes or private properties.
3. No methods/getters on context objects use `this`.

We now have:

* Separate `Context` object per rule, containing properties related to the rule - a plain object which uses data from closure scope.
* All rule `Context`s inherit from the same singleton `FILE_CONTEXT` object, which provides getters for properties related to the file (same for all rules).

Tests adapted from #15326.
2025-11-07 19:43:57 +00:00
overlookmotel 075079cc9c test(linter/plugins): improve reliability of replacing paths in output (#15424)
When replacing absolute paths in fixture snapshots, replace paths anywhere in the output, rather than only in certain specified patterns.

Additionally, introduce `<fixtures>` and `<fixture>` replacements to shorten paths in snapshots.

```diff
- File path: <root>/apps/oxlint/test/fixtures/fixture_name/files/1.js
+ File path: <fixture>/files/1.js
- File path: <root>/apps/oxlint/test/fixtures
+ File path: <fixtures>
```

This allows removing the `relativePath` helper function from some test plugins, outputting paths (e.g. `cwd`) anywhere, and generally will avoid problems with snapshots being system-dependent, and dependent on directory layout of fixtures.

Also, amend ESLint `stdout` output in snapshots to align all rule names, to reduce churn in snapshots, and avoid mismatches between local and CI (presumably due to differences in terminal width).

```diff
- filename: <fixture>/files/1.js                              define-plugin-plugin/create-once
- filename: <fixture>/files/long_filename.js                              define-plugin-plugin/create-once
- filename: <fixture>/files/very_long_filename.js                              define-plugin-plugin/create-once
+ filename: <fixture>/files/1.js                                 define-plugin-plugin/create-once
+ filename: <fixture>/files/long_filename.js                     define-plugin-plugin/create-once
+ filename: <fixture>/files/very_long_filename.js                define-plugin-plugin/create-once
```
2025-11-07 12:28:48 +00:00
overlookmotel fcb32ffd74 refactor(linter/plugins): use Record types (#15379)
Pure refactor. We were using a mix of `{ [key: string]: T }` and `Record<string, T>`. Standardize on `Record`.
2025-11-06 15:05:26 +00:00
magic-akari cc403f5216 fix(linter/plugins): Return empty object for unimplemented parserServices (#15364)
## Summary

- Changed `sourceCode.parserServices` from throwing an error to
returning an empty object `{}`
- Aligns with ESLint specification for parsers that don't implement
parser services
- Prevents crashes in ESLint plugins such as
`eslint-plugin-better-tailwindcss`.

## Motivation

According to the [ESLint custom parser
documentation](https://eslint.org/docs/latest/extend/custom-parsers#parseforeslint-return-object):

> services can contain any parser-dependent services (such as type
checkers for nodes). The value of the services property is available to
rules as context.sourceCode.parserServices. **Default is an empty
object.**

The current implementation throws an error when `parserServices` is
accessed, which breaks plugins that use defensive checks like:

```typescript
if(typeof ctx.sourceCode.parserServices?.defineTemplateBodyVisitor === "function"){
  // ...
}
```

Plugin authors defensively handle:
- ✅ `parserServices` being undefined
- ✅ `defineTemplateBodyVisitor` not existing
- ❌ `parserServices` getter throwing an error (unexpected)

## Solution

Return an empty object `{}` for unimplemented parser services, which:
1. Matches ESLint's documented default behavior
2. Allows plugins' defensive checks to work correctly
3. Provides correct semantics for "not implemented"

## Test Plan

- Existing tests should continue to pass
- Plugins using defensive checks like the example above will no longer
crash

## Related

Fixes the compatibility issue with plugins like
[eslint-plugin-better-tailwindcss](https://github.com/schoero/eslint-plugin-better-tailwindcss/blob/a90cc3f547098a4293d7b0b7998bf6774f717cd2/src/utils/rule.ts#L140)

---------

Signed-off-by: magic-akari <akari.ccino@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>
2025-11-06 14:44:04 +00:00
Arsh 230e34c6eb feat(linter/plugins): allow js plugins to access settings (#14724)
So far, settings have only been for use for the first party rules
written in Rust. Now that we support JS plugins, we need to provide
settings in the JS API.
- Fixes #14649
- [x] `OxlintSettings` now contains the full source settings in the new
`.json` field, in addition to the 5 well known fields used by internal
rust plugins.
- [x] Settings are serialized to the JS side as arguments of the
`lint_file` callback.
- [x] Overrides may also contain settings, which is handled.
- [x] Merging of settings when the config is extended.
- Direct commits from maintainers welcome.
#### Future Work
- Optimizing settings serialization frequency.

---------

Co-authored-by: Cameron Clark <cameron.clark@hey.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-11-05 18:15:59 +00:00
Arsh f7bef7325f feat(linter/plugins): scope manager API (#14890)
- "For now" implementation of #14827
- Uses `@typescript-eslint/scope-manager` which works thanks to recent
efforts to align JS side AST with ESTree.
- `@typescript-eslint/scope-manager` is well-built: It is factored out
from `ts-eslint` neatly, and is pure scope analysis with minimal
dependencies. Tsconfig resolution and syntax parsing is done by its
dependents.
### Tasks
- [x] `ScopeManager` class instance at `sourceCode.scopeManager`
- [x] Direct usage APIs: `sourceCode.isGlobalReference`,
`sourceCode.getDeclaredVariables`, `sourceCode.getScope`,
~~`sourceCode.markVariableAsUsed`~~
  - [x] Tests
- [x] Limit API surface. We want maneuverability for our eventual
implementation, so we should limit the exposed methods to the only two
methods documented as non-deprecated: [ScopeManager |
ESLint](https://eslint.org/docs/latest/extend/scope-manager-interface#acquirenode-inner--false:~:text=ScopeManager%20interface-,Fields,getDeclaredVariables(node),-Deprecated%20members).
- Limiting other interfaces will probably need monkey patching; only
public types are limited instead.
### ScopeManager API real world use examples
-
[`eslint-plugin-import`](https://github.com/import-js/eslint-plugin-import/blob/01c9eb04331d2efa8d63f2d7f4bfec3bc44c94f3/src/rules/no-import-module-exports.js#L20)
-
[`eslint-plugin-react`](https://github.com/facebook/react/blob/71b3a03cc936c8eb30a6e6108abf5550f5037f71/packages/eslint-plugin-react-hooks/src/rules/ExhaustiveDeps.ts#L149)
-
[`eslint-plugin-vue`](https://github.com/vuejs/eslint-plugin-vue/blob/917787c46a268b1910b9c77e091656a428d70a89/lib/utils/scope.js#L14)
-
[`eslint-plugin-svelte`](https://github.com/search?q=repo%3Asveltejs%2Feslint-plugin-svelte%20scopeManager&type=code)

---------

Signed-off-by: Arsh <emmagoldmanvevo+github@pm.me>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Cameron <cameron.clark@hey.com>
2025-10-29 10:53:35 +00:00
camc314 593309722a test(oxlint): add test for nested configs importing the same plugin 2x (#14646)
@overlookmotel looks like we already handle this case here:

https://github.com/oxc-project/oxc/blob/55becc5ffc4392bb5ae1d9c19bed0d9073e0d13f/crates/oxc_linter/src/config/config_builder.rs#L535-L537
2025-10-20 10:03:52 +00:00
camc314 28e76ec846 fix(oxlint): resolving JS plugin failing when extends is used (#14556) 2025-10-20 10:03:51 +00:00
Arsh 78ee7b8e4d fix(linter/plugins): handle utf16 characters within comment spans (#14768)
Part of #14564. Corrects start and end offsets to accommodate two byte
characters. Conversion of UTF-8 indices to UTF-16 takes place on the
rust side for performance.
2025-10-19 12:54:39 +01:00
Arsh 9700a56b78 feat(linter/plugins): comment-related APIs (#14715)
Part of #14564. Implement the remaining `SourceCode` APIs related to
comments (`getCommentsBefore`, `getCommentsAfter`, `getCommentsInside`,
`commentsExistBetween`).

---------

Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>
2025-10-18 14:14:31 +01:00
Arsh b1a9a032c1 feat(linter/plugins): implement SourceCode#getAllComments (#14589)
- Towards #14564

### Future PRs
- look into `RawTransferData { program.comments, comments }`
duplication.
- oxlint's `interface Program` doesn't include the comments type.
- lazy deserialization
- remove `comment.parent`
- UTF8 to UTF16 conversion on the JS side
- correct start/end offsets
- [ ] getCommentsBefore
- [ ] getCommentsAfter
- [ ] getCommentsInside
- [ ] commentsExistBetween

---------

Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>
2025-10-14 17:50:07 +01:00
overlookmotel 576be209b4 feat(linter/plugins): support selectors DSL (#14435)
Implement support for selectors DSL in Oxlint JS plugins.

The implementation is based on ESLint's implementation. Like ESLint, it uses [esquery](https://www.npmjs.com/package/esquery) as the underlying selector parser and matcher.

One detail is not implemented. ESLint ensures that visit functions are called in order of their "specificity" with the most specific called first. This implementation just calls them in the order they're defined. This is a shortcoming and will need to be fixed in future, but I imagine that in practice visitation order makes no difference for the vast majority of rules.

I've made what I hope are some optimizations versus ESLint's version. Notably:

1. Making simple selectors which unconditionally visit a subset of nodes (e.g. `:matches(FunctionDeclaration, FunctionExpression)` bypass the selector match process - as it'd always return `true` anyway.
2. Faster implementations of union and intersection.
2025-10-07 23:35:32 +00:00
overlookmotel b2de44fa1e feat(linter/plugins): support interpolation in normal diagnostic message (#14419)
Extend support for placeholder interpolation to normal `message` (without `messageId`).

```js
context.report({
  message: 'Do not use {{ type }}',
  data: { type: node.type },
  node,
});
```
2025-10-07 19:12:47 +00:00
camc314 382c5be881 feat(linter/plugins): support placeholders in messageIds (#14416) 2025-10-07 17:11:30 +00:00
camc314 529e88ee47 feat(linter/plugins): support messageIds (#14415) 2025-10-07 17:11:29 +00:00
overlookmotel c8de6fe9cf feat(linter/plugins): add parent field to AST nodes (#14345)
Use the new raw transfer deserializer added in #14344 to add `parent` field to all AST node in Oxlint JS plugins.
2025-10-05 00:32:09 +00:00
overlookmotel 1347de43ea feat(linter/plugins): accept diagnostics with loc (#14304)
Allow calling `context.report` with `loc` instead of `node`.
2025-10-02 17:00:34 +00:00
overlookmotel c27a39338e perf(linter/plugins): deserialize AST on demand (#14288)
Avoid deserializing the AST if it's not required.

It's possible that all rules return an empty visitor, or that all `createOnce` rules return `false` from their `before` hook. In those cases, the AST does not need to be walked, so AST doesn't need to be deserialized. And the source text doesn't need to be decoded from buffer either.

These cases probably aren't so common, but not completely uncommon either.

However, source text and AST are both accessible before traversal via `context.sourceCode`. Enable the usage of those APIs in `create` method / `before` hook by decoding source text / deserializing AST on demand when those APIs are used.
2025-10-02 08:32:04 +00:00
overlookmotel bdf901033e feat(linter/plugins): add SourceCode API (#14281)
Add support for ESLint's `SourceCode` API. At present the only method on `SourceCode` is `getText`. More methods will be added in further PRs to follow.
2025-10-01 16:36:28 +00:00
overlookmotel e045391baf fix(linter/plugins): error on JS plugin with reserved name (#14226)
Raise an error if a JS plugin has same name as a built-in plugin e.g. `import`. It'd be impossible to know whether `import/rule-name` was referring to the built-in rule, or the JS plugin's rule of same name.
2025-09-29 08:27:26 +00:00
overlookmotel 7f2c1011cd test(linter/plugins): specify path to node in tests (#14152)
Make tests for Oxlint more robust by specifying the current NodeJS executable to run `oxlint` with. I was hitting problems locally with a node version manager resulting in running the tests in an older NodeJS version.
2025-09-26 11:33:07 +00:00
overlookmotel 00954dec3c feat(linter/plugins): remove --js-plugins CLI option (#14134)
Remove `--js-plugins` CLI option. JS plugins are now enabled by default if config contains a `jsPlugins` array.

In place of the CLI option, print a warning when user uses JS plugins:

```
WARNING: JS plugins are experimental and not subject to semver.
Breaking changes are possible while JS plugins support is under development.
```
2025-09-26 10:13:35 +00:00
overlookmotel a6f965f1a2 test(linter/plugins): simplify configs in test fixtures (#14124)
Pure refactor. Remove `"ignorePatterns": ["**/*", "!files/**"]` from `.oxlintrc.json` in every test fixture, by running `oxlint` with `oxlint --js-plugins files`.
2025-09-25 20:35:48 +00:00
overlookmotel b1685f7a6a test(linter/plugins): refactor tests (#14123)
Refactor tests for Oxlint plugins. Break up snapshots into 1 per fixture directory, to make them easier to navigate.
2025-09-25 20:35:47 +00:00
overlookmotel 5750077ad6 test(linter/plugins): fix file paths in snapshots (#14115)
Test snapshots for JS plugins had incorrect paths where plugin throws an error. Fix that.
2025-09-25 12:09:54 +00:00
overlookmotel 5c862f95ae test(linter/plugins): standardize test fixture structure (#14114)
Pure refactor of tests. Standardize the directory structure of all test fixtures.

* Move files to be linted into `files` subdirectory.
* Move plugin to a file called `plugin.js` (except 1 fixture which has multiple plugins).
* Change `ignorePatterns` in `.oxlintrc.json` config files to whitelist files in `files` dir, instead of blacklisting the plugin file.
2025-09-25 12:09:54 +00:00
overlookmotel 9f3e2bc4f6 fix(linter/plugins): output errors thrown in JS plugins (#14096)
Previously any errors on JS side in JS plugins were silently ignored. Instead create a diagnostic including stack trace.
2025-09-25 08:52:53 +00:00
overlookmotel 9c3afea704 feat(linter/plugins): support fixes (#14094)
Add support for fixes in JS plugins.

```js
export const noDebuggerRule = {
  create(context) {
    return {
      DebuggerStatement(node) {
        return context.report({
          message: 'Remove this filth!',
          node,
          fix(fixer) {
            return fixer.remove(node);
          },
        });
      },
    };
  },
};
```

All of [ESLint's fixer APIs](https://eslint.org/docs/latest/extend/custom-rules#applying-fixes) are supported.

Note: Suggestions are not implemented yet, only fixes.
2025-09-25 08:15:33 +00:00
overlookmotel 314c27de60 fix(linter/plugins): definePlugin apply defineRule to rules (#14065)
`definePlugin` previously passed the input through unchanged. This necessitated wrapping every rule in `defineRule` too.

Instead, make `definePlugin` call `defineRule` for every rule.

Before:

```js
import { definePlugin, defineRule } from 'oxlint';

export default definePlugin({
  meta: { name: 'my-plugin' },
  rules: {
    'my-rule': defineRule({
      createOnce: (context) => ({ /* visitor */ }),
    }),
    'my-other-rule': defineRule({
      createOnce: (context) => ({ /* visitor */ }),
    }),
  },
});
```

After:

```js
import { definePlugin } from 'oxlint';

export default definePlugin({
  meta: { name: 'my-plugin' },
  rules: {
    'my-rule': {
      createOnce: (context) => ({ /* visitor */ }),
    },
    'my-other-rule': {
      createOnce: (context) => ({ /* visitor */ }),
    },
  },
});
```
2025-09-24 00:25:08 +00:00
overlookmotel 2fd4b1ebd3 test(linter/plugins): rename test (#14064)
Pure refactor. Just rename a test. Makes for a less messy diff on following PR #14065.
2025-09-24 00:03:42 +00:00
overlookmotel f47f9788bc feat(linter/plugins): add definePlugin API (#14008)
Export a method `definePlugin` from `oxlint` package, to go with `defineRule`. Used as follows:

```js
import { definePlugin, defineRule } from 'oxlint';

const myRule = defineRule({
  create(context) { /* rule impl */ },
});

export default definePlugin({
  meta: { name: "my-plugin" },
  rules: {
   'my-rule': myRule,
  },
});
```

At present this method doesn't have much utility, as we don't export TS types for it yet, but it's part of the intended API, so may as well add it now.
2025-09-22 20:22:54 +00:00