File tree 7 files changed +78
-265
lines changed
7 files changed +78
-265
lines changed Original file line number Diff line number Diff line change @@ -174,11 +174,10 @@ export async function generate(
174
174
) ;
175
175
176
176
const contents = readFileSync ( pathToDoc ) . toString ( ) ;
177
- const contentsNew = await replaceOrCreateHeader (
177
+ const contentsNew = replaceOrCreateHeader (
178
178
contents ,
179
179
newHeaderLines ,
180
- END_RULE_HEADER_MARKER ,
181
- pathToDoc
180
+ END_RULE_HEADER_MARKER
182
181
) ;
183
182
184
183
if ( options ?. check ) {
@@ -230,7 +229,7 @@ export async function generate(
230
229
231
230
// Update the rules list in the README.
232
231
const readmeContents = readFileSync ( pathToReadme , 'utf8' ) ;
233
- const readmeContentsNew = await updateRulesList (
232
+ const readmeContentsNew = updateRulesList (
234
233
details ,
235
234
readmeContents ,
236
235
plugin ,
Original file line number Diff line number Diff line change 1
1
// General helpers for dealing with markdown files / content.
2
2
3
- export async function format ( str : string , filePath : string ) : Promise < string > {
4
- try {
5
- const { default : prettier } = await import ( 'prettier' ) ;
6
- const options = await prettier . resolveConfig ( filePath ) ;
7
- return prettier
8
- . format ( str , {
9
- ...options ,
10
- parser : 'markdown' ,
11
- } )
12
- . trimEnd ( ) ; // Trim the ending newline that prettier may add.
13
- } catch {
14
- // Skip prettier formatting if not installed.
15
- /* istanbul ignore next -- TODO: Figure out how to test when prettier is not installed. */
16
- return str ;
17
- }
18
- }
19
-
20
3
/**
21
4
* Replace the header of a doc up to and including the specified marker.
22
5
* Insert at beginning if header doesn't exist.
23
6
* @param markdown - doc content
24
7
* @param newHeader - new header including marker
25
8
* @param marker - marker to indicate end of header
26
9
*/
27
- export async function replaceOrCreateHeader (
10
+ export function replaceOrCreateHeader (
28
11
markdown : string ,
29
12
newHeader : string ,
30
- marker : string ,
31
- pathToDoc : string
13
+ marker : string
32
14
) {
33
15
const lines = markdown . split ( '\n' ) ;
34
16
@@ -39,9 +21,7 @@ export async function replaceOrCreateHeader(
39
21
lines . splice ( 0 , 1 ) ;
40
22
}
41
23
42
- return `${ await format ( newHeader , pathToDoc ) } \n${ lines
43
- . slice ( markerLineIndex + 1 )
44
- . join ( '\n' ) } `;
24
+ return `${ newHeader } \n${ lines . slice ( markerLineIndex + 1 ) . join ( '\n' ) } ` ;
45
25
}
46
26
47
27
/**
Original file line number Diff line number Diff line change 7
7
} from './emojis.js' ;
8
8
import { getConfigsForRule } from './configs.js' ;
9
9
import { getColumns , COLUMN_HEADER } from './rule-list-columns.js' ;
10
- import { findSectionHeader , format } from './markdown.js' ;
10
+ import { findSectionHeader } from './markdown.js' ;
11
11
import { getPluginRoot } from './package-json.js' ;
12
12
import { generateLegend } from './legend.js' ;
13
13
import { relative } from 'node:path' ;
@@ -271,7 +271,7 @@ function generateRulesListMarkdownWithSplitBy(
271
271
return parts . join ( '\n\n' ) ;
272
272
}
273
273
274
- export async function updateRulesList (
274
+ export function updateRulesList (
275
275
details : RuleDetails [ ] ,
276
276
markdown : string ,
277
277
plugin : Plugin ,
@@ -284,7 +284,7 @@ export async function updateRulesList(
284
284
ruleListColumns : COLUMN_TYPE [ ] ,
285
285
urlConfigs ?: string ,
286
286
splitBy ?: string
287
- ) : Promise < string > {
287
+ ) : string {
288
288
let listStartIndex = markdown . indexOf ( BEGIN_RULE_LIST_MARKER ) ;
289
289
let listEndIndex = markdown . indexOf ( END_RULE_LIST_MARKER ) ;
290
290
@@ -360,7 +360,7 @@ export async function updateRulesList(
360
360
ignoreConfig
361
361
) ;
362
362
363
- const newContent = await format ( `${ legend } \n\n${ list } ` , pathToReadme ) ;
363
+ const newContent = ` ${ legend ? `${ legend } \n\n` : '' } ${ list } `;
364
364
365
365
return `${ preList } ${ BEGIN_RULE_LIST_MARKER } \n\n${ newContent } \n\n${ END_RULE_LIST_MARKER } ${ postList } ` ;
366
366
}
Original file line number Diff line number Diff line change 55
55
"@types/jest" : " ^29.1.0" ,
56
56
"@types/mock-fs" : " ^4.13.1" ,
57
57
"@types/node" : " ^18.7.23" ,
58
- "@types/prettier" : " ^2.7.1" ,
59
58
"@types/sinon" : " ^10.0.13" ,
60
59
"@typescript-eslint/eslint-plugin" : " ^5.38.1" ,
61
60
"@typescript-eslint/parser" : " ^5.38.1" ,
77
76
"typescript" : " ^4.8.4"
78
77
},
79
78
"peerDependencies" : {
80
- "eslint" : " >= 7" ,
81
- "prettier" : " >= 2"
79
+ "eslint" : " >= 7"
82
80
},
83
81
"engines" : {
84
82
"node" : " ^14.18.0 || ^16.0.0 || >=18.0.0"
You can’t perform that action at this time.
0 commit comments