ESLint выбрасывает неиспользуемые выражения с необязательной цепочкой `obj? .Fn ()` - PullRequest
0 голосов
/ 28 мая 2020

Почему eslint кидает на inputRef.current?.focus()? Я использую опциональную цепочку неправильно?

Expected an assignment or function call and instead saw an expression. eslint no-unused-expressions

Вот мои конфигурации (первая находится в пакете моей рабочей области, вторая - в моей рабочей области root):

{
  "env": {
    "es6": true,
    "shared-node-browser": true
  },
  "extends": [
    "universe/native",
    "eslint:recommended"
  ],
  "plugins": [
    "@typescript-eslint"
  ],
  "rules": {
    "require-atomic-updates": 0
  }
}
{
  "root": true,
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    // Required for certain syntax usages
    "ecmaVersion": 2017
  },
  "env": {
    "es6": true,
    "node": true,
    "jest": true
  },
  "extends": [
    "plugin:prettier/recommended"
  ],
  "plugins": [
    "prettier",
    "@typescript-eslint",
    "promise",
    "babel"
  ],
  "rules": {
    "prettier/prettier": "error",
    // Warn against shorthand type conversions
    "no-implicit-coercion": 1,

    // Require using Error objects as Promise rejection reasons
    "prefer-promise-reject-errors": 2,

    // Enforce “for” loop update clause moving the counter in the right direction
    "for-direction": 2,

    // Enforce return statements in getters
    "getter-return": 2,

    // Disallow await inside of loops
    "no-await-in-loop": 2,

    // Disallow comparing against -0
    "no-compare-neg-zero": 2,

    // Warn against catch clause parameters from shadowing variables in the outer scope
    "no-catch-shadow": 1,

    // Disallow identifiers from shadowing restricted names
    "no-shadow-restricted-names": 2,

    // Enforce return statements in callbacks of array methods
    "callback-return": 2,

    // Require error handling in callbacks
    "handle-callback-err": 2,

    // Warn against string concatenation with __dirname and __filename
    "no-path-concat": 1,

    // Prefer using arrow functions for callbacks
    "prefer-arrow-callback": 1,

    // Return inside each then() to create readable and reusable Promise chains.
    // Forces developers to return console logs and http calls in promises.
    "promise/always-return": 2,

    //Enforces the use of catch() on un-returned promises
    "promise/catch-or-return": 2,

    // Warn against nested then() or catch() statements
    "promise/no-nesting": 1
  }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...