The BrighterScript compiler emits errors and warnings when it encounters potentially invalid code. Errors and warnings may also be emitted by compiler plugins, such as by the BrighterScript linter.
Developers may want to suppress some of these messages. There are two ways to do so.
There are three bsconfig.json settings which modify the reporting of compiler messages: diagnosticFilters, diagnosticLevel, and diagnosticSeverityOverride.
diagnosticFilters allows users to ignore specific errors and specific file paths. It is useful for targetted suppression of errors.
diagnosticLevel allows users to toggle the level of diagnostics which they wish to see. For example, it allows one to hide all warnings and only show errors.
diagnosticSeverityOverride allows users to manually change the severity of a diagnostic, such as setting a particular kind of error to instead by reported as a warning or vice versa. This works in conjunction with the other two options.
In addition to modifying errors using bsconfig.json, you may also disable errors for a subset of the complier rules within a file with the following comment flags:
bs:disable-next-linebs:disable-next-line: code1 code2 code3bs:disable-linebs:disable-line: code1 code2 code3
Here are some examples:
sub Main()
'disable errors about invalid syntax here
'bs:disable-next-line
DoSomething(
DoSomething( 'bs:disable-line
'disable errors about wrong parameter count
DoSomething(1,2,3) 'bs:disable-line
DoSomething(1,2,3) 'bs:disable-line:1002
end sub
sub DoSomething()
end subThe primary motivation for this feature was to provide a stopgap measure to hide incorrectly-thrown errors on legitimate BrightScript code due to parser bugs. It is recommended that you only use these comments when absolutely necessary.
Use bs:disable and bs:enable to suppress diagnostics for a span of code. A bs:disable opens a suppression block, and a matching bs:enable closes it. If no bs:enable follows, the block runs to the end of the file, so a bare bs:disable at the top of a file suppresses the whole file.
bs:disable: suppress all diagnostics from this line until the nextbs:enablebs:disable: code1 code2 code3: suppress only the listed codesbs:enable: close any openbs:disableblockbs:enable: code1 code2 code3: re-enable specific codes from an openbs:disable
' bs:disable: 1001 1002
sub Main()
DoSomething()
end sub<?xml version="1.0" encoding="utf-8" ?>
<!-- bs:disable: 1006 -->
<component name="Foo">
</component>bs:enable: <code> after a bare bs:disable re-enables one diagnostic while keeping the rest suppressed:
' bs:disable
' 1006 is still suppressed below, but 1001 reports normally
' bs:enable: 1001
sub Main()
DoSomething()
end subThe BrighterScript language server offers two quick-fix actions on every diagnostic so you can suppress the message without leaving your editor:
- Disable {code} for this line: {message}: if a
bs:disable-lineorbs:disable-next-linedirective already exists on or above the diagnostic line, the code is appended to it. Otherwise a newbs:disable-next-line: {code}comment is inserted above the diagnostic. - Disable {code} for this file: {message}: if a header-level
bs:disabledirective already exists, the code is appended to it. Otherwise a newbs:disable: {code}comment is inserted at the top of the file.
These actions appear after the standard quick fixes for a diagnostic.