Compare commits

...

3 Commits

Author SHA1 Message Date
Affaan Mustafa
9dc76fd27b Merge pull request #323 from pythonstrup/chore/add-prettierrc
chore: add .prettierrc and fix pre-existing lint errors
2026-03-03 07:56:15 -08:00
Jonghyeok Park
3260c7449e fix(lint): remove unnecessary escape characters in regex patterns
- doc-file-warning.js: \/ → / inside character classes (4 occurrences)
- project-detect.js: \[ → [ inside character classes (2 occurrences)

These are pre-existing no-useless-escape errors on upstream main.
2026-03-03 22:11:51 +09:00
Jonghyeok Park
66143eaf74 chore: add .prettierrc for consistent code formatting
The post-edit-format hook runs Prettier on JS/TS files after edits,
but without a project-level config it applied default settings (double
quotes, etc.) that conflicted with the existing code style. Adding
.prettierrc ensures the hook respects the project conventions.

Settings derived from existing codebase analysis:
- singleQuote: true
- trailingComma: none
- arrowParens: avoid
- printWidth: 200
2026-03-03 22:06:09 +09:00
3 changed files with 54 additions and 27 deletions

8
.prettierrc Normal file
View File

@@ -0,0 +1,8 @@
{
"singleQuote": true,
"trailingComma": "none",
"semi": true,
"tabWidth": 2,
"printWidth": 200,
"arrowParens": "avoid"
}

View File

@@ -5,20 +5,24 @@
*/
let data = '';
process.stdin.on('data', c => data += c);
process.stdin.on('data', c => (data += c));
process.stdin.on('end', () => {
try {
const input = JSON.parse(data);
const filePath = input.tool_input?.file_path || '';
if (/\.(md|txt)$/.test(filePath) &&
!/(README|CLAUDE|AGENTS|CONTRIBUTING|CHANGELOG|LICENSE|SKILL)\.md$/i.test(filePath) &&
!/\.claude[\/\\]plans[\/\\]/.test(filePath) &&
!/(^|[\/\\])(docs|skills|\.history)[\/\\]/.test(filePath)) {
if (
/\.(md|txt)$/.test(filePath) &&
!/(README|CLAUDE|AGENTS|CONTRIBUTING|CHANGELOG|LICENSE|SKILL)\.md$/i.test(filePath) &&
!/\.claude[/\\]plans[/\\]/.test(filePath) &&
!/(^|[/\\])(docs|skills|\.history)[/\\]/.test(filePath)
) {
console.error('[Hook] WARNING: Non-standard documentation file detected');
console.error('[Hook] File: ' + filePath);
console.error('[Hook] Consider consolidating into README.md or docs/ directory');
}
} catch { /* ignore parse errors */ }
} catch {
/* ignore parse errors */
}
console.log(data);
});

View File

@@ -165,10 +165,7 @@ function getPackageJsonDeps(projectDir) {
const pkgPath = path.join(projectDir, 'package.json');
if (!fs.existsSync(pkgPath)) return [];
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
return [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.devDependencies || {})
];
return [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.devDependencies || {})];
} catch {
return [];
}
@@ -190,12 +187,17 @@ function getPythonDeps(projectDir) {
content.split('\n').forEach(line => {
const trimmed = line.trim();
if (trimmed && !trimmed.startsWith('#') && !trimmed.startsWith('-')) {
const name = trimmed.split(/[>=<!\[;]/)[0].trim().toLowerCase();
const name = trimmed
.split(/[>=<![;]/)[0]
.trim()
.toLowerCase();
if (name) deps.push(name);
}
});
}
} catch { /* ignore */ }
} catch {
/* ignore */
}
// pyproject.toml — simple extraction of dependency names
try {
@@ -206,12 +208,18 @@ function getPythonDeps(projectDir) {
if (depMatches) {
const block = depMatches[1];
block.match(/"([^"]+)"/g)?.forEach(m => {
const name = m.replace(/"/g, '').split(/[>=<!\[;]/)[0].trim().toLowerCase();
const name = m
.replace(/"/g, '')
.split(/[>=<![;]/)[0]
.trim()
.toLowerCase();
if (name) deps.push(name);
});
}
}
} catch { /* ignore */ }
} catch {
/* ignore */
}
return deps;
}
@@ -282,10 +290,7 @@ function getComposerDeps(projectDir) {
const composerPath = path.join(projectDir, 'composer.json');
if (!fs.existsSync(composerPath)) return [];
const composer = JSON.parse(fs.readFileSync(composerPath, 'utf8'));
return [
...Object.keys(composer.require || {}),
...Object.keys(composer['require-dev'] || {})
];
return [...Object.keys(composer.require || {}), ...Object.keys(composer['require-dev'] || {})];
} catch {
return [];
}
@@ -355,17 +360,27 @@ function detectProjectType(projectDir) {
if (rule.packageKeys.length > 0) {
let depList = [];
switch (rule.language) {
case 'python': depList = pyDeps; break;
case 'python':
depList = pyDeps;
break;
case 'typescript':
case 'javascript': depList = npmDeps; break;
case 'golang': depList = goDeps; break;
case 'rust': depList = rustDeps; break;
case 'php': depList = composerDeps; break;
case 'elixir': depList = elixirDeps; break;
case 'javascript':
depList = npmDeps;
break;
case 'golang':
depList = goDeps;
break;
case 'rust':
depList = rustDeps;
break;
case 'php':
depList = composerDeps;
break;
case 'elixir':
depList = elixirDeps;
break;
}
hasDep = rule.packageKeys.some(key =>
depList.some(dep => dep.toLowerCase().includes(key.toLowerCase()))
);
hasDep = rule.packageKeys.some(key => depList.some(dep => dep.toLowerCase().includes(key.toLowerCase())));
}
if (hasMarker || hasDep) {