deno_lint icon indicating copy to clipboard operation
deno_lint copied to clipboard

[explicit-function-return-type] does not work on inline arrow functions

Open tainn opened this issue 1 year ago • 2 comments

deno 2.0.0 (stable, release, x86_64-unknown-linux-gnu)
v8 12.9.202.13-rusty
typescript 5.6.2

deno lint does not enforce the explicit-function-return-type rule.

Assuming the following deno.json snippet:

{
  "lint": {
    "include": ["src"],
    "rules": {
      "include": [
        "camelcase",
        "default-param-last",
        "eqeqeq",
        "explicit-function-return-type",
        "explicit-module-boundary-types",
        "guard-for-in",
        "no-await-in-loop",
        "no-boolean-literal-for-arguments",
        "no-eval",
        "no-inferrable-types",
        "no-non-null-asserted-optional-chain",
        "no-non-null-assertion",
        "no-self-compare",
        "no-sparse-arrays",
        "no-sync-fn-in-async-fn",
        "no-throw-literal",
        "no-top-level-await",
        "no-undef",
        "prefer-ascii",
        "single-var-declarator",
        "triple-slash-reference",
        "verbatim-module-syntax"
      ]
    }
  }
}

And the following TS snippet of a Hono project:

const rootHandler = (ctx: Context) => {
  return ctx.json({ shade: "?", random: randomInt(0, 256) });
};

That rule would have to raise an error during linting, because a Response return type was not provided. But it does not raise any errors and the lint succeeds.

As a reference, other linting rules seem to work, at least the few that I intentionally tested out, such as camelcase and eqeqeq.

tainn avatar Oct 17 '24 20:10 tainn

Looks like the lint rule only works on exported functions.

marvinhagemeister avatar Oct 18 '24 08:10 marvinhagemeister

Issue is in const name = ()=>{} syntax. With casual function name() {} it works as expected.

voltflake avatar Oct 18 '24 21:10 voltflake