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.

space-in-parens throws false positive inside if condition between closing parens

See original GitHub issue

Tell us about your environment

  • ESLint Version: 5.6.1
  • Node Version: 8.11.4
  • npm Version: 5.6.0

What parser (default, Babel-ESLint, etc.) are you using? Default

Please show your full configuration:

{
  "plugins": [
    "cypress",
    "chai-friendly"
  ],
  "env": {
    "cypress/globals": true
  },
  "extends": [
    "eslint:recommended",
    "standard"
  ],
  "parserOptions": {
    "ecmaVersion": 6,
    "sourceType": "module"
  },
  "globals": {
    "App": true
  },
  "rules": {
    "max-len": [
      "error", {
        "code": 80,
        "tabWidth": 2
      }
    ],
  "space-in-parens": ["error", "never", {
    "exceptions": ["()"]
    }],
  "no-unused-expressions": 0,
  "chai-friendly/no-unused-expressions": 2
  }
}

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

Code which exhibits the bug:

const theTrueFunc = () => true

// this will complain that there is no space after the function call and the closing if bracket
if (theTrueFunc()) {
  console.log('True dat')
}

What did you expect to happen? Should not have to insert space after function

What actually happened? Please include the actual, raw output from ESLint.

/home/grayedfox/github/comgy/mh-tests/cypress/support/helpers.js
  8:32  error  There must be a space inside this paren  space-in-parens

✖ 1 problem (1 error, 0 warnings)
  1 error and 0 warnings potentially fixable with the `--fix` option.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
platinumazurecommented, Oct 4, 2018

Hi @GrayedFox, thanks for the issue.

I’ve just read the docs, and I think the key point is that any tokens listed in the rule’s exceptions option must completely surround the expression.

Some examples:

/* eslint space-in-parens: ["error", "always", { "exceptions": ["()"] }] */

// Allowed:
foo(( 5*2 ));    // The outer parentheses don't need spaces just inside them.
                 // Subexpression is completely surrounded by parentheses.
                 // Inner parentheses need spaces because the expression within does not have parens.

// Not allowed:

foo(5 * (2+3));  // Whole expression is not surrounded by parentheses
                 // Expected: foo( 5 * ( 2 + 3 ) );

foo(someFunc());  // Whole expression is not surrounded by parentheses
                  // Expected: foo( someFunc() );

If you think the documentation could be improved, we would welcome a pull request!

0reactions
eslint-deprecated[bot]commented, Dec 25, 2018

Unfortunately, it looks like there wasn’t enough interest from the team or community to implement this change. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to reach accepted status after 21 days tend to never be accepted, and as such, we close those issues. This doesn’t mean the idea isn’t interesting or useful, just that it’s not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

Read more comments on GitHub >

github_iconTop Results From Across the Web

space-in-parens - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Reduce smelling code and detect JavaScript issues with ESLint
Problem statement: Smelling Code Have you ever had to fix an error in someone else's code - but you had to reformat the...
Read more >
Diff - 402e1b6e55e9041dfd1a93580e45e5c5dba1db55^!
+ + "License" shall mean the terms and conditions for use, ... 61dfe68 Fix: `no-useless-rename` false positive in babel-eslint (fixes #6266) ...
Read more >
Different Results With Parentheses and Variable Placement in ...
I was under the impression that the placement of the variable in this conditional if statement didn't matter if I was using the...
Read more >
eslint-config-dbk - npm
shareable eslint config. Latest version: 3.3.4, last published: 4 years ago. Start using eslint-config-dbk in your project by running `npm i ...
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