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

internalError: Error running rule requirePaddingNewLineAfterVariableDeclaration #2250

Closed
Arcanemagus opened this issue May 16, 2016 · 2 comments · Fixed by #2252
Closed

internalError: Error running rule requirePaddingNewLineAfterVariableDeclaration #2250

Arcanemagus opened this issue May 16, 2016 · 2 comments · Fixed by #2252

Comments

@Arcanemagus
Copy link

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.

@Arcanemagus
Copy link
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 added the bug label May 17, 2016
@markelog
Copy link
Member

Duplicate of #2244

markelog added a commit to markelog/node-jscs that referenced this issue May 17, 2016
* Slightly changes token-assert API by providing result of the check
with return values

* Apply fixes only in fix mode

* Modify couple rules to adjust to new strategy

* Make "fixed" property of the Error instance consistent

* Introduce "fix" property of the Error class

* Divide fix behaviour on "common" and "specific" actions

Consequently should speed up linting

Fixes jscs-dev#2250
markelog added a commit that referenced this issue May 18, 2016
* Slightly changes token-assert API by providing result of the check
with return values

* Apply fixes only in fix mode

* Modify couple rules to adjust to new strategy

* Make "fixed" property of the Error instance consistent

* Introduce "fix" property of the Error class

* Divide fix behaviour on "common" and "specific" actions

Consequently should speed up linting

Fixes #2250
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants