Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tainn opened this issue Oct 17, 2024 · 2 comments
Open

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

tainn opened this issue Oct 17, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@tainn
Copy link

tainn commented Oct 17, 2024

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.

@littledivy littledivy added the bug Something isn't working label Oct 18, 2024
@marvinhagemeister
Copy link
Contributor

Looks like the lint rule only works on exported functions.

@voltflake
Copy link

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

@lucacasonato lucacasonato transferred this issue from denoland/deno Oct 21, 2024
@lucacasonato lucacasonato changed the title deno lint does not enforce explicit-function-return-type [explicit-function-return-type] does not work on inline arrow functions Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants