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.

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(); })
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.
npm install brslint
yarn add brslint
pnpm add brslint

Shows how to create a Linter instance, configure it with custom rules, and lint individual files or directories.

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);