npm-package-json-lint
Advanced tools
Comparing version 3.4.0 to 3.4.1
@@ -14,2 +14,12 @@ # Change Log | ||
## [3.4.1] - 2018-10-13 | ||
### Fixed | ||
- Resolved an issue with the following rules: | ||
* `no-caret-version-dependencies` | ||
* `no-caret-version-devDependencies` | ||
* `no-tilde-version-dependencies` | ||
* `no-tilde-version-devDependencies` | ||
Addresses [#97](https://github.com/tclindner/npm-package-json-lint/issues/97) from @agvctm. | ||
## [3.4.0] - 2018-10-06 | ||
@@ -16,0 +26,0 @@ ### Added |
{ | ||
"name": "npm-package-json-lint", | ||
"version": "3.4.0", | ||
"version": "3.4.1", | ||
"description": "Configurable linter for package.json files.", | ||
@@ -46,9 +46,9 @@ "keywords": [ | ||
"plur": "^3.0.1", | ||
"semver": "^5.5.1", | ||
"semver": "^5.6.0", | ||
"strip-json-comments": "^2.0.1", | ||
"validator": "^10.5.0" | ||
"validator": "^10.8.0" | ||
}, | ||
"devDependencies": { | ||
"chai": "^4.2.0", | ||
"eslint": "^5.6.1", | ||
"eslint": "^5.7.0", | ||
"eslint-config-tc": "^4.2.0", | ||
@@ -55,0 +55,0 @@ "eslint-formatter-pretty": "^1.3.0", |
'use strict'; | ||
const areVersRangesValid = require('./../validators/dependency-audit').areVersRangesValid; | ||
const doVersContainInvalidRange = require('./../validators/dependency-audit').doVersContainInvalidRange; | ||
const LintIssue = require('./../LintIssue'); | ||
@@ -13,3 +13,3 @@ const lintId = 'no-caret-version-dependencies'; | ||
if (packageJsonData.hasOwnProperty(nodeName) && areVersRangesValid(packageJsonData, nodeName, rangeSpecifier)) { | ||
if (packageJsonData.hasOwnProperty(nodeName) && doVersContainInvalidRange(packageJsonData, nodeName, rangeSpecifier)) { | ||
return new LintIssue(lintId, severity, nodeName, message); | ||
@@ -16,0 +16,0 @@ } |
'use strict'; | ||
const areVersRangesValid = require('./../validators/dependency-audit').areVersRangesValid; | ||
const doVersContainInvalidRange = require('./../validators/dependency-audit').doVersContainInvalidRange; | ||
const LintIssue = require('./../LintIssue'); | ||
@@ -13,3 +13,3 @@ const lintId = 'no-caret-version-devDependencies'; | ||
if (packageJsonData.hasOwnProperty(nodeName) && areVersRangesValid(packageJsonData, nodeName, rangeSpecifier)) { | ||
if (packageJsonData.hasOwnProperty(nodeName) && doVersContainInvalidRange(packageJsonData, nodeName, rangeSpecifier)) { | ||
return new LintIssue(lintId, severity, nodeName, message); | ||
@@ -16,0 +16,0 @@ } |
'use strict'; | ||
const areVersRangesValid = require('./../validators/dependency-audit').areVersRangesValid; | ||
const doVersContainInvalidRange = require('./../validators/dependency-audit').doVersContainInvalidRange; | ||
const LintIssue = require('./../LintIssue'); | ||
@@ -13,3 +13,3 @@ const lintId = 'no-tilde-version-dependencies'; | ||
if (packageJsonData.hasOwnProperty(nodeName) && areVersRangesValid(packageJsonData, nodeName, rangeSpecifier)) { | ||
if (packageJsonData.hasOwnProperty(nodeName) && doVersContainInvalidRange(packageJsonData, nodeName, rangeSpecifier)) { | ||
return new LintIssue(lintId, severity, nodeName, message); | ||
@@ -16,0 +16,0 @@ } |
'use strict'; | ||
const areVersRangesValid = require('./../validators/dependency-audit').areVersRangesValid; | ||
const doVersContainInvalidRange = require('./../validators/dependency-audit').doVersContainInvalidRange; | ||
const LintIssue = require('./../LintIssue'); | ||
@@ -13,3 +13,3 @@ const lintId = 'no-tilde-version-devDependencies'; | ||
if (packageJsonData.hasOwnProperty(nodeName) && areVersRangesValid(packageJsonData, nodeName, rangeSpecifier)) { | ||
if (packageJsonData.hasOwnProperty(nodeName) && doVersContainInvalidRange(packageJsonData, nodeName, rangeSpecifier)) { | ||
return new LintIssue(lintId, severity, nodeName, message); | ||
@@ -16,0 +16,0 @@ } |
@@ -82,2 +82,14 @@ 'use strict'; | ||
/** | ||
* Determines if the dependencies version string starts with the specified range | ||
* @param {String} dependencyVersion Dependency's version range | ||
* @param {String} rangeSpecifier A version range specifier | ||
* @return {Boolean} True if the version starts with the range, false if it doesn't. | ||
*/ | ||
const doesVersStartsWithRange = function(dependencyVersion, rangeSpecifier) { | ||
const firstCharOfStr = 0; | ||
return dependencyVersion.startsWith(rangeSpecifier, firstCharOfStr); | ||
}; | ||
/** | ||
* Determines whether or not all dependency version ranges match expected range | ||
@@ -94,3 +106,2 @@ * @param {object} packageJsonData Valid JSON | ||
const firstCharOfStr = 0; | ||
let rangesValid = true; | ||
@@ -101,3 +112,3 @@ | ||
if (!dependencyVersion.startsWith(rangeSpecifier, firstCharOfStr)) { | ||
if (!doesVersStartsWithRange(dependencyVersion, rangeSpecifier)) { | ||
rangesValid = false; | ||
@@ -111,2 +122,27 @@ } | ||
/** | ||
* Determines if any dependencies have a version string that starts with the specified invalid range | ||
* @param {object} packageJsonData Valid JSON | ||
* @param {string} nodeName Name of a node in the package.json file | ||
* @param {string} rangeSpecifier A version range specifier | ||
* @return {Boolean} True if any dependencies versions start with the invalid range, false if they don't. | ||
*/ | ||
const doVersContainInvalidRange = function(packageJsonData, nodeName, rangeSpecifier) { | ||
if (!packageJsonData.hasOwnProperty(nodeName)) { | ||
return false; | ||
} | ||
let containsInvalidVersion = false; | ||
for (const dependencyName in packageJsonData[nodeName]) { | ||
const dependencyVersion = packageJsonData[nodeName][dependencyName]; | ||
if (doesVersStartsWithRange(dependencyVersion, rangeSpecifier)) { | ||
containsInvalidVersion = true; | ||
} | ||
} | ||
return containsInvalidVersion; | ||
}; | ||
/** | ||
* Determines whether or not all dependency versions are absolut | ||
@@ -145,3 +181,5 @@ * @param {object} packageJsonData Valid JSON | ||
module.exports.hasDepVersZero = hasDepVersZero; | ||
module.exports.doesVersStartsWithRange = doesVersStartsWithRange; | ||
module.exports.areVersRangesValid = areVersRangesValid; | ||
module.exports.doVersContainInvalidRange = doVersContainInvalidRange; | ||
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
139900
3001
Updatedsemver@^5.6.0
Updatedvalidator@^10.8.0