Commit Graph

26 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 f8fbd6e958 fix(linter/plugins): remove hashbang property from AST (#20365)
#20364 removed the reliance internally on `hashbang` property being present on `Program`. Now we can remove this field.

It's not part of ESTree standard. We include it in `oxc-parser` as a non-standard extension as it can be useful, but in the case of Oxlint, rules written with the alternative `createOnce` API are meant to also be compatible with ESLint, so we can't provided APIs which ESLint doesn't support.
2026-03-14 12:19:28 +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
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
overlookmotel b2b87c608f feat(linter/plugins): add getRange and getLoc methods to SourceCode (#17179)
ESLint has undocumented `getRange` and `getLoc` methods on `SourceCode`. Add them.

These are the last 2 missing methods on `SourceCode` (according to Claude).

Also add more tests for correct functioning of `range` and `loc` properties.
2025-12-20 15:49:56 +00:00
overlookmotel 563b039da5 feat(linter/plugins): add SourceCode#getLines method (#17177)
ESLint has an undocumented `SourceCode#getLines` method. Implement it.

Discovered the existence of this method from conformance tests.
2025-12-20 13:52:49 +00:00
overlookmotel 26ae895c45 test(linter/plugins): remove @ts-expect-error from tests (#16795)
Remove `// @ts-expect-error` and `// @ts-ignore` comments from test fixtures, and use assertions instead. This makes sure that the input to methods under test is what we intend it to be.

Note: Using `assert` rather than `expect`, because `assert` gives TypeScript information about types, which `expect` doesn't seem to be capable of.
2025-12-13 14:33:39 +00:00
overlookmotel b38c2d06be feat(linter/plugins): add SourceCode#lineStartIndices getter (#16510)
Add a getter `lineStartIndices` to `SourceCode`. ESLint has this property, but it's undocumented. Possible that some ESLint plugins rely on it (if it's there, people will use it!).
2025-12-04 19:14:21 +00:00
overlookmotel d2ca540080 feat(linter/plugins): add SourceCode#isESTree property (#16499)
Add `isESTree` property to `SourceCode`. ESLint's has this property, though it's undocumented.
2025-12-04 16:39:55 +00:00
overlookmotel 2a9d7e9d89 test(linter/plugins): shorten code in SourceCode test fixture (#16498)
Pure refactor of tests. Shorten code by putting `sourceCode` in a local var, rather than repeating `context.sourceCode` over and over.
2025-12-04 16:39:55 +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 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
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 93d81641b2 refactor(linter/plugins): export AST types direct from oxlint package (#14353)
Export AST types directly from `oxlint` package, instead of depending on `@oxc-project/types`. This enables altering the types to reflect that `range` field is always present on AST node in Oxlint's AST (#14354).
2025-10-05 13:47:32 +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 aefc8b3f6f feat(linter/plugins): implement SourceCode#getIndexFromLoc and getLocFromIndex (#14303)
Implement methods to convert offset to line+column, and vice-versa, using the lines table added in #14290.
2025-10-02 16:45:22 +00:00
overlookmotel 93807dbc5d feat(linter/plugins): implement SourceCode#lines property (#14290)
Add support for obtaining source text split into lines via `context.sourceCode.lines`.
2025-10-02 08:32:05 +00:00
overlookmotel 2f8c985393 feat(linter/plugins): implement SourceCode#visitorKeys property (#14289)
Add support for obtaining visitor keys for AST via `context.sourceCode.visitorKeys`.
2025-10-02 08:32:04 +00:00
overlookmotel b69028f5ac feat(linter/plugins): implement SourceCode#ast property (#14287)
Add support for obtaining the AST via `context.sourceCode.ast`.
2025-10-02 08:32:03 +00:00
overlookmotel 95a8cc41d1 perf(linter/plugins): use singleton for SourceCode (#14286)
Only 1 file is linted at a time, so it's unnecessary for each rule to have its own instance of `SourceCode`. Replace `SourceCode` class with a singleton object `SOURCE_CODE` which is reused for all rules, on all files.
2025-10-02 08:32:03 +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