streetsidesoftware / vscode-spell-checker

A simple source code spell checker for code
https://streetsidesoftware.github.io/vscode-spell-checker/
Other
1.43k stars 128 forks source link

pre-commit hook #1294

Closed janosh closed 3 years ago

janosh commented 3 years ago

Could this extension be used as a pre-commit hook?

Jason3S commented 3 years ago

This extension uses cspell. CSpell can be wired up as a pre-commit hook.

janosh commented 3 years ago

Oops, wrong place to open this issue then. 😅 Perhaps you can transfer it?

Since it's opened, let me mention that there appears to be a problem with the current setup.

After adding

  - repo: https://github.com/streetsidesoftware/cspell
    rev: v5.9.1
    hooks:
    - id: cspell

to .pre-commit-config.yaml and running pre-commit run cspell -av, pre-commit gets stuck in

[INFO] Installing environment for https://github.com/streetsidesoftware/cspell.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...

for more than 10 min (usually just takes seconds) and then finally fails with this error

An unexpected error has occurred: CalledProcessError: command: ('/Users/janosh/.cache/pre-commit/repo04hvcoyp/node_env-system/bin/node', '/usr/local/bin/npm', 'install', '-g', '/Users/janosh/.cache/pre-commit/repo04hvcoyp/cspell-monorepo-1.0.0.tgz')
return code: 1
expected return code: 0
stdout: (none)
stderr:
    npm ERR! code 1
    npm ERR! path /Users/janosh/.cache/pre-commit/repo04hvcoyp/node_env-system/lib/node_modules/cspell-monorepo
    npm ERR! command failed
    npm ERR! command sh -c lerna bootstrap --ci
    npm ERR! > @cspell/cspell-types@5.9.1 prepare /Users/janosh/.cache/pre-commit/repo04hvcoyp/node_env-system/lib/node_modules/cspell-monorepo/packages/cspell-types
    npm ERR! > npm run build
    npm ERR! 
    npm ERR! 
    npm ERR! > @cspell/cspell-types@5.9.1 build
    npm ERR! > npm run compile && npm run build-schema
    npm ERR! 
    npm ERR! 
    npm ERR! > @cspell/cspell-types@5.9.1 compile
    npm ERR! > tsc -p .
    npm ERR! 
    npm ERR! 
    npm ERR! > @cspell/cspell-types@5.9.1 build-schema
    npm ERR! > ts-json-schema-generator --no-top-ref --path src/settings/CSpellSettingsDef.ts --type CSpellSettings --validation-keywords markdownDescription  --validation-keywords scope --validation-keywords deprecated --validation-keywords deprecationMessage -o  ./cspell.schema.json && cp ./cspell.schema.json ../..
    npm ERR! 
    npm ERR! 
    npm ERR! > hunspell-reader@5.9.1 prepare /Users/janosh/.cache/pre-commit/repo04hvcoyp/node_env-system/lib/node_modules/cspell-monorepo/packages/hunspell-reader
    npm ERR! > npm run build
    npm ERR! 
    npm ERR! 
    npm ERR! > hunspell-reader@5.9.1 build
    npm ERR! > tsc -p .
    npm ERR! 
    npm ERR! error TS5057: Cannot find a tsconfig.json file at the specified directory: '.'.
    npm ERR! lerna notice cli v4.0.0
    npm ERR! lerna info ci enabled
    npm ERR! lerna info Bootstrapping 22 packages
    npm ERR! lerna info Symlinking packages and binaries
    npm ERR! lerna info lifecycle @cspell/cspell-types@5.9.1~prepare: @cspell/cspell-types@5.9.1
    npm ERR! lerna info lifecycle hunspell-reader@5.9.1~prepare: hunspell-reader@5.9.1
    npm ERR! lerna info lifecycle test-yarn2@5.6.0~prepare: test-yarn2@5.6.0
    npm ERR! lerna WARN lifecycle The node binary used for scripts is /Users/janosh/.cache/pre-commit/repo04hvcoyp/node_env-system/bin/node but npm is using /usr/local/Cellar/node/16.9.0/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
    npm ERR! sh: ts-json-schema-generator: command not found
    npm ERR! lerna info lifecycle @cspell/cspell-types@5.9.1~prepare: Failed to exec prepare script

    npm ERR! A complete log of this run can be found in:
    npm ERR!     /Users/janosh/.npm/_logs/2021-09-13T07_31_06_213Z-debug.log

Check the log at /Users/janosh/.cache/pre-commit/pre-commit.log
Jason3S commented 3 years ago

I had not clicked on your link, so I misunderstood. Pre-commit hooks are a standard part of git. The pre-commit tool, is not. A request had come in a couple of years ago to get it working. Which is why there is an old .pre-commit-hooks.yaml file there. But during the move to a mono-repo, the process broke. I pulled cspell-cli into its own repo to help get it to work again, but didn't hear back from the person asking.

Other than the missing .pre-commit-hooks.yaml file, I think cspell-cli meets the requirements for pre-commit.

janosh commented 3 years ago

Other than the missing .pre-commit-hooks.yaml file, I think cspell-cli meets the requirements for pre-commit.

It does indeed, thanks!

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.