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.

Rule Enhancement Proposal: indent and multiline parameters.

See original GitHub issue

From requireAlignedMultilineParams.

JSCS has the rule to align parameters vertically. I think this is a responsibility of indent rule.

{
    "indent": ["error", 4, {
        "FunctionDeclaration": {
            "parameters": "first", // or an integer
            "body": 1
        },
        "FunctionExpression": {
            "parameters": "first", // or an integer
            "body": 1
        }
    }]
}

Those options are similar to existing SwitchCase and VariableDeclarator options. But "parameters": "first" is special. If "parameters": "first" is specified, 2nd line of parameters and later will be aligned with the same column as the first parameter item.

/*eslint indent: ["error", 4, {"FunctionDeclaration": {"parameters": "first"}}]*/

function foo(aaa, bbb,
             ccc, ddd) {
    doSomething();
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:14 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
BYKcommented, Jun 16, 2016

@eslint/doctrine-team we need three 👍s and a champion right? I can champion this and giving my 👍. 2 more to go I guess?

1reaction
not-an-aardvarkcommented, Sep 2, 2016

The default behavior should be current behavior (backward compatibility).

It looks like with the current behavior, the indentation of function parameters isn’t checked at all:

// This is valid

/* eslint indent: [2, 2] */
function foo(
bar,
    baz,
        qux) {
  qux();
}

So we should only check parameter indentation if the user explicitly includes the parameters option.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PEP 8 – Style Guide for Python Code
Python Enhancement Proposals (PEPs) ... Python disallows mixing tabs and spaces for indentation. ... Pick a rule and stick to it.
Read more >
PEP8 — Python Enhancement Proposal | Analytics Vidhya
PEP-8 or the Python Enhancement Proposal presents some of the key points that you can use to make your code more organized and...
Read more >
Nim Enhancement Proposal #1 - Standard Library Style Guide
This enhancement proposal aims to list a series of guidelines that the standard library should follow. Note that there can be exceptions to...
Read more >
indent - 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 >
Manual :: Split function call on several lines
The CS require lines to have a maximum length of 80 chars. Calling functions or methods with many parameters while adhering to CS...
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