File tree Expand file tree Collapse file tree 3 files changed +29
-15
lines changed
eslint-plugin-mdx/src/rules Expand file tree Collapse file tree 3 files changed +29
-15
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " eslint-mdx " : patch
3+ " eslint-plugin-mdx " : patch
4+ ---
5+
6+ fix: pass through ` remarkConfigPath ` of ` parserOptions `
Original file line number Diff line number Diff line change @@ -5,12 +5,15 @@ import type { JSXElement } from 'estree-jsx'
55import type { Root } from 'mdast'
66import type { VFileMessage } from 'vfile-message'
77
8- export interface ParserOptions extends Linter . ParserOptions {
8+ export interface CommonOptions {
9+ ignoreRemarkConfig ?: boolean
10+ remarkConfigPath ?: string
11+ }
12+
13+ export interface ParserOptions extends Linter . ParserOptions , CommonOptions {
914 extensions ?: string [ ] | string
1015 markdownExtensions ?: string [ ] | string
1116 filePath ?: string
12- ignoreRemarkConfig ?: boolean
13- remarkConfigPath ?: string
1417}
1518
1619export interface NormalPosition {
@@ -23,10 +26,8 @@ export interface NormalPosition {
2326 range : [ number , number ]
2427}
2528
26- export interface SyncOptions {
29+ export interface SyncOptions extends CommonOptions {
2730 cwd ?: string
28- ignoreRemarkConfig ?: boolean
29- remarkConfigPath ?: string
3031}
3132
3233export interface WorkerOptions extends SyncOptions {
Original file line number Diff line number Diff line change @@ -27,25 +27,31 @@ export const remark: Rule.RuleModule = {
2727 const extname = path . extname ( filename )
2828 // eslint-disable-next-line sonarjs/deprecation -- FIXME: ESLint 8.40+ required
2929 const sourceCode = context . getSourceCode ( )
30- // eslint-disable-next-line sonarjs/deprecation -- FIXME: ESLint 8.40+ required
31- const options = context . parserOptions as ParserOptions
32- const isMdx = [
33- ...DEFAULT_EXTENSIONS ,
34- ...( options . extensions || [ ] ) ,
35- ] . includes ( extname )
30+
31+ const {
32+ extensions,
33+ markdownExtensions,
34+ ignoreRemarkConfig,
35+ remarkConfigPath,
36+ } =
37+ // eslint-disable-next-line sonarjs/deprecation -- FIXME: ESLint 8.40+ required
38+ context . parserOptions as ParserOptions
39+
40+ const isMdx = [ ...DEFAULT_EXTENSIONS , ...( extensions || [ ] ) ] . includes (
41+ extname ,
42+ )
3643 const isMarkdown = [
3744 ...MARKDOWN_EXTENSIONS ,
38- ...( options . markdownExtensions || [ ] ) ,
45+ ...( markdownExtensions || [ ] ) ,
3946 ] . includes ( extname )
47+
4048 return {
4149 Program ( node ) {
4250 /* istanbul ignore if */
4351 if ( ! isMdx && ! isMarkdown ) {
4452 return
4553 }
4654
47- const ignoreRemarkConfig = Boolean ( options . ignoreRemarkConfig )
48-
4955 const sourceText = sourceCode . getText ( node )
5056
5157 const { messages, content : fixedText } = performSyncWork ( {
@@ -56,6 +62,7 @@ export const remark: Rule.RuleModule = {
5662 isMdx,
5763 process : true ,
5864 ignoreRemarkConfig,
65+ remarkConfigPath,
5966 } )
6067
6168 let fixed = 0
You can’t perform that action at this time.
0 commit comments