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.

Add method option for space-before-function-paren

See original GitHub issue

Proposal: Add a new method option for the space-before-function-paren rule to specify whether a method on a class should have a space following it.

Reason: A common coding style for ES2015 is to never add a space after a named function (ie: function name()), but to still always add a space after a class method name, (ie: class A { constructor () {} }). This style is currently not possible to enforce, since methods get lumped in with all named functions.

ESLint Version Tested: 1.10.1

Documentation Example:

/*eslint space-before-function-paren: [2, { "anonymous": "always", "named": "never", "method": "always" }]*/
/*eslint-env es6*/

function foo () {      /*error Unexpected space before function parentheses.*/
    // ...
}

var bar = function() { /*error Missing space before function parentheses.*/
    // ...
};

class Foo {
    constructor() {    /*error Missing space before method parentheses.*/
        // ...
    }
}

var foo = {
    bar () {           /*error Unexpected space before function parentheses.*/
        // ...
    }
};

<bountysource-plugin>

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
btmillscommented, Aug 11, 2016

@iglvzx you want no-spaced-func (func-call-spacing will replace it in the next minor release)

0reactions
iglvzxcommented, Aug 11, 2016

@btmills Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

space-before-function-paren - 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 >
VS Code - space before function parentheses - Stack Overflow
In VS Code open File -> Preferences -> Settings; Add to your JSON config: "javascript.format.insertSpaceBeforeFunctionParenthesis": true.
Read more >
Rule: space-before-function-paren - Palantir Open Source
One argument which is an object which may contain the keys anonymous , named , and asyncArrow These should be set to either...
Read more >
space-before-function-paren - TypeScript ESLint
space -before-function-paren ... We strongly recommend you do not use this rule or any other formatting linter rules. Use a separate dedicated formatter...
Read more >
space-before-function-paren rule in WebStorm
The ESLint space-before-function-paren rule forbits space before function parentheses. Using the settings below: when formatting this...
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