-
-
Notifications
You must be signed in to change notification settings - Fork 99
Add oxlint plugin to @fedify/lint #760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nyanrus
wants to merge
8
commits into
fedify-dev:main
Choose a base branch
from
nyanrus:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
14f5ce4
Add oxlint plugin to @fedify/lint
nyanrus 6cf1efc
Drop incorrect Node-only claim and run oxlint test cross-runtime
nyanrus 8c26d82
Capitalize Oxlint as a proper noun in lint docs
nyanrus 4d15c72
Note Oxlint JS plugin alpha status in lint example README
nyanrus 50be486
Mark Oxlint config example as jsonc
nyanrus de2b2ba
Document oxlint test runtime expectations and clean up tmpdir
nyanrus f1c8be9
Update docs/manual/lint.md
nyanrus d9fbb43
Remove unused link reference definition
nyanrus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "$schema": "https://raw.githubusercontent.com/oxc-project/oxc/main/npm/oxlint/configuration_schema.json", | ||
| "jsPlugins": ["@fedify/lint/oxlint"], | ||
| "rules": { | ||
| "@fedify/lint/actor-id-required": "error", | ||
| "@fedify/lint/actor-id-mismatch": "error", | ||
| "@fedify/lint/actor-inbox-property-required": "warn", | ||
| "@fedify/lint/actor-outbox-property-required": "warn", | ||
| "@fedify/lint/actor-followers-property-required": "warn" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| <!-- deno-fmt-ignore-file --> | ||
|
|
||
| @fedify/lint with oxlint | ||
| ======================== | ||
|
|
||
| This example demonstrates how to use [`@fedify/lint`] together with [oxlint] | ||
| to catch common Fedify federation mistakes. | ||
|
|
||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| [`@fedify/lint`]: https://www.npmjs.com/package/@fedify/lint | ||
| [oxlint]: https://oxc.rs/docs/guide/usage/linter/ | ||
|
|
||
|
|
||
| Layout | ||
| ------ | ||
|
|
||
| - *.oxlintrc.json* — oxlint configuration that enables `@fedify/lint` | ||
| via the JS plugin API. | ||
| - *federation.ts* — code that intentionally violates several rules | ||
| (missing `id`, `inbox`, `outbox`, `followers`). | ||
| - *federation.fixed.ts* — corrected version that passes all rules. | ||
|
|
||
|
|
||
| Usage | ||
| ----- | ||
|
|
||
| Install dependencies and run the linter: | ||
|
|
||
| ~~~~ sh | ||
| pnpm install | ||
| pnpm lint | ||
| ~~~~ | ||
|
|
||
| You should see at least one `@fedify/lint(actor-id-required)` error on | ||
| *federation.ts*. Running against *federation.fixed.ts* alone produces no | ||
| diagnostics: | ||
|
|
||
| ~~~~ sh | ||
| pnpm lint:fixed | ||
| ~~~~ | ||
|
|
||
|
|
||
| How it works | ||
| ------------ | ||
|
|
||
| The plugin is loaded via the `jsPlugins` field in *.oxlintrc.json*: | ||
|
|
||
| ~~~~ json | ||
| { | ||
| "jsPlugins": ["@fedify/lint/oxlint"], | ||
| "rules": { | ||
| "@fedify/lint/actor-id-required": "error" | ||
| } | ||
| } | ||
| ~~~~ | ||
|
|
||
| `@fedify/lint/oxlint` is a subpath export that exposes the same rules as the | ||
| ESLint plugin in oxlint's plugin shape. Rule IDs are namespaced under | ||
| `@fedify/lint/`. | ||
|
|
||
| See the [Linting] manual for the full rule reference. | ||
|
|
||
| [Linting]: https://fedify.dev/manual/lint | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { | ||
| createFederation, | ||
| InProcessMessageQueue, | ||
| MemoryKvStore, | ||
| } from "@fedify/fedify"; | ||
| import { Person } from "@fedify/vocab"; | ||
|
|
||
| const federation = createFederation<void>({ | ||
| kv: new MemoryKvStore(), | ||
| queue: new InProcessMessageQueue(), | ||
| }); | ||
|
|
||
| federation.setActorDispatcher("/users/{identifier}", (ctx, identifier) => { | ||
| return new Person({ | ||
| id: ctx.getActorUri(identifier), | ||
| name: "Example User", | ||
| inbox: ctx.getInboxUri(identifier), | ||
| outbox: ctx.getOutboxUri(identifier), | ||
| followers: ctx.getFollowersUri(identifier), | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { | ||
| createFederation, | ||
| InProcessMessageQueue, | ||
| MemoryKvStore, | ||
| } from "@fedify/fedify"; | ||
| import { Person } from "@fedify/vocab"; | ||
|
|
||
| const federation = createFederation<void>({ | ||
| kv: new MemoryKvStore(), | ||
| queue: new InProcessMessageQueue(), | ||
| }); | ||
|
|
||
| federation.setActorDispatcher("/users/{identifier}", (_ctx, _identifier) => { | ||
| return new Person({ | ||
| name: "Example User", | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| "name": "@fedify/example-lint-oxlint", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "description": "Example project demonstrating @fedify/lint with oxlint", | ||
| "type": "module", | ||
| "scripts": { | ||
| "lint": "oxlint .", | ||
| "lint:fixed": "oxlint federation.fixed.ts" | ||
| }, | ||
| "dependencies": { | ||
| "@fedify/fedify": "workspace:^", | ||
| "@fedify/vocab": "workspace:^" | ||
| }, | ||
| "devDependencies": { | ||
| "@fedify/lint": "workspace:^", | ||
| "oxlint": "catalog:" | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.