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.

newline-after-var: false negative if semicolon is moved to a new line

See original GitHub issue

Tell us about your environment

  • ESLint Version: 3.13.1
  • Node Version: 7.4.0
  • npm Version: 4.1.1

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

Please show your full configuration:

{
  "rules": {
    "newline-after-var": "error",
    "no-extra-semi": "error",
    "semi-spacing": "error",
    "semi": "error"
  }
}


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

import angular from 'angular';
import homeComponent from './home.component';
import uiRouter from 'angular-ui-router';

const homeModule = angular
  .module('home', [
    uiRouter,
  ])

  .component('home', homeComponent)
;

export default homeModule.name;

What did you expect to happen? newline-after-var should not report error

What actually happened? Please include the actual, raw output from ESLint. 5:1 error Expected blank line after variable declarations newline-after-var

The problem is the semicolon moved to the new line: if semicolon is in the line that starts with .component( the rule does not report error.

No other rule reports error in this case including 3 semicolon-related ones I noticed in configuration section (my config is much bigger than the 4 rules I mentioned but other rules does not affect the case).

The reason semicolon is moved to a new line is purely VCS-related. I don’t want my diff to show that line starting with .component( was changed if any other chained method is added (which in this case means: if other mart of angular the module is added)

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
venikxcommented, Jan 18, 2017

@platinumazure Thank you! Favorited ASTExplorer! Learning every day through open source ^^ pretty new around Js!

0reactions
jrenczcommented, Jan 18, 2017

@platinumazure thank you for checking that.

@not-an-aardvark can you think of how to preserve the behaviour you mentioned yet to be able to cover may case?

Read more comments on GitHub >

github_iconTop Results From Across the Web

newline-after-var - 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 >
Split string with commas to new line - javascript - Stack Overflow
With the built in split and join methods var formattedString = yourString.split(",").join("\n"). If you'd like the newlines to be HTML line ...
Read more >
declaration-block-semicolon-newline-after - Stylelint
Require a newline or disallow whitespace after the semicolons of declaration blocks. This rule ignores: semicolons that are preceded by Less mixins.
Read more >
config.txt
Default: auto newlines = auto # lf/crlf/cr/auto # The original size of tabs in ... space after the final semicolon of an empty...
Read more >
C Basics - C Programming Tutorial
Each of the following lines is a programming statement, which ends with a semi-colon (;) int number1 = 10; int number2, number3 =...
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