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

Function runChecks

scripts/pre-commit-check.js:158–187  ·  view source on GitHub ↗
(stagedFiles)

Source from the content-addressed store, hash-verified

156}
157
158function runChecks(stagedFiles) {
159 const failures = [];
160
161 for (const relPath of stagedFiles) {
162 const ext = path.extname(relPath).toLowerCase();
163 if (!JS_EXTENSIONS.has(ext) && ext !== '.json') {
164 continue;
165 }
166
167 const content = readStagedContent(relPath);
168 if (SMART_QUOTES_RE.test(content)) {
169 failures.push(
170 `${relPath}: 检测到智能引号(U+201C/U+201D/U+2018/U+2019),请改为标准半角引号。`
171 );
172 continue;
173 }
174
175 try {
176 if (JS_EXTENSIONS.has(ext)) {
177 checkJavaScriptSyntax(relPath, content);
178 } else if (ext === '.json') {
179 JSON.parse(content);
180 }
181 } catch (error) {
182 failures.push(`${relPath}: ${error.message}`);
183 }
184 }
185
186 return failures;
187}
188
189/**
190 * Run pre-commit validation and normalization for staged files, aborting the commit on violations.

Callers 1

mainFunction · 0.70

Calls 3

readStagedContentFunction · 0.85
checkJavaScriptSyntaxFunction · 0.85
hasMethod · 0.80

Tested by

no test coverage detected