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 3.4.1 to 3.5.0

6

CHANGELOG.md

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

## [3.5.0] - 2019-02-03
### Added
- New cli flag, `ignorePath` (`-i`) - Path to a file containing patterns that describe files to ignore.
Huge shout-out to @evilebottnawi for contributing the new cli option! :tada:
## [3.4.1] - 2018-10-13

@@ -16,0 +22,0 @@ ### Fixed

13

package.json
{
"name": "npm-package-json-lint",
"version": "3.4.1",
"version": "3.5.0",
"description": "Configurable linter for package.json files.",

@@ -37,5 +37,6 @@ "keywords": [

"dependencies": {
"ajv": "^6.5.4",
"chalk": "^2.4.1",
"ajv": "^6.7.0",
"chalk": "^2.4.2",
"glob": "^7.1.3",
"ignore": "^5.0.5",
"is-path-inside": "^2.0.0",

@@ -49,9 +50,9 @@ "is-plain-obj": "^1.1.0",

"strip-json-comments": "^2.0.1",
"validator": "^10.8.0"
"validator": "^10.11.0"
},
"devDependencies": {
"chai": "^4.2.0",
"eslint": "^5.7.0",
"eslint": "^5.13.0",
"eslint-config-tc": "^4.2.0",
"eslint-formatter-pretty": "^1.3.0",
"eslint-formatter-pretty": "^2.1.1",
"figures": "^2.0.0",

@@ -58,0 +59,0 @@ "mocha": "^5.2.0",

@@ -57,2 +57,3 @@ # npm-package-json-lint

| npmPkgJsonLint --noConfigFiles | -ncf | Skips loading project config files (i.e. .npmpackagejsonlintrc.json and npmpackagejsonlint.config.js) |
| npmPkgJsonLint --ignorePath | -i | Path to a file containing patterns that describe files to ignore. |

@@ -103,2 +104,8 @@ ### Examples

```bash
$ npmPkgJsonLint . --ignorePath .gitignore
```
> Looks for all `package.json` files in the project and exclude ignored paths. The CLI engine automatically looks for relevant config files for each package.json file that is found.
## Node.js API

@@ -185,3 +192,4 @@

* `useConfigFiles` {boolean} False disables use of .npmpackagejsonlintrc.json files and npmpackagejsonlint.config.js files.
* `rules` {object} An object of rules to use.
* `ignorePath` {string} Path to a file containing patterns that describe files to ignore. The path can be absolute or relative to process.cwd(). By default, npm-package-json-lint looks for .npmpackagejsonlintignore in process.cwd().
* `rules` {object} An object of rules to use.

@@ -199,2 +207,3 @@ ##### Example

useConfigFiles: true,
ignorePath: '',
rules: {}

@@ -227,2 +236,3 @@ };

useConfigFiles: true,
ignorePath: '',
rules: {}

@@ -275,2 +285,3 @@ };

useConfigFiles: true,
ignorePath: '',
rules: {}

@@ -344,2 +355,2 @@ };

Copyright (c) 2016-2018 Thomas Lindner. Licensed under the MIT license.
Copyright (c) 2016-2019 Thomas Lindner. Licensed under the MIT license.

@@ -27,2 +27,3 @@ #!/usr/bin/env node

--configFile, -c File path of .npmpackagejsonlintrc.json
--ignorePath, -i Path to a file containing patterns that describe files to ignore. The path can be absolute or relative to process.cwd(). By default, npm-package-json-lint looks for .npmpackagejsonlintignore in process.cwd().

@@ -38,2 +39,4 @@ Examples

$ npmPkgJsonLint --quiet ./packages
$ npmPkgJsonLint . --ignorePath .gitignore
$ npmPkgJsonLint . -i .gitignore
`, {

@@ -55,2 +58,7 @@ flags: {

'default': ''
},
ignorePath: {
'type': 'string',
'alias': 'i',
'default': ''
}

@@ -79,2 +87,3 @@ }

useConfigFiles: !cli.flags.noConfigFiles,
ignorePath: cli.flags.ignorePath,
rules: {}

@@ -81,0 +90,0 @@ };

@@ -10,2 +10,3 @@ 'use strict';

const glob = require('glob');
const ignore = require('ignore');
const ConfigValidator = require('./config/ConfigValidator');

@@ -15,2 +16,5 @@ const Parser = require('./Parser');

const DEFAULT_IGNORE_FILENAME = '.npmpackagejsonlintignore';
const FILE_NOT_FOUND_ERROR_CODE = 'ENOENT';
const noIssues = 0;

@@ -160,2 +164,27 @@

/**
* Generates ignorer based on ignore file content.
*
* @param {String} cwd Current work directory.
* @param {CLIEngineOptions} options CLIEngineOptions object.
* @returns {Object} Ignorer
*/
const getIgnorer = function(cwd, options) {
const ignoreFilePath = options.ignorePath || DEFAULT_IGNORE_FILENAME;
const absoluteIgnoreFilePath = path.isAbsolute(ignoreFilePath)
? ignoreFilePath
: path.resolve(cwd, ignoreFilePath);
let ignoreText = '';
try {
ignoreText = fs.readFileSync(absoluteIgnoreFilePath, 'utf8');
} catch (readError) {
if (readError.code !== FILE_NOT_FOUND_ERROR_CODE) {
throw readError;
}
}
return ignore().add(ignoreText);
};
/**
* Generates a list of files to lint based on a list of provided patterns

@@ -203,2 +232,3 @@ *

const addedFiles = new Set();
const ignorer = getIgnorer(cwd, options);

@@ -209,3 +239,3 @@ globPatterns.forEach((pattern) => {

if (fs.existsSync(file) && fs.statSync(file).isFile()) {
if (addedFiles.has(file)) {
if (addedFiles.has(file) || ignorer.ignores(path.relative(cwd, file))) {
return;

@@ -233,3 +263,3 @@ }

if (addedFiles.has(filePath)) {
if (addedFiles.has(filePath) || ignorer.ignores(path.relative(cwd, filePath))) {
return;

@@ -236,0 +266,0 @@ }

Sorry, the diff of this file is not supported yet

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