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.
Uh oh!
There was an error while loading. Please reload this page.
-
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-eslintrules, others require "parserServices to be generated".An example of this is
@typescript-eslint/consistent-type-exports. After following the setup instructions foreslint-plugin-mdxand 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/*.tsusing 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/*.tsto the include array to no avail..eslintrc.json{ "$schema": "https://json.schemastore.org/eslintrc.json", "env": { "browser": true, "node": true, "es2022": true }, "extends": ["eslint:recommended"], "overrides": [ { "files": ["*.mdx"], "extends": ["plugin:mdx/recommended"], "settings": { "mdx/code-blocks": true }, "rules": { // for mdx shortcodes, and snippets "react/jsx-no-undef": ["off"] } }, { "files": ["*.ts", "**/*.mdx/**.ts"], "extends": ["plugin:@typescript-eslint/recommended"], "parser": "@typescript-eslint/parser", "parserOptions": { "project": "./tsconfig.json", "extraFileExtensions": [".mdx"] }, "rules": { "@typescript-eslint/consistent-type-exports": [ "error", { "fixMixedExportsWithInlineTypeSpecifier": false } ], "@typescript-eslint/consistent-type-imports": [ "error", { "prefer": "type-imports" } ] } }, { "files": ["*.d.ts"], "rules": { "@typescript-eslint/triple-slash-reference": "off" } }, { "files": ["*.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" }, "rules": { "@typescript-eslint/consistent-type-exports": [ "error", { "fixMixedExportsWithInlineTypeSpecifier": false } ], "@typescript-eslint/consistent-type-imports": [ "error", { "prefer": "type-imports" } ] } } ] }I believe I have this configured correctly, though linting snippets is new to me. Is this plugin compatible with these
typescript-eslintrules?Beta Was this translation helpful? Give feedback.
All reactions