Skip to content

Commit

Permalink
fix: result could be null in plugins.reduce
Browse files Browse the repository at this point in the history
related to disable `remark-lint-file-extension` automatically
  • Loading branch information
JounQin committed Apr 2, 2021
1 parent 0a97c20 commit cc2a7e7
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions packages/eslint-plugin-mdx/src/rules/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,17 @@ export const getRemarkProcessor = (searchFrom: string, isMdx: boolean) => {
const { plugins = [], settings } = (result?.config ||
{}) as Partial<RemarkConfig>

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

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

0 comments on commit cc2a7e7

Please sign in to comment.