Skip to content

Can't get it to work with the built-in SCM input #744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
eusousu opened this issue Jun 12, 2023 · 10 comments · Fixed by #792
Closed

Can't get it to work with the built-in SCM input #744

eusousu opened this issue Jun 12, 2023 · 10 comments · Fixed by #792

Comments

@eusousu
Copy link

eusousu commented Jun 12, 2023

List of things I have done:

  • installed commitlint;
  • added a commitlint.config.js file;
  • validated with commitlint --from=HEAD~1
  • downloaded the extension;
  • tried to commit an invalid message via built-in SCM input.

on the last step nothing happened and the invalid message was commited with no warnings.

Is there something I'm missing?

@joshbolduc
Copy link
Owner

The extension won't prevent you from committing with a message that fails linting, if that's what you're expecting. You should see diagnostics (e.g., squiggly lines) but that's all.

Let's narrow down some other possibilities:

  • If you use the full editor instead, do you see any diagnostics/squiggly lines?
  • With the full editor open, you can hover over the {} part of the language status and it should say whether it's able to load any rules:
    image
    Is it saying it's loaded any rules? There's also the commitlint.log.enabled setting to enable logging to the output panel, which might also help narrow things down.
  • What does your commitlint.config.js look like?
  • Did you install commitlint globally on your system, or locally in your project?
  • What OS are you using?

@eusousu
Copy link
Author

eusousu commented Jun 12, 2023

Okay, cheking:

  • I see no squiggly lines on built-in SCM input
    image
  • Same on full editor
    image
  • On the {} I see an error "error loading config"
    image
  • Tried enabling the commitlint.log.enabled but no new messages appeared
  • I have not touched my commitlint.config.js, using as default:
/* global module */
module.exports = { extends: ["@commitlint/config-conventional"] };
  • Commitlint is installed globally:
$ npm list -g
C:\Users\user\AppData\Roaming\npm
├── @commitlint/[email protected]
├── @commitlint/[email protected]
  • I'm using Windows 10
  • I can use commitlint normally from cli, ex.:
$ commitlint --from=HEAD~1
⧗   input: dsaiyugdiuysadisda
✖   subject may not be empty [subject-empty]
✖   type may not be empty [type-empty]

✖   found 2 problems, 0 warnings
ⓘ   Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint

@joshbolduc
Copy link
Owner

I'm going to need some time to dig into this. Globally installed commitlint on Windows is a bit of a blind spot and I don't have a good test environment for it handy.

You can probably work around the issue by installing any plugins locally in your project (and/or tweaking some config settings), but I understand that's not appealing for non-npm projects.

@eusousu
Copy link
Author

eusousu commented Jun 14, 2023

installing locally on project solves the issue, but the possibility to have it global would be nice!

additionally the commitlint site linked on the requirements of the project now instructs to install commitlint globally (see here), but their repo readme instructs to install locally to dev, maybe it changed in the way but as I followed the linked one I had this problem

joshbolduc added a commit that referenced this issue Jun 20, 2023
When loading a local instance of `@commitlint/load`, use its path as the
`PREFIX` when attempting to actually load a configuration. This should
improve the chances that any installed configurations or plugins are
discovered by preferring the location of a previously discovered library
rather over a more generic global location.

Fixes #600
Fixes #744
@joshbolduc
Copy link
Owner

I think I got this working and published 2.4.3 with a fix. Let me know if it's still misbehaving for you. Thanks for the help reproducing the issue!

@joshbolduc
Copy link
Owner

I reverted the fix for this to fix #750--on review, my initial attempt was ill-conceived and effectively just undid the work that was done to improve compatibility with global installations for #491.

Short term, v2.4.6 is the latest version with this behavior, so if that works for you, feel free to stay on that version.

Longer term, I think the fix here might involve trying to load configs multiple times (e.g., with or without PREFIX) unless there's a better test or heuristic I can identify. But I will probably also want to prioritize #107 to establish some base level of automated test coverage for these different environments, which will be more reliable than my ad-hoc testing to date.

@jibbers42
Copy link

#744 (comment) says that installing locally may work and #744 (comment) says that it does work, but I can't get diagnostics to show. I use the Commit button with a blank message to get the full editor COMMIT_EDITMSG view. When I type there is no diagnostic to help.

I have this installed locally...

  "devDependencies": {
    "@commitlint/cli": "^19.5.0",
    "@commitlint/config-conventional": "^19.5.0",
    "@commitlint/cz-commitlint": "^19.5.0",
    "commitizen": "^4.3.1",
    "husky": "^9.1.6"
  },

I've installed the extension, git cz works from terminal, and the documented commitlint seems to work fine:

> npx commitlint --from HEAD~1 --to HEAD --verbose
⧗   input: chore: add eslint rules
✔   found 0 problems, 0 warnings

Any suggestion as to what I could be missing?

@joshbolduc
Copy link
Owner

@jibbers42 What you've shared seems okay to me. If you could answer the questions from #744 (comment) it could help narrow things down a bit more. (For instance, the commitlint command you shared did not show any problems, so one possibility could be that something is wrong with the configuration.)

@jibbers42
Copy link

Here is the requested info...

  • If you use the full editor instead, do you see any diagnostics/squiggly lines?
    no
  • With the full editor open, you can hover over the {} part of the language status and it should say whether it's able to load any rules:
    There are no rules loaded:
    image
  • Is it saying it's loaded any rules? There's also the commitlint.log.enabled setting to enable logging to the output panel, which might also help narrow things down.
    loading @commitlint/load dynamically via <absolute path to project>\node_modules\@commitlint\load\lib\load.js
    loading @commitlint/load dynamically via <absolute path to project>\node_modules\@commitlint\load\lib\load.js
    loading @commitlint/load dynamically via <absolute path to project>\node_modules\@commitlint\load\lib\load.js
    loading @commitlint/load dynamically via <absolute path to project>\node_modules\@commitlint\load\lib\load.js
    loading @commitlint/load dynamically via <absolute path to project>\node_modules\@commitlint\load\lib\load.js
    loading @commitlint/parse dynamically via <absolute path to project>\node_modules\@commitlint\parse\lib\index.js
    loading @commitlint/parse dynamically via <absolute path to project>\node_modules\@commitlint\parse\lib\index.js
    loading @commitlint/parse dynamically via <absolute path to project>\node_modules\@commitlint\parse\lib\index.js
    ...
    
  • What does your commitlint.config.js look like?
    module.exports = {
        // See config at https://github.com/conventional-changelog/commitlint/tree/master/@commitlint/config-conventional
        extends: ['@commitlint/config-conventional'],
        rules: {
            // Add scopes as needed
            // 'scope-enum': [2, 'always', [
            // ]],
        },
        prompt: {
            settings: {
                enableMultipleScopes: true,
                scopeEnumSeparator: ','
            }
        }
    };
    ``
  • Did you install commitlint globally on your system, or locally in your project?
    commitlint is installed locally. I have commitizen installed globally via volta (and installed locally). As a test I removed commitizen from global and verified that git cz failed, but npx cz still worked. I restarted vscode, but it had the same behavior.
  • What OS are you using?
    Windows 11 (latest updates/patches)

BinToss added a commit to BinToss/joshbolduc.vscode-commitlint that referenced this issue Feb 25, 2025
…mically importing them

Fixes joshbolduc#744, but opens the path to previously inaccessible bugs e.g.
```
RangeError: Found rules without implementation: extends.
Supported rules are: body-case, body-empty, body-full-stop, body-leading-blank, body-max-length, body-max-line-length, body-min-length, footer-empty, footer-leading-blank, footer-max-length, footer-max-line-length, footer-min-length, header-case, header-full-stop, header-max-length, header-min-length, header-trim, references-empty, scope-case, scope-empty, scope-enum, scope-max-length, scope-min-length, signed-off-by, subject-case, subject-empty, subject-full-stop, subject-max-length, subject-min-length, subject-exclamation-mark, trailer-exists, type-case, type-empty, type-enum, type-max-length, type-min-length.
    at lint (file:///c:/Repos/HaloSPV3/hce.shared-config/node_modules/@commitlint/lint/lib/lint.js:48:15)
    at async lint (c:\Repos\BinToss\joshbulduc.vscode-commitlint\dist\worker\index.js:213:22)
    at async handleAsync (c:\Repos\BinToss\joshbulduc.vscode-commitlint\dist\worker\index.js:238:22)
```
@BinToss
Copy link
Contributor

BinToss commented Feb 25, 2025

I fixed it. It's the ol' ERR_UNSUPPORTED_ESM_URL_SCHEME issue caused by Node not automatically accounting for Windows' Disk Volume Letter paths (e.g. C:\).

Image


Formatting the module path(s) with pathToFileURL at least got the dynamic module imports working, but then I started seeing odd errors. See #793. This was caused by a bad configuration I wasn't aware of in my user-scope settings.json.

After writing a fix for it (and later fixing the bad config), the extension now works in both the full editor and the Git side panel on Windows

Image

joshbolduc added a commit that referenced this issue Feb 27, 2025
…mically importing them (#792)

Fixes #744, but opens the path to previously inaccessible bugs e.g.
```
RangeError: Found rules without implementation: extends.
Supported rules are: body-case, body-empty, body-full-stop, body-leading-blank, body-max-length, body-max-line-length, body-min-length, footer-empty, footer-leading-blank, footer-max-length, footer-max-line-length, footer-min-length, header-case, header-full-stop, header-max-length, header-min-length, header-trim, references-empty, scope-case, scope-empty, scope-enum, scope-max-length, scope-min-length, signed-off-by, subject-case, subject-empty, subject-full-stop, subject-max-length, subject-min-length, subject-exclamation-mark, trailer-exists, type-case, type-empty, type-enum, type-max-length, type-min-length.
    at lint (file:///c:/Repos/HaloSPV3/hce.shared-config/node_modules/@commitlint/lint/lib/lint.js:48:15)
    at async lint (c:\Repos\BinToss\joshbulduc.vscode-commitlint\dist\worker\index.js:213:22)
    at async handleAsync (c:\Repos\BinToss\joshbulduc.vscode-commitlint\dist\worker\index.js:238:22)
```

---------

Co-authored-by: Josh Bolduc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants