@@ -610,20 +610,26 @@ Yes!
610
610
611
611
### ` standard.lintText(text, [opts], callback) `
612
612
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:
615
614
616
615
``` 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)
618
619
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)
623
624
}
624
625
```
625
626
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:
627
633
628
634
``` js
629
635
var results = {
@@ -634,14 +640,20 @@ var results = {
634
640
{ ruleId: ' ' , message: ' ' , line: 0 , column: 0 }
635
641
],
636
642
errorCount: 0 ,
637
- warningCount: 0
643
+ warningCount: 0 ,
644
+ output: ' ' // fixed source code (only present with {fix: true} option)
638
645
}
639
646
],
640
647
errorCount: 0 ,
641
648
warningCount: 0
642
649
}
643
650
```
644
651
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
+
645
657
### ` standard.lintFiles(files, [opts], callback) `
646
658
647
659
Lint the provided ` files ` globs. An ` opts ` object may be provided:
0 commit comments