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.

Object-curly-newline for destructuring not working as expected in editor

See original GitHub issue

I’m utilizing prettier to format code based on eslint rules. According to the documentation, the following rules should reformat the destructure (originally all in 1 line) into multiple line with one property per line (just like the object literal). However, it’s not working as expected (see attached for how the code gets formatted). Can someone explain to me what I might be doing wrong?

ivwao

.eslintrc.json

{
  "env": {
    "browser": true,
    "commonjs": true,
    "es6": true
  },
  "parserOptions": {
    "sourceType": "module"
  },
  "rules": {
    "max-len": [
      2,
      80,
      4,
      {
        "ignoreStrings": true,
        "ignoreComments": true,
        "ignoreUrls": true
      }
    ],
    "object-curly-newline": [
      "error",
      {
        "ObjectExpression": "always",
        "ObjectPattern": { "minProperties": 2 }
      }
    ]
  }
}

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
platinumazurecommented, Feb 3, 2018

Oh, also: If any ESLint documentation is incorrect, could you please let us know where it is so we can fix it? Thanks!

0reactions
not-an-aardvarkcommented, Apr 12, 2018

Actually never mind, after reading this issue again I figured out what’s going on. It seems like the issue is just that the object-property-newline rule doesn’t check object destructuring.

There is already an issue about this (https://github.com/eslint/eslint/issues/9259), so I’m going to close this issue in favor of that one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

object-curly-newline - 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 >
eslint object-curly-newline conflicts prettier multi-line rationale
I'm new in prettier + typescript + eslint. Most of the integration works fine but multi-line in destructure object is not. Prettier 1.19.1 ......
Read more >
Destructuring assignment - JavaScript - MDN Web Docs
The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from ...
Read more >
Code Issues - Embold Help Center
In this block, the logger level is expected to be as "error". This is a good list describing the log levels : 1....
Read more >
Code style for JS6 destructured object lacks settings in ...
I can't even fix it manually, as I'm too used to reformat the code every now and then and I can't always remember...
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