File tree 2 files changed +11
-10
lines changed
2 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -21,13 +21,13 @@ module Lint.Configuration {
21
21
22
22
var CONFIG_FILENAME = "tslint.json" ;
23
23
24
- export function findConfiguration ( configFile : string ) : any {
24
+ export function findConfiguration ( configFile : string , inputFileLocation : string ) : any {
25
25
if ( configFile ) {
26
26
return JSON . parse ( fs . readFileSync ( configFile , "utf8" ) ) ;
27
27
}
28
28
29
- // First look for package.json
30
- configFile = findup ( "package.json" , { nocase : true } ) ;
29
+ // First look for package.json from input file location
30
+ configFile = findup ( "package.json" , { cwd : inputFileLocation , nocase : true } ) ;
31
31
32
32
if ( configFile ) {
33
33
var content = require ( configFile ) ;
@@ -46,7 +46,7 @@ module Lint.Configuration {
46
46
47
47
var defaultPath = path . join ( homeDir , CONFIG_FILENAME ) ;
48
48
49
- configFile = findup ( CONFIG_FILENAME , { nocase : true } ) || defaultPath ;
49
+ configFile = findup ( CONFIG_FILENAME , { cwd : inputFileLocation , nocase : true } ) || defaultPath ;
50
50
51
51
return configFile ? JSON . parse ( fs . readFileSync ( configFile , "utf8" ) ) : undefined ;
52
52
}
Original file line number Diff line number Diff line change @@ -136,26 +136,27 @@ if ("help" in argv) {
136
136
process . exit ( 0 ) ;
137
137
}
138
138
139
- var configuration = Lint . Configuration . findConfiguration ( argv . c ) ;
140
- if ( configuration === undefined ) {
141
- console . error ( "unable to find tslint configuration" ) ;
142
- process . exit ( 1 ) ;
143
- }
144
-
145
139
if ( ! fs . existsSync ( argv . f ) ) {
146
140
console . error ( "Unable to open file: " + argv . f ) ;
147
141
process . exit ( 1 ) ;
148
142
}
149
143
150
144
var processFile = ( file : string ) => {
151
145
var contents = fs . readFileSync ( file , "utf8" ) ;
146
+ var configuration = Lint . Configuration . findConfiguration ( argv . c , file ) ;
147
+
148
+ if ( configuration === undefined ) {
149
+ console . error ( "unable to find tslint configuration" ) ;
150
+ process . exit ( 1 ) ;
151
+ }
152
152
153
153
var linter = new Lint . Linter ( file , contents , {
154
154
configuration : configuration ,
155
155
formatter : argv . t ,
156
156
rulesDirectory : argv . r ,
157
157
formattersDirectory : argv . s
158
158
} ) ;
159
+
159
160
var lintResult = linter . lint ( ) ;
160
161
161
162
if ( lintResult . failureCount > 0 ) {
You can’t perform that action at this time.
0 commit comments