Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

Null object issues with no-private-func rule #64

Closed
loopyDeveloper opened this issue Feb 7, 2018 · 2 comments
Closed

Null object issues with no-private-func rule #64

loopyDeveloper opened this issue Feb 7, 2018 · 2 comments

Comments

@loopyDeveloper
Copy link

Issue with node.children being null when using "no-private-func" rule.

let openParen = node.children[1];

Cannot read property '1' of null
TypeError: Cannot read property '1' of null
    at isFunctionInvocation (/usr/local/lib/node_modules/@willowtreeapps/wist/lib/rules/no-private-func.js:11:42)
    at Linter.expression:exit (/usr/local/lib/node_modules/@willowtreeapps/wist/lib/rules/no-private-func.js:37:22)
    at emitOne (events.js:96:13)
    at Linter.emit (events.js:191:7)
    at BrightScriptEventListener.exitExpression (/usr/local/lib/node_modules/@willowtreeapps/wist/parser/BrightScriptEventGenerator.js:261:22)
    at ExpressionContext.exitRule (/usr/local/lib/node_modules/@willowtreeapps/wist/parser/antlr/BrightScriptParser.js:5439:18)
    at ParseTreeWalker.exitRule (/usr/local/lib/node_modules/antlr4/tree/Tree.js:212:6)
    at ParseTreeWalker.walk (/usr/local/lib/node_modules/antlr4/tree/Tree.js:195:8)
    at ParseTreeWalker.walk (/usr/local/lib/node_modules/antlr4/tree/Tree.js:193:9)
    at ParseTreeWalker.walk (/usr/local/lib/node_modules/antlr4/tree/Tree.js:193:9)

Sample File:

function sampleFunction() as object
    if GetGlobalAA().user = invalid then
        user = {
            _name : "",
        }
        GetGlobalAA()["user"] = user
    end if
    return invalid
end function

The dangling comma in _name : "",

Maybe we can add new rules for trailing commas?
https://eslint.org/docs/rules/comma-dangle

@nishtahir
Copy link
Member

I'm working on a fix for this in #66. I've also opened a new ticket #65 to address the trailing comma rule separately.

@nishtahir
Copy link
Member

This issue has been addressed in #66

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

No branches or pull requests

2 participants