Skip to content

Commit 064f477

Browse files
committed
fix: export a lint rule
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 03c8bb7 commit 064f477

File tree

5 files changed

+73
-16
lines changed

5 files changed

+73
-16
lines changed

lib/node_modules/@stdlib/_tools/remark/plugins/remark-lint-expected-html-sections/README.md

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ This plugin checks for the presence of required HTML sections in README.md files
3535
## Usage
3636

3737
```javascript
38-
var expectedSections = require( '@stdlib/_tools/remark/plugins/remark-lint-expected-html-sections' );
38+
var plugin = require( '@stdlib/_tools/remark/plugins/remark-lint-expected-html-sections' );
3939
```
4040

41-
### expectedSections( \[options] )
41+
### plugin()
4242

43-
Validates the presence of expected HTML sections in README files.
43+
A [remark][remark] plugin which validates the presence of expected HTML sections in README files.
4444

4545
```javascript
4646
var remark = require( 'remark' );
4747

48-
remark().use( expectedSections ).process( '# README', done );
48+
remark().use( plugin ).process( '# README', done );
4949

5050
function done( error, file ) {
5151
if ( error ) {
@@ -54,11 +54,27 @@ function done( error, file ) {
5454
}
5555
```
5656

57-
The plugin accepts the following `options`:
57+
### plugin.factory( \[options] )
58+
59+
Returns a configured [remark][remark] plugin for validating expected HTML sections in README files.
60+
61+
```javascript
62+
var remark = require( 'remark' );
63+
64+
remark().use( plugin.factory() ).process( '# README', done );
65+
66+
function done( error, file ) {
67+
if ( error ) {
68+
console.error( error );
69+
}
70+
}
71+
```
72+
73+
The function accepts the following `options`:
5874

5975
- **schema**: schema for expected HTML sections.
6076

61-
The default schema requires `usage`, `examples`, and `links` at the root level, and if a `c` section exists, it requires `usage` and `examples` subsections.
77+
The default schema requires `usage`, `examples`, and `links` at the root level, and, if a `c` section exists, it requires `usage` and `examples` subsections.
6278

6379
To specify a custom schema, set the `schema` option.
6480

@@ -74,7 +90,7 @@ var customSchema = {
7490
var opts = {
7591
'schema': customSchema
7692
};
77-
remark().use( expectedSections, opts ).process( '# README', done );
93+
remark().use( plugin.factory( opts ) ).process( '# README', done );
7894

7995
function done( error, file ) {
8096
if ( error ) {
@@ -105,7 +121,7 @@ function done( error, file ) {
105121

106122
```javascript
107123
var remark = require( 'remark' );
108-
var expectedSections = require( '@stdlib/_tools/remark/plugins/remark-lint-expected-html-sections' );
124+
var plugin = require( '@stdlib/_tools/remark/plugins/remark-lint-expected-html-sections' );
109125

110126
var lines = [
111127
'# Example Package',
@@ -151,7 +167,7 @@ var opts = {
151167
};
152168

153169
// Process source with linter:
154-
remark().use( expectedSections, opts ).process( source, done );
170+
remark().use( plugin, opts ).process( source, done );
155171

156172
function done( error, file ) {
157173
var i;

lib/node_modules/@stdlib/_tools/remark/plugins/remark-lint-expected-html-sections/lib/attacher.js renamed to lib/node_modules/@stdlib/_tools/remark/plugins/remark-lint-expected-html-sections/lib/factory.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
// MODULES //
2222

23+
var rule = require( 'unified-lint-rule' );
2324
var copy = require( '@stdlib/utils/copy' );
2425
var defaults = require( './defaults.json' );
2526
var validate = require( './validate.js' );
@@ -59,15 +60,15 @@ var linter = require( './linter.js' );
5960
* ''
6061
* ].join( '\n' );
6162
*
62-
* remark().use( lint ).process( str, done );
63+
* remark().use( factory() ).process( str, done );
6364
*
6465
* function done( error ) {
6566
* if ( error ) {
6667
* throw error;
6768
* }
6869
* }
6970
*/
70-
function attacher( options ) {
71+
function factory( options ) {
7172
var opts;
7273
var err;
7374

@@ -81,10 +82,10 @@ function attacher( options ) {
8182
throw err;
8283
}
8384
}
84-
return linter( opts );
85+
return rule( 'remark-lint:expected-html-sections', linter( opts ) );
8586
}
8687

8788

8889
// EXPORTS //
8990

90-
module.exports = attacher;
91+
module.exports = factory;

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,16 @@
3232

3333
// MODULES //
3434

35-
var attacher = require( './attacher.js' );
35+
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
36+
var main = require( './main.js' );
37+
var factory = require( './factory.js' );
38+
39+
40+
// MAIN //
41+
42+
setReadOnly( main, 'factory', factory );
3643

3744

3845
// EXPORTS //
3946

40-
module.exports = attacher;
47+
module.exports = main;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var factory = require( './factory.js' );
24+
25+
26+
// MAIN //
27+
28+
var main = factory();
29+
30+
31+
// EXPORTS //
32+
33+
module.exports = main;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ tape( 'the function validates an invalid Markdown file containing a missing root
163163
t.fail( err.message );
164164
}
165165
t.strictEqual( file.messages.length, 1, 'returns expected value' );
166-
t.strictEqual( contains( file.messages[ 0 ].reason, 'usage' ) && contains( file.messages[ 0 ].reason, 'related' ), true, 'returns expected value' );
166+
t.strictEqual( contains( file.messages[ 0 ].reason, 'usage' ) && contains( file.messages[ 0 ].reason, 'examples' ), true, 'returns expected value' );
167167
t.end();
168168
}
169169
});

0 commit comments

Comments
 (0)