covariants icon indicating copy to clipboard operation
covariants copied to clipboard

Update MDX usage

Open AdvancedCodingMonkey opened this issue 1 year ago • 2 comments

We use mdx 1.6, the current version is 3. The migration seems to not be straightforward however, which is why we kept it at version 1.6 so far. Usage of mdx seems to have changed.

One can also implement linting for mdx files, which I could not get to work so far. Here is how far I got:

  1. Install eslint-plugin-mdx
  2. Adding the mdx config and file extension in eslint.config.mjs:
import * as mdx from 'eslint-plugin-mdx'
...
importPlugin.flatConfigs.warnings,
importPlugin.flatConfigs.typescript,
jsxA11Y.flatConfigs.recommended,
mdx.flat,
...
parserOptions: {
    ecmaFeatures: {
      jsx: true,
    },

    project: ['./tsconfig.eslint.json'],
    warnOnUnsupportedTypeScriptVersion: true,
    extraFileExtensions: ['.md', '.mdx'],
  },
  1. Adding file extensions to tsconfig.eslint.json:
"include": ["**/*.ts", "**/*.js", "**/*.tsx", "**/*.jsx", "**/*.mjs", "**/*.md", "**/*.mdx"]

=> eslint runs put results in parsing errors for .md and .mdx files.

Additionally, all our "mdx" files actually have a .md file extension, which we should probably change.

AdvancedCodingMonkey avatar Feb 19 '25 09:02 AdvancedCodingMonkey

It seems one also needs to import and add the mdx parser

import * as mdx from eslint-mdx

languageOptions:
   parser: mdx.parser

but this leads to more error mesages

AdvancedCodingMonkey avatar Apr 11 '25 13:04 AdvancedCodingMonkey

I did get mdx to work, just the linting remains.

AdvancedCodingMonkey avatar Apr 11 '25 13:04 AdvancedCodingMonkey