@@ -19,6 +19,7 @@ const markdownIt = require("markdown-it");
1919const markdownItRuleExample = require ( "./tools/markdown-it-rule-example" ) ;
2020const prismESLintHook = require ( "./tools/prism-eslint-hook" ) ;
2121const preWrapperPlugin = require ( "./src/_plugins/pre-wrapper.js" ) ;
22+ const typescriptESLintParser = require ( "@typescript-eslint/parser" ) ;
2223
2324module . exports = function ( eleventyConfig ) {
2425 /*
@@ -206,22 +207,23 @@ module.exports = function (eleventyConfig) {
206207 // markdown-it plugin options for playground-linked code blocks in rule examples.
207208 const ruleExampleOptions = markdownItRuleExample ( {
208209 open ( { type, code, languageOptions, env, codeBlockToken } ) {
209- /*
210- * TypeScript isn't yet supported on the playground:
211- * https://github.com/eslint/eslint.org/issues/709
212- */
213- if ( codeBlockToken . info === "ts" ) {
214- return `<div class="${ type } ">` ;
215- }
210+ const isTypeScriptCode =
211+ codeBlockToken . info === "ts" || codeBlockToken . info === "tsx" ;
216212
217213 prismESLintHook . addContentMustBeMarked (
218214 codeBlockToken . content ,
219- languageOptions ,
215+ isTypeScriptCode
216+ ? { ...languageOptions , parser : typescriptESLintParser }
217+ : languageOptions ,
220218 ) ;
221219
222220 const isRuleRemoved = ! Object . hasOwn ( env . rules_meta , env . title ) ;
223221
224- if ( isRuleRemoved ) {
222+ /*
223+ * TypeScript isn't yet supported on the playground:
224+ * https://github.com/eslint/eslint.org/issues/709
225+ */
226+ if ( isRuleRemoved || isTypeScriptCode ) {
225227 return `<div class="${ type } ">` ;
226228 }
227229
0 commit comments