File tree 2 files changed +21
-10
lines changed
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 1
1
'use strict' ;
2
2
3
- const fs = require ( 'fs' ) ;
4
3
const path = require ( 'path' ) ;
5
- const pkg = require ( '../package.json' ) ;
4
+ const version = require ( '../package.json' ) . version ;
6
5
7
6
const REPO_URL = 'https://github.com/jest-community/eslint-plugin-jest' ;
8
7
@@ -123,18 +122,11 @@ const isFunction = node =>
123
122
*
124
123
* @param {string } filename - Name of the eslint rule
125
124
* @returns {string } URL to the documentation for the given rule
126
- * @throws {Error } If the documentation file for the given rule is not present.
127
125
*/
128
126
const getDocsUrl = filename => {
129
127
const ruleName = path . basename ( filename , '.js' ) ;
130
128
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` ;
138
130
} ;
139
131
140
132
module . exports = {
You can’t perform that action at this time.
0 commit comments