Replies: 5 comments 2 replies
-
I don't think you can use TypeScript ESLint rules that require parser services with any custom ESLint parsers. |
Beta Was this translation helpful? Give feedback.
-
@josefaidt
I have the same one but no luck yet.. |
Beta Was this translation helpful? Give feedback.
-
It could be related to this issue. |
Beta Was this translation helpful? Give feedback.
-
any luck for anyone? |
Beta Was this translation helpful? Give feedback.
-
There is an issue where eslint rules are being applied to TypeScript code blocks within For eslint versions below 9:"overrides": [
{
"files": ["*.ts"],
+ "excludedFiles": ["*.mdx/**/*.ts"],
"extends": ["plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
"extraFileExtensions": [".mdx"]
},
// Other rules...
},
{
"files": ["*.tsx"],
+ "excludedFiles": ["*.mdx/**/*.tsx"],
"extends": [
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:react-hooks/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "prettier"],
"parserOptions": {
"project": "./tsconfig.json"
},
// Other rules...
}
] Here, For eslint version 9 and above:[
{
"files": ["*.ts", "*.tsx"],
+ "ignores": ["**/*.mdx/**.ts", "**/*.mdx/**.tsx"]
// Other settings...
}
] Additional Note on Type CheckingFor issues related to type checking in .mdx files, there are several potential solutions discussed in this GitHub issue. It's recommended to review these solutions for a more comprehensive approach to handling TypeScript in MDX files. |
Beta Was this translation helpful? Give feedback.
-
Hey folks I'm looking to apply a few
@typescript-eslint/*
rules to ts and tsx snippets in MDX files. I've gone through a few iterations of an eslint config aimed at addressing this, and while I'm able to lint ts snippets without some of the@typescript-eslint
rules, others require "parserServices to be generated".An example of this is
@typescript-eslint/consistent-type-exports
. After following the setup instructions foreslint-plugin-mdx
and adding this rule I encounter the following error:After digging around a few issues and other discussions I'm able to set up a rule that matches the virtual files with
*.mdx/*.ts
using overrides, however this begins to emit a different set of errors:This error alludes to a misconfiguration in the project's
tsconfig.json
, though it already includes this (virtual) file:In an effort to resolve this I've also attempted to add
**/*.mdx/*.ts
to the include array to no avail..eslintrc.json
I believe I have this configured correctly, though linting snippets is new to me. Is this plugin compatible with these
typescript-eslint
rules?Beta Was this translation helpful? Give feedback.
All reactions