javascript - 在 Deno 中使用 linter/linting 工具

标签 javascript typescript deno deno-lint

我目前正在探索Deno作为概念验证,我正在尝试找到合适的方法来在项目中设置 linting。

这是我正在考虑设置的 eslint 配置的一部分,但我知道由于 Node.JS 和 Deno 之间的差异,这可能会导致更多问题:

parser: '@typescript-eslint/parser',
extends: [
  'eslint:recommended',
  'plugin:@typescript-eslint/eslint-recommended',
  'plugin:@typescript-eslint/recommended',
],

话虽如此,在 Deno/TypeScript 项目中设置 linting 和格式化有哪些实践/方法?

我了解 deno lint仍在进行中,缺乏文档阻碍了我目前采用它。

最佳答案

这是eslint配置Deno uses , 非常适合 std/使用 Deno .

{
  "root": true,
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "createDefaultProgram": true
  },
  "plugins": ["@typescript-eslint"],
  "extends": [
    "plugin:@typescript-eslint/recommended",
    "prettier",
    "prettier/@typescript-eslint"
  ],
  "rules": {
    "@typescript-eslint/array-type": ["error", { "default": "array-simple" }],
    "@typescript-eslint/ban-ts-comment": ["off"],
    "@typescript-eslint/explicit-member-accessibility": ["off"],
    "@typescript-eslint/explicit-module-boundary-types": ["off"],
    "@typescript-eslint/no-non-null-assertion": ["off"],
    "@typescript-eslint/no-use-before-define": ["off"],
    "@typescript-eslint/no-parameter-properties": ["off"],
    "@typescript-eslint/no-unused-vars": [
      "error",
      { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }
    ],
    "@typescript-eslint/ban-ts-ignore": ["off"],
    "@typescript-eslint/no-empty-function": ["off"],
    "no-return-await": "error",
    "require-await": "error",
    "no-async-promise-executor": "error"
  },
  "overrides": [
    {
      "files": ["*.js"],
      "rules": {
        "@typescript-eslint/explicit-function-return-type": ["off"]
      }
    },
    {
      "files": ["tools/node_*.js"],
      "rules": {
        "@typescript-eslint/no-var-requires": ["off"]
      }
    }
  ]
}

关于javascript - 在 Deno 中使用 linter/linting 工具,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62033813/

相关文章:

javascript - 即使在同一域上,访问控制允许来源

typescript - 语法错误 : Unexpected token import TypeORM entity

deno - 如何解决 Deno 错误 : Uncaught PermissionDenied

node.js - Mac 上的 Node/Deno Postgres 客户端速度缓慢

javascript - 根据新数据检查旧数据,仅处理工作表上谷歌应用程序脚本中的实际更改值

javascript - 具有添加或删除值的选择器

javascript - 如何在 WP7 中使用固定页脚定位 ·

typescript - 为什么 Typescript 会处理对象中的 `object.hasOwnProperty("key")` as essentially different from ` "key"

angular - 如何从 ag-grid valueFormatter 调用服务

javascript - 在 deno 框架中等待没有异步