Skip to content

Commit 9ca50d0

Browse files
authored
fix: result could be null in plugins.reduce (#302)
related to disable `remark-lint-file-extension` automatically
1 parent 0a97c20 commit 9ca50d0

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

packages/eslint-plugin-mdx/src/rules/helpers.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,17 @@ export const getRemarkProcessor = (searchFrom: string, isMdx: boolean) => {
7575
const { plugins = [], settings } = (result?.config ||
7676
{}) as Partial<RemarkConfig>
7777

78-
try {
79-
// disable this rule automatically since we already have a parser option `extensions`
80-
// eslint-disable-next-line node/no-extraneous-require
81-
plugins.push([require.resolve('remark-lint-file-extension'), false])
82-
} catch {
83-
// just ignore if the package does not exist
78+
// disable this rule automatically since we already have a parser option `extensions`
79+
// only disable this plugin if there are at least one plugin enabled
80+
// otherwise `result` could be null inside `plugins.reduce`
81+
/* istanbul ignore else */
82+
if (plugins.length > 0) {
83+
try {
84+
// eslint-disable-next-line node/no-extraneous-require
85+
plugins.push([require.resolve('remark-lint-file-extension'), false])
86+
} catch {
87+
// just ignore if the package does not exist
88+
}
8489
}
8590

8691
const initProcessor = remarkProcessor().use({ settings }).use(remarkStringify)

0 commit comments

Comments
 (0)