npm-package-json-lint
Advanced tools
Comparing version 2.4.0 to 2.5.0
@@ -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 |
{ | ||
"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; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
86232
1843