Skip to content

Commit 00f9cad

Browse files
refactor: Adds support for Twoslash-Eslint and makes Twoslasher selection more dynamic (#80)
* feat: add Twoslash ESLint support and documentation - Introduced support for Twoslash ESLint in the expressive-code-twoslash package. - Added a new ESLint option for defining types of code blocks. - Created documentation for Twoslash ESLint integration with usage examples. - Updated pnpm workspace configuration to include twoslash-eslint dependency. * docs: enhance Twoslash ESLint integration description for clarity * feat: add themes configuration to EC-Twoslash * fix: remove unnecessary await from shouldTransform function call * fix: add missing await to shouldTransform function call in ecTwoSlash * feat: disable syntax highlighting in markdown configuration * feat: disable built-in syntax highlighting in Astro configuration * feat: add ESLint configuration options for Twoslash instance * feat: add documentation for PluginTwoslashOptions interface * fix: ensure getTwoslasher returns null when no valid function is found * feat: comment out shikiColorizedBrackets plugin configuration in ec.config.mjs * fix: add missing addedIn field to Twoslash ESLint documentation * refactor: remove shikiColorizedBrackets plugin and related theme files from configuration * feat: re-organize sidebar * fix: update TypeScript Twoslasher description to include hyperlink * feat: add usage instructions for ESLint and Vue integrations in documentation * fix: update reference to Twoslash ESLint documentation in ESLint integration guide * fix: add eslint to ignored dependencies in Renovate configuration * fix: remove unused @types/eslint dependency from package.json and pnpm-lock.yaml
1 parent b323683 commit 00f9cad

19 files changed

Lines changed: 1383 additions & 624 deletions

File tree

.changeset/huge-hoops-say.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
"expressive-code-twoslash": minor
3+
---
4+
5+
Adds support for Twoslash Eslint
6+
7+
Adds a new Eslint option for defining types of codeblocks.
8+
9+
Example usage:
10+
11+
``````md
12+
13+
```ts eslint
14+
const unused = 1
15+
16+
type Foo = {
17+
bar: string
18+
}
19+
```
20+
21+
``````
22+
23+
This will cause two eslint errors as annotations in the code

.github/renovate.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@
2222
"matchManagers": ["npm"],
2323
"matchFileNames": ["playground/**"]
2424
}
25-
]
25+
],
26+
"ignoreDeps": ["eslint"]
2627
}

docs/astro.config.mts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ const ogImageUrl = new URL("/og.png", site).href;
1111
// https://astro.build/config
1212
export default defineConfig({
1313
site,
14+
markdown: {
15+
// Disable Astro's built-in syntax highlighting since Expressive Code will handle it for us, and to avoid conflicts between the two.
16+
syntaxHighlight: false,
17+
},
1418
integrations: [
1519
starlight({
1620
title: "Expressive Code Twoslash",

docs/ec.config.mjs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import { defineEcConfig } from "@astrojs/starlight/expressive-code";
22
import ectwoslash from "expressive-code-twoslash";
3-
import shikiColorizedBrackets from "./plugins/shiki-color-brackets/index.js";
43

54
export default defineEcConfig({
65
plugins: [ectwoslash()],
7-
shiki: {
8-
transformers: [shikiColorizedBrackets()],
9-
},
106
});

docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"@types/mdast": "^4.0.4",
1717
"astro": "catalog:",
1818
"astro-expressive-code": "catalog:ec",
19+
"eslint": "^9.39.2",
1920
"expressive-code-twoslash": "workspace:*",
2021
"mdast-util-from-markdown": "catalog:mdast",
2122
"mdast-util-to-markdown": "^2.1.2",

0 commit comments

Comments
 (0)