Skip to content

Commit 9bbdbf2

Browse files
committed
docs: add docs for standard.lintTextSync()
1 parent e618256 commit 9bbdbf2

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

README.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -610,20 +610,26 @@ Yes!
610610

611611
### `standard.lintText(text, [opts], callback)`
612612

613-
Lint the provided source `text` to enforce JavaScript Standard Style. An `opts` object may
614-
be provided:
613+
Lint the provided source `text`. An `opts` object may be provided:
615614

616615
```js
617-
var opts = {
616+
{
617+
cwd: '', // current working directory (default: process.cwd())
618+
filename: '', // path of the file containing the text being linted (optional, though some eslint plugins require it)
618619
fix: false, // automatically fix problems
619-
globals: [], // global variables to declare
620-
plugins: [], // eslint plugins
621-
envs: [], // eslint environment
622-
parser: '' // js parser (e.g. babel-eslint)
620+
globals: [], // custom global variables to declare
621+
plugins: [], // custom eslint plugins
622+
envs: [], // custom eslint environment
623+
parser: '' // custom js parser (e.g. babel-eslint)
623624
}
624625
```
625626

626-
The `callback` will be called with an `Error` and `results` object:
627+
Additional options may be loaded from a `package.json` if it's found for the
628+
current working directory.
629+
630+
The `callback` will be called with an `Error` and `results` object.
631+
632+
The `results` object will contain the following properties:
627633

628634
```js
629635
var results = {
@@ -634,14 +640,20 @@ var results = {
634640
{ ruleId: '', message: '', line: 0, column: 0 }
635641
],
636642
errorCount: 0,
637-
warningCount: 0
643+
warningCount: 0,
644+
output: '' // fixed source code (only present with {fix: true} option)
638645
}
639646
],
640647
errorCount: 0,
641648
warningCount: 0
642649
}
643650
```
644651

652+
### `results = standard.lintTextSync(text, [opts])`
653+
654+
Synchronous version of `standard.lintText()`. If an error occurs, an exception is
655+
thrown. Otherwise, a `results` object is returned.
656+
645657
### `standard.lintFiles(files, [opts], callback)`
646658

647659
Lint the provided `files` globs. An `opts` object may be provided:

0 commit comments

Comments
 (0)