Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

internalError: Error running rule requirePaddingNewLineAfterVariableDeclaration #2250

@Arcanemagus

Description

@Arcanemagus

When running jscs v3.0.3 against this file:

foo.js:

let foo = false;
function bar($foobar) {}

With this configuration:

.jshintrc:

{
  "disallowUnusedParams": true,
  "requirePaddingNewLineAfterVariableDeclaration": true
}

I get the following error in the output:

internalError: Error running rule requirePaddingNewLineAfterVariableDeclaration: This is an issue with JSCS and not your codebase.
Please file an issue (with the stack trace below) at: https://github.com/jscs-dev/node-jscs/issues/new
TypeError: elements.map is not a function
    at Array.<anonymous> (C:\Temp\github\linter-jscs_GH249\node_modules\cst\src\plugins\scopes\ScopesApi.js:56:22)
    at Program._emit (C:\Temp\github\linter-jscs_GH249\node_modules\cst\src\elements\types\Program.js:107:17)
    at Program._addElementsToProgram (C:\Temp\github\linter-jscs_GH249\node_modules\cst\src\elements\types\Program.js:79:14)
    at Program.replaceChildren (C:\Temp\github\linter-jscs_GH249\node_modules\cst\src\elements\Element.js:518:26)
    at Program.replaceChild (C:\Temp\github\linter-jscs_GH249\node_modules\cst\src\elements\Element.js:571:14)
    at Object.JsFile.setWhitespaceBefore (C:\Temp\github\linter-jscs_GH249\node_modules\jscs\lib\js-file.js:110:37)
    at TokenAssert._updateWhitespaceByLine (C:\Temp\github\linter-jscs_GH249\node_modules\jscs\lib\token-assert.js:174:16)
    at TokenAssert._augmentLineCount (C:\Temp\github\linter-jscs_GH249\node_modules\jscs\lib\token-assert.js:364:10)
    at TokenAssert.<anonymous> (C:\Temp\github\linter-jscs_GH249\node_modules\jscs\lib\token-assert.js:284:18)
    at TokenAssert.linesBetween (C:\Temp\github\linter-jscs_GH249\node_modules\jscs\lib\token-assert.js:296:9)

It seems the issue with requirePaddingNewLineAfterVariableDeclaration is causing the code issue reported by disallowUnusedParams to be reported on the wrong line:
image

A folder with a minimal reproduction case is included here: linter-jscs_GH249-1.zip

If there is any further information you need just let me know.

Note that this was initially filed here.

Activity

Arcanemagus

Arcanemagus commented on May 16, 2016

@Arcanemagus
Author

There is also a bug with the following:
.jscsrc:

{
  "disallowPaddingNewlinesInBlocks": true,
  "requirePaddingNewLineAfterVariableDeclaration": true
}

foo.js:

let foo = 42;
function bar() {

  let foobar = 42;
}

I'm assuming that the root cause is the same as this one since it requires the requirePaddingNewLineAfterVariableDeclaration rule as well, but if you want this filed as a separate bug just let me know.

markelog

markelog commented on May 17, 2016

@markelog
Member

Duplicate of #2244

added a commit that references this issue on May 17, 2016
cbf974c
added a commit that references this issue on May 18, 2016
3dfeb1b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @Arcanemagus@markelog

      Issue actions

        internalError: Error running rule requirePaddingNewLineAfterVariableDeclaration · Issue #2250 · jscs-dev/node-jscs