VS Code CFLint
CFLint is a linter for CFML and you can find more information at its GitHub repository. This extension integrates CFLint into VS Code.
This extension uses the CFLint tool to scan CFML files and provide feedback on potential issues through the editor and Problems view of VS Code. The ways in which this is triggered are configurable in the Settings. The defaults are only to run when CFML files are opened or saved. The linter optionally takes rule configuration via a
.cflintrc file, for which details can be found at CFLint's repo. This extension facilitates the creation and viewing of this file via Commands. It also facilitates editing the file by utilizing the schema.
Here is an example from the CFDocs project using CFLint v1.4.1 with no rule configuration on VS Code v1.28.
- The status bar item for Problems. Indicates number of Error, Warning, and Info issues reported, respectively. Clicking it will bring up the Problems view. Alternatively, you can use
- The Problems view. Grouped by file, ordered by severity, line number, column number. Clicking the problem will focus the issue in the editor.
[Quick Fixes] [Severity icon] [Provider] [Issue Message] [Issue ID] (line number, column number)
- Highlights within the editor. Hovering reveals the message.
- Filter issues in Problems view.
Code Actions / Quick Fixes
These are potential resolutions that are provided for each diagnostic. Aside from the rule changes in the settings file, these are largely dependent on the location given by CFLint. See Known Issues/Limitations
- Ignoring rules in settings file: For all rules, this code action is available and when executed will update the
.cflintrc file that applies to the document within which the diagnostic is triggered.
- Transforming variable case: For the
*_ALLCAPS_NAME rules, a code action will be offered based on the case preference set.
- var/local scoping: For the rule
MISSING_VAR, two code actions are offered to either add
var beforehand or
local as the scope.
See Commands below.
You must first install CFLint. You may skip the steps below if you already have them.
- Download and install latest Java SE 8+ JRE, or JDK if you plan to build it yourself.
- Download latest CFLint (v1.4.0+) standalone/all JAR from Maven Central or the GitHub releases. Alternatively, build it yourself using these instructions. This is the JAR file that will be provided to
cflint.jarPath in the settings.
Requires an extension that contributes the language since linting is only done for particular language IDs. The recommended one is KamasamaK.vscode-cfml.
The following are the configurable Settings (
Comma) that this extension contributes to VS Code:
cflint.enabled: Enable/disable this extension.
cflint.javaPath: [Optional] Path to Java executable. Unnecessary if compatible Java path is defined in
PATH environment variables.
cflint.jarPath: A path to the CFLint standalone JAR file (
cflint.outputDirectory: A directory in which to place output files when invoking one of the output commands.
cflint.exclude: Glob patterns for excluding files and folders. The pattern is based on the workspace folder being the root.
cflint.runModes: Determines when linter is run.
cflint.runModes.onOpen: Run linter whenever a CFML file is opened. [Default:
cflint.runModes.onSave: Run linter whenever a CFML file is saved. [Default:
cflint.runModes.onChange: Run linter whenever a CFML file is changed. (Not recommended) [Default:
cflint.altConfigFile.path: [Optional] The path to an alternate rule configuration file.
cflint.altConfigFile.usage: Usage of the rule config file from
fallback: Use only if no rule config is found for document being linted. [Default]
always: Always use.
cflint.typingDelay: The number of milliseconds to wait for typing to stop until linting. Only valid when
cflint.runModes.onChange is true. [Default:
cflint.linterCooldown: The minimum number of milliseconds to wait between running the linter on a document. [Default:
cflint.maxSimultaneousLints: The maximum number of simultaneously running lints. Any exceeding this number will be queued. [Default:
cflint.ignoreInfo: Whether to ignore issues with Info severity as problems. [Default:
cflint.ignoreWarnings: Whether to ignore issues with Warning severity as problems. [Default:
cflint.notify.latestVersion: Whether to notify when there is a newer version available. [Default:
Used in Command Palette (
P). Alternatively, can be bound to Keyboard Shortcuts (
Enable CFLint for this workspace
Disable CFLint for this workspace
Manually run CFLint on currently active file
Create '.cflintrc' file in the root of the current working directory
Open '.cflintrc' file in the root of the current working directory
Create '.cflintrc' file in the current working directory
Open '.cflintrc' file for currently active document
Clear CFLint problems for active document
Clear all CFLint problems
View CFLint rules documentation (online)
Output CFLint text file for currently active document
Output CFLint HTML file for currently active document
Output CFLint JSON file for currently active document
Output CFLint XML file for currently active document
Note: The output commands above have CFLint produce the reports directly, so some extension settings are not considered.
- Not an issue with the extension itself, but be aware that CFLint is a heavy/slow application compared to most linters, especially when used through the command line. Some things are done with the extension to account for this.
- As of this writing, CFLint (v1.4.1) often misreports issue location.
- Investigate using CFLint NPM wrapper as a default with optional manual installation. Currently not using an up-to-date version.
- Investigate useful menu items.
- Investigate where extension performance may be able to be improved (e.g. with Promises, Cancellation Tokens, or Language Server).