File tree Expand file tree Collapse file tree 2 files changed +21
-10
lines changed Expand file tree Collapse file tree 2 files changed +21
-10
lines changed Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ const fs = require ( 'fs' ) ;
4+ const path = require ( 'path' ) ;
5+ const rules = require ( '../index' ) . rules ;
6+
7+ describe ( 'rules' , ( ) => {
8+ it ( 'should have a corresponding doc for each rule' , ( ) => {
9+ Object . keys ( rules ) . forEach ( rule => {
10+ const docPath = path . resolve ( __dirname , '../docs/rules' , `${ rule } .md` ) ;
11+
12+ if ( ! fs . existsSync ( docPath ) ) {
13+ throw new Error (
14+ `Could not find documentation file for rule "${ rule } " in path "${ docPath } "`
15+ ) ;
16+ }
17+ } ) ;
18+ } ) ;
19+ } ) ;
Original file line number Diff line number Diff line change 11'use strict' ;
22
3- const fs = require ( 'fs' ) ;
43const path = require ( 'path' ) ;
5- const pkg = require ( '../package.json' ) ;
4+ const version = require ( '../package.json' ) . version ;
65
76const REPO_URL = 'https://github.com/jest-community/eslint-plugin-jest' ;
87
@@ -123,18 +122,11 @@ const isFunction = node =>
123122 *
124123 * @param {string } filename - Name of the eslint rule
125124 * @returns {string } URL to the documentation for the given rule
126- * @throws {Error } If the documentation file for the given rule is not present.
127125 */
128126const getDocsUrl = filename => {
129127 const ruleName = path . basename ( filename , '.js' ) ;
130128
131- const docsFile = path . join ( __dirname , `../docs/rules/${ ruleName } .md` ) ;
132- // istanbul ignore if
133- if ( ! fs . existsSync ( docsFile ) ) {
134- throw new Error ( `Could not find documentation file for rule "${ ruleName } "` ) ;
135- }
136-
137- return `${ REPO_URL } /blob/v${ pkg . version } /docs/rules/${ ruleName } .md` ;
129+ return `${ REPO_URL } /blob/v${ version } /docs/rules/${ ruleName } .md` ;
138130} ;
139131
140132module . exports = {
You can’t perform that action at this time.
0 commit comments