Skip to content

Commit 0836731

Browse files
authored
chore: clean-up
Signed-off-by: Athan <[email protected]>
1 parent 8ac5b4b commit 0836731

File tree

1 file changed

+10
-11
lines changed
  • lib/node_modules/@stdlib/_tools/remark/plugins/remark-lint-expected-html-sections/lib

1 file changed

+10
-11
lines changed

lib/node_modules/@stdlib/_tools/remark/plugins/remark-lint-expected-html-sections/lib/validate.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var isObject = require( '@stdlib/assert/is-plain-object' );
2525
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
2626
var isArray = require( '@stdlib/assert/is-array' );
2727
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
28+
var join = require( '@stdlib/array/base/join' );
2829
var format = require( '@stdlib/string/format' );
2930

3031

@@ -40,34 +41,32 @@ var format = require( '@stdlib/string/format' );
4041
*/
4142
function validateSection( schema, section ) {
4243
var i;
43-
var j;
44-
4544
if ( !isObject( schema ) ) {
4645
return new TypeError( format( 'invalid option. `%s` schema section must be an object. Value: `%s`.', section, schema ) );
4746
}
4847
if ( hasOwnProp( schema, 'required' ) ) {
4948
if ( !isArray( schema.required ) ) {
50-
return new TypeError( format( 'invalid option. `%s.required` must be an array. Value: `%s`.', section, schema.required ) );
49+
return new TypeError( format( 'invalid option. `%s` must be an array. Value: `%s`.', section+'.required', schema.required ) );
5150
}
5251
for ( i = 0; i < schema.required.length; i++ ) {
5352
if ( !isString( schema.required[ i ] ) ) {
54-
return new TypeError( format( 'invalid option. `%s.required` must only contain strings. Found: `%s`.', section, schema.required[ i ] ) );
53+
return new TypeError( format( 'invalid option. `%s` must only contain strings. Index: `%u`. Value: `%s`.', section+'.required', i, schema.required[ i ] ) );
5554
}
5655
}
5756
} else {
58-
return new TypeError( format( 'invalid option. `%s` schema section must have a `required` property.', section ) );
57+
return new TypeError( format( 'invalid option. `%s` schema section must have %s `%s` property.', section, 'a', 'required' ) );
5958
}
6059
if ( hasOwnProp( schema, 'optional' ) ) {
6160
if ( !isArray( schema.optional ) ) {
62-
return new TypeError( format( 'invalid option. `%s.optional` must be an array. Value: `%s`.', section, schema.optional ) );
61+
return new TypeError( format( 'invalid option. `%s` must be an array. Value: `%s`.', section+'.optional', schema.optional ) );
6362
}
64-
for ( j = 0; j < schema.optional.length; j++ ) {
65-
if ( !isString( schema.optional[ j ] ) ) {
66-
return new TypeError( format( 'invalid option. `%s.optional` must only contain strings. Found: `%s`.', section, schema.optional[ j ] ) );
63+
for ( i = 0; i < schema.optional.length; i++ ) {
64+
if ( !isString( schema.optional[ i ] ) ) {
65+
return new TypeError( format( 'invalid option. `%s` must only contain strings. Index: `%u`. Value: `%s`.', section+'.optional', i, schema.optional[ i ] ) );
6766
}
6867
}
6968
} else {
70-
return new TypeError( format( 'invalid option. `%s` schema section must have an `optional` property.', section ) );
69+
return new TypeError( format( 'invalid option. `%s` schema section must have %s `%s` property.', section, 'an', 'optional' ) );
7170
}
7271
return null;
7372
}
@@ -113,7 +112,7 @@ function validate( opts, options ) {
113112
return new TypeError( format( 'invalid option. `%s` option must be an object. Option: `%s`.', 'schema', options.schema ) );
114113
}
115114
if ( !hasOwnProp( options.schema, 'root' ) ) {
116-
return new TypeError( format( 'invalid option. Schema must contain a `root` section.' ) );
115+
return new TypeError( format( 'invalid option. `%s` option must have %s `%s` property.', 'schema', 'a', 'root' ) );
117116
}
118117
keys = objectKeys( options.schema );
119118
for ( i = 0; i < keys.length; i++ ) {

0 commit comments

Comments
 (0)