cli icon indicating copy to clipboard operation
cli copied to clipboard

Supabase Edge Functions Linting Issue - `supabase functions new` generates code with Deno IDE and linting errors

Open geeron opened this issue 3 months ago • 1 comments

Description:

When creating a new Edge Function using the Supabase CLI, the generated template code contains Deno linting errors out of the box.

Steps to reproduce:

  1. Clear Deno cache: rm -rf ~/.cache/deno (or rm -rf ~/Library/Caches/deno on macOS) or similar to clear your local deno cache.
  2. Run supabase functions new test-function
  3. Open the generated supabase/functions/test-function/index.ts file in VSCode with the Deno extension enabled
  4. Observe linting errors on line 6

Expected behavior:

The generated code should be free of linting-errors and follow Deno best practices without requiring manual fixes.

Actual behavior:

The generated template produces Deno IDE error and Deno linting warnings on line 6:

import 'jsr:@supabase/functions-js/edge-runtime.d.ts'

Errors shown in IDE:

  1. JSR package "@supabase/functions-js" is not installed or doesn't exist. (deno: not-installed-jsr)
  2. Inline 'npm:', 'jsr:' or 'https:' dependency not allowed - Add it as a dependency in a deno.json or package.json instead and reference it here via its bare specifier (deno-lint: no-import-prefix)
  3. Missing version in specifier - Add a version requirement after the package name (deno-lint: no-unversioned-import)

Note: Seems the 1st error sometimes goes away after a couple of minutes / seconds, to have it re-appear clear deno cache and restart/reload VSCode.

Suggested fix: Error 2 and 3:

Add linting ignore comment:

// deno-lint-ignore no-import-prefix no-unversioned-import

For the 1st error to disappear you will need to install the package manually, or run the function locally with deno: deno run --allow-net --allow-env supabase/functions/test-function/index.ts to have it cached.

I guess for the devs of Supabase this have not been an issue since they probably have the package already installed.

Suggested fix: Error 1:

Not sure the best way, but can be "fixed" this way (also fixes error 2 and 3):

The CLI should generate a deno.json file alongside the function with proper import mappings:

{
  "imports": {
    "@supabase/functions-js": "jsr:@supabase/functions-js@2"
  }
}

Then update the import to use the bare specifier:

import '@supabase/functions-js/edge-runtime.d.ts'

But that generates a large lock file (100+ packages) since @supabase/functions-js has a transitive dependency on openai@^4.52.5

Environment:

  • Supabase CLI version: 2.54.11
  • Deno version: 2.5.6 (stable)
  • OS: macOS (Darwin 23.6.0, aarch64)
  • IDE: VSCode Version: 1.105.1

geeron avatar Nov 09 '25 11:11 geeron

Moved over from the supabase/supabase repo.

Hallidayo avatar Nov 09 '25 20:11 Hallidayo