mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-03-30 13:43:26 +08:00
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.
This commit is contained in:
@@ -5,20 +5,24 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
let data = '';
|
let data = '';
|
||||||
process.stdin.on('data', c => data += c);
|
process.stdin.on('data', c => (data += c));
|
||||||
process.stdin.on('end', () => {
|
process.stdin.on('end', () => {
|
||||||
try {
|
try {
|
||||||
const input = JSON.parse(data);
|
const input = JSON.parse(data);
|
||||||
const filePath = input.tool_input?.file_path || '';
|
const filePath = input.tool_input?.file_path || '';
|
||||||
|
|
||||||
if (/\.(md|txt)$/.test(filePath) &&
|
if (
|
||||||
!/(README|CLAUDE|AGENTS|CONTRIBUTING|CHANGELOG|LICENSE|SKILL)\.md$/i.test(filePath) &&
|
/\.(md|txt)$/.test(filePath) &&
|
||||||
!/\.claude[\/\\]plans[\/\\]/.test(filePath) &&
|
!/(README|CLAUDE|AGENTS|CONTRIBUTING|CHANGELOG|LICENSE|SKILL)\.md$/i.test(filePath) &&
|
||||||
!/(^|[\/\\])(docs|skills|\.history)[\/\\]/.test(filePath)) {
|
!/\.claude[/\\]plans[/\\]/.test(filePath) &&
|
||||||
|
!/(^|[/\\])(docs|skills|\.history)[/\\]/.test(filePath)
|
||||||
|
) {
|
||||||
console.error('[Hook] WARNING: Non-standard documentation file detected');
|
console.error('[Hook] WARNING: Non-standard documentation file detected');
|
||||||
console.error('[Hook] File: ' + filePath);
|
console.error('[Hook] File: ' + filePath);
|
||||||
console.error('[Hook] Consider consolidating into README.md or docs/ directory');
|
console.error('[Hook] Consider consolidating into README.md or docs/ directory');
|
||||||
}
|
}
|
||||||
} catch { /* ignore parse errors */ }
|
} catch {
|
||||||
|
/* ignore parse errors */
|
||||||
|
}
|
||||||
console.log(data);
|
console.log(data);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -165,10 +165,7 @@ function getPackageJsonDeps(projectDir) {
|
|||||||
const pkgPath = path.join(projectDir, 'package.json');
|
const pkgPath = path.join(projectDir, 'package.json');
|
||||||
if (!fs.existsSync(pkgPath)) return [];
|
if (!fs.existsSync(pkgPath)) return [];
|
||||||
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
||||||
return [
|
return [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.devDependencies || {})];
|
||||||
...Object.keys(pkg.dependencies || {}),
|
|
||||||
...Object.keys(pkg.devDependencies || {})
|
|
||||||
];
|
|
||||||
} catch {
|
} catch {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@@ -190,12 +187,17 @@ function getPythonDeps(projectDir) {
|
|||||||
content.split('\n').forEach(line => {
|
content.split('\n').forEach(line => {
|
||||||
const trimmed = line.trim();
|
const trimmed = line.trim();
|
||||||
if (trimmed && !trimmed.startsWith('#') && !trimmed.startsWith('-')) {
|
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);
|
if (name) deps.push(name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch { /* ignore */ }
|
} catch {
|
||||||
|
/* ignore */
|
||||||
|
}
|
||||||
|
|
||||||
// pyproject.toml — simple extraction of dependency names
|
// pyproject.toml — simple extraction of dependency names
|
||||||
try {
|
try {
|
||||||
@@ -206,12 +208,18 @@ function getPythonDeps(projectDir) {
|
|||||||
if (depMatches) {
|
if (depMatches) {
|
||||||
const block = depMatches[1];
|
const block = depMatches[1];
|
||||||
block.match(/"([^"]+)"/g)?.forEach(m => {
|
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);
|
if (name) deps.push(name);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch { /* ignore */ }
|
} catch {
|
||||||
|
/* ignore */
|
||||||
|
}
|
||||||
|
|
||||||
return deps;
|
return deps;
|
||||||
}
|
}
|
||||||
@@ -282,10 +290,7 @@ function getComposerDeps(projectDir) {
|
|||||||
const composerPath = path.join(projectDir, 'composer.json');
|
const composerPath = path.join(projectDir, 'composer.json');
|
||||||
if (!fs.existsSync(composerPath)) return [];
|
if (!fs.existsSync(composerPath)) return [];
|
||||||
const composer = JSON.parse(fs.readFileSync(composerPath, 'utf8'));
|
const composer = JSON.parse(fs.readFileSync(composerPath, 'utf8'));
|
||||||
return [
|
return [...Object.keys(composer.require || {}), ...Object.keys(composer['require-dev'] || {})];
|
||||||
...Object.keys(composer.require || {}),
|
|
||||||
...Object.keys(composer['require-dev'] || {})
|
|
||||||
];
|
|
||||||
} catch {
|
} catch {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@@ -355,17 +360,27 @@ function detectProjectType(projectDir) {
|
|||||||
if (rule.packageKeys.length > 0) {
|
if (rule.packageKeys.length > 0) {
|
||||||
let depList = [];
|
let depList = [];
|
||||||
switch (rule.language) {
|
switch (rule.language) {
|
||||||
case 'python': depList = pyDeps; break;
|
case 'python':
|
||||||
|
depList = pyDeps;
|
||||||
|
break;
|
||||||
case 'typescript':
|
case 'typescript':
|
||||||
case 'javascript': depList = npmDeps; break;
|
case 'javascript':
|
||||||
case 'golang': depList = goDeps; break;
|
depList = npmDeps;
|
||||||
case 'rust': depList = rustDeps; break;
|
break;
|
||||||
case 'php': depList = composerDeps; break;
|
case 'golang':
|
||||||
case 'elixir': depList = elixirDeps; break;
|
depList = goDeps;
|
||||||
|
break;
|
||||||
|
case 'rust':
|
||||||
|
depList = rustDeps;
|
||||||
|
break;
|
||||||
|
case 'php':
|
||||||
|
depList = composerDeps;
|
||||||
|
break;
|
||||||
|
case 'elixir':
|
||||||
|
depList = elixirDeps;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
hasDep = rule.packageKeys.some(key =>
|
hasDep = rule.packageKeys.some(key => depList.some(dep => dep.toLowerCase().includes(key.toLowerCase())));
|
||||||
depList.some(dep => dep.toLowerCase().includes(key.toLowerCase()))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasMarker || hasDep) {
|
if (hasMarker || hasDep) {
|
||||||
|
|||||||
Reference in New Issue
Block a user