Skip to content

Commit fd45725

Browse files
authored
Website (#125)
* 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
1 parent 5f0669f commit fd45725

File tree

221 files changed

+22425
-73
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

221 files changed

+22425
-73
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
website

.gitignore

Lines changed: 63 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,88 @@
1-
####################################
2-
####################################
3-
### OS Files
4-
####################################
5-
####################################
6-
Thumbs.db
7-
.DS_Store
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
88

9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
911

12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
1017

18+
# Directory for instrumented libs generated by jscoverage/JSCover
19+
lib-cov
1120

12-
####################################
13-
####################################
14-
### Git
15-
####################################
16-
####################################
17-
*.orig
21+
# Coverage directory used by tools like istanbul
22+
coverage
23+
*.lcov
1824

25+
# nyc test coverage
26+
.nyc_output
1927

28+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29+
.grunt
2030

31+
# Bower dependency directory (https://bower.io/)
32+
bower_components
2133

22-
####################################
23-
####################################
24-
### Sublime Text
25-
####################################
26-
####################################
27-
# cache files for sublime text
28-
*.tmlanguage.cache
29-
*.tmPreferences.cache
30-
*.stTheme.cache
34+
# node-waf configuration
35+
.lock-wscript
3136

32-
# workspace files are user-specific
33-
*.sublime-workspace
37+
# Compiled binary addons (https://nodejs.org/api/addons.html)
38+
build/Release
3439

35-
# sublime project files
36-
*.sublime-project
40+
# Dependency directories
41+
node_modules/
42+
jspm_packages/
3743

38-
# sftp configuration file
39-
sftp-config.json
44+
# TypeScript v1 declaration files
45+
typings/
4046

47+
# TypeScript cache
48+
*.tsbuildinfo
4149

50+
# Optional npm cache directory
51+
.npm
4252

53+
# Optional eslint cache
54+
.eslintcache
4355

44-
####################################
45-
####################################
46-
### Node
47-
####################################
48-
####################################
49-
# Logs
50-
logs
51-
*.log
52-
53-
# Coverage directory used by tools like istanbul
54-
coverage
56+
# Optional REPL history
57+
.node_repl_history
5558

56-
# Compiled binary addons (http://nodejs.org/api/addons.html)
57-
build/Release
59+
# Output of 'npm pack'
60+
*.tgz
5861

59-
# Dependency directory
60-
node_modules
62+
# Yarn Integrity file
63+
.yarn-integrity
6164

65+
# dotenv environment variables file
66+
.env
67+
.env.test
6268

69+
# parcel-bundler cache (https://parceljs.org/)
70+
.cache
6371

72+
# next.js build output
73+
.next
6474

65-
####################################
66-
####################################
67-
### Mocha
68-
####################################
69-
####################################
70-
mocha.json
75+
# nuxt.js build output
76+
.nuxt
7177

78+
# vuepress build output
79+
.vuepress/dist
7280

81+
# Serverless directories
82+
.serverless/
7383

84+
# FuseBox cache
85+
.fusebox/
7486

75-
####################################
76-
####################################
77-
### nyc
78-
####################################
79-
####################################
80-
.nyc_output/
81-
coverage/
87+
# DynamoDB Local files
88+
.dynamodb/

docs/api.md

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
---
2+
id: api
3+
title: Node.js API
4+
---
5+
6+
npm-package-json-lint exports two main objects: `CLIEngine` and `NpmPackageJsonLint`.
7+
8+
## NpmPackageJsonLint()
9+
10+
Creates an instance of NpmPackageJsonLint
11+
12+
`NpmPackageJsonLint` has one public method, `lint`. `lint` takes a package.json object in object form and a config object as parameters.
13+
14+
### .lint(packageJsonData, configObj)
15+
16+
Runs configured rules against the provided package.json object.
17+
18+
#### packageJsonData
19+
20+
Type: `Object`
21+
22+
A package.json file in object form.
23+
24+
#### configObj
25+
26+
Type: `Object`
27+
28+
A valid configuration object.
29+
30+
#### Example
31+
32+
The following example demostrates how to use `lint`.
33+
34+
```js
35+
const {NpmPackageJsonLint} = require('npm-package-json-lint');
36+
37+
const npmPackageJsonLint = new NpmPackageJsonLint();
38+
const results = npmPackageJsonLint.lint(packageJsonDataAsObject, configObject);
39+
```
40+
41+
#### Return
42+
43+
`lint` returns an object with an array of `LintIssue`s. Please see `LintIssue` section for more detail.
44+
45+
```js
46+
{
47+
issues: [
48+
{
49+
lintId: 'require-name',
50+
severity: 'error',
51+
node: 'name',
52+
lintMessage: 'name is required'
53+
}
54+
]
55+
}
56+
```
57+
58+
### .version
59+
60+
Calling `.version` on an instance of `NpmPackageJsonLint` will return the version number of npm-package-json-lint that the linter is associated with.
61+
62+
#### Example
63+
64+
```js
65+
const {NpmPackageJsonLint} = require('npm-package-json-lint');
66+
67+
const npmPackageJsonLint = new NpmPackageJsonLint();
68+
69+
npmPackageJsonLint.version;
70+
// => '3.0.0'
71+
```
72+
73+
## CLIEngine(options)
74+
75+
Creates an instance of CLIEngine
76+
77+
### options
78+
79+
Type: `Object`
80+
81+
CLIEngine configuration object
82+
83+
* `configFile` {String} Name of module/file to use.
84+
* `cwd` {String} The current working diretory for all file operations.
85+
* `useConfigFiles` {Boolean} False disables use of .npmpackagejsonlintrc.json files and npmpackagejsonlint.config.js files.
86+
* `rules` {Object} An object of rules to use.
87+
88+
### Example
89+
90+
The following example demostrates how to initialize a `CLIEngine`.
91+
92+
```js
93+
const {CLIEngine} = require('npm-package-json-lint');
94+
95+
const cliEngineOptions = {
96+
configFile: '',
97+
cwd: process.cwd(),
98+
useConfigFiles: true,
99+
rules: {}
100+
};
101+
102+
const cliEngine = new CLIEngine(cliEngineOptions);
103+
```
104+
105+
### .executeOnPackageJsonFiles(patterns)
106+
107+
Runs npm-package-json-lint against the array a patterns.
108+
109+
#### patterns
110+
111+
Type: `Array`
112+
113+
An array of glob patterns
114+
115+
#### Example
116+
117+
The following example demostrates how to use `executeOnPackageJsonFiles`.
118+
119+
```js
120+
const {CLIEngine} = require('npm-package-json-lint');
121+
122+
const cliEngineOptions = {
123+
configFile: '',
124+
cwd: process.cwd(),
125+
useConfigFiles: true,
126+
rules: {}
127+
};
128+
const patterns = ['.'];
129+
130+
const cliEngine = new CLIEngine(cliEngineOptions);
131+
const results = cliEngine.executeOnPackageJsonFiles(patterns);
132+
```
133+
134+
#### Return
135+
136+
`executeOnPackageJsonFiles` returns an object with an array of results.
137+
138+
```js
139+
{
140+
results: [
141+
{
142+
filePath: './package.json',
143+
issues: [
144+
{
145+
lintId: 'require-name',
146+
severity: 'error',
147+
node: 'name',
148+
lintMessage: 'name is required'
149+
}
150+
],
151+
errorCount: 1,
152+
warningCount: 0
153+
}
154+
],
155+
errorCount: 1,
156+
warningCount: 0
157+
}
158+
```
159+
160+
### .version
161+
162+
Calling `.version` on an instance of `CLIEngine` will return the version number of npm-package-json-lint that the CLIEngine is associated with.
163+
164+
#### Example
165+
166+
```js
167+
const {CLIEngine} = require('npm-package-json-lint');
168+
169+
const cliEngineOptions = {
170+
configFile: '',
171+
cwd: process.cwd(),
172+
useConfigFiles: true,
173+
rules: {}
174+
};
175+
176+
const cliEngine = new CLIEngine(cliEngineOptions);
177+
178+
cliEngine.version;
179+
// => '3.0.0'
180+
```
181+
182+
> **WARNING**
183+
184+
Only the functions documented above are supported. All other functions that are exposed may change with any release. Please refrain from using them.

0 commit comments

Comments
 (0)