Commit Graph

25 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
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
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
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 4e844c1927 test(linter/plugins): add tests for new Context methods (#15656)
Add test coverage for methods and getters on `Context` added in #15606 and #15632. I neglected to add tests in those PRs. Disgraceful.
2025-11-12 23:56:03 +00:00
overlookmotel def251dee0 test(linter/plugins): remove unused imports from fixtures (#15655)
Pure refactor to tests. These imports are no longer used. Remove them.
2025-11-12 23:49:48 +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
magic-akari 54ec8e360a feat(linter): add cwd property to JS plugin Context (#14814)
- Closes: #14777

---------

Co-authored-by: Cameron Clark <cameron.clark@hey.com>
2025-10-21 09:08:03 +01:00
overlookmotel a2914fe8d8 feat(linter/plugins): add loc field getter to all AST nodes (#14355)
Add `loc` to all AST nodes.

`loc` is computed lazily, as it's quite an expensive operation - because it requires searching the source text for line breaks and building a translation table.

We can consider making `loc` a "real" property once we have a faster translation table built on Rust side.
2025-10-05 14:02:12 +00:00
overlookmotel 5505a86121 feat(linter/plugins): include range field in AST (#14321)
Add `range` field to AST nodes, using the support for `range` in raw transfer added in #14319.

Use `range` field rather than `start` + `end` in nodes passed to `context.report` and fixer methods - for closer alignment with ESLint.
2025-10-04 15:47:47 +00:00
overlookmotel a9b603eb24 test(linter/plugins): convert all plugins in tests to TS (#14200)
Convert all plugins in test fixtures to TS, so can check the types work correctly.
2025-09-28 18:17:49 +01:00
overlookmotel aca083a8dc test(linter/plugins): include stderr output in snapshots (#14155)
Include `stderr` output in test snapshots. This makes sure that the "JS plugins are experimental" warning is not output if user doesn't use JS plugins.
2025-09-26 13:34:52 +00:00
overlookmotel 0029b7f218 test(linter/plugins): normalize line breaks in snapshots (#14154)
Trim leading/trailing line breaks from `stdout` in test snapshots and convert `\r\n` to `\n`. This ensures tests will pass on Windows, and removes extraneous line breaks from snapshots.
2025-09-26 12:31:19 +00:00
overlookmotel b4d716fd72 feat(linter/plugins): move custom JS plugin config to jsPlugins (#14133)
Fixes #12432.

JS plugins were previously configured by adding them to `plugins` array in config file. Instead, move them to a separate `jsPlugins` array.

Before:

```json
{
  "plugins": ["oxc", "react", "./custom-plugin.js"],
}
```

After:

```json
{
  "plugins": ["oxc", "react"],
  "jsPlugins": ["./custom-plugin.js"],
}
```
2025-09-26 10:06:36 +00:00
overlookmotel fc14abc5b5 test(linter/plugins): format test fixtures (#14125)
Pure refactor. Format files in `test/fixtures` directory. Only changes to fixture files are to add `// dprint-ignore-file` comments to 2 of them.
2025-09-25 20:35:48 +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 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 407c95e271 test(linter/plugins): check this is undefined in visit functions (#13811)
Add test coverage for the value of `this` within visit functions. It should be `undefined`, to match ESLint.
2025-09-17 10:37:28 +00:00
overlookmotel 53d04dd1dc feat(linter): convert oxlint to NAPI app (#13723)
Convert `oxlint` to a NAPI package.

This PR:

1. Moves files from `napi/oxlint` into `apps/oxlint`.
2. Converts `oxlint` into a NAPI package.
3. Alters the [release workflow](https://github.com/oxc-project/oxc/pull/13723/files#diff-80cb497c859bbaf7756da6ced2bca3d31933affc96102983eee1ad7d4bcc60fd) and [script](https://github.com/oxc-project/oxc/pull/13723/files#diff-4c4b7045c68805aeeae7c0af94cf7cf7487cb0403496da974a6a23accdc457d0) for building `oxlint` packages.

Most of necessary code modifications and refactoring was done in previous PRs (#13701, #13712, #13722, #13745), so this PR only includes changes necessary for packaging as NAPI.

I've done my best to update release workflow, but am mostly "flying blind" without ability to test it, so very likely there are mistakes.

A few notes and oddities:

* I've kept the `oxlint` NPM package as CommonJS. We could probably switch to ESM, but I thought it better to minimize the changes in this PR.
* NAPI-RS creates `.node` files named with a `-msvc` postfix for Windows. The scripts here remove that postfix so that filename of `.node` files and NPM package names match for all platforms, for simplicity.
* `tasks/website` has a dependency on `oxlint` as a normal library. This resulted in linker errors, so have had to put all the NAPI stuff behind `napi` cargo feature. Tests for `tasks/website` are run separately in CI, to avoid feature unification turning on the `napi` feature for `website`.

I've made a few comments below for the parts which aren't fairly self-explanatory.
2025-09-17 09:20:21 +00:00