question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error starting eslint when using the object option in the no-extra-boolean-cast rule

See original GitHub issue

Environment

Node version: v14.18.3 npm version: 6.14.15 Local ESLint version: 8.16.0 Global ESLint version: - Operating System: macOS Monterey 12.4

What parser are you using?

Default (Espree)

What did you do?

Configuration
{
  "extends": [
    "react-app",
    "plugin:react-hooks/recommended",
    "prettier",
    "plugin:import/typescript"
  ],
  "plugins": [
    "sort-keys-fix"
  ],
  "ignorePatterns": [
    "**/core/api/**/*",
    "react-app-env.d.ts",
    ".eslintrc.js"
  ],
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "project": "./tsconfig.json"
  },
  "rules": {
    "@typescript-eslint/brace-style": "warn",
    "@typescript-eslint/comma-spacing": "warn",
    "@typescript-eslint/default-param-last": "warn",
    "@typescript-eslint/dot-notation": "warn",
    "@typescript-eslint/func-call-spacing": "warn",
    "@typescript-eslint/keyword-spacing": "warn",
    "@typescript-eslint/no-array-constructor": "warn",
    "@typescript-eslint/no-dupe-class-members": "warn",
    "@typescript-eslint/no-unused-vars": "warn",
    "@typescript-eslint/no-useless-constructor": "warn",
    "@typescript-eslint/quotes": [
      "warn",
      "single",
      {
        "avoidEscape": true
      }
    ],
    "array-bracket-spacing": [
      "warn",
      "never"
    ],
    "array-callback-return": "warn",
    "arrow-body-style": "warn",
    "arrow-parens": "warn",
    "arrow-spacing": "warn",
    "block-spacing": [
      "warn",
      "always"
    ],
    "comma-dangle": [
      "warn",
      {
        "arrays": "always-multiline",
        "objects": "always-multiline",
        "exports": "always-multiline",
        "imports": "always-multiline",
        "functions": "never"
      }
    ],
    "comma-style": "warn",
    "computed-property-spacing": "warn",
    "eol-last": "warn",
    "eqeqeq": "warn",
    "import/first": "warn",
    "import/no-duplicates": "warn",
    "import/no-mutable-exports": "warn",
    "import/no-cycle": "error",
    "key-spacing": "warn",
    "newline-before-return": "warn",
    "no-else-return": "warn",
    "no-eval": "warn",
    "no-extra-boolean-cast": ["warn", {"enforceForLogicalOperands": true}],
    "no-iterator": "warn",
    "no-mixed-operators": "warn",
    "no-multi-assign": "warn",
    "no-multiple-empty-lines": "warn",
    "no-nested-ternary": "warn",
    "no-new-func": "warn",
    "no-new-object": "warn",
    "no-new-wrappers": "warn",
    "no-param-reassign": "warn",
    "no-plusplus": "warn",
    "no-prototype-builtins": "warn",
    "no-restricted-globals": "warn",
    "no-restricted-properties": "warn",
    "no-restricted-syntax": "warn",
    "no-trailing-spaces": "warn",
    "no-undef": "warn",
    "no-unneeded-ternary": "warn",
    "no-useless-escape": "warn",
    "no-use-before-define": [
      "warn",
      {
        "functions": true,
        "classes": true,
        "variables": true
      }
    ],
    "no-var": "warn",
    "no-whitespace-before-property": "warn",
    "nonblock-statement-body-position": [
      "warn",
      "any"
    ],
    "object-curly-spacing": [
      "warn",
      "always"
    ],
    "object-shorthand": "warn",
    "padded-blocks": [
      "warn",
      "never"
    ],
    "prefer-arrow-callback": "warn",
    "prefer-const": "warn",
    "prefer-object-spread": "warn",
    "prefer-rest-params": "warn",
    "prefer-spread": "warn",
    "prefer-template": "warn",
    "quote-props": [
      "warn",
      "as-needed",
      {
        "keywords": false,
        "unnecessary": true,
        "numbers": false
      }
    ],
    "react/jsx-no-literals": [
      "warn",
      {
        "noStrings": false,
        "ignoreProps": true,
        "noAttributeStrings": false
      }
    ],
    "space-before-blocks": "warn",
    "space-in-parens": "warn",
    "space-infix-ops": "warn",
    "spaced-comment": "warn",
    "template-curly-spacing": [
      "warn",
      "never"
    ],
    "yoda": "warn"
  },
  "overrides": [
    {
      "files": [
        "*.ts",
        "*.tsx"
      ],
      "rules": {
        "constructor-super": "off",
        "getter-return": "off",
        "no-const-assign": "off",
        "no-dupe-args": "off",
        "no-dupe-class-members": "off",
        "no-dupe-keys": "off",
        "no-func-assign": "off",
        "no-new-symbol": "off",
        "no-obj-calls": "off",
        "no-redeclare": "off",
        "no-this-before-super": "off",
        "no-undef": "off",
        "no-unreachable": "off",
        "no-unsafe-negation": "off",
        "valid-typeof": "off",
        "import/named": "off",
        "import/no-unresolved": "off"
      }
    },
    {
      "files": [
        "**/core/local/**/*"
      ],
      "excludedFiles": [
        "local.config.ts"
      ],
      "rules": {
        "sort-keys-fix/sort-keys-fix": "warn"
      }
    }
  ]
}

<!-- Paste your code here -->

What did you expect to happen?

ESLint is running, the object option is working

What actually happened?

/Users/maksim/Projects/lms/frontend/lms

eslint ./src --ext .js,.jsx,.ts,.tsx

Error: .eslintrc.json: Configuration for rule “no-extra-boolean-cast” is invalid: Value [{“enforceForLogicalOperands”:true}] should NOT have more than 0 items.

at validateRuleOptions (/Users/maksim/Projects/lms/frontend/lms/node_modules/eslint/lib/shared/config-validator.js:138:19)
at /Users/maksim/Projects/lms/frontend/lms/node_modules/eslint/lib/shared/config-validator.js:193:9
at Array.forEach (<anonymous>)
at validateRules (/Users/maksim/Projects/lms/frontend/lms/node_modules/eslint/lib/shared/config-validator.js:190:30)
at validateConfigArray (/Users/maksim/Projects/lms/frontend/lms/node_modules/eslint/lib/shared/config-validator.js:337:9)
at CascadingConfigArrayFactory._finalizeConfigArray (/Users/maksim/Projects/lms/frontend/lms/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:417:13)
at CascadingConfigArrayFactory.getConfigArrayForFile (/Users/maksim/Projects/lms/frontend/lms/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:271:21)
at FileEnumerator._iterateFilesRecursive (/Users/maksim/Projects/lms/frontend/lms/node_modules/eslint/lib/cli-engine/file-enumerator.js:396:49)
at _iterateFilesRecursive.next (<anonymous>)
at FileEnumerator.iterateFiles (/Users/maksim/Projects/lms/frontend/lms/node_modules/eslint/lib/cli-engine/file-enumerator.js:251:49)

npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! lms@0.1.0 lint: eslint ./src --ext .js,.jsx,.ts,.tsx npm ERR! Exit status 2 npm ERR! npm ERR! Failed at the lms@0.1.0 lint script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /Users/maksim/.npm/_logs/2022-06-02T10_41_20_905Z-debug.log

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mdjermanoviccommented, Jun 3, 2022

The enforceForLogicalOperands option was added in ESLint v7.0.0, so you can only use this option with ESLint >= 7.

ESLint < 7 will throw a configuration error, as in the original post. Since you have ESLint v6.8.0, this is the expected behavior.

0reactions
mvshvetscommented, Jun 3, 2022

Thank you for helping me figure it out

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-extra-boolean-cast - ESLint - Pluggable JavaScript Linter
This rule has an object option: "enforceForLogicalOperands" when set to true , in addition to checking default contexts, checks whether the extra boolean...
Read more >
List of available rules - ESLint - Pluggable JavaScript linter
These rules relate to possible syntax or logic errors in JavaScript code: ... disallow new operators with the String , Number , and...
Read more >
tslint-eslint-rules | Yarn - Package Manager
You want to code in TypeScript but miss all the rules available in ESLint? Now you can combine both worlds by using this...
Read more >
Disallow this keywords outside of classes or class-like objects ...
/*eslint no-invalid-this: "error"*/ /*eslint-env es6*/ "use strict"; this.a = 0; baz(() => this); ... This rule has an object option, with one option:....
Read more >
React typescript: eslint max-length autofix does not work
There have been a couple of issues that are opened, about adding auto-fix for the max-len rule, but unfortunately, the eslint team doesn't ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found