Skip to content
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

Does .lockfile-lint.js config work? #192

Closed
jerone opened this issue Feb 16, 2024 · 5 comments · Fixed by #193 or #197
Closed

Does .lockfile-lint.js config work? #192

jerone opened this issue Feb 16, 2024 · 5 comments · Fixed by #193 or #197
Assignees

Comments

@jerone
Copy link
Contributor

jerone commented Feb 16, 2024

The documentation states that it's possible to define a config with the following filenames .lockfile-lint.js or lockfilelint.config.js. Per convention it should return a JavaScript object.

However, it seems to not work. When running lockfile-lint with one of the examples below, it errors with the following message:

Missing required argument: path

I've tried the following config:

const config = {
  allowedHosts: ["npm"],
  path: "package-lock.json",
  type: "npm",
  validateHttps: true,
  validatePackageNames: true,
};
export default config;

or

const config = {
  allowedHosts: ["npm"],
  path: "package-lock.json",
  type: "npm",
  validateHttps: true,
  validatePackageNames: true,
};
module.exports = config;

When I try a JSON config (e.g. .lockfile-lintrc) it just works.


It also appears there is no @types for the config. Not in the package or as a separate npm package. There is an @types/lockfile-lint-api package, but it's only for the API, not the config. I would like to use the types in the JavaScript configs:

/** @type {import("lockfile-lint").Config} */
const config = {
  allowedHosts: ["npm"],
  path: "package-lock.json",
  type: "npm",
  validateHttps: true,
  validatePackageNames: true,
};
@lirantal
Copy link
Owner

About the config file loader - we're using cosmiconfig in the project and it appears that some naming conventions work, and others don't for some reason but I didn't check why.

Works:

  • .lockfile-lintrc - a JSON file
  • lockfile-lint.config.js - a JavaScript file with module.exports like your above example

If you wanted to update the README for the project with this information and examples, I'm happy to merge the PR so it is more helpful to other users in the future.

As for the types - if you want to contribute that in a PR as well, I'm happy to land it.

jerone added a commit to jerone/lockfile-lint that referenced this issue Feb 19, 2024
@jerone
Copy link
Contributor Author

jerone commented Feb 19, 2024

I fixed my issue; it was a small error in the documentation. See #193.

Would you mind updating to the latest release of cosmiconfig: https://github.com/cosmiconfig/cosmiconfig/releases/tag/v9.0.0
It has support for the .config folder.
Or provide a cli option to use a custom config location.

@lirantal
Copy link
Owner

Ahh yes! Good catch.

I'll also shoot out a new release for the cosmiconfig dependency in a bit.

@jerone
Copy link
Contributor Author

jerone commented Jun 3, 2024

I'll also shoot out a new release for the cosmiconfig dependency in a bit.

@lirantal I noticed that cosmiconfig still is pinned on version 8, and not yet updated to v9.

"cosmiconfig": "^8.2.0",

@lirantal
Copy link
Owner

Sorry for the delay, @jerone
New version now published with cosmiconfig@9: https://github.com/lirantal/lockfile-lint/releases/tag/lockfile-lint%404.14.0

Let me know if there are still any pending issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants