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.

one-var with --fix is adding multiple empty lines between var declarations on keeping on the same line

See original GitHub issue

Tell us about your environment

  • ESLint Version: v5.2.0

  • Node Version: 8.11.3

  • npm Version: 5.6.0

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

Please show your full configuration:

Configuration
{
  "env": {
    "browser": true
  },
  "extends": "eslint:recommended",
  "parserOptions": {
    "ecmaVersion": 5
  },
  "rules": {
    "indent": ["error", 2],
    "linebreak-style": ["error", "unix"],
    "quotes": ["error", "single"],
    "semi": ["error", "always"],
    "one-var": ["error", "never"]
  }
}

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

Input A

var a = 1, b = 2, c = 3;

Output A

var a = 1; var b = 2; var c = 3;

Input B

var a = 1, 
  b = 2, 
  c = 3;

Output B

var a = 1;
 
    
var b = 2;
 
    
var c = 3;
eslint --quiet --fix src/

What did you expect to happen? Do not include multiple lines between variables declaration

Expected output on both cases

var a = 1; 
var b = 2;
var c = 3;

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
carlos-algmscommented, Jan 30, 2019

This does feel like a bug rather than the intended behaviour. --fix shouldn’t do more than what the rule intends it to do

It is a bug when the fix cause more problems, like including useless empty lines between declarations. That is not acceptable on any style-guide.

3reactions
podkotcommented, Jan 30, 2019

reopen please, the current behavior is quite annoying when --fix is applied on a large legacy codebase

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-multiple-empty-lines - 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 >
How to add blank lines between definitions? - Stack Overflow
I want a blank line between definitions of structs/classes/functions and between declarations of functions. Currently, when formatting, clang- ...
Read more >
GNU make
A recipe may have more than one command, either on the same line or each ... We give the force target an empty...
Read more >
tslint-eslint-rules - npm Package Health Analysis | Snyk
Snyk scans all the packages in your projects for vulnerabilities and ... the same variable more than once (https://eslint.org/docs/rules/recommended).
Read more >
Rules - JavaScript Standard Style
Keep else statements on the same line as their curly braces. ... operator in a multi-line setting, place ? and : on their...
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