Linter class is a low-level API for verifying JavaScript code. Unlike the ESLint class, Linter does not handle file I/O or configuration file loading. It works directly with code strings and configuration objects.
Constructor
Configuration options for the Linter instance.
Static Properties
Linter.version
The ESLint version string.
Instance Methods
verify()
Verifies text against the specified rules.The JavaScript code to verify, or a SourceCode object.
The configuration object or array of configuration objects.
The filename or options object.
Array of lint messages.
verifyAndFix()
Performs multiple autofix passes over the text.The source text to apply fixes to.
The ESLint config object or array.
The filename or options object.
getSourceCode()
Gets the SourceCode object from the last verification.The SourceCode object from the last
verify() call, or null.getSuppressedMessages()
Gets suppressed messages from the last verification.Array of messages that were suppressed by directives.
getTimes()
Gets timing information from the last verification (when stats are enabled).getFixPassCount()
Gets the number of autofix passes made in the last run.The number of autofix passes.
hasFlag()
Checks if a feature flag is enabled.The feature flag name to check.
true if the flag is enabled, false otherwise.Examples
- Basic Verification
- Auto-fixing
- With Filename
- Custom CWD
Differences from ESLint Class
TheLinter class differs from the ESLint class in several ways:
Use
Linter when you need fine-grained control and already have the code and configuration in memory. Use ESLint for a complete linting workflow with file handling.