Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

npm-package-json-lint

Package Overview
Dependencies
Maintainers
1
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npm-package-json-lint - npm Package Compare versions

Comparing version 2.4.0 to 2.5.0

7

CHANGELOG.md

@@ -14,2 +14,9 @@ # Change Log

## [2.5.0] - 2017-06-11
### Changed
@chr1shaefn3r enhanced the following rules so they no longer require a leading equals sign
- [prefer-absolute-version-dependencies](https://github.com/tclindner/npm-package-json-lint/wiki/prefer-absolute-version-dependencies)
- [prefer-absolute-version-devDependencies](https://github.com/tclindner/npm-package-json-lint/wiki/prefer-absolute-version-devDependencies)
## [2.4.0] - 2017-05-24

@@ -16,0 +23,0 @@ ### Added

6

package.json
{
"name": "npm-package-json-lint",
"version": "2.4.0",
"version": "2.5.0",
"description": "CLI app for linting package.json files.",

@@ -54,5 +54,5 @@ "keywords": [

"grunt-mocha-test": "^0.13.2",
"mocha": "^3.4.1",
"mocha": "^3.4.2",
"should": "^11.2.1",
"sinon": "^2.3.0",
"sinon": "^2.3.4",
"time-grunt": "^1.4.0"

@@ -59,0 +59,0 @@ },

'use strict';
const areVersRangesValid = require('./../validators/dependency-audit').areVersRangesValid;
const isVersionAbsolute = require('./../validators/dependency-audit').isVersionAbsolute;
const LintIssue = require('./../LintIssue');

@@ -11,5 +11,4 @@ const lintId = 'prefer-absolute-version-dependencies';

const lint = function(packageJsonData, lintType) {
const rangeSpecifier = '=';
if (!areVersRangesValid(packageJsonData, nodeName, rangeSpecifier)) {
if (!isVersionAbsolute(packageJsonData, nodeName)) {
return new LintIssue(lintId, lintType, nodeName, message);

@@ -16,0 +15,0 @@ }

'use strict';
const areVersRangesValid = require('./../validators/dependency-audit').areVersRangesValid;
const isVersionAbsolute = require('./../validators/dependency-audit').isVersionAbsolute;
const LintIssue = require('./../LintIssue');

@@ -11,5 +11,4 @@ const lintId = 'prefer-absolute-version-devDependencies';

const lint = function(packageJsonData, lintType) {
const rangeSpecifier = '=';
if (!areVersRangesValid(packageJsonData, nodeName, rangeSpecifier)) {
if (!isVersionAbsolute(packageJsonData, nodeName)) {
return new LintIssue(lintId, lintType, nodeName, message);

@@ -16,0 +15,0 @@ }

@@ -108,2 +108,33 @@ 'use strict';

/**
* Determines whether or not all dependency versions are absolut
* @param {object} packageJsonData Valid JSON
* @param {string} nodeName Name of a node in the package.json file
* @return {boolean} False if the package has an non-absolute version. True if it is not or the node is missing.
*/
const isVersionAbsolute = function(packageJsonData, nodeName) {
if (!packageJsonData.hasOwnProperty(nodeName)) {
return true;
}
const NOT_FOUND = -1;
const firstCharOfStr = 0;
let rangesValid = true;
for (const dependencyName in packageJsonData[nodeName]) {
const dependencyVersion = packageJsonData[nodeName][dependencyName];
if (dependencyVersion.startsWith('^', firstCharOfStr) ||
dependencyVersion.startsWith('~', firstCharOfStr) ||
dependencyVersion.startsWith('>', firstCharOfStr) ||
dependencyVersion.startsWith('<', firstCharOfStr) ||
dependencyVersion.indexOf('*') !== NOT_FOUND
) {
rangesValid = false;
}
}
return rangesValid;
};
module.exports.hasDependency = hasDependency;

@@ -113,1 +144,2 @@ module.exports.hasDepPrereleaseVers = hasDepPrereleaseVers;

module.exports.areVersRangesValid = areVersRangesValid;
module.exports.isVersionAbsolute = isVersionAbsolute;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc