11---
22description : >-
3- Fedify provides linting plugins for Deno Lint and ESLint to help you catch
4- common mistakes and enforce best practices when building federated server
5- apps.
3+ Fedify provides linting plugins for Deno Lint, ESLint, and oxlint to help you
4+ catch common mistakes and enforce best practices when building federated
5+ server apps.
66---
77
88Linting
@@ -15,8 +15,9 @@ _This package is available since Fedify 2.0.0._
1515> app to catch common mistakes early and enforce best practices.
1616
1717Fedify provides the [ ` @fedify/lint ` ] package, which includes lint rules
18- specifically designed for Fedify applications. It supports both [ Deno Lint] and
19- [ ESLint] , so you can use it regardless of your JavaScript/TypeScript runtime.
18+ specifically designed for Fedify applications. It supports [ Deno Lint] ,
19+ [ ESLint] , and [ oxlint] , so you can use it regardless of your
20+ JavaScript/TypeScript runtime.
2021
2122The plugin includes rules that check for:
2223
@@ -29,6 +30,7 @@ The plugin includes rules that check for:
2930[ `@fedify/lint` ] : https://jsr.io/@fedify/lint
3031[ Deno Lint ] : https://docs.deno.com/runtime/reference/lint_plugins/
3132[ ESLint ] : https://eslint.org/
33+ [ oxlint ] : https://oxc.rs/docs/guide/usage/linter/
3234
3335
3436Installation
@@ -262,6 +264,118 @@ bunx eslint .
262264:::
263265
264266
267+ Oxlint
268+ ------
269+
270+ [ oxlint] is a fast Rust-based linter that supports ESLint-compatible JS
271+ plugins. ` @fedify/lint ` exposes its rules through oxlint's [ JS plugin API]
272+ via the ` @fedify/lint/oxlint ` subpath export.
273+
274+ > [ !NOTE]
275+ > oxlint's JS plugin API is currently in alpha and the loader runs only under
276+ > Node.js. The ` @fedify/lint/oxlint ` subpath is therefore distributed via npm
277+ > only, not JSR.
278+
279+ [ JS plugin API ] : https://oxc.rs/docs/guide/usage/linter/writing-js-plugins.html
280+
281+ ### Basic setup
282+
283+ Add the plugin to your _ .oxlintrc.json_ via the ` jsPlugins ` field, then enable
284+ the rules you want:
285+
286+ ~~~~ json
287+ {
288+ "$schema" : " https://raw.githubusercontent.com/oxc-project/oxc/main/npm/oxlint/configuration_schema.json" ,
289+ "jsPlugins" : [" @fedify/lint/oxlint" ],
290+ "rules" : {
291+ "@fedify/lint/actor-id-required" : " error" ,
292+ "@fedify/lint/actor-id-mismatch" : " error"
293+ }
294+ }
295+ ~~~~
296+
297+ Rule IDs are namespaced under ` @fedify/lint/ ` , matching the ESLint preset.
298+
299+ ### Custom configuration
300+
301+ Each rule accepts ` "error" ` , ` "warn" ` , or ` "off" ` . Enable any subset listed in
302+ the [ Rules] section below:
303+
304+ ~~~~ json
305+ {
306+ "jsPlugins" : [" @fedify/lint/oxlint" ],
307+ "rules" : {
308+ "@fedify/lint/actor-id-required" : " error" ,
309+ "@fedify/lint/actor-id-mismatch" : " error" ,
310+ "@fedify/lint/actor-inbox-property-required" : " warn" ,
311+ "@fedify/lint/actor-outbox-property-required" : " warn" ,
312+ "@fedify/lint/actor-followers-property-required" : " warn" ,
313+ "@fedify/lint/actor-public-key-required" : " warn" ,
314+ "@fedify/lint/actor-assertion-method-required" : " warn" ,
315+ "@fedify/lint/collection-filtering-not-implemented" : " warn"
316+ }
317+ }
318+ ~~~~
319+
320+ [ Rules ] : #rules
321+
322+ ### Running oxlint
323+
324+ Add a script to _ package.json_ :
325+
326+ ~~~~ jsonc
327+ {
328+ " scripts" : {
329+ " lint" : " oxlint ."
330+ }
331+ }
332+ ~~~~
333+
334+ Then run the linter:
335+
336+ ::: code-group
337+
338+ ~~~~ sh [npm]
339+ npm run lint
340+ ~~~~
341+
342+ ~~~~ sh [pnpm]
343+ pnpm lint
344+ ~~~~
345+
346+ ~~~~ sh [Yarn]
347+ yarn lint
348+ ~~~~
349+
350+ ~~~~ sh [Bun]
351+ bun lint
352+ ~~~~
353+
354+ :::
355+
356+ Or invoke oxlint directly:
357+
358+ ::: code-group
359+
360+ ~~~~ sh [npm]
361+ npx oxlint .
362+ ~~~~
363+
364+ ~~~~ sh [pnpm]
365+ pnpx oxlint .
366+ ~~~~
367+
368+ ~~~~ sh [Yarn]
369+ yarn oxlint .
370+ ~~~~
371+
372+ ~~~~ sh [Bun]
373+ bunx oxlint .
374+ ~~~~
375+
376+ :::
377+
378+
265379Rules
266380-----
267381
@@ -1217,10 +1331,12 @@ See also
12171331 - [ ` @fedify/lint ` on npm]
12181332 - [ Deno Lint plugins documentation]
12191333 - [ ESLint documentation]
1334+ - [ oxlint documentation]
12201335 - [ Example project]
12211336
12221337[ `@fedify/lint` on JSR ] : https://jsr.io/@fedify/lint
12231338[ `@fedify/lint` on npm ] : https://www.npmjs.com/package/@fedify/lint
12241339[ Deno Lint plugins documentation ] : https://docs.deno.com/runtime/reference/lint_plugins/
12251340[ ESLint documentation ] : https://eslint.org/
1341+ [ oxlint documentation ] : https://oxc.rs/docs/guide/usage/linter/
12261342[ Example project ] : https://github.com/fedify-dev/fedify/tree/main/examples/lint
0 commit comments