(bufferContents)
| 92 | }; |
| 93 | |
| 94 | export const isJSON = (bufferContents) => { |
| 95 | const isSavedFile = ORIGINAL_FILE_PATH !== '?'; |
| 96 | const useEditorFileSyntaxForDeterminingFileType = EDITOR_FILE_SYNTAX !== '?'; |
| 97 | |
| 98 | const isAllowedExtension = hasAllowedFileExtension('json', ORIGINAL_FILE_PATH); |
| 99 | const isAllowedSyntax = hasAllowedFileSyntax('json', EDITOR_FILE_SYNTAX); |
| 100 | const isDisallowedFilePattern = hasDisallowedFilePathPattern('json', ORIGINAL_FILE_PATH); |
| 101 | const isMaybeJson = bufferContents.match(/^\s*[{[]/); |
| 102 | |
| 103 | if (!isSavedFile) { |
| 104 | return useEditorFileSyntaxForDeterminingFileType |
| 105 | ? isAllowedSyntax || isMaybeJson |
| 106 | : isMaybeJson; |
| 107 | } |
| 108 | |
| 109 | if (isDisallowedFilePattern) { |
| 110 | return false; |
| 111 | } |
| 112 | |
| 113 | return useEditorFileSyntaxForDeterminingFileType |
| 114 | ? isAllowedSyntax || isAllowedExtension |
| 115 | : isAllowedExtension; |
| 116 | }; |
| 117 | |
| 118 | export const isJS = (bufferContents) => { |
| 119 | const isSavedFile = ORIGINAL_FILE_PATH !== '?'; |
nothing calls this directly
no test coverage detected