-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update .gitignore * Add docs * Add docusaurus * Create .eslintignore * Delete why.md * Fix a bug in getFileList where it didn't respect the cwd * New beta
- Loading branch information
Showing
221 changed files
with
22,425 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
website |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,88 @@ | ||
#################################### | ||
#################################### | ||
### OS Files | ||
#################################### | ||
#################################### | ||
Thumbs.db | ||
.DS_Store | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
#################################### | ||
#################################### | ||
### Git | ||
#################################### | ||
#################################### | ||
*.orig | ||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
#################################### | ||
#################################### | ||
### Sublime Text | ||
#################################### | ||
#################################### | ||
# cache files for sublime text | ||
*.tmlanguage.cache | ||
*.tmPreferences.cache | ||
*.stTheme.cache | ||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# workspace files are user-specific | ||
*.sublime-workspace | ||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# sublime project files | ||
*.sublime-project | ||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# sftp configuration file | ||
sftp-config.json | ||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
#################################### | ||
#################################### | ||
### Node | ||
#################################### | ||
#################################### | ||
# Logs | ||
logs | ||
*.log | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Dependency directory | ||
node_modules | ||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
|
||
# next.js build output | ||
.next | ||
|
||
#################################### | ||
#################################### | ||
### Mocha | ||
#################################### | ||
#################################### | ||
mocha.json | ||
# nuxt.js build output | ||
.nuxt | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
#################################### | ||
#################################### | ||
### nyc | ||
#################################### | ||
#################################### | ||
.nyc_output/ | ||
coverage/ | ||
# DynamoDB Local files | ||
.dynamodb/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
--- | ||
id: api | ||
title: Node.js API | ||
--- | ||
|
||
npm-package-json-lint exports two main objects: `CLIEngine` and `NpmPackageJsonLint`. | ||
|
||
## NpmPackageJsonLint() | ||
|
||
Creates an instance of NpmPackageJsonLint | ||
|
||
`NpmPackageJsonLint` has one public method, `lint`. `lint` takes a package.json object in object form and a config object as parameters. | ||
|
||
### .lint(packageJsonData, configObj) | ||
|
||
Runs configured rules against the provided package.json object. | ||
|
||
#### packageJsonData | ||
|
||
Type: `Object` | ||
|
||
A package.json file in object form. | ||
|
||
#### configObj | ||
|
||
Type: `Object` | ||
|
||
A valid configuration object. | ||
|
||
#### Example | ||
|
||
The following example demostrates how to use `lint`. | ||
|
||
```js | ||
const {NpmPackageJsonLint} = require('npm-package-json-lint'); | ||
|
||
const npmPackageJsonLint = new NpmPackageJsonLint(); | ||
const results = npmPackageJsonLint.lint(packageJsonDataAsObject, configObject); | ||
``` | ||
|
||
#### Return | ||
|
||
`lint` returns an object with an array of `LintIssue`s. Please see `LintIssue` section for more detail. | ||
|
||
```js | ||
{ | ||
issues: [ | ||
{ | ||
lintId: 'require-name', | ||
severity: 'error', | ||
node: 'name', | ||
lintMessage: 'name is required' | ||
} | ||
] | ||
} | ||
``` | ||
|
||
### .version | ||
|
||
Calling `.version` on an instance of `NpmPackageJsonLint` will return the version number of npm-package-json-lint that the linter is associated with. | ||
|
||
#### Example | ||
|
||
```js | ||
const {NpmPackageJsonLint} = require('npm-package-json-lint'); | ||
|
||
const npmPackageJsonLint = new NpmPackageJsonLint(); | ||
|
||
npmPackageJsonLint.version; | ||
// => '3.0.0' | ||
``` | ||
|
||
## CLIEngine(options) | ||
|
||
Creates an instance of CLIEngine | ||
|
||
### options | ||
|
||
Type: `Object` | ||
|
||
CLIEngine configuration object | ||
|
||
* `configFile` {String} Name of module/file to use. | ||
* `cwd` {String} The current working diretory for all file operations. | ||
* `useConfigFiles` {Boolean} False disables use of .npmpackagejsonlintrc.json files and npmpackagejsonlint.config.js files. | ||
* `rules` {Object} An object of rules to use. | ||
|
||
### Example | ||
|
||
The following example demostrates how to initialize a `CLIEngine`. | ||
|
||
```js | ||
const {CLIEngine} = require('npm-package-json-lint'); | ||
|
||
const cliEngineOptions = { | ||
configFile: '', | ||
cwd: process.cwd(), | ||
useConfigFiles: true, | ||
rules: {} | ||
}; | ||
|
||
const cliEngine = new CLIEngine(cliEngineOptions); | ||
``` | ||
|
||
### .executeOnPackageJsonFiles(patterns) | ||
|
||
Runs npm-package-json-lint against the array a patterns. | ||
|
||
#### patterns | ||
|
||
Type: `Array` | ||
|
||
An array of glob patterns | ||
|
||
#### Example | ||
|
||
The following example demostrates how to use `executeOnPackageJsonFiles`. | ||
|
||
```js | ||
const {CLIEngine} = require('npm-package-json-lint'); | ||
|
||
const cliEngineOptions = { | ||
configFile: '', | ||
cwd: process.cwd(), | ||
useConfigFiles: true, | ||
rules: {} | ||
}; | ||
const patterns = ['.']; | ||
|
||
const cliEngine = new CLIEngine(cliEngineOptions); | ||
const results = cliEngine.executeOnPackageJsonFiles(patterns); | ||
``` | ||
|
||
#### Return | ||
|
||
`executeOnPackageJsonFiles` returns an object with an array of results. | ||
|
||
```js | ||
{ | ||
results: [ | ||
{ | ||
filePath: './package.json', | ||
issues: [ | ||
{ | ||
lintId: 'require-name', | ||
severity: 'error', | ||
node: 'name', | ||
lintMessage: 'name is required' | ||
} | ||
], | ||
errorCount: 1, | ||
warningCount: 0 | ||
} | ||
], | ||
errorCount: 1, | ||
warningCount: 0 | ||
} | ||
``` | ||
|
||
### .version | ||
|
||
Calling `.version` on an instance of `CLIEngine` will return the version number of npm-package-json-lint that the CLIEngine is associated with. | ||
|
||
#### Example | ||
|
||
```js | ||
const {CLIEngine} = require('npm-package-json-lint'); | ||
|
||
const cliEngineOptions = { | ||
configFile: '', | ||
cwd: process.cwd(), | ||
useConfigFiles: true, | ||
rules: {} | ||
}; | ||
|
||
const cliEngine = new CLIEngine(cliEngineOptions); | ||
|
||
cliEngine.version; | ||
// => '3.0.0' | ||
``` | ||
|
||
> **WARNING** | ||
Only the functions documented above are supported. All other functions that are exposed may change with any release. Please refrain from using them. |
Oops, something went wrong.