Bslint
A linter for BrightScript and BrighterScript.
Install / Use
/learn @rokucommunity/BslintREADME
bslint - BrighterScript Lint
brighterscript is a Roku BrightScript compiler featuring many diagnostics out of the box: syntax check, function calls validation, script imports verification...
bslint is:
- a CLI tool to lint your code without compiling your project,
- a
brighterscriptplugin offering additional insights on your code.
Installation
You need Node 10+ and npm or yarn:
# if you don't have a package.json
npm init -y
# install modules
npm install brighterscript @rokucommunity/bslint
Important: add the plugin to your bsconfig.json file in the root of your project,
or create a minimal bsconfig.json like that:
{
"plugins": [ "@rokucommunity/bslint" ]
}
Otherwise, you will only see issues coming from the brighterscript compiler.
Command line interface (CLI)
The bslint command will run the BrighterScript compiler without publishing
step, only outputing the diagnostics.
Note: the CLI can be used without adding the bslint plugin; you will only
get the default brighterscript diagnostics.
npx bslint --help
# lint with default options
npx bslint
# lint and fix basic code-style issues (see below)
npx bslint --fix
# lint and attempt to identify unused components and scripts (see below)
npx bslint --checkUsage
or add a npm script in package.json, e.g.:
{
...
"scripts": {
"lint": "bslint"
}
...
}
and call npm run lint.
Plugin configuration
bslint can be configured using a bslint.json file in the root of your project.
Note: bslint.json is not the same file as bsconfig.json!
{
"rules": {},
"globals": [],
"ignores": []
}
Where each value is optional:
rules: see belowglobals: a list of tokens which should always be considered as safe (ex._brs_)ignores: a list of files or globs of files to omit from linting
If you are using brighterscript with the Visual Studio Code plugin, you might want to mention your configuration file in brighterscript's bsconfig.json as follow:
{
"plugins": [ "@rokucommunity/bslint" ],
"lintConfig": "path/to/bslint.json"
}
Ignores
Unlike brighterscripts's diagnosticFilter which hides issues, bslint will completely
skip ignored files when running the extra linting rules.
Note: it won't remove issues reported by the compiler itself!
Format should follow "glob search" rules, as implemented in minimatch module.
Examples:
"lib/**/*": ignore everything under anylibfolder,"**/lib/**/*": same with explicit initial wildcard (added automatically if missing)"specific-script.brs": ignore specific file name"*.test.brs": partial match of file name
Rules
Linting rules can be set in a bslint.json file in the root of your project.
Rules are organised in 3 categories:
- "Code style": how the code should look like for consistency
- "Strictness": requirement to ensure code safety
- "Code flow": tracks the code flow to identify risky patterns
Default rules:
{
"rules": {
"inline-if-style": "then",
"block-if-style": "no-then",
"condition-style": "no-group",
"named-function-style": "auto",
"anon-function-style": "auto",
"aa-comma-style": "no-dangling",
"no-print": "off",
"no-todo": "off",
"todo-pattern": "TODO|todo|FIXME",
"no-stop": "warn",
"eol-last": "always",
"type-annotations": "off",
"color-format": "off",
"color-case": "off",
"color-alpha": "off",
"color-alpha-defaults": "off",
"color-cert": "off",
"assign-all-paths": "error",
"unsafe-path-loop": "error",
"unsafe-iterators": "error",
"unreachable-code": "info",
"case-sensitivity": "warn",
"unused-variable": "warn",
"unused-parameter": "warn",
"consistent-return": "error",
"no-assocarray-component-field-type": "off",
"no-array-component-field-type": "off",
"no-regex-duplicates": "off"
}
}
Code style rules
-
inline-if-style: validation of inlineif/thenstatements.never: do not allow,no-then: do not usethenkeywordthen: always usethenkeyword (default)off: do not validate
-
block-if-style: validation of regular blockif/thenstatements.no-then: do not usethenkeyword (default)then: always usethenkeywordoff: do not validate
-
condition-style: validation ofif/whilestatements conditions: should the condition be wrapped around parenthesis?no-group: do not wrap with parenthesis (default)group: always wrap with parenthesesoff: do not validate
-
named-function-style,anon-function-style: validation of function style (function/sub)no-function: always usesubno-sub: always usefunctionauto: usesubforVoidfunctions, otherwise usefunction(default)off: no not validate
-
aa-comma-style: validation of commas in Associative Array (AA) literalsalways: enforce the presence of commas, alwaysno-dangling: enforce the presence of commas but don't leave one dangling (default)never: enforce that optional commas aren't usedoff: do not validate
-
no-print: prevent usage ofprintstatements in code (error | warn | info | off) -
no-todo: prevent usage oftodocomments in code (error | warn | info | off) -
todo-pattern: string regex pattern to determine what a TODO is. default isTODO|todo|FIXME(do not include surrounding/characters). -
no-stop: prevent usage ofSTOPstatements in the code (error | warn | info | off) -
eol-last: enforces at least one newline (or absence thereof) at the end of non-empty filesalways: enforces that files end with a newline (default)neverenforces that files do not end with a newlineoff: do not validate
-
color-format: ensures that all the color values follow the same prefix formatting. Can also use to prevent any colors values from being defined in the code-base (brs or bs files), except for values in a stand-alone file (ie. theme file).hash-hex: enforces all color values are type string or template string and use a#prefixquoted-numeric-hex: enforces all color values are type string or template string and use a0xprefixnever: enforces that no color values can be defined in the code-base (brs or bs files). Useful if you define colors in a separate stand-alone file. To use this option you would list your stand-alone file in theignorelist ordiagnosticFilters.off: do not validate (default)
-
color-case: ensures that all color values follow the same case. Requires thatcolor-formatis set tohash-hexorquoted-numeric-hex.lower: enforces all color values that are type string or template string and all lowercase. ie.#11bbddupper: enforces all color values that are type string or template string and all uppercase. ie.#EEAA44off: do not validate (default)
-
color-alpha: defines the usage of the color alpha value. ie.#xxxxxxFF. Requires thatcolor-formatis set tohash-hexorquoted-numeric-hex.always: enforces all color values that are type string or template string define an alpha valueallowed: allows color values that are type string or template string to define an alpha valuenever: enforces that none of the color values that are type string or template string define an alpha valueoff: do not validate (default)
-
color-alpha-defaults: enforces default color-alpha values. ie.#xxxxxxFFor#xxxxxx00. Requires thatcolor-alphais not set tooffandcolor-formatis set tohash-hexorquoted-numeric-hex.allowed: allows both types of defaults to be usedonly-hidden: only allows opacity 0% (hidden) from being usednever: enforces that no defaults can be usedoff: do not validate (default)
-
color-cert: enforces Roku's broadcast safe color 6.4 certification requirement. Requires thatcolor-formatis set tohash-hexorquoted-numeric-hex.always: ensures all white and black color-format values either match or are darker/ lighter than the minimum recommended values. For white the maximum value is#EBEBEBand for black the minimum value is#161616off: do not validate (default)
-
no-assocarray-component-field-type: Using 'assocarray' type in component markup can result in inefficient copying of data during transfer to the render thread. Use 'n
Related Skills
node-connect
337.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
337.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.2kCommit, push, and open a PR
