Skip to content

hugoalh/deno-lint-rules

Repository files navigation

hugoalh Deno Lint Rules

⚖️ MIT

GitHub: hugoalh/deno-lint-rules JSR: @hugoalh/deno-lint-rules

A Deno module for hugoalh Deno lint rules.

🔰 Begin

🎯 Targets

Remote JSR
Deno >= v2.2.5 ✔️ ✔️

Note

  • It is possible to use this module in other methods/ways which not listed in here, however those methods/ways are not officially supported, and should beware maybe cause security issues.

#️⃣ Resources Identifier

  • Remote - GitHub Raw:
    https://raw.githubusercontent.com/hugoalh/deno-lint-rules/{Tag}/mod.ts
    
  • JSR:
    [jsr:]@hugoalh/deno-lint-rules[@{Tag}]
    

Note

  • For usage of remote resources, it is recommended to import the entire module with the main path mod.ts, however it is also able to import part of the module with sub path if available, but do not import if:

    • it's path has an underscore prefix (e.g.: _foo.ts, _util/bar.ts), or
    • it is a benchmark or test file (e.g.: foo.bench.ts, foo.test.ts), or
    • it's symbol has an underscore prefix (e.g.: _bar, _foo).

    These elements are not considered part of the public API, thus no stability is guaranteed for them.

  • For usage of JSR resources, it is recommended to import the entire module with the main entrypoint, however it is also able to import part of the module with sub entrypoint if available, please visit the file jsr.jsonc property exports for available sub entrypoints.

  • It is recommended to use this module with tag for immutability.

🛡️ Runtime Permissions

This module does not request any runtime permission.

🧩 APIs

  • function configureDenoLintPlugin(options?: DenoLintRulesOptions): Deno.lint.Plugin;

Note

🧩 Rules

Legend Description
✔️ Default and recommended.
🔧 Configurable.
🩹 Automatically fixable.
Identifier (Prefix hugoalh/) Description
🔧 max-params Restrict maximum number of parameters per function/method definition.
no-alert Forbid use of alert.
no-confirm Forbid use of confirm.
✔️🩹 no-duplicate-typeofs Forbid duplicate typeof operators.
✔️ no-empty-yield Forbid empty yield.
✔️ no-enum Forbid use of enum.
✔️ no-if-return-else Forbid statement else after statement if with return statement at the end.
✔️🩹 no-import-absolute Forbid import module via absolute path.
✔️ no-import-data Forbid import module via protocol data:.
✔️🩹 no-import-file Forbid import module via protocol file:.
✔️🩹 no-import-http Forbid import module via protocol http:.
no-import-https Forbid import module via protocol https:.
✔️🔧 no-import-jsr Forbid import JSR module. By default, only forbid import JSR module via URL.
no-import-node Forbid import module via protocol node:.
🔧🩹 no-import-npm Forbid import NPM module.
✔️ no-import-self Forbid the module import itself.
✔️ no-nan Forbid use of NaN.
no-prompt Forbid use of prompt.
no-ternary-nest Forbid nested ternary expression.
✔️ no-unsafe-number Forbid unsafe number.
✔️🩹 no-use-strict Forbid use of use strict directive as ECMAScript modules always have strict mode semantics.
✔️🩹 no-useless-block Forbid useless block.
✔️🩹 no-useless-class-constructor Forbid useless class constructor.
✔️🩹 no-useless-class-static-block Forbid useless class static (initialization) block.
✔️🩹 no-useless-continue Forbid useless continue statement.
✔️🩹 no-useless-export Forbid useless export statement.
✔️ no-useless-expression Forbid useless expression which will do nothing, possibly missing the assignment or call.
✔️🩹 no-useless-switch Forbid useless switch statement.
✔️🩹 no-useless-ternary Forbid useless ternary expression.
✔️🩹 no-useless-try Forbid useless try-catch-finally statement.
✔️ no-useless-typealias Forbid useless type alias.
✔️ prefer-ascii-identifier Prefer ASCII identifier, an alternative of the Deno lint rule prefer-ascii which only enforce on the identifier.
✔️ prefer-import-at-begin Forbid any import statement that come after non import statements.
✔️🩹 prefer-interface Prefer to use interface instead of type.
🔧🩹 prefer-regexp-flag-unicode Prefer the regular expression is contain Unicode flag (u or v).
✔️🩹 prefer-statement-block Prefer curly braces around statement blocks.
prefer-symbol-description Prefer Symbol to have a description.
✔️ std-on-jsr Enforce import Deno Standard Library (std) via JSR.

✍️ Examples

  • Use recommended ruleset via Deno configuration file
    {
      "lint": {
        "plugins": [
          "jsr:@hugoalh/deno-lint-rules[@{Tag}]"
        ]
      }
    }
  • Configure rules
    /* .hugoalh.lint.ts */
    import { configureDenoLintPlugin } from "HUGOALH_DENO_LINT_RULES";
    export default configureDenoLintPlugin({
      ...
    }) satisfies Deno.lint.Plugin as Deno.lint.Plugin;
    /* deno.jsonc */
    {
      "lint": {
        "plugins": [
          "./.hugoalh.lint.ts"
        ]
      }
    }