Tslint всегда применяет правило no-submodule-import, даже если оно отключено - PullRequest
0 голосов
/ 07 января 2019

Я пытаюсь настроить свой tslint для разрешения подмодулей из библиотеки Parse (https://www.npmjs.com/package/parse-js), чтобы я мог использовать parse/react-native, но это не работает.

Я попытался добавить оба значения "no-submodule-imports": [true, "parse", "parse/react-native"] и "no-submodule-imports": false в свой tslint, но я все еще получаю следующую ошибку:

ERROR: src/App.tsx:2:19 - Submodule import paths from this package are disallowed; import from the root instead

Объявление в @types/parse для этого подмодуля в node_modules:

declare module "parse/node" {
    export = Parse;
}

declare module "parse" {
    import * as parse from "parse/node";
    export = parse
}

declare module "parse/react-native" {
    import * as parse from "parse/node";
    export = parse
}

Код работает нормально, но если я запускаю tslint, я получаю эту ошибку. Я пробовал разные комбинации, но проблема не устранена.

Вот как выглядит мой tslint.json:

{
  "extends": [
    "tslint:latest",
    "tslint-react",
    "tslint-react-a11y",
    "tslint-config-prettier"
  ],
  "no-submodule-imports": [true, "parse", "parse/react-native"],
  "import-blacklist": false,
  "defaultSeverity": "error",
  "rules": {
    "ban": {
      "options": [
        ["_", "extend", "use object spread: { ...a, ...b }"],
        ["_", "isNull", "use plain JS: == null"],
        ["_", "isDefined", "use plain JS: != null"],
        ["Object", "assign", "use object spread: { ...a, ...b }"],
        ["Object", "getOwnPropertyNames", "use Object.keys()"],
        ["describe", "only", "should not be committed to repo"],
        ["it", "only", "should not be committed to repo"],
        ["test", "only", "should not be committed to repo"]
      ]
    },
    "no-object-literal-type-assertion": false,
    "ordered-imports": [
      true,
      {
        "import-sources-order": "any",
        "named-imports-order": "any"
      }
    ],
    "no-any": true,
    "interface-over-type-literal": false,
    "linebreak-style": {
      "options": ["LF"]
    },
    "quotemark": [true, "single"],
    "jsx-boolean-value": ["never"],
    "member-access": [true],
    "no-console": false,
    "no-implicit-dependencies": false,
    "no-invalid-this": {
      "options": ["check-function-in-method"]
    },
    "interface-name": false,
    "max-classes-per-file": false,
    "jsx-no-lambda": false,
    "no-trailing-whitespace": true,
    "no-this-assignment": [
      true,
      {
        "allow-destructuring": true
      }
    ],
    "no-unnecessary-callback-wrapper": false,
    "no-unnecessary-initializer": true,
    "object-literal-sort-keys": false,
    "prefer-conditional-expression": false,
    "variable-name": {
      "options": [
        "allow-leading-underscore",
        "allow-pascal-case",
        "ban-keywords",
        "check-format"
      ]
    },
    "member-ordering": [
      true,
      "private-before-public",
      "static-before-instance",
      "variables-before-functions"
    ],
    "trailing-comma": [
      true,
      {
        "multiline": "always",
        "singleline": "never",
        "esSpecCompliant": true
      }
    ]
  },
  "jsRules": {
    "object-literal-sort-keys": false
  },
  "linterOptions": {
    "exclude": [
      "/**/packages/newrelic-webpack-plugin/embedded.js",
      "/**/coverage/**/*",
      "/**/*.json",
      "/**/build/**/*"
    ]
  }
}

Заранее спасибо за помощь.

1 Ответ

0 голосов
/ 23 мая 2019

Я тоже столкнулся с этим. Похоже, для углового проекта правило должно быть в файле tslint внутри папки src.

...