-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjs-lint.js
More file actions
98 lines (81 loc) · 2.68 KB
/
js-lint.js
File metadata and controls
98 lines (81 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env node
/**
* JavaScript/TypeScript Lint Command
*
* Run linter for JavaScript/TypeScript projects
*/
const JSCommandRunner = require('../javascript/javascript-command-runner-refactored');
async function main() {
try {
const projectPath = process.cwd();
const runner = new JSCommandRunner(projectPath);
// Parse command line arguments
const args = process.argv.slice(2);
const options = {};
// Parse options
const parsedArgs = [];
for (let i = 0; i < args.length; i++) {
const arg = args[i];
if (arg === '--fix' || arg === '-f') {
options.fix = true;
parsedArgs.push('--fix');
} else if (arg === '--quiet' || arg === '-q') {
options.quiet = true;
parsedArgs.push('--quiet');
} else if (arg === '--format' || arg === '-F') {
options.format = 'stylish';
parsedArgs.push('--format', 'stylish');
} else if (arg === '--help' || arg === '-h') {
showHelp();
return;
} else {
parsedArgs.push(arg);
}
}
// Initialize and run linter
await runner.initialize();
await runner.lint(parsedArgs, options);
} catch (error) {
console.error('\n❌ Linting failed:', error.message);
// Show additional help for common errors
if (error.message.includes('not configured') || error.message.includes('not found')) {
console.log('\n💡 Try running /js-setup first to configure your project.');
console.log('💡 Or install ESLint: npm install --save-dev eslint');
}
process.exit(1);
}
}
function showHelp() {
console.log(`
🔍 JavaScript/TypeScript Lint Command
Usage: /js-lint [options] [files...]
Options:
--fix, -f Automatically fix problems
--quiet, -q Report errors only
--format, -F Use specific output format (default: stylish)
--help, -h Show this help message
Examples:
/js-lint # Lint all files
/js-lint --fix # Lint and fix automatically
/js-lint src/ # Lint specific directory
/js-lint file1.js file2.js # Lint specific files
/js-lint -f -q # Fix quietly
Supported Linters:
• ESLint (default)
• Other linters via npm scripts
Configuration:
Run /js-setup first to configure your project.
Create .eslintrc.js for custom ESLint configuration.
Add lint script to package.json for custom setup.
Common ESLint Extensions:
• @typescript-eslint/eslint-plugin - TypeScript support
• eslint-plugin-react - React support
• eslint-plugin-vue - Vue.js support
• eslint-config-prettier - Prettier integration
`);
}
// Run if called directly
if (require.main === module) {
main();
}
module.exports = main;