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,114 @@ 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 not subject to semver.
276+
277+ [ JS plugin API ] : https://oxc.rs/docs/guide/usage/linter/writing-js-plugins.html
278+
279+ ### Basic setup
280+
281+ Add the plugin to your _ .oxlintrc.json_ via the ` jsPlugins ` field, then enable
282+ the rules you want:
283+
284+ ~~~~ json
285+ {
286+ "$schema" : " https://raw.githubusercontent.com/oxc-project/oxc/main/npm/oxlint/configuration_schema.json" ,
287+ "jsPlugins" : [" @fedify/lint/oxlint" ],
288+ "rules" : {
289+ "@fedify/lint/actor-id-required" : " error" ,
290+ "@fedify/lint/actor-id-mismatch" : " error"
291+ }
292+ }
293+ ~~~~
294+
295+ Rule IDs are namespaced under ` @fedify/lint/ ` , matching the ESLint preset.
296+
297+ ### Custom configuration
298+
299+ Each rule accepts ` "error" ` , ` "warn" ` , or ` "off" ` . Enable any subset listed in
300+ the [ * Rules* section] ( #rules ) below:
301+
302+ ~~~~ json
303+ {
304+ "jsPlugins" : [" @fedify/lint/oxlint" ],
305+ "rules" : {
306+ "@fedify/lint/actor-id-required" : " error" ,
307+ "@fedify/lint/actor-id-mismatch" : " error" ,
308+ "@fedify/lint/actor-inbox-property-required" : " warn" ,
309+ "@fedify/lint/actor-outbox-property-required" : " warn" ,
310+ "@fedify/lint/actor-followers-property-required" : " warn" ,
311+ "@fedify/lint/actor-public-key-required" : " warn" ,
312+ "@fedify/lint/actor-assertion-method-required" : " warn" ,
313+ "@fedify/lint/collection-filtering-not-implemented" : " warn"
314+ }
315+ }
316+ ~~~~
317+
318+ ### Running Oxlint
319+
320+ Add a script to _ package.json_ :
321+
322+ ~~~~ jsonc
323+ {
324+ " scripts" : {
325+ " lint" : " oxlint ."
326+ }
327+ }
328+ ~~~~
329+
330+ Then run the linter:
331+
332+ ::: code-group
333+
334+ ~~~~ sh [npm]
335+ npm run lint
336+ ~~~~
337+
338+ ~~~~ sh [pnpm]
339+ pnpm lint
340+ ~~~~
341+
342+ ~~~~ sh [Yarn]
343+ yarn lint
344+ ~~~~
345+
346+ ~~~~ sh [Bun]
347+ bun lint
348+ ~~~~
349+
350+ :::
351+
352+ Or invoke Oxlint directly:
353+
354+ ::: code-group
355+
356+ ~~~~ sh [npm]
357+ npx oxlint .
358+ ~~~~
359+
360+ ~~~~ sh [pnpm]
361+ pnpx oxlint .
362+ ~~~~
363+
364+ ~~~~ sh [Yarn]
365+ yarn oxlint .
366+ ~~~~
367+
368+ ~~~~ sh [Bun]
369+ bunx oxlint .
370+ ~~~~
371+
372+ :::
373+
374+
265375Rules
266376-----
267377
@@ -1217,10 +1327,12 @@ See also
12171327 - [ ` @fedify/lint ` on npm]
12181328 - [ Deno Lint plugins documentation]
12191329 - [ ESLint documentation]
1330+ - [ Oxlint documentation]
12201331 - [ Example project]
12211332
12221333[ `@fedify/lint` on JSR ] : https://jsr.io/@fedify/lint
12231334[ `@fedify/lint` on npm ] : https://www.npmjs.com/package/@fedify/lint
12241335[ Deno Lint plugins documentation ] : https://docs.deno.com/runtime/reference/lint_plugins/
12251336[ ESLint documentation ] : https://eslint.org/
1337+ [ Oxlint documentation ] : https://oxc.rs/docs/guide/usage/linter/
12261338[ Example project ] : https://github.com/fedify-dev/fedify/tree/main/examples/lint
0 commit comments