Commit Graph

7 Commits

Author SHA1 Message Date
overlookmotel 88f30e0b4a feat(linter/plugins): move eslint compatible plugin conversion to eslintCompatPlugin function (#18791)
Closes #18611.

Previously `definePlugin` and `defineRule` were doing double duty:

1. Providing type safety (standard `defineConfig` pattern).
2. Converting a plugin/rule to be ESLint compatible

Combining the two duties is probably confusing to users. Users are familiar with the `defineConfig` pattern and these functions generally don't do anything at runtime - just require a specific type as param and return the input untouched.

This PR adds a separate function `eslintCompatPlugin` which does the conversion to an ESLint-compatible plugin.

`definePlugin` and `defineRule` are now no-ops at runtime - they just pass through the plugin/rule unchanged.
2026-02-01 12:37:48 +00:00
overlookmotel 2e1fbc2238 fix(linter/plugins): implement context.parserPath (#18644)
Closes #18119. Implement `context.parserPath`. It evaluates to `undefined`, same as what ESLint does by default.
2026-01-28 02:26:55 +00:00
overlookmotel 3a0a190d2c fix(linter/plugins)!: prevent access to cwd in createOnce (#18081)
Supporting JS plugins in LSP requires that different workspaces have a different value for `Context#cwd`.

As a first step, prevent accessing `cwd` property, or calling `getCwd` method in `createOnce`. Later on, we can make `cwd` a dynamic property.
2026-01-16 15:49:07 +00:00
overlookmotel da509be78a refactor(linter/plugins): convert global properties to vars with TSDown plugin, instead of manually (#16961)
Previously we had a pattern of destructuring properties of global objects into top-level vars. e.g.:

```js
const { keys: ObjectKeys, hasOwn } = Object,
  { isArray } = Array;
```

Doing this is more performant, but it makes the code harder to read.

Instead, write code normally, and use a TSDown plugin to convert:

```js
const keys = Object.keys(obj);
```

to:

```js
import { ObjectKeys } from "../utils/globals.ts";
const keys = ObjectKeys(obj);
```

Defining all the destructured globals in a single file (`utils/globals.ts`) is advantageous for bundle size. If the TSDown plugin created top level `const ObjectKeys = Object.keys;` statements in each file, then you can end up with this in bundle as minifier doesn't de-duplicate:

```js
const ObjectKeys = Object.keys;
const ObjectKeys$1 = Object.keys;
const ObjectKeys$2 = Object.keys;
```

The globals we use have to be manually added to `utils/globals.ts`, but TSDown plugin warns when this needs to be done, and doesn't generate a broken build in the meantime.

This plugin is run in debug builds too, so that the tests will catch any bugs.
2025-12-16 17:33:37 +00:00
camc314 2acd66ed42 style(all): enable eslint/curly lint rule (#16753)
built on https://github.com/oxc-project/oxc/pull/16749, we can use the linter to be consistent here
2025-12-11 14:49:48 +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
overlookmotel c4b65f86c1 refactor(linter/plugins): move definePlugin and defineRule into own file (#16169)
Pure refactor. Move `definePlugin` and `defineRule` into their own module. Rule tester will live in this directory too.
2025-11-26 21:33:37 +00:00