MCPcopy Create free account
hub / github.com/Silentely/eSIM-Tools / shouldFormat

Function shouldFormat

scripts/pre-commit-check.js:80–88  ·  view source on GitHub ↗

* Determine whether a file should be normalized (text formatting enforced) based on its path. * @param {string} relPath - File path relative to the repository root. * @returns {boolean} `true` if the file extension is in TEXT_EXTENSIONS or the basename is `.gitignore` or `.gitattributes`, `false`

(relPath)

Source from the content-addressed store, hash-verified

78 * @returns {boolean} `true` if the file extension is in TEXT_EXTENSIONS or the basename is `.gitignore` or `.gitattributes`, `false` otherwise.
79 */
80function shouldFormat(relPath) {
81 const ext = path.extname(relPath).toLowerCase();
82 if (TEXT_EXTENSIONS.has(ext)) {
83 return true;
84 }
85
86 const baseName = path.basename(relPath);
87 return baseName === '.gitignore' || baseName === '.gitattributes';
88}
89
90function normalizeText(content) {
91 let next = content.replace(/\r\n/g, '\n');

Callers 1

formatStagedFilesFunction · 0.85

Calls 1

hasMethod · 0.80

Tested by

no test coverage detected