npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@inngest/eslint-plugin

v0.0.7

Published

An ESLint plugin and config for [`inngest`](/packages/inngest/).

Downloads

40,088

Readme

@inngest/eslint-plugin

An ESLint plugin and config for inngest.

Getting started

Install the package using whichever package manager you'd prefer as a dev dependency.

npm install -D @inngest/eslint-plugin

Add the plugin to your ESLint configuration file with the recommended config.

{
  "plugins": ["@inngest"],
  "extends": ["plugin:@inngest/recommended"]
}

You can also manually configure each rule instead of using the plugin:@inngest/recommended config.

{
  "plugins": ["@inngest"],
  "rules": {
    "@inngest/await-inngest-send": "warn"
  }
}

See below for a list of all rules available to configure.

Rules

@inngest/await-inngest-send

You should use await or return before `inngest.send().

"@inngest/await-inngest-send": "warn" // recommended

In serverless environments, it's common that runtimes are forcibly killed once a request handler has resolved, meaning any pending promises that are not performed before that handler ends may be cancelled.

// ❌ Bad
inngest.send({ name: "some.event" });
// ✅ Good
await inngest.send({ name: "some.event" });

When not to use it

There are cases where you have deeper control of the runtime or when you'll safely await the send at a later time, in which case it's okay to turn this rule off.

@inngest/no-nested-steps

Use of step.* within a step.run() function is not allowed.

"@inngest/no-nested-steps": "error" // recommended

Nesting step.run() calls is not supported and will result in an error at runtime. If your steps are nested, they're probably reliant on each other in some way. If this is the case, extract them into a separate function that runs them in sequence instead.

// ❌ Bad
await step.run("a", async () => {
  const someValue = "...";
  await step.run("b", () => {
    return use(someValue);
  });
});
// ✅ Good
const aThenB = async () => {
  const someValue = await step.run("a", async () => {
    return "...";
  });

  return step.run("b", async () => {
    return use(someValue);
  });
};

await aThenB();

@inngest/no-variable-mutation-in-step

Do not mutate variables inside step.run(), return the result instead.

"@inngest/no-variable-mutation-in-step": "error" // recommended

Inngest executes your function multiple times over the course of a single run, memoizing state as it goes. This means that code within calls to step.run() is not called on every execution.

This can be confusing if you're using steps to update variables within the function's closure, like so:

// ❌ Bad
// THIS IS WRONG!  step.run only runs once and is skipped for future
// steps, so userID will not be defined.
let userId;

// Do NOT do this!  Instead, return data from step.run.
await step.run("get-user", async () => {
  userId = await getRandomUserId();
});

console.log(userId); // undefined

Instead, make sure that any variables needed for the overall function are returned from calls to step.run().

// ✅ Good
// This is the right way to set variables within step.run :)
const userId = await step.run("get-user", () => getRandomUserId());

console.log(userId); // 123