Skip to main content
Home

latest
It is unknown whether this package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
It is unknown whether this package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
17%
Published
6 months ago (0.0.2)

@mizchi/lint

for deno-lint

  • plugins
    • @mizchi/lint/do-try
    • @mizchi/lint/strict-module

How to use

deno.json

{
  "lint": {
    "plugins": ["jsr:@mizchi/lint/do-try", "jsr:@mizchi/lint/strict-module"]
  }
}

lint plugins

@mizchi/lint/do-try

// Allow
function doThrowableFunction() {
  if (Math.random() > 0.5) {
    throw new Error("Random error");
  }
  return "data";
}

try {
  doThrowableFunction();
} catch (error) {
  console.error("An error occurred:", error);
}

async function doThrowableAsync(): Promise<string> {
  if (Math.random() > 0.5) {
    await Promise.reject(new Error("Random error"));
  }
  return "data";
}
try {
  await doThrowableAsync();
} catch (error) {
  console.error("An error occurred:", error);
}

async function doTask() {
  await Promise.resolve();
}
async function doMain(): Promise<void> {
  await doTask();
}

try {
  await doMain();
} catch (error) {
  console.error("An error occurred:", error);
}

// Errors
doSomething();
await doSomething();
await obj.doSomething();
try {
  const run = async () => {
    // should be wrapped in try-catch
    await doSomething();
  };
  await run();
} catch (error) {
  console.error("An error occurred:", error);
}
function _throwableFunction() {
  if (Math.random() > 0.5) {
    throw new Error("Random error");
  }
  return "data";
}

async function _throwableAsync(): Promise<string> {
  if (Math.random() > 0.5) {
    await Promise.reject(new Error("Random error"));
  }
  return "data";
}

@mizchi/lint/strict-module

// ok
import {} from "./xxx/mod.ts"; // allow ./mod.ts
import type { Foo as _2 } from "./xxx/types.ts"; // allow ./types.ts
import {} from "../../mod.ts"; // allow direct parent mod
import {} from "../../internal.ts"; // allow direct parent internal

// error
import {} from "./xxx/internal.ts"; // direct import
import { Foo as _1 } from "./xxx/types.ts"; // no type import
import {} from "../../submodule/internal.ts"; // direct parent sub mobule

LICENSE

MIT

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.