eslint-docgen 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/build-docs-from-tests.js +3 -4
- package/src/write-docs-from-tests.js +8 -21
- package/Changelog.md +0 -99
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-docgen",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Automatically generate ESLint plugin documentation from rule metadata and test cases.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"upath": "^2.0.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"eslint-config-wikimedia": "^0.
|
|
39
|
+
"eslint-config-wikimedia": "^0.21.0",
|
|
40
40
|
"eslint-plugin-node": "^11.1.0",
|
|
41
41
|
"mocha": "^9.1.3",
|
|
42
42
|
"nyc": "^15.1.0"
|
|
@@ -78,7 +78,7 @@ function buildDocsFromTests(
|
|
|
78
78
|
return path.basename( test.filename );
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
function buildRuleDetails( testList,
|
|
81
|
+
function buildRuleDetails( testList, isValid, showFixes ) {
|
|
82
82
|
testList = testList.filter( ( test ) =>
|
|
83
83
|
test.docgen === undefined ?
|
|
84
84
|
!config.excludeExamplesByDefault :
|
|
@@ -176,9 +176,8 @@ function buildDocsFromTests(
|
|
|
176
176
|
};
|
|
177
177
|
|
|
178
178
|
if ( showFixes && test.output ) {
|
|
179
|
-
const output = fixedOutput[ i ];
|
|
180
179
|
const codeLines = code.split( '\n' );
|
|
181
|
-
const outputLines =
|
|
180
|
+
const outputLines = fixedOutput[ i ].split( '\n' );
|
|
182
181
|
const maxLines = Math.max( codeLines.length, outputLines.length );
|
|
183
182
|
const exampleLines = [];
|
|
184
183
|
for ( let l = 0; l < maxLines; l++ ) {
|
|
@@ -237,7 +236,7 @@ function buildDocsFromTests(
|
|
|
237
236
|
|
|
238
237
|
return {
|
|
239
238
|
key: key,
|
|
240
|
-
valid:
|
|
239
|
+
valid: isValid,
|
|
241
240
|
options: options ? JSON.stringify( options ) : '',
|
|
242
241
|
settings: settings ? JSON.stringify( settings ) : '',
|
|
243
242
|
filename: filename || '',
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
/* eslint-disable no-process-exit */
|
|
4
3
|
const fs = require( 'fs' );
|
|
5
4
|
const mkdirp = require( 'mkdirp' );
|
|
6
5
|
const path = require( 'upath' );
|
|
@@ -14,20 +13,14 @@ let config, configPath;
|
|
|
14
13
|
try {
|
|
15
14
|
( { config, configPath } = getConfig() );
|
|
16
15
|
} catch ( e ) {
|
|
17
|
-
|
|
18
|
-
console.log( formatter.error( e.message ) );
|
|
19
|
-
console.log();
|
|
20
|
-
process.exit( 1 );
|
|
16
|
+
throw new Error( [ formatter.heading( 'eslint-docgen' ), formatter.error( e.message ) ].join( '\n' ) );
|
|
21
17
|
}
|
|
22
18
|
|
|
23
19
|
const configValidator = require( './validate-config' );
|
|
24
20
|
function assertValidConfig( maybeValidConfig, configSource ) {
|
|
25
21
|
const configErrors = configValidator( maybeValidConfig );
|
|
26
22
|
if ( configErrors.length ) {
|
|
27
|
-
|
|
28
|
-
configErrors.forEach( ( error ) => console.log( formatter.error( error ) ) );
|
|
29
|
-
console.log();
|
|
30
|
-
process.exit( 1 );
|
|
23
|
+
throw new Error( [ formatter.heading( configSource ), ...configErrors.map( formatter.error ) ].join( '\n' ) );
|
|
31
24
|
}
|
|
32
25
|
}
|
|
33
26
|
|
|
@@ -53,11 +46,7 @@ function writeDocsFromTests( name, rule, tests, testerConfig, done ) {
|
|
|
53
46
|
const outputPath = packagePath( configForRule.docPath.replace( '{name}', name ) );
|
|
54
47
|
const ruleWithConfig = rulesWithConfig.get( name );
|
|
55
48
|
if ( !ruleWithConfig ) {
|
|
56
|
-
|
|
57
|
-
console.log( formatter.heading( outputPath ) );
|
|
58
|
-
console.log( formatter.error( 'Rule not found.' ) );
|
|
59
|
-
console.log();
|
|
60
|
-
process.exit( 1 );
|
|
49
|
+
throw new Error( [ formatter.heading( outputPath ), formatter.error( 'Rule not found.' ) ].join( '\n' ) );
|
|
61
50
|
}
|
|
62
51
|
const configMap = rulesWithConfig.get( name ).configMap;
|
|
63
52
|
let output, messages;
|
|
@@ -67,11 +56,7 @@ function writeDocsFromTests( name, rule, tests, testerConfig, done ) {
|
|
|
67
56
|
globalTemplates, loadRuleTemplate, testerConfig
|
|
68
57
|
) );
|
|
69
58
|
} catch ( e ) {
|
|
70
|
-
|
|
71
|
-
console.log( formatter.heading( outputPath ) );
|
|
72
|
-
console.log( formatter.error( e.message ) );
|
|
73
|
-
console.log();
|
|
74
|
-
process.exit( 1 );
|
|
59
|
+
throw new Error( [ formatter.heading( outputPath ), formatter.error( e.message ) ].join( '\n' ) );
|
|
75
60
|
}
|
|
76
61
|
|
|
77
62
|
const outputDir = path.dirname( outputPath );
|
|
@@ -92,8 +77,10 @@ function writeDocsFromTests( name, rule, tests, testerConfig, done ) {
|
|
|
92
77
|
console.log();
|
|
93
78
|
}
|
|
94
79
|
|
|
95
|
-
|
|
96
|
-
|
|
80
|
+
const errors = messages.filter( ( message ) => message.type === 'error' );
|
|
81
|
+
|
|
82
|
+
if ( errors.length ) {
|
|
83
|
+
throw new Error( errors.map( formatter.error ).join( '\n' ) );
|
|
97
84
|
}
|
|
98
85
|
|
|
99
86
|
done();
|
package/Changelog.md
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
# eslint-docgen release history
|
|
2
|
-
|
|
3
|
-
## v0.6.1
|
|
4
|
-
* Fix: Filter out docgen:false tests before parsing (#120)
|
|
5
|
-
|
|
6
|
-
## v0.6.0
|
|
7
|
-
* Breaking change: Drop deprecated 'noDoc' option and '--doc' CLI flag (#115)
|
|
8
|
-
* New: build-docs-from-tests: add Vue syntax highlighting (#105) (DannyS712)
|
|
9
|
-
* New: Add TypeScript syntax highlighting
|
|
10
|
-
* New: Add HTML syntax highlighting
|
|
11
|
-
* New: Separate syntax highlighting support from showFilenames (#114)
|
|
12
|
-
* Fix: Don't put an empty line before the first multi-line examples in a set (#117)
|
|
13
|
-
* Code: Cleanup code for detecting highlight language (#113)
|
|
14
|
-
|
|
15
|
-
## v0.5.1
|
|
16
|
-
* Breaking change: Change the default icon for rules which are included in a preset (#109)
|
|
17
|
-
* Breaking change: Add generated-file-warning comment to the top of MD files (#107)
|
|
18
|
-
* Breaking change: Drop support for Node 10 (#110)
|
|
19
|
-
* New: Add configuration to show file names for test cases (#101) (DannyS712)
|
|
20
|
-
* New: Add per-rule config overrides (DannyS7123)
|
|
21
|
-
* Docs: Various README fixes
|
|
22
|
-
* Code: Update dependencies
|
|
23
|
-
|
|
24
|
-
## v0.4.5
|
|
25
|
-
* Code: Update dependencies
|
|
26
|
-
|
|
27
|
-
## v0.4.4
|
|
28
|
-
|
|
29
|
-
* Code: Ensure config.docPath exists before writing output path. (Raine Revere)
|
|
30
|
-
* Code: Calculate outputDir from outputPath
|
|
31
|
-
* Code: Fix reporting of writeFile error messages
|
|
32
|
-
* Code: Output formatted error when rule not found (#92)
|
|
33
|
-
* Docs: Fix config param heading level in README (#91)
|
|
34
|
-
|
|
35
|
-
## v0.4.3
|
|
36
|
-
|
|
37
|
-
* Code: Run one test 'it' per rule
|
|
38
|
-
|
|
39
|
-
## v0.4.2
|
|
40
|
-
|
|
41
|
-
* New: Introduce excludeExamplesByDefault config
|
|
42
|
-
* Code: Remove some whitespace in config-schema
|
|
43
|
-
* Code: Add a 'report' script
|
|
44
|
-
|
|
45
|
-
## v0.4.1
|
|
46
|
-
|
|
47
|
-
* Code: Update mocha to 8.0.1
|
|
48
|
-
* Code: Replace path with upath for windows compatibility (#83)
|
|
49
|
-
* Code: Use DOCGEN environment variable instead of --doc flag
|
|
50
|
-
* Code: Add an editorconfig to make the tabs a reasonable width on GitHub (Jed Fox)
|
|
51
|
-
* Code: Allow package.main to be empty
|
|
52
|
-
* Code: Support scoped plugin names
|
|
53
|
-
* Docs: Add more method documentation
|
|
54
|
-
* Docs: Fix external links to examples
|
|
55
|
-
* Docs: Add Migration section to README and move some pieces around
|
|
56
|
-
|
|
57
|
-
## v0.4.0
|
|
58
|
-
|
|
59
|
-
* Breaking change: New: Add fix message to introduction (#49)
|
|
60
|
-
* Breaking change: New: Format long lists correctly ("a, b, and c")
|
|
61
|
-
* Breaking change: New: Sort examples by options *then* valid/invalid (#48)
|
|
62
|
-
* New: Refactor rulesData to rulesWithConfig and expose (#16)
|
|
63
|
-
* New: Add ruleTemplatePath config (#14)
|
|
64
|
-
* New: Add showFixExamples config (#49)
|
|
65
|
-
* Code: Update eslint-config-wikimedia to 0.16.1 and use /mocha
|
|
66
|
-
* Code: Use pkg-dir
|
|
67
|
-
* Code: Create a JSON-schema to validate configs (#63)
|
|
68
|
-
* Code: Update various dependencies
|
|
69
|
-
* Tests: Separate config tests into get/validate
|
|
70
|
-
* Tests: Increase timeout
|
|
71
|
-
* Tests: Separate buildDocsFromTests cases
|
|
72
|
-
* Docs: Fix example docpath
|
|
73
|
-
|
|
74
|
-
## v0.3.1
|
|
75
|
-
|
|
76
|
-
* Fix: Use plugin's version of ESLint
|
|
77
|
-
|
|
78
|
-
## v0.3.0
|
|
79
|
-
|
|
80
|
-
* Breaking change: New: Support multi-line test cases (#34)
|
|
81
|
-
* New: Support multiple lines in formatter
|
|
82
|
-
* New: Add min/maxExamples to config (#29)
|
|
83
|
-
* New: Use chalk to do pretty output of warnings/errors (#38)
|
|
84
|
-
* Code: Bump node dependency to 10 (#44)
|
|
85
|
-
* Code: Use strict mode
|
|
86
|
-
* Code: Use eslint-plugin-node/recommended
|
|
87
|
-
* Code: Removed fixed length truncation from rules-data.js
|
|
88
|
-
* Tests: Add tests for most utils (#39)
|
|
89
|
-
* Tests: Increase code coverage to 100%
|
|
90
|
-
* Docs: Add "plugin" to description
|
|
91
|
-
|
|
92
|
-
## v0.2.0
|
|
93
|
-
|
|
94
|
-
* Breaking change: Refactor templates. Users with existing template overrides will need to rewrite them.
|
|
95
|
-
* Release: Update ejs to 3.1.3
|
|
96
|
-
|
|
97
|
-
## v0.1.0
|
|
98
|
-
|
|
99
|
-
* Initial release.
|