Skip to content

Commit 0281fb3

Browse files
authored
fix: react could be unavailable, add hardcoded component names to… (#70)
1 parent b2a735d commit 0281fb3

File tree

13 files changed

+77
-59
lines changed

13 files changed

+77
-59
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
*.log
2+
*.tsbuildinfo
23
.changelog
34
.type-coverage
45
coverage
56
lib
67
node_modules
7-
tsconfig.tsbuildinfo
8-
test.*

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ script:
2323
- yarn test
2424

2525
after_success:
26-
- yarn global add codecov
26+
- yarn global add codecov codacy-coverage
2727
- codecov
28+
- cat ./coverage/lcov.info | codacy-coverage
2829

2930
before_deploy:
3031
- npm set //registry.npmjs.org/:_authToken $NPM_TOKEN
@@ -49,6 +50,5 @@ deploy:
4950
branch: develop
5051

5152
after_script:
52-
- yarn add -D @codechecks/client @codechecks/build-size-watcher @codechecks/type-coverage-watcher codacy-coverage -W
53+
- yarn add -D @codechecks/client @codechecks/build-size-watcher @codechecks/type-coverage-watcher -W
5354
- yarn codechecks
54-
- cat ./coverage/lcov.info | yarn codacy-coverage

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"jest": "^24.9.0",
4242
"lerna": "^3.16.4",
4343
"lerna-changelog": "^0.8.2",
44-
"lint-staged": "^9.2.5",
44+
"lint-staged": "^9.3.0",
4545
"npm-run-all": "^4.1.5",
4646
"prettier": "1.18.2",
4747
"react": "^16.9.0",

packages/eslint-mdx/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
"name": "eslint-mdx",
33
"version": "1.5.2",
44
"description": "ESLint Parser for MDX",
5-
"repository": {
6-
"type": "git",
7-
"url": "https://github.com/rx-ts/eslint-mdx.git",
8-
"directory": "packages/eslint-mdx"
9-
},
5+
"repository": "git+https://github.com/rx-ts/eslint-mdx.git",
6+
"homepage": "https://github.com/rx-ts/eslint-mdx/blob/master/packages/eslint-mdx",
107
"author": "JounQin <[email protected]>",
118
"license": "MIT",
9+
"engines": {
10+
"node": ">=7.0.0"
11+
},
1212
"main": "lib",
1313
"files": [
1414
"lib",
@@ -26,8 +26,8 @@
2626
},
2727
"dependencies": {
2828
"espree": "^6.1.1",
29-
"remark-mdx": "^1.4.4",
29+
"remark-mdx": "^1.4.5",
3030
"remark-parse": "^7.0.1",
31-
"unified": "^8.3.2"
31+
"unified": "^8.4.0"
3232
}
3333
}

packages/eslint-mdx/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../../tsconfig.base.json",
2+
"extends": "../../tsconfig.base",
33
"compilerOptions": {
44
"composite": true,
55
"rootDir": "src",

packages/eslint-plugin-mdx/package.json

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
"name": "eslint-plugin-mdx",
33
"version": "1.5.2",
44
"description": "ESLint Plugin for MDX",
5-
"repository": {
6-
"type": "git",
7-
"url": "https://github.com/rx-ts/eslint-mdx.git",
8-
"directory": "packages/eslint-plugin-mdx"
9-
},
5+
"repository": "git+https://github.com/rx-ts/eslint-mdx.git",
6+
"homepage": "https://github.com/rx-ts/eslint-mdx/blob/master/packages/eslint-plugin-mdx",
107
"author": "JounQin <[email protected]>",
118
"license": "MIT",
9+
"engines": {
10+
"node": ">=7.0.0"
11+
},
1212
"main": "lib",
1313
"files": [
1414
"lib",
@@ -22,17 +22,19 @@
2222
"eslint-mdx"
2323
],
2424
"peerDependencies": {
25-
"eslint": ">=5.0.0",
26-
"eslint-plugin-react": ">=7.0.0"
25+
"eslint": ">=5.0.0"
2726
},
2827
"dependencies": {
2928
"cosmiconfig": "^5.2.1",
3029
"eslint-mdx": "^1.5.2",
31-
"rebass": "^4.0.5",
32-
"remark-mdx": "^1.4.4",
30+
"eslint-plugin-react": ">=7.0.0",
31+
"remark-mdx": "^1.4.5",
3332
"remark-parse": "^7.0.1",
3433
"remark-stringify": "^7.0.3",
35-
"unified": "^8.3.2",
34+
"unified": "^8.4.0",
3635
"vfile": "^4.0.1"
36+
},
37+
"optionalDependencies": {
38+
"rebass": "^4.0.6"
3739
}
3840
}

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
import * as rebass from 'rebass'
2-
31
import { base } from './base'
42
import { getGlobals } from './helper'
53

4+
let rebass: typeof import('rebass') | string[]
5+
6+
try {
7+
// eslint-disable-next-line @typescript-eslint/no-require-imports
8+
rebass = require('rebass')
9+
} catch {
10+
// `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
11+
/* istanbul ignore next */
12+
rebass = ['Box', 'Flex', 'Text', 'Heading', 'Link', 'Button', 'Image', 'Card']
13+
}
14+
615
export const overrides = {
716
...base,
817
globals: getGlobals(rebass, {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ export const recommended = {
1919
},
2020
}
2121

22+
const OVERRIDES_AVAILABLE_VERSION = 6.4
23+
2224
// overrides in npm pkg is supported after v6.4.0
2325
// istanbul ignore else
24-
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
25-
if (minorVersion >= 6.4) {
26+
if (minorVersion >= OVERRIDES_AVAILABLE_VERSION) {
2627
const overrides: Array<{
2728
files: string | string[]
2829
extends?: string | string[]

packages/eslint-plugin-mdx/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
2-
"extends": "../../tsconfig.base.json",
2+
"extends": "../../tsconfig.base",
33
"compilerOptions": {
4+
"baseUrl": ".",
45
"composite": true,
56
"rootDir": "src",
67
"outDir": "lib"

packages/eslint-plugin-mdx/typings.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@ declare module 'eslint-plugin-react/lib/rules/no-unescaped-entities' {
99
const reactNoUnescapedEntities: Rule.RuleModule
1010
export = reactNoUnescapedEntities
1111
}
12+
13+
declare module 'remark-mdx' {
14+
import * as unified from 'unified'
15+
const mdx: unified.Attacher
16+
export = mdx
17+
}

0 commit comments

Comments
 (0)