Skip to content

Conversation

csvn
Copy link
Contributor

@csvn csvn commented Aug 2, 2025

Adapts the two existing Fresh lint rules in Deno into it's own Lint plugin.

Used as an example for #3174 for possible creating new Fresh lint rules too.

Note

Requires the AST regex selector fix that is included in Deno v2.4.5

TODO's

  • Avoid duplicate rules when using fresh tag in Deno
  • Add a "fresh/island-imports" rule to disallow importing fresh from Islands

Potential future rules

  • fresh/route-exports: Lint module exports of routes/*
    • Must have at least one export (not just config for RouteConfig)
    • Lint that the export is a valid one, e.g. handlers, default export, config, etc
    • Disallow exports that are "unknown", probably better to move to a non-route if it's shared
  • fresh/island-props: Lint values that can be serialized correctly (may not work without type info)

Closes #2950

@@ -0,0 +1,13 @@
{
"name": "@fresh/lint",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps a new package for linting is overkill, or could perhaps allow more drift (version mismatch between @fresh/lint and @fresh/core). The lint plugin could instead be a export on @fresh/core, e.g. @fresh/core/lint.

Given that it's unlikely for lint rules to require extra dependencies, it might be better to have the lint plugin just as a new export on @fresh/core. I feel like most projects will want the lint rules anyway, so maybe it's better to skip another dependency.

   {
     "lint": {
       "plugins": ["jsr:@fresh/core/lint"]
     }
   }

Note

It seems that it's not possible to use import maps with "lint.plugins" at the moment, so requires the jsr: prefix currently. I created denoland/deno#30297 to highlight this.

@csvn csvn force-pushed the feat/lint-plugin branch from 5be05f5 to 5e720ed Compare August 5, 2025 22:18
@csvn csvn force-pushed the feat/lint-plugin branch 4 times, most recently from 9a632d5 to ef642ec Compare August 20, 2025 08:19
@csvn csvn marked this pull request as ready for review August 20, 2025 08:22
@csvn csvn force-pushed the feat/lint-plugin branch from ef642ec to 1d4962d Compare August 21, 2025 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

suggestion: Fresh lint plugin

1 participant