Commit Graph

5 Commits

Author SHA1 Message Date
overlookmotel 9de9385fd1 refactor(linter/plugins): rename oxlint/plugin to oxlint/plugins (#18792)
Part of #18610.

Our intent is to move `definePlugin`, `defineRule`, and `eslintCompatPlugin` to a separate package `@oxlint/plugins` (plural to avoid confusion with naming convention for plugins `oxlint-plugin-xxx`).

So rename the current entry point which exports these functions from `oxlint/plugin` to `oxlint/plugins` (plural).
2026-02-01 13:23:14 +00:00
camc314 81eb6fa9db refactor(linter): split entry points for custom plugins/config/types (#18601)
This is technically breaking (only for types), but custom plugins are experimental.

The ruletester/defineRule/definePlugin are re-exported but with a `@deprecated` tag which I think is a good enough trade off

I want to avoid users bringing in a ton of custom plugin code when doing `import { defineConfig } from 'oxlint'`
2026-01-27 00:58:08 +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 690abec235 test(linter/plugins): use subpath imports (#15920)
Shorten imports in test fixtures using [subpath imports](https://nodejs.org/docs/latest-v24.x/api/packages.html#subpath-imports).

Before:

```ts
import type { Plugin } from '../../../dist/index.js';
```

After:

```ts
import type { Plugin } from '#oxlint';
```
2025-11-21 11:44:25 +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