A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/mdx-js/eslint-mdx/commit/7b5e7489f59659df7cc8d03b5ed5354e0f8a452e below:

support specifying `remarkConfigPath` manually (#589) · mdx-js/eslint-mdx@7b5e748 · GitHub

@@ -86,19 +86,26 @@ const ignoreCheckCache = new Map<

86 86

(filePath: string) => Promise<boolean>

87 87

>()

88 88 89 -

const getRemarkConfig = async (filePath: string, cwd: string) => {

90 -

let configLoad = configLoadCache.get(cwd)

89 +

const getRemarkConfig = async (

90 +

filePath: string,

91 +

cwd: string,

92 +

remarkConfigPath?: string,

93 +

) => {

94 +

const cacheKey = remarkConfigPath ? `${cwd}\0${remarkConfigPath}` : cwd

95 + 96 +

let configLoad = configLoadCache.get(cacheKey)

91 97 92 98

if (!configLoad) {

93 99

const config = new Configuration({

94 100

cwd,

95 101

packageField: 'remarkConfig',

96 102

pluginPrefix: 'remark',

97 103

rcName: '.remarkrc',

104 +

rcPath: remarkConfigPath,

98 105

detectConfig: true,

99 106

})

100 107

configLoad = promisify(config.load.bind(config))

101 -

configLoadCache.set(cwd, configLoad)

108 +

configLoadCache.set(cacheKey, configLoad)

102 109

}

103 110 104 111

if (!Ignore) {

@@ -109,7 +116,7 @@ const getRemarkConfig = async (filePath: string, cwd: string) => {

109 116

)) as { Ignore: IgnoreClass })

110 117

}

111 118 112 -

let ignoreCheck = ignoreCheckCache.get(cwd)

119 +

let ignoreCheck = ignoreCheckCache.get(cacheKey)

113 120 114 121

if (!ignoreCheck) {

115 122

const ignore = new Ignore({

@@ -118,7 +125,7 @@ const getRemarkConfig = async (filePath: string, cwd: string) => {

118 125

detectIgnore: true,

119 126

})

120 127

ignoreCheck = promisify(ignore.check.bind(ignore))

121 -

ignoreCheckCache.set(cwd, ignoreCheck)

128 +

ignoreCheckCache.set(cacheKey, ignoreCheck)

122 129

}

123 130 124 131

return configLoad(filePath)

@@ -142,6 +149,7 @@ export const getRemarkProcessor = async (

142 149

isMdx: boolean,

143 150

ignoreRemarkConfig?: boolean,

144 151

cwd = process.cwd(),

152 +

remarkConfigPath?: string,

145 153

) => {

146 154

const initCacheKey = `${String(isMdx)}-${cwd}\0${filePath}`

147 155

@@ -153,7 +161,7 @@ export const getRemarkProcessor = async (

153 161 154 162

const result = ignoreRemarkConfig

155 163

? null

156 -

: await getRemarkConfig(filePath, cwd)

164 +

: await getRemarkConfig(filePath, cwd, remarkConfigPath)

157 165 158 166

const cacheKey = result?.filePath

159 167

? `${String(isMdx)}-${result.filePath}`

@@ -227,6 +235,8 @@ runAsWorker(

227 235

isMdx,

228 236

process,

229 237

ignoreRemarkConfig,

238 +

remarkConfigPath,

239 +

// eslint-disable-next-line sonarjs/cognitive-complexity

230 240

}: WorkerOptions): Promise<WorkerResult> => {

231 241

sharedTokens.length = 0

232 242

@@ -245,6 +255,7 @@ runAsWorker(

245 255

isMdx,

246 256

ignoreRemarkConfig,

247 257

cwd,

258 +

remarkConfigPath,

248 259

)

249 260 250 261

const fileOptions: VFileOptions = {

@@ -254,7 +265,9 @@ runAsWorker(

254 265

}

255 266 256 267

if (process) {

257 -

if (await ignoreCheckCache.get(cwd)(filePath)) {

268 +

const cacheKey = remarkConfigPath ? `${cwd}\0${remarkConfigPath}` : cwd

269 + 270 +

if (await ignoreCheckCache.get(cacheKey)(filePath)) {

258 271

return {

259 272

messages: [],

260 273

}


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4