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.

`key-spacing`: `multiLine.align.mode` is overridden, `multiLine.mode` with `align` causes an error

See original GitHub issue

What version of ESLint are you using? ESLint 3.1.0

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

Please show your full configuration:

case1.js

module.exports = {
    "rules"   : {
        "key-spacing"                  : [
            "error",
            {
                "multiLine" : {
                    "beforeColon": false,
                    "afterColon" : true,
                    "mode"       : "strict",
                    "align"      : {
                        "beforeColon": false,
                        "afterColon" : true,
                        "on"         : "colon",
                        "mode"       : "minimum"
                    }
                }
            }
        ]
    }
};

case2.js

module.exports = {
    "rules": {
        "key-spacing": [
            "error",
            {
                "multiLine": {
                    "beforeColon": false,
                    "afterColon" : true,
                    "mode"       : "strict"
                },
                "align"    : {
                    "beforeColon": false,
                    "afterColon" : true,
                    "on"         : "colon",
                    "mode"       : "minimum"
                }
            }
        ]
    }
};

What did you do? Please include the actual source code causing the issue.

test.js

var a = {
    foo   : 1,
    align1: {
        foo:    2
    },
    align2: {
        foo:    3
    },
    bar: 4
};

What did you expect to happen?

Case 1

  5:5   warning  Unexpected a line break before this close brace  object-curly-newline
  6:13  warning  Unexpected a line break after this open brace    object-curly-newline

Case2

  1:1   error    Unexpected var, use let or const instead         no-var
  1:5   error    'a' is defined but never used                    no-unused-vars
  3:13  warning  Unexpected a line break after this open brace    object-curly-newline
  5:5   warning  Unexpected a line break before this close brace  object-curly-newline
  6:13  warning  Unexpected a line break after this open brace    object-curly-newline
  8:5   warning  Unexpected a line break before this close brace  object-curly-newline

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

Case 1

  4:17  error    Extra space before value for key 'foo'           key-spacing
  5:5   warning  Unexpected a line break before this close brace  object-curly-newline
  6:13  warning  Unexpected a line break after this open brace    object-curly-newline
  7:17  error    Extra space before value for key 'foo'           key-spacing

Because of https://github.com/eslint/eslint/blob/67c3cc2fa655e9e92e01d7a88e9a9d60cd4a4ce9/lib/rules/key-spacing.js#L139

Case2

/path/to/config/case2.js:
        Configuration for rule "key-spacing" is invalid:
        Value "[object Object]" no schemas match.

Error: /path/to/config/case2.js:
        Configuration for rule "key-spacing" is invalid:
        Value "[object Object]" no schemas match.

Because of https://github.com/eslint/eslint/blob/67c3cc2fa655e9e92e01d7a88e9a9d60cd4a4ce9/lib/rules/key-spacing.js#L271-L321 (multiLine.mode isn’t allowed with align option)

Are they designed as they are?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
btmillscommented, Jul 16, 2016

@whizark is right - align isn’t respecting its own mode at all, and is instead using multiLine’s mode value.

Two steps to fixing this:

  1. Change the schema to allow mode.align. Right now just multiLine.align.mode is permitted.
  2. Change the code so that mode uses align’s setting, if present, when properties are part of a group.
0reactions
anniecommented, Aug 28, 2016

@btmills made a PR if you’d like to check it out

Read more comments on GitHub >

github_iconTop Results From Across the Web

A very complicated multiple lines problem in the align ...
As you see in the pdf file, formulas (1) and (2) are usual situation in the align environment. But if (2) is too...
Read more >
How to align equations in LaTeX?
1. Left alignment of multiline equations in LaTeX. The first environment from the amsmath package that we are going to explain is the...
Read more >
Developers Who Use Spaces Make More Money Than Those ...
In my experience, it's the complete opposite. Tabs “just work” and let me align things effortlessly. You can align with spaces, but that...
Read more >
Configuration | Grafana Loki documentation
Configuring Grafana Loki Grafana Loki is configured in a YAML file (usually referred to as loki.yaml ) which contains information on the Loki...
Read more >
Using Adobe FrameMaker (2019 release)
Structured FrameMaker mode . ... Set automatic alignment for a vertical list or multiline equation . ... Align items in a horizontal list...
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