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
Ctrl
+Shift
+M
. - 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.
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
*_INVALID_NAME
and*_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 addvar
beforehand orlocal
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.5.0+) standalone/all JAR from Maven Central or the GitHub releases. Alternatively, build it yourself using these instructions to get the bleeding-edge. 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 (Ctrl
+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 inJAVA_HOME
orPATH
environment variables.cflint.jarPath
: A path to the CFLint standalone JAR file (CFLint-*-all.jar
).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.
Propertiescflint.runModes.onOpen
: Run linter whenever a CFML file is opened. [Default:true
]cflint.runModes.onSave
: Run linter whenever a CFML file is saved. [Default:true
]cflint.runModes.onChange
: Run linter whenever a CFML file is changed. (Not recommended) [Default:false
]
cflint.altConfigFile.path
: [Optional] The path to an alternate rule configuration file.cflint.altConfigFile.usage
: Usage of the rule config file fromcflint.altConfigFile.path
.
Valuesfallback
: 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 whencflint.runModes.onChange
is true. [Default:700
]cflint.linterCooldown
: The minimum number of milliseconds to wait between running the linter on a document. [Default:5000
]cflint.maxSimultaneousLints
: The maximum number of simultaneously running lints. Any exceeding this number will be queued. [Default:3
]cflint.ignoreInfo
: Whether to ignore issues with Info severity as problems. [Default:false
]cflint.ignoreWarnings
: Whether to ignore issues with Warning severity as problems. [Default:false
]cflint.notify.latestVersion
: Whether to notify when there is a newer version available. [Default:true
]
Used in Command Palette (Ctrl
+Shift
+P
). Alternatively, can be bound to Keyboard Shortcuts (Ctrl
+K
Ctrl
+S
).
-
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.5.0) often misreports issue location.
- Investigate useful menu items.
- Investigate where extension performance may be able to be improved (e.g. with Promises, Cancellation Tokens, or Language Server).
See CHANGELOG.md
See CONTRIBUTING.md
For questions or help, join the #ide
channel in the CFML Slack workspace to talk with people about this or other editor tools. To file a bug or feature request, open a GitHub issue.