首页 > 解决方案 > 如何在打字稿中禁用独角兽/首选模块?

问题描述

禁用的正确方法是unicorn/prefer-module什么?

我已经试过了/* eslint-disable unicorn/prefer-module */

但我越来越[eslint unicorn/prefer-module] [E] Definition for rule 'unicorn/prefer-module' was not found.

包.json

{
  "name": "",
  "version": "0.1.0",
  "main": "lib/index.js",
  "dependencies": {
    "argon2": "^0.28.2",
    "date-fns": "^2.22.1",
    "express": "^4.17.1",
    "express-mysql-session": "^2.1.6",
    "express-session": "^1.17.2",
    "helmet": "^4.6.0",
    "mysql2": "^2.2.5"
  },
  "devDependencies": {
    "@types/express": "^4.17.12",
    "@types/express-mysql-session": "^2.1.2",
    "@types/express-session": "^1.17.3",
    "@types/helmet": "^4.0.0",
    "@types/node": "^15.12.4",
    "eslint-plugin-unicorn": "^32.0.1",
    "typescript": "^4.3.4",
    "xo": "^0.40.3"
  },
  "eslintConfig": {
    "extends": [
      "xo",
      "xo-typescript"
    ],
    "rules": {
      "@typescript-eslint/no-require-imports": "off",
      "@typescript-eslint/dot-notation": "off"
    }
  },
  "xo": {
    "rules": {
      "@typescript-eslint/no-require-imports": 0,
      "@typescript-eslint/dot-notation": 0,
      "unicorn/prevent-abbreviations": 0
    }
  }
}

标签: typescripteslint

解决方案


您需要unicorn在 eslintConfig 部分添加plugins

"plugins": [
    "unicorn"
],

参考:使用文档


推荐阅读