summaryrefslogtreecommitdiff
path: root/packages/integrations/mdx
diff options
context:
space:
mode:
authorGravatar Josh Goldberg ✨ <git@joshuakgoldberg.com> 2023-07-03 05:59:43 -0700
committerGravatar GitHub <noreply@github.com> 2023-07-03 20:59:43 +0800
commit2fea174303ca60f4765c6294d99ebc7a19e73403 (patch)
tree671f1f27d6d0827e51aaa20704b7f6154ad5d053 /packages/integrations/mdx
parentfc6826ff7620b0c5e419de93ef7c463a12fe3652 (diff)
downloadastro-2fea174303ca60f4765c6294d99ebc7a19e73403.tar.gz
astro-2fea174303ca60f4765c6294d99ebc7a19e73403.tar.zst
astro-2fea174303ca60f4765c6294d99ebc7a19e73403.zip
feat: use typescript-eslint@v6's reworked configs (#7425)
Diffstat (limited to 'packages/integrations/mdx')
-rw-r--r--packages/integrations/mdx/src/plugins.ts2
-rw-r--r--packages/integrations/mdx/src/remark-shiki.ts3
-rw-r--r--packages/integrations/mdx/src/utils.ts2
-rw-r--r--packages/integrations/mdx/test/mdx-get-headings.test.js4
-rw-r--r--packages/integrations/mdx/test/mdx-page.test.js2
-rw-r--r--packages/integrations/mdx/test/mdx-plus-react.test.js2
6 files changed, 5 insertions, 10 deletions
diff --git a/packages/integrations/mdx/src/plugins.ts b/packages/integrations/mdx/src/plugins.ts
index 94c3c10ba..ed03f4b2b 100644
--- a/packages/integrations/mdx/src/plugins.ts
+++ b/packages/integrations/mdx/src/plugins.ts
@@ -33,7 +33,7 @@ export function recmaInjectImportMetaEnvPlugin({
estreeVisit(tree, (node) => {
if (node.type === 'MemberExpression') {
// attempt to get "import.meta.env" variable name
- const envVarName = getImportMetaEnvVariableName(node as MemberExpression);
+ const envVarName = getImportMetaEnvVariableName(node);
if (typeof envVarName === 'string') {
// clear object keys to replace with envVarLiteral
for (const key in node) {
diff --git a/packages/integrations/mdx/src/remark-shiki.ts b/packages/integrations/mdx/src/remark-shiki.ts
index 3f3310de7..83625051e 100644
--- a/packages/integrations/mdx/src/remark-shiki.ts
+++ b/packages/integrations/mdx/src/remark-shiki.ts
@@ -69,7 +69,6 @@ const remarkShiki = async ({ langs = [], theme = 'github-dark', wrap = false }:
if (langExists) {
lang = node.lang;
} else {
- // eslint-disable-next-line no-console
console.warn(`The language "${node.lang}" doesn't exist, falling back to plaintext.`);
lang = 'plaintext';
}
@@ -77,7 +76,7 @@ const remarkShiki = async ({ langs = [], theme = 'github-dark', wrap = false }:
lang = 'plaintext';
}
- let html = highlighter!.codeToHtml(node.value, { lang });
+ let html = highlighter.codeToHtml(node.value, { lang });
// Q: Couldn't these regexes match on a user's inputted code blocks?
// A: Nope! All rendered HTML is properly escaped.
diff --git a/packages/integrations/mdx/src/utils.ts b/packages/integrations/mdx/src/utils.ts
index 80f8c3e20..3425c50e3 100644
--- a/packages/integrations/mdx/src/utils.ts
+++ b/packages/integrations/mdx/src/utils.ts
@@ -32,7 +32,7 @@ export function getFileInfo(id: string, config: AstroConfig): FileInfo {
const isPage = fileId.includes('/pages/');
if (isPage) {
fileUrl = fileId.replace(/^.*?\/pages\//, sitePathname).replace(/(\/index)?\.mdx$/, '');
- } else if (url && url.pathname.startsWith(config.root.pathname)) {
+ } else if (url?.pathname.startsWith(config.root.pathname)) {
fileUrl = url.pathname.slice(config.root.pathname.length);
} else {
fileUrl = fileId;
diff --git a/packages/integrations/mdx/test/mdx-get-headings.test.js b/packages/integrations/mdx/test/mdx-get-headings.test.js
index 1b1987e77..5b415c70f 100644
--- a/packages/integrations/mdx/test/mdx-get-headings.test.js
+++ b/packages/integrations/mdx/test/mdx-get-headings.test.js
@@ -72,7 +72,7 @@ describe('MDX heading IDs can be customized by user plugins', () => {
rehypePlugins: [
() => (tree) => {
let count = 0;
- visit(tree, 'element', (node, index, parent) => {
+ visit(tree, 'element', (node) => {
if (!/^h\d$/.test(node.tagName)) return;
if (!node.properties?.id) {
node.properties = { ...node.properties, id: String(count++) };
@@ -125,7 +125,7 @@ describe('MDX heading IDs can be injected before user plugins', () => {
rehypePlugins: [
rehypeHeadingIds,
() => (tree) => {
- visit(tree, 'element', (node, index, parent) => {
+ visit(tree, 'element', (node) => {
if (!/^h\d$/.test(node.tagName)) return;
if (node.properties?.id) {
node.children.push({ type: 'text', value: ' ' + node.properties.id });
diff --git a/packages/integrations/mdx/test/mdx-page.test.js b/packages/integrations/mdx/test/mdx-page.test.js
index 726f091c9..52d10bce3 100644
--- a/packages/integrations/mdx/test/mdx-page.test.js
+++ b/packages/integrations/mdx/test/mdx-page.test.js
@@ -1,5 +1,3 @@
-import mdx from '@astrojs/mdx';
-
import { expect } from 'chai';
import { parseHTML } from 'linkedom';
import { loadFixture } from '../../../astro/test/test-utils.js';
diff --git a/packages/integrations/mdx/test/mdx-plus-react.test.js b/packages/integrations/mdx/test/mdx-plus-react.test.js
index 49c25d558..22d7ca0e7 100644
--- a/packages/integrations/mdx/test/mdx-plus-react.test.js
+++ b/packages/integrations/mdx/test/mdx-plus-react.test.js
@@ -1,5 +1,3 @@
-import mdx from '@astrojs/mdx';
-
import { expect } from 'chai';
import { parseHTML } from 'linkedom';
import { loadFixture } from '../../../astro/test/test-utils.js';