npm-package-json-lint icon indicating copy to clipboard operation
npm-package-json-lint copied to clipboard

Include git dependencies in version linting

Open thethomaseffect opened this issue 7 years ago • 5 comments

With Github and Gitlab (there might be more) you can depend on a git URL in package.json like so:

"mydep": "git+ssh://[email protected]:internalapps/mydep.git"

However, the version is optional and at my org I want to ensure that a version is included like so for commit id:

"mydep": "git+ssh://[email protected]:internalapps/mydep.git#500546a"

or string for a tag or branch name

"mydep": "git+ssh://[email protected]:internalapps/mydep.git#v0.1.1"

I think just ensuring that .git isn't at the end of the value could be enough but I haven't done much testing. ..+\.git#.+ could work too. Let me know if you think this could be an addition :)

thethomaseffect avatar Jun 14 '17 12:06 thethomaseffect

Hi @thethomaseffect I think this is a great suggestion! I have a couple of questions for you.

  1. On your projects do you require that all dependencies utilize git references?
  2. Do you ever use GitHub URL formats for dependencies over standard Git URLs? Ex: "myModule": "user/repo#feature/branch"

I think we could add a few new rules.

  • Note: Each one of these would include an equivalent for all of the dependency types (e.g. devDependencies, optionalDependencies, etc.)
  1. prefer-git-sha-dependencies
  2. prefer-git-tag-dependencies
  3. prefer-git-branch-dependencies

Each of these rules would detect if the dependency is a git dependency then enforce the preferred style. If the dependency isn't a git url then it would fallback to other version formats.

Let me know what you think and I'll get started on building the rules.

tclindner avatar Jun 17 '17 12:06 tclindner

Hey @thethomaseffect have you had a chance to review my comment above?

tclindner avatar Jul 10 '17 01:07 tclindner

Hey @thethomaseffect what do you think about the comment above?

tclindner avatar Aug 09 '17 02:08 tclindner

Hi @tclindner , apologies for lack of response, for some reason I was notified about all 3 comments at the same time this morning!

  1. Nope, there's still regular NPM ones
  2. Not at the moment, I'd need to test if Gitlab supports that as well

I think your suggestion sounds good, as long as an explicit version in the path is required I think it would satisfy my requirements.

thethomaseffect avatar Aug 09 '17 09:08 thethomaseffect

No problem at all!! I'll start thinking about the new rules 👍

tclindner avatar Aug 10 '17 01:08 tclindner