mirror of
https://github.com/Fission-AI/OpenSpec.git
synced 2026-10-02 05:24:34 +08:00
* fix(cli): use dynamic import for @inquirer/prompts in config command The config command (added in #382) reintroduced the pre-commit hook hang issue that was fixed in #380. The static import of @inquirer/prompts at module load time causes stdin event listeners to be registered even when running non-interactive commands, preventing clean process exit when stdin is piped (as pre-commit does). Convert the static import to a dynamic import that only loads inquirer when the `config reset` command is actually used interactively. Fixes #367 * chore: add ESLint with no-restricted-imports rule for @inquirer Add ESLint configuration that prevents static imports of @inquirer/* modules. This prevents future regressions of the pre-commit hook hang issue fixed in this PR. The rule shows a helpful error message pointing to issue #367 for context. init.ts is exempted since it's already dynamically imported from the CLI. * ci: add ESLint step to lint job Run `pnpm lint` in CI to enforce the no-restricted-imports rule that prevents static @inquirer imports.
43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
import tseslint from 'typescript-eslint';
|
|
|
|
export default tseslint.config(
|
|
{
|
|
files: ['src/**/*.ts'],
|
|
extends: [...tseslint.configs.recommended],
|
|
rules: {
|
|
// Prevent static imports of @inquirer modules to avoid pre-commit hook hangs.
|
|
// These modules have side effects that can keep the Node.js event loop alive
|
|
// when stdin is piped. Use dynamic import() instead.
|
|
// See: https://github.com/Fission-AI/OpenSpec/issues/367
|
|
'no-restricted-imports': [
|
|
'error',
|
|
{
|
|
patterns: [
|
|
{
|
|
group: ['@inquirer/*'],
|
|
message:
|
|
'Use dynamic import() for @inquirer modules to prevent pre-commit hook hangs. See #367.',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
// Disable rules that need broader cleanup - focus on critical issues only
|
|
'@typescript-eslint/no-explicit-any': 'off',
|
|
'@typescript-eslint/no-unused-vars': 'off',
|
|
'no-empty': 'off',
|
|
'prefer-const': 'off',
|
|
},
|
|
},
|
|
{
|
|
// init.ts is dynamically imported from cli/index.ts, so static @inquirer
|
|
// imports there are safe - they won't be loaded at CLI startup
|
|
files: ['src/core/init.ts'],
|
|
rules: {
|
|
'no-restricted-imports': 'off',
|
|
},
|
|
},
|
|
{
|
|
ignores: ['dist/**', 'node_modules/**', '*.js', '*.mjs'],
|
|
}
|
|
);
|