Skip to content

Commit 2ee7e94

Browse files
tools: run eslint on mdx files (#92324)
Enable eslint linting for mdx files. Currently with type aware linting disabled as MDX doesn't support TS expressions --------- Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
1 parent 3e5a8d9 commit 2ee7e94

File tree

4 files changed

+511
-28
lines changed

4 files changed

+511
-28
lines changed

eslint.config.mjs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import prettier from 'eslint-config-prettier';
1818
import importPlugin from 'eslint-plugin-import';
1919
import jest from 'eslint-plugin-jest';
2020
import jestDom from 'eslint-plugin-jest-dom';
21+
import * as mdx from 'eslint-plugin-mdx';
2122
import noRelativeImportPaths from 'eslint-plugin-no-relative-import-paths';
2223
import react from 'eslint-plugin-react';
2324
import reactHooks from 'eslint-plugin-react-hooks';
@@ -37,9 +38,14 @@ invariant(react.configs.flat, 'For typescript');
3738
invariant(react.configs.flat.recommended, 'For typescript');
3839
invariant(react.configs.flat['jsx-runtime'], 'For typescript');
3940

41+
// Exclude MDX files from type-aware linting
42+
// https://github.com/orgs/mdx-js/discussions/2454
43+
const MDXIgnore = ['**/*.mdx'];
44+
4045
// lint rules that need type information need to go here
4146
export const typeAwareLintRules = {
4247
name: 'plugin/typescript-eslint/type-aware-linting',
48+
ignores: MDXIgnore,
4349
rules: {
4450
'@typescript-eslint/await-thenable': 'error',
4551
'@typescript-eslint/no-array-delete': 'error',
@@ -457,8 +463,10 @@ export default typescript.config([
457463
'react-hooks/rules-of-hooks': 'error',
458464
},
459465
},
466+
typeAwareLintRules,
460467
{
461468
name: 'plugin/typescript-eslint/custom',
469+
ignores: MDXIgnore,
462470
rules: {
463471
'no-shadow': 'off', // Disabled in favor of @typescript-eslint/no-shadow
464472
'no-use-before-define': 'off', // See also @typescript-eslint/no-use-before-define
@@ -502,7 +510,6 @@ export default typescript.config([
502510
// https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/stylistic.ts
503511
...typescript.configs.strict.map(c => ({...c, name: `plugin/${c.name}`})),
504512
...typescript.configs.stylistic.map(c => ({...c, name: `plugin/${c.name}`})),
505-
typeAwareLintRules,
506513
{
507514
name: 'plugin/typescript-eslint/overrides',
508515
// https://typescript-eslint.io/rules/
@@ -976,4 +983,11 @@ export default typescript.config([
976983
'no-restricted-imports': 'off',
977984
},
978985
},
986+
987+
// MDX Configuration
988+
{
989+
...mdx.flat,
990+
name: 'files/mdx',
991+
files: ['**/*.mdx'],
992+
},
979993
]);

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"@dnd-kit/sortable": "^8.0.0",
2020
"@dnd-kit/utilities": "^3.2.2",
2121
"@emotion/babel-plugin": "^11.13.5",
22-
"@emotion/css": "^11.13.5",
2322
"@emotion/cache": "^11.14.0",
23+
"@emotion/css": "^11.13.5",
2424
"@emotion/is-prop-valid": "^1.3.0",
2525
"@emotion/react": "^11.14.0",
2626
"@emotion/styled": "^11.14.0",
@@ -195,9 +195,9 @@
195195
"@mdx-js/loader": "^3.1.0",
196196
"@mdx-js/mdx": "^3.1.0",
197197
"@pmmmwh/react-refresh-webpack-plugin": "0.5.16",
198+
"@sentry-internal/rrweb-types": "2.34.0",
198199
"@sentry/jest-environment": "6.0.0",
199200
"@sentry/profiling-node": "9.16.1",
200-
"@sentry-internal/rrweb-types": "2.34.0",
201201
"@styled/typescript-styled-plugin": "^1.0.1",
202202
"@swc/plugin-emotion": "9.0.4",
203203
"@tanstack/eslint-plugin-query": "^5.66.1",
@@ -215,6 +215,7 @@
215215
"eslint-plugin-import": "^2.31.0",
216216
"eslint-plugin-jest": "^28.11.0",
217217
"eslint-plugin-jest-dom": "^5.5.0",
218+
"eslint-plugin-mdx": "^3.4.2",
218219
"eslint-plugin-no-relative-import-paths": "^1.6.1",
219220
"eslint-plugin-react": "^7.37.4",
220221
"eslint-plugin-react-hooks": "5.2.0",

static/app/styles/colors.mdx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import DontAccentColors from 'sentry-images/stories/color/dont-accent-colors.svg
88
import DontContrast from 'sentry-images/stories/color/dont-contrast.svg';
99
import DontDifferentiation from 'sentry-images/stories/color/dont-differentiation.svg';
1010

11-
import ExternalLink from 'sentry/components/links/externalLink';
1211
import Panel from 'sentry/components/panels/panel';
1312
import PanelItem from 'sentry/components/panels/panelItem';
1413
import {IconCheckmark, IconClose} from 'sentry/icons';
@@ -144,17 +143,19 @@ export const ExampleCardGrid = styled('figcaption')`
144143
padding: ${space(1)} ${space(1)} 0;
145144
`;
146145

147-
export const ExampleCard = ({imgSrc, text, isPositive}) => (
148-
<figure>
149-
<ExampleImg src={imgSrc} />
150-
<ExampleCardGrid>
151-
{isPositive ? <PositiveLabel /> : <NegativeLabel />}
152-
<span>{text}</span>
153-
</ExampleCardGrid>
154-
</figure>
155-
);
156-
157-
export const ColorPalette = ({name, palette}) => {
146+
export function ExampleCard({imgSrc, text, isPositive}) {
147+
return (
148+
<figure>
149+
<ExampleImg src={imgSrc} />
150+
<ExampleCardGrid>
151+
{isPositive ? <PositiveLabel /> : <NegativeLabel />}
152+
<span>{text}</span>
153+
</ExampleCardGrid>
154+
</figure>
155+
);
156+
}
157+
158+
export function ColorPalette({name, palette}) {
158159
const theme = useTheme();
159160

160161
return (

0 commit comments

Comments
 (0)