Skip to content

Commit fd07925

Browse files
committed
Docs: Clarify docs for api.verify (fixes #5101, fixes #5104)
1 parent 1803f87 commit fd07925

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

docs/developer-guide/nodejs-api.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,12 @@ var linter = require("eslint").linter;
6060
The most important method on `linter` is `verify()`, which initiates linting of the given text. This method accepts four arguments:
6161

6262
* `code` - the source code to lint (a string or instance of `SourceCode`).
63-
* `config` - a configuration object.
64-
* `options` - (optional) Additional options for this run.
63+
* `config` - a configuration object that is equivalent to an eslintrc file.
64+
* `optionsOrFilename` - (optional) Additional options for this run or a string representing the filename to associate with the code being linted.
6565
* `filename` - (optional) the filename to associate with the source code.
66-
* `saveState` - (optional) set to true to maintain the internal state of `linter` after linting (mostly used for testing purposes).
66+
* `saveState` - (optional) see below. This will override any value passed as the fourth argument if an options object is used here instead of the filename.
6767
* `allowInlineConfig` - (optional) set to `false` to disable inline comments from changing eslint rules.
68+
* `saveState` - (optional) set to true to maintain the internal state of `linter` after linting (mostly used for testing purposes)
6869

6970
You can call `verify()` like this:
7071

lib/eslint.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,10 +641,21 @@ module.exports = (function() {
641641
sourceCode = null;
642642
};
643643

644+
/**
645+
* Configuration object for the `verify` API. A JS representation of the eslintrc files.
646+
* @typedef {Object} ESLintConfig
647+
* @param {Object} rules The rule configuration to verify against.
648+
* @param {string} [parser] Parser to use when generatig the AST.
649+
* @param {Object} [parserOptions] Options for the parsed used.
650+
* @param {Object} [settings] Global settings passed to each rule.
651+
* @param {Object} [env] The environment to verify in.
652+
* @param {Object} [globals] Available globalsto the code.
653+
*/
654+
644655
/**
645656
* Verifies the text against the rules specified by the second argument.
646657
* @param {string|SourceCode} textOrSourceCode The text to parse or a SourceCode object.
647-
* @param {Object} config An object whose keys specify the rules to use.
658+
* @param {ESLintConfig} config An object whose keys specify the rules to use.
648659
* @param {(string|Object)} [filenameOrOptions] The optional filename of the file being checked.
649660
* If this is not set, the filename will default to '<input>' in the rule context. If
650661
* an object, then it has "filename", "saveState", and "allowInlineConfig" properties.

0 commit comments

Comments
 (0)