Code Monkey home page Code Monkey logo

wist's Introduction

Wist

Node version Npm version Npm downloads Travis branch

Website | Configuring | Rules | Contributing | Reporting Bugs | Code of Conduct

Wist is a linter for identifying and reporting errors found in Brightscript code. It helps you identify errors before you upload code to your Roku.

For full documentation, please see our user and developer guides here

How does it compare to other tools?

Wist has one of the most accurate and complete implementations of the Brightscript grammar available right now. It focuses reporting not just syntax violations, but reporting patterns that are likely to result in errors.

Questions?

Join us in the #tooling channel on the Roku Developers Slack.

Requirements

  • NodeJS

  • (Optional) JDK8

Clients

The easiest and best way to use Wist, is through our editor clients.

You can install them through their respective package managers and work out of the box with a .wistrc.json included in your root directory.

Standalone installation

We recommend taking this approach if you if you want to include Wist as part of your project's build pipeline. Wist is available via as an NPM package and can be installed like so:

$ npm install -g @willowtreeapps/wist

It can be invoked directly using the wist command

$ wist yourfile.brs

Wist can also be installed locally to the project

$ npm install @willowtreeapps/wist --save-dev

After that, you can run Wist in your project's root directory like this:

$ ./node_modules/.bin/wist yourfile.brs

Usage

wist [options] file.brs [file.brs] [dir]

Basic configuration:
  -i, --init           Initialize Wist
  -c, --config String  Use specified configuration file
  -f, --format String  Output format - either: compact, json, stylish, unix, or visualstudio - default: stylish
  -v, --verbose        Verbose logging
  -h, --help           Show help

To get started linting your Brightscript project, you should then setup a wist configuration file:

$ wist --init

This will generate a .wistrc.json file in your directory. In it, you'll see some rules configured like this:

{
    "rules": {
        "no-stop": ["error"],
        "no-print": ["warn"]
    }
}

These configures the sort of errors that the rules engine reports back. There are several other rules that can be configured. See the documentation for the full list.

Once your .wistrc.json has been configured to your liking. Invoke wist on your Brightscript file.

$ wist yourfile.brs

Wist format (experimental)

Wist format or wist-fmt is an opinionated code formatter built into Wist. It works by traversing your codes abstract syntax tree and reprinting it with the appropriate whitespace after. wist-fmt can be run in a pre-commit hook, or in your CI environments to ensure your codebase has a consistent code style.

Usage: wist-fmt [options] [file.brs]

  -i, --indent Int  Number of tokens to indent
  --use-tabs        Indent with tabs
  -h, --help        Show help
  -v, --version     Show version information

You can invoke the formatter in the terminal using the wist-fmt command.

wist-fmt yourfile.brs

You can specify the number of spaces used to indent your code using the -i flag.

wist-fmt -i 2 yourfile.brs

Contributing to Wist

Contributions are welcome. Please see the Contributing guidelines.

Wist has adopted a Code of Conduct defined by the Contributor Covenant. Please see our Code of Conduct as well as our Contributing Guidelines for more information.

FAQ

  1. How do I run wist on directory or path?

    You can use the directory syntax to pass a pattern. For example, if I wanted lint all the *.brs files in my sources directory, I can do so with this command.

    $ wist source/*.brs
    
  2. Wist takes a really long time on large projects

    The reason for this is because Wist currently doesn't run lints in parallel. A work around for this would be to run multiple intances of wist in parallel. For example,

    $ find source/ -name *.brs | xargs -P 8 wist
    
  3. How do I install the latest development version

    You can do this through npm. Please note that while the latest development version might have bug fixes and enhancements, it's not guaranteed to be stable until release.

    You have to first uninstall the current version of Wist you have installed

    $ npm uninstall -g @willowtreeapps/wist
    

    Then install from the git repository using,

    $ npm install -g git+https://github.com/willowtreeapps/wist.git
    

    You can also install a version based on a specific commit

    $ npm install -g git+https://github.com/willowtreeapps/wist.git#[commit hash]
    

    For example,

    $ npm install -g git+https://github.com/willowtreeapps/wist.git#de1e2b6
    

License

   Copyright 2018 WillowTree Inc.

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

wist's People

Contributors

cazacutudor avatar cdthompson avatar cschandler avatar darrennolan avatar kconner avatar nishtahir avatar pbrown719 avatar samuelmaddock avatar vannuysm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wist's Issues

Incorrect reporting of some errors

For each of the following two cases, an error is incorrectly reported as

Parsing error: mismatched input 'sub' expecting <EOF>
  1. sub with non-void return
sub dostuff() as Object
end sub
  1. print followed with elements separated by comma
sub dostuff()
  print "Restarting app", appStoreID
end sub

Add rule: Avoid declaring argument types

Description:

Use 'As Dynamic' or omit parameter types to avoid runtime "Type Mismatch" exceptions. Specifying explicit types requires parameter type validation at the caller, which is more verbose than checking within the function and also prone to omission.

Explanation:

This is a pattern adopted after encountering many runtime errors. Because BRS type coercion is incosistent, (example: invalid is ok for Object but not for Integer), we avoid type declarations in function definitions and resort to manual type checks where needed.

Add rule: limited "dot" chaining

At some point, chaining objects with the . operator becomes dangerous and prone to runtime errors due to an intermedia object being invalid.

It'd be nice to warn against some threshold of chained operations, such as:

if m.object.child.child.child.field = true
...

Rationalize licensing

We need to make sure that we are giving proper attribution for ESLint in the spots where we have forked their code. The same goes for any other code that we've pulled from other repos.

Ability to add exceptions to generic rules

My application has the

"no-private-func": [ "error" ],

Rule enabled which is causing linting error when including third party libraries. I wanted to see if there is an option to add an exception to the generic rule.

Parse error on inline array definitions

The following valid syntax causes a parse error in wist

sub main()
  for each i in [1,2,3]
    print i
  end for
end sub

if the array is defined before the block, wist will parse it ok.

RFC: Rules

This is an open RFC to define what our initial set of default rules should be. Please comment below and I will aggregate them into a list here.

Best Practices

  • no-print: warn : Disallow print statements
  • no-stop: warn : Disallow stop statements
  • function-return-statement: error : Require return statements for functions
  • function-return-type: warn : Require return type for functions

Possible Errors

  • no-private-func: warn : Disallow calls to private functions outside of current script scope
  • no-unused-vars: warn : Disallow unused variables (including function parameters)

Style Issues

  • no-void-func: warn : Disallow void functions
  • no-shorthand-if: warn : Disallow shorthand if statements
  • comma-separated-arrays: warn : Require array/associative array entries to be comma separated
  • no-comma-separated-arrays: warn : Disallow array/associative array entries from being comma separated
  • no-inferred-types: warn : Disallow type inference for variables
  • camel-case-functions: warn : Require functions to conform to camel case

Parse error on dangling dot operator

Dangling dot operators are valid syntax and the roku interpreter ends up ignoring the final dot. I dislike the language behavior here but it does run as valid syntax. Would be nice to have wist successfully parse this but also have a rule to warn against it since it almost surely was not intended by the developer.

Example behavior from the console

Brightscript Debugger> print m
<Component: roAssociativeArray> =
{
}

Brightscript Debugger> m.foo. = "hi"

Brightscript Debugger> print m
<Component: roAssociativeArray> =
{
    foo: "hi"
}

Brightscript Debugger> m.bar = "bye"

Brightscript Debugger> a = m.bar.

Brightscript Debugger> print a
bye

Brightscript Debugger> 

Add rule for trailing commas

We should add a new rule for trailing commas?

Reference eslint implementation
https://eslint.org/docs/rules/comma-dangle

For example, the following function

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

would warn about the trailing comma , in the code block.

stop keyword warning

Original issue: willowtreeapps/brs-lang#41

'stop' is currently considered a parser error but should probably be a warning for users so they don't accidentally ship code with 'stop' keywords in them since that would halt script execution.

Trailing comma in array is mis-reported

sub whatever()
  m.constants = {
    test: [
        "pkg:/images/1.png",
        "pkg:/images/2.png",
    ]
  }
end sub

produces : 7:0 error Parsing error: mismatched input 'sub' expecting <EOF>

Add minimum firmware version

We could leverage wist to find or enforce minimum firmware versions, something which is required for Roku app submission. The Roku SDK docs are pretty good at documenting which version recent features were introduced. They could be put into a rule or set of rules in order to verify.

Grammar does not recover correctly on parse error

Normally, when the ANTLR runtime encounters a parse error, it attempts to recover by removing tokens from the token stream until it finds a token that satisfies the current or enclosing context.

However, in our case, it seems that Wist is unable to recover from a parse error because it makes the assumption that the enclosing scope is always a componentContext or componentHeadContext. These are always followed by EOF which means that the runtime will continue to remove tokens from the stream until the end of the file.

It seems that the solution is to remove the component rule as well as the componentBody rule from componentHeadElement.

-c flag does not work

Using the '-c' flag always gives an "Invalid path to configuration file." error. It looks like handleConfiguration is being passed an object rather than a string argument.

Shortened If Statement crashes Wist

The shortened version of an 'If' statement causes Wist to crash.

Sample Code:

Sub Main(args As Dynamic)
    ' Check for Something
    if not myFunctionThatChecksSomething() return
End Sub

Call Stack Trace:

Cannot read property 'start' of undefined
TypeError: Cannot read property 'start' of undefined
    at checkThen (/Users/joffa/node_modules/@willowtreeapps/wist/lib/rules/no-shorthand-if.js:17:47)
    at Linter.ifSingleLineStatement:enter (/Users/joffa/node_modules/@willowtreeapps/wist/lib/rules/no-shorthand-if.js:25:17)
    at Linter.emit (events.js:182:13)
    at BrightScriptEventListener.enterIfSingleLineStatement (/Users/joffa/node_modules/@willowtreeapps/wist/parser/BrightScriptEventGenerator.js:84:22)
    at IfSingleLineStatementContext.enterRule (/Users/joffa/node_modules/@willowtreeapps/wist/parser/antlr/BrightScriptParser.js:4263:18)
    at ParseTreeWalker.enterRule (/Users/joffa/node_modules/antlr4/tree/Tree.js:207:6)
    at ParseTreeWalker.walk (/Users/joffa/node_modules/antlr4/tree/Tree.js:190:8)
    at ParseTreeWalker.walk (/Users/joffa/node_modules/antlr4/tree/Tree.js:193:9)
    at ParseTreeWalker.walk (/Users/joffa/node_modules/antlr4/tree/Tree.js:193:9)
    at ParseTreeWalker.walk (/Users/joffa/node_modules/antlr4/tree/Tree.js:193:9)

Parse error when using trailing comma on arrays

The following example returns a parsing error because of the trailing comma:

someArray = [
  1,
  2,
  3,
]

Here is the error:

[wist] Parsing error: no viable alternative at input 'subinit()\nsomeArray=[\n1,\n2,\n3,\n]'

The following example runs fine:

someArray = [
  1,
  2,
  3
]

Add rule: no boolean type coersion

boolean type coersion is inconsistent. A rule to detect this would be helpful.

Motivation:

Brightscript Debugger> a = invalid

Brightscript Debugger> if a: print "hi": end if
Type Mismatch. (runtime error &h18) in $LIVECOMPILE(8)

Brightscript Debugger> a = "true"

Brightscript Debugger> if a: print "hi": end if
Type Mismatch. (runtime error &h18) in $LIVECOMPILE(10)

Brightscript Debugger> a = true

Brightscript Debugger> if a: print "hi": end if
hi

Brightscript Debugger> a = 1

Brightscript Debugger> if a: print "hi": end if
hi

Improved style allows for invalid without crashes (though string vs. boolean still crashes)

Brightscript Debugger> a = invalid

Brightscript Debugger> if a = true: print "hi": end if

Brightscript Debugger> a = "true"

Brightscript Debugger> if a = true: print "hi": end if
Type Mismatch. (runtime error &h18) in $LIVECOMPILE(18)

Brightscript Debugger> a = 1

Brightscript Debugger> if a = true: print "hi": end if
hi

Code formatting

I think we can take advantage of wist's abstract syntax tree to implement a code formatting tool. This is currently on track to merge with the experimental WASM parser. The general specification that I have in mind right now is as follows.

Indentation

  • The default indentation should be 4 spaces
  • Logical blocks including function, sub, if, else if, while, etc... should increase indentation level
function myFunction()
    ' increase indent
    a  = 10
end function

Whitespace

The code formatter should manage whitespace before and after tokens in the tree. For example,

  • There should not be whitespace before ., ,, (, ),:, [ and ]
  • There should not be whitespace after ., }, (, [
vars["sample"] = test.doSomething("some string") 

Array and Associative array definitions should be placed on new lines with an increased indent inside the block.

val = [
    "foo",
    "bar",
    "baz"
]

Comments

  • The content of comments should be preserved and written back unaltered
  • Comments within a block should respect the current indentation level
' comment at 0 indent
function foo()
    'comment at 1 indent
    bar = 0
end function

A single Error cascades and triggers numerous alerts

In my file I had a "print" statement with a quoted string followed by a comma and a var (line 153):
print "something", something_else

this generated an appropriate error, however the rest of the file then generated a bunch of errors:

  153:24  error    Parsing error: mismatched input ',' expecting {COMMENT, NEWLINE, ':'}
  161:40  error    Parsing error: mismatched input 'as' expecting {COMMENT, NEWLINE, ':'}
  162:2   error    Parsing error: extraneous input 'overrides' expecting {<EOF>, FUNCTION, SUB, COMMENT, NEWLINE}
  165:2   error    Parsing error: extraneous input 'if' expecting {FUNCTION, SUB, COMMENT, NEWLINE}
  166:4   error    Parsing error: extraneous input 'overrides' expecting {FUNCTION, SUB, COMMENT, NEWLINE}
  167:2   error    Parsing error: extraneous input 'end' expecting {FUNCTION, SUB, COMMENT, NEWLINE}
  169:2   error    Parsing error: extraneous input 'if' expecting {FUNCTION, SUB, COMMENT, NEWLINE}
  170:4   error    Parsing error: extraneous input 'overrides' expecting {FUNCTION, SUB, COMMENT, NEWLINE}
  171:2   error    Parsing error: extraneous input 'end' expecting {FUNCTION, SUB, COMMENT, NEWLINE}
  173:2   error    Parsing error: extraneous input 'if' expecting {FUNCTION, SUB, COMMENT, NEWLINE}
  174:4   error    Parsing error: extraneous input 'overrides' expecting {FUNCTION, SUB, COMMENT, NEWLINE}
  175:2   error    Parsing error: extraneous input 'end' expecting {FUNCTION, SUB, COMMENT, NEWLINE}
  177:2   error    Parsing error: extraneous input 'print' expecting {FUNCTION, SUB, COMMENT, NEWLINE}
  179:2   error    Parsing error: extraneous input 'return' expecting {FUNCTION, SUB, COMMENT, NEWLINE}
  180:0   error    Parsing error: extraneous input 'end' expecting {FUNCTION, SUB, COMMENT, NEWLINE}
  180:7   error    Parsing error: missing IDENTIFIER at '\n'
  181:0   error    Parsing error: extraneous input '<EOF>' expecting {BOX, CREATEOBJECT, DIM, END, ENDSUB, EXIT, EXITWHILE, EVAL, FALSE, FOR, GETGLOBALAA, GETLASTRUNCOMPILEERROR, GETLASTRUNRUNTIMEERROR, GOTO, IF, INVALID, NEXT, NOT, PRINT, RETURN, RUN, STOP, STRING, TAB, TRUE, TYPE, WHILE, STRING_LITERAL, INT_LITERAL, FLOAT_LITERAL, IDENTIFIER, COMMENT, NEWLINE, CONDITIONAL_CONST, CONDITIONAL_ERROR, CONDITIONAL_IF, '?', '(', ':', '+', '-'}

Performance?

Running wist on my 2013 Macbook, it takes ~14s for wist to lint a 200-line BRS file. This is a lot longer than I expected but I don't have much experience with antlr.

Does this seem in line with performance you guys are seeing? If not, any hints on where I should start to isolate bottlenecks?

wist source/*.brs doesn't work on Windows

The error:

Error: ENOENT: no such file or directory, open 'C:\Git_work\Roku-Sample-App\source\*.brs'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.readFileSync (fs.js:551:33)
    at processFile (C:\Users\eg874k\AppData\Roaming\npm\node_modules\@willowtreeapps\wist\src\js\cli-engine.js:64:21)
    at executeOnFile (C:\Users\eg874k\AppData\Roaming\npm\node_modules\@willowtreeapps\wist\src\js\cli-engine.js:89:28)
    at patterns.forEach.filename (C:\Users\eg874k\AppData\Roaming\npm\node_modules\@willowtreeapps\wist\src\js\cli-engine.js:94:13)
    at Array.forEach (<anonymous>)
    at CLIEngine.executeOnFiles (C:\Users\eg874k\AppData\Roaming\npm\node_modules\@willowtreeapps\wist\src\js\cli-engine.js:93:18)
    at Object.execute (C:\Users\eg874k\AppData\Roaming\npm\node_modules\@willowtreeapps\wist\src\js\cli.js:61:35)
    at Object.<anonymous> (C:\Users\eg874k\AppData\Roaming\npm\node_modules\@willowtreeapps\wist\bin\wist.js:13:24)
    at Module._compile (module.js:635:30)

It's works fine on single file

Add unit tests

We need unit tests.

  • Add AVA to project
  • Add unit test guidelines
  • Add tests

wist init error

Running wist --init returns

Invalid path to configuration file.

Allow an inline code way to override rules

Something like a comment-based format to override rules.
Maybe ' bslint "rule-name": "severity"

As an example to turn off the rule no-print you would add the following comment:
' bslint "no-print": "off"

String has UTF-16 code units that do not fit in 8 bits

When wist encounters a character not in the supported character encoding, it completely bombs. It would be nice if wist would be able to recover a bit more gracefully, perhaps add a specific error message about that token.

Here's the sample brightscript file (note the question mark character at the end of the print statement).

sub PrintError()
    print "request failed �"
end sub

When I run this command: wist PrintError.brs, it fails with this output.

C:\Users\MY_USER_NAME\AppData\Roaming\nvm\v10.11.0\node_modules@willowtreeapps\wist\dist\libwist.js:1
(function (exports, require, module, __filename, __dirname) { var Module=typeof Module!=="undefined"?Module:{};var Module={"locateFile":(function(url){const path=require("path");return path.resolve(_dirname)+"/"+url})};var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}Module["arguments"]=[];Module["thisProgram"]="./this.program";Module["quit"]=(function(status,toThrow){throw toThrow});Module["preRun"]=[];Module["postRun"]=[];var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;if(Module["ENVIRONMENT"]){if(Module["ENVIRONMENT"]==="WEB"){ENVIRONMENT_IS_WEB=true}else if(Module["ENVIRONMENT"]==="WORKER"){ENVIRONMENT_IS_WORKER=true}else if(Module["ENVIRONMENT"]==="NODE"){ENVIRONMENT_IS_NODE=true}else if(Module["ENVIRONMENT"]==="SHELL"){ENVIRONMENT_IS_SHELL=true}else{throw new Error("
BindingError: String has UTF-16 code units that do not fit in 8 bits
at BindingError. (C:\Users\MY_USER_NAME\AppData\Roaming\nvm\v10.11.0\node_modules@willowtreeapps\wist\dist\libwist.js:1:102871)
at new BindingError (eval at createNamedFunction (C:\Users\MY_USER_NAME\AppData\Roaming\nvm\v10.11.0\node_modules@willowtreeapps\wist\dist\libwist.js:1:102577), :4:34)
at throwBindingError (C:\Users\MY_USER_NAME\AppData\Roaming\nvm\v10.11.0\node_modules@willowtreeapps\wist\dist\libwist.js:1:106396)
at Object.toWireType (C:\Users\MY_USER_NAME\AppData\Roaming\nvm\v10.11.0\node_modules@willowtreeapps\wist\dist\libwist.js:1:135594)
at Object.parseText (eval at new
(C:\Users\MY_USER_NAME\AppData\Roaming\nvm\v10.11.0\node_modules@willowtreeapps\wist\dist\libwist.js:1:125751), :7:26)
at Linter.verify (C:\Users\MY_USER_NAME\AppData\Roaming\nvm\v10.11.0\node_modules@willowtreeapps\wist\src\js\linter.js:141:36)
at processText (C:\Users\MY_USER_NAME\AppData\Roaming\nvm\v10.11.0\node_modules@willowtreeapps\wist\src\js\cli-engine.js:49:23)
at processFile (C:\Users\MY_USER_NAME\AppData\Roaming\nvm\v10.11.0\node_modules@willowtreeapps\wist\src\js\cli-engine.js:65:18)
at executeOnFile (C:\Users\MY_USER_NAME\AppData\Roaming\nvm\v10.11.0\node_modules@willowtreeapps\wist\src\js\cli-engine.js:89:28)
at patterns.forEach.filename (C:\Users\MY_USER_NAME\AppData\Roaming\nvm\v10.11.0\node_modules@willowtreeapps\wist\src\js\cli-engine.js:94:13)

Add rule: use ";" to concatenate print strings

When constructing console strings from non-string objects, avoid '+' operator which requires objects to be converted to strings first, where many approaches are susceptible to crashes.

Null object issues with no-private-func rule

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

Best way to programmatically use wist

Hey,

I'm looking for some guidance on the best way to programmatically use wist. I've got some gulp tasks setup for building and deploying. I'd like to have another task that's used to lint code before that happens.

I can use exec however that seems a little dirty when the code is all JavaScript. Any ideas or best practice?

Thanks!

Add documentation

  • User's Guide
    • Configuration
    • CLI
    • Rules
  • Developer's Guide
    • Getting Started
    • Create rules
    • API documentation
    • Contributing
    • Architecture
  • About
    • History
    • Philosophy
    • Contributors

Performance

Running wist on my 2013 Macbook, it takes ~14s for wist to lint a 200-line BRS file. This is a lot longer than I expected but I don't have much experience with antlr.

Does this seem in line with performance you guys are seeing? If not, any hints on where I should start to isolate bottlenecks?

Add support for `bslint --init`

BSLint should generate a .bslintrc.json file in the cwd where bslint --init is executed. The config would include a set of recommended rules, with a secondary command line parameter that allows an override to a file path with a different set of default rules to use for initialization.

Unexpected error report when comments included in array with trailing comma

sub Main()
  showChannelSGScreen()
  test = {
    ' will this report a strange error?
    myarray: [
      "something",
      "something_else",
    ]
  }
end sub
RectangleExample/source/main.brs
   8:6  error  Parsing error: mismatched input '"something"' expecting <EOF>
  10:4  error  Parsing error: no viable alternative at input '={\r\n' will this report a strange error?\r\nmyarray:[\r\n"something",\r\n"something_else",\r\n]'
  10:4  error  Parsing error: no viable alternative at input '[\r\n"something",\r\n"something_else",\r\n]

Parse error on inline array definitions

Sample to reproduce.

Function com_rostreamer_screen_CreateBaseScreen()
    imageCanvas.SetLayer(0, { color : "#000000" }) ' fails here
    return imageCanvas
End Function

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.