@@ -36,33 +36,34 @@ const DEFAULT_CONFIG = {
36
36
} ;
37
37
38
38
export function findConfiguration ( configFile : string , inputFileLocation : string ) : any {
39
- if ( configFile ) {
40
- return JSON . parse ( fs . readFileSync ( configFile , "utf8" ) ) ;
41
- }
42
-
43
- // first look for package.json from input file location
44
- configFile = findup ( "package.json" , { cwd : inputFileLocation , nocase : true } ) ;
39
+ if ( configFile == null ) {
40
+ // first look for package.json from input file location
41
+ configFile = findup ( "package.json" , { cwd : inputFileLocation , nocase : true } ) ;
45
42
46
- if ( configFile ) {
47
- const content = require ( configFile ) ;
43
+ if ( configFile ) {
44
+ const content = require ( configFile ) ;
48
45
49
- if ( content . tslintConfig ) {
50
- return content . tslintConfig ;
46
+ if ( content . tslintConfig ) {
47
+ return content . tslintConfig ;
48
+ }
51
49
}
52
- }
53
50
54
- // next look for tslint.json
55
- const homeDir = getHomeDir ( ) ;
56
- if ( ! homeDir ) {
57
- return undefined ;
58
- }
51
+ // next look for tslint.json
52
+ const homeDir = getHomeDir ( ) ;
53
+ if ( ! homeDir ) {
54
+ return undefined ;
55
+ }
59
56
60
- const defaultPath = path . join ( homeDir , CONFIG_FILENAME ) ;
57
+ const defaultPath = path . join ( homeDir , CONFIG_FILENAME ) ;
61
58
62
- configFile = findup ( CONFIG_FILENAME , { cwd : inputFileLocation , nocase : true } ) || defaultPath ;
59
+ configFile = findup ( CONFIG_FILENAME , { cwd : inputFileLocation , nocase : true } ) || defaultPath ;
60
+ }
63
61
64
62
if ( fs . existsSync ( configFile ) ) {
65
- return JSON . parse ( fs . readFileSync ( configFile , "utf8" ) ) ;
63
+ let fileData = fs . readFileSync ( configFile , "utf8" ) ;
64
+ // remove BOM if present
65
+ fileData = fileData . replace ( / ^ \uFEFF / , "" ) ;
66
+ return JSON . parse ( fileData ) ;
66
67
} else {
67
68
return DEFAULT_CONFIG ;
68
69
}
0 commit comments