MCPcopy
hub / github.com/victorporof/Sublime-HTMLPrettify / isJS

Function isJS

src/js/utils/fileUtils.js:118–140  ·  view source on GitHub ↗
(bufferContents)

Source from the content-addressed store, hash-verified

116};
117
118export const isJS = (bufferContents) => {
119 const isSavedFile = ORIGINAL_FILE_PATH !== '?';
120 const useEditorFileSyntaxForDeterminingFileType = EDITOR_FILE_SYNTAX !== '?';
121
122 const isAllowedExtension = hasAllowedFileExtension('js', ORIGINAL_FILE_PATH);
123 const isAllowedSyntax = hasAllowedFileSyntax('js', EDITOR_FILE_SYNTAX);
124 const isDisallowedFilePattern = hasDisallowedFilePathPattern('js', ORIGINAL_FILE_PATH);
125 const isMaybeJs = !bufferContents.match(/^\s*</);
126
127 if (!isSavedFile) {
128 return useEditorFileSyntaxForDeterminingFileType
129 ? isAllowedSyntax || isMaybeJs
130 : isMaybeJs;
131 }
132
133 if (isDisallowedFilePattern) {
134 return false;
135 }
136
137 return useEditorFileSyntaxForDeterminingFileType
138 ? isAllowedSyntax || isAllowedExtension
139 : isAllowedExtension;
140};
141
142// Checks if a file path matches a particular glob string.
143export const isMatchingGlob = (globString) => {

Callers

nothing calls this directly

Calls 3

hasAllowedFileExtensionFunction · 0.85
hasAllowedFileSyntaxFunction · 0.85

Tested by

no test coverage detected