brslint
raw JSON → 0.2.3 verified Fri May 01 auth: no javascript
Brslint is a parsing and linting tool for Roku's BrightScript language. The current stable version is 0.2.3, released as a maintenance update with support for try/throw/catch syntax from OS 9.4. It provides static analysis for BrightScript files, including validation of component XML files, customizable rules via brslint.config, and over 30 built-in rules. Unlike generic linters, it is purpose-built for BrightScript and integrates with Roku development workflows. Release cadence is irregular, with updates approximately every 2-6 months. Key differentiators: native support for BrightScript syntax, configurable rule sets, and XML component validation.
Common errors
error Error: Cannot find module 'nearley' ↓
cause Missing peer dependency nearley which is required for parsing.
fix
Install nearley: npm install nearley
error SyntaxError: Unexpected token (1:1) while parsing... ↓
cause Brslint does not support newer BrightScript syntax introduced after OS 9.4 (e.g., interfaces).
fix
Update brslint to a version that supports the syntax, or avoid using unsupported features.
error TypeError: Linter is not a constructor ↓
cause Attempting to use CommonJS require incorrectly with the ESM package.
fix
Use dynamic import: import('brslint').then(m => { const linter = new m.Linter(); })
Warnings
breaking In v0.2.0, the configuration format changed from inline JSON to brslint.config file; existing configs may not be compatible. ↓
fix Migrate to brslint.config format as described in the README.
deprecated The rule 'no_tab' is deprecated in v0.1.8; use 'indentation' instead. ↓
fix Replace 'no_tab' with 'indentation' in your rules configuration.
gotcha Brslint only lints *.brs files; other file extensions are ignored silently. ↓
fix Ensure your BrightScript files have the .brs extension.
gotcha When using a brslint.config file, all paths are relative to the config file's location, not the current working directory. ↓
fix Use paths relative to the config file directory.
Install
npm install brslint yarn add brslint pnpm add brslint Imports
- Linter wrong
const Linter = require('brslint');correctimport { Linter } from 'brslint'; - default wrong
const brslint = require('brslint').default;correctimport brslint from 'brslint'; - Rule wrong
import Rule from 'brslint';correctimport { Rule } from 'brslint';
Quickstart
import brslint from 'brslint';
const linter = new brslint.Linter();
// Configure rules
linter.config({
rules: {
include: ['no_empty_then', 'no_empty_else']
}
});
// Lint a file
const result = linter.lint('source/main.brs');
console.log(result.warnings);
// Or lint a directory
const dirResult = linter.lint('source/');
console.log(dirResult.warnings);