Commit Graph

15 Commits

Author SHA1 Message Date
Boshen 1193c9dbaf chore(oxfmt): dogfood operator position at line start (#25937)
dogfood
2026-08-20 14:36:47 +00:00
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
overlookmotel 6ad44809e6 refactor(linter/plugins): remove experimental warning (#18771)
As we prepare for alpha release of JS plugins, it feels like we can remove the warning logged to stderr.

```
WARNING: JS plugins are experimental and not subject to semver.
Breaking changes are possible while JS plugins support is under development.
```

They do still remain experimental, but I don't think we need to shout that quite as loudly now.
2026-01-31 17:28:11 +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
overlookmotel 44be0ebef4 fix(linter/plugins): set scope analyse settings based on source type (#18306)
Set `globalReturn` and `impliedStrict` options passed to TS-ESLint scope manager, dependent on source type. In particular, set `globalReturn: true` for CommonJS files. This adds an extra function scope above the global scope.
2026-01-20 18:25:33 +00:00
connorshea 529901cfc9 fix(linter): include JS plugin rules when calculating total rule count (#17520)
This ensures that we print the expected number of rules for users that are using JS Plugins.

Fix #17519.

Based on #17517, because otherwise we'd end up with weird snapshot differences when trying to merge these anyway.

AI Disclosure: The fix here was generated with Copilot + GitHub's Raptor mini model.
2025-12-31 23:14:52 +00:00
connorshea 96ef2cced3 fix(linter): print total rule # when using a single nested config (#17517)
For a while, we've been skipping the printing of rule runs unless `--disable-nested-config` was passed. This was a result of the nested_configs value including the base config (see #16356). When we were checking whether that value was empty, it would always have at least 1 item (unless nested configs were entirely disabled).

As part of this, I've updated some configs in the fixtures to disable correctness rules, otherwise we will end up with a bunch of fixture snapshots needing updates every time a new default rule is added.

It's probably easiest to review this one commit at a time.
2025-12-31 22:56:47 +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
overlookmotel a72b093b05 refactor(linter/plugins): enable TS strictNullChecks (#15886)
Adapted from #15868. Enable `strictNullChecks` in TSConfig for `apps/oxlint`.

Rather than using `!` all over the place, I've added a function `assertIsNonNull`, which performs the same function. Idea is that we can later on produce a debug build where `assertIsNonNull` does an actual runtime assertion (rather than just a TS `asserts`) that the value is not `null` or `undefined`. We can use the debug build in tests, and catch any logic errors.

Unfortunately, TypeScript doesn't seem able to track side effects, so there seems to be no way to tell it "after calling `initAst()`, `ast` is always non-null". Don't want to switch to a having a `getAst` function which returns a non-null value, as that'd introduce unnecessary temp vars, and function calls, on hot paths. So this seems to be the best we can do without incurring runtime cost.
2025-11-20 15:52:49 +00:00
overlookmotel ccc54a5754 test(linter/plugins): add test fixture for CommonJS file (#15809)
Follow-on after #15214. Add a test fixture for scope manager running on a CommonJS file.
2025-11-17 21:11:51 +00:00
overlookmotel 3a3de4953e test(linter/plugins): simplify test case (#15808)
Follow-on after #15214. Pure refactor of tests. Just simplify the plugin used in the test fixture, to make it easier to read, and remove dead code.
2025-11-17 21:11:51 +00:00
Arsh fba31fa7dd fix(linter): patch @typescript-eslint/scope manager (#15214)
- Part of #14827
- Fixes the bug noticed in a review in
https://github.com/oxc-project/oxc/pull/14890#discussion_r2452315938
- Originally reported as
https://github.com/typescript-eslint/typescript-eslint/issues/11714
- Originally fixed in
https://github.com/typescript-eslint/typescript-eslint/pull/11715
- Patching in oxlint because neither the bug nor the fix has been
reviewed in the `typescript-eslint` org.
2025-11-17 19:37:21 +00:00
overlookmotel aee9be1f05 style(oxlint/plugins): format test fixtures (#15600)
Format `oxlint` test fixtures. The directory `fixtures` contains not just the fixtures themselves, but also Oxlint plugins, which should be formatted.

Skip 2 specific test fixture files which must not be formatted to maintain correctness of the tests.
2025-11-11 15:56:52 +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