Skip to content

Commit 4974093

Browse files
authored
fix: clean up rebass which is not bundled with mdx (#295)
If you’re using `rebass` or other library as global components of mdx, you can use the helper `getGlobals` which is exported from `eslint-plugin-mdx` to simplify the usage.
1 parent 260a07e commit 4974093

File tree

4 files changed

+9
-363
lines changed

4 files changed

+9
-363
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"@types/jest": "^26.0.20",
3131
"@types/node": "^14.14.35",
3232
"@types/react": "^17.0.3",
33-
"@types/rebass": "^4.0.8",
3433
"@types/unist": "^2.0.3",
3534
"eslint-mdx": "link:packages/eslint-mdx/src",
3635
"eslint-plugin-mdx": "link:packages/eslint-plugin-mdx/src",

packages/eslint-plugin-mdx/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,5 @@
4141
"tslib": "^2.1.0",
4242
"unified": "^9.2.1",
4343
"vfile": "^4.2.1"
44-
},
45-
"optionalDependencies": {
46-
"rebass": "^4.0.7"
4744
}
4845
}

packages/eslint-plugin-mdx/src/configs/overrides.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,12 @@
11
import type { Linter } from 'eslint'
2-
import type Rebass from 'rebass'
32

43
import { base } from './base'
5-
import { getGlobals } from './helpers'
6-
7-
let rebass: typeof Rebass | string[]
8-
9-
try {
10-
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
11-
rebass = require('rebass') as typeof rebass
12-
} catch {
13-
// `rebass`(or `reflexbox` actually) requires `react` as peerDependency, but not all projects using `mdx` are `React` based, so we fallback to hardcoded `rebass` Components here
14-
/* istanbul ignore next */
15-
rebass = ['Box', 'Flex', 'Text', 'Heading', 'Link', 'Button', 'Image', 'Card']
16-
}
174

185
export const overrides: Linter.Config = {
196
...base,
20-
globals: getGlobals(rebass, {
21-
React: false,
22-
}),
7+
globals: {
8+
React: 'readonly',
9+
},
2310
rules: {
2411
'lines-between-class-members': 0, // See https://github.com/mdx-js/mdx/issues/195
2512
'react/jsx-no-undef': [

0 commit comments

Comments
 (0)