Skip to content

Commit 3e862c7

Browse files
authored
fix: set processor for flat config, prefer context.languageOptions.parserOptions (#593)
1 parent 2d77937 commit 3e862c7

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

.changeset/new-pumpkins-remain.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-mdx": patch
3+
---
4+
5+
fix: set `processor` for flat config

.changeset/purple-terms-agree.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-mdx": patch
3+
---
4+
5+
fix: prefer `context.languageOptions.parserOptions` over `context.parserOptions`

packages/eslint-plugin-mdx/src/configs/flat.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ import type { Linter } from 'eslint'
22
import * as eslintMdx from 'eslint-mdx'
33

44
import * as mdx from '../index.js'
5+
import { remark } from '../processors/remark.js'
56

67
import { codeBlocks } from './code-blocks.js'
78

89
// eslint-disable-next-line sonarjs/deprecation
910
export const flat: Linter.FlatConfig = {
1011
files: ['**/*.{md,mdx}'],
1112
languageOptions: {
12-
sourceType: 'module',
13-
ecmaVersion: 'latest',
1413
parser: eslintMdx,
1514
globals: {
1615
React: false,
@@ -19,6 +18,7 @@ export const flat: Linter.FlatConfig = {
1918
plugins: {
2019
mdx,
2120
},
21+
processor: remark,
2222
rules: {
2323
'mdx/remark': 'warn',
2424
'no-unused-expressions': 'error',

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,17 @@ export const remark: Rule.RuleModule = {
2828
// eslint-disable-next-line sonarjs/deprecation -- FIXME: ESLint 8.40+ required
2929
const sourceCode = context.getSourceCode()
3030

31+
/* istanbul ignore next */
3132
const {
3233
extensions,
3334
markdownExtensions,
3435
ignoreRemarkConfig,
3536
remarkConfigPath,
36-
} =
37+
} = {
3738
// eslint-disable-next-line sonarjs/deprecation -- FIXME: ESLint 8.40+ required
38-
context.parserOptions as ParserOptions
39+
...context.parserOptions,
40+
...context.languageOptions?.parserOptions,
41+
} as ParserOptions
3942

4043
const isMdx = [...DEFAULT_EXTENSIONS, ...(extensions || [])].includes(
4144
extname,

0 commit comments

Comments
 (0)