Skip to content

Commit

Permalink
fix: react could be unavailable, add hardcoded component names to… (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin authored Sep 23, 2019
1 parent b2a735d commit 0281fb3
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 59 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
*.log
*.tsbuildinfo
.changelog
.type-coverage
coverage
lib
node_modules
tsconfig.tsbuildinfo
test.*
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ script:
- yarn test

after_success:
- yarn global add codecov
- yarn global add codecov codacy-coverage
- codecov
- cat ./coverage/lcov.info | codacy-coverage

before_deploy:
- npm set //registry.npmjs.org/:_authToken $NPM_TOKEN
Expand All @@ -49,6 +50,5 @@ deploy:
branch: develop

after_script:
- yarn add -D @codechecks/client @codechecks/build-size-watcher @codechecks/type-coverage-watcher codacy-coverage -W
- yarn add -D @codechecks/client @codechecks/build-size-watcher @codechecks/type-coverage-watcher -W
- yarn codechecks
- cat ./coverage/lcov.info | yarn codacy-coverage
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"jest": "^24.9.0",
"lerna": "^3.16.4",
"lerna-changelog": "^0.8.2",
"lint-staged": "^9.2.5",
"lint-staged": "^9.3.0",
"npm-run-all": "^4.1.5",
"prettier": "1.18.2",
"react": "^16.9.0",
Expand Down
14 changes: 7 additions & 7 deletions packages/eslint-mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"name": "eslint-mdx",
"version": "1.5.2",
"description": "ESLint Parser for MDX",
"repository": {
"type": "git",
"url": "https://github.com/rx-ts/eslint-mdx.git",
"directory": "packages/eslint-mdx"
},
"repository": "git+https://github.com/rx-ts/eslint-mdx.git",
"homepage": "https://github.com/rx-ts/eslint-mdx/blob/master/packages/eslint-mdx",
"author": "JounQin <admin@1stg.me>",
"license": "MIT",
"engines": {
"node": ">=7.0.0"
},
"main": "lib",
"files": [
"lib",
Expand All @@ -26,8 +26,8 @@
},
"dependencies": {
"espree": "^6.1.1",
"remark-mdx": "^1.4.4",
"remark-mdx": "^1.4.5",
"remark-parse": "^7.0.1",
"unified": "^8.3.2"
"unified": "^8.4.0"
}
}
2 changes: 1 addition & 1 deletion packages/eslint-mdx/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.base",
"compilerOptions": {
"composite": true,
"rootDir": "src",
Expand Down
22 changes: 12 additions & 10 deletions packages/eslint-plugin-mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"name": "eslint-plugin-mdx",
"version": "1.5.2",
"description": "ESLint Plugin for MDX",
"repository": {
"type": "git",
"url": "https://github.com/rx-ts/eslint-mdx.git",
"directory": "packages/eslint-plugin-mdx"
},
"repository": "git+https://github.com/rx-ts/eslint-mdx.git",
"homepage": "https://github.com/rx-ts/eslint-mdx/blob/master/packages/eslint-plugin-mdx",
"author": "JounQin <admin@1stg.me>",
"license": "MIT",
"engines": {
"node": ">=7.0.0"
},
"main": "lib",
"files": [
"lib",
Expand All @@ -22,17 +22,19 @@
"eslint-mdx"
],
"peerDependencies": {
"eslint": ">=5.0.0",
"eslint-plugin-react": ">=7.0.0"
"eslint": ">=5.0.0"
},
"dependencies": {
"cosmiconfig": "^5.2.1",
"eslint-mdx": "^1.5.2",
"rebass": "^4.0.5",
"remark-mdx": "^1.4.4",
"eslint-plugin-react": ">=7.0.0",
"remark-mdx": "^1.4.5",
"remark-parse": "^7.0.1",
"remark-stringify": "^7.0.3",
"unified": "^8.3.2",
"unified": "^8.4.0",
"vfile": "^4.0.1"
},
"optionalDependencies": {
"rebass": "^4.0.6"
}
}
13 changes: 11 additions & 2 deletions packages/eslint-plugin-mdx/src/configs/overrides.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import * as rebass from 'rebass'

import { base } from './base'
import { getGlobals } from './helper'

let rebass: typeof import('rebass') | string[]

try {
// eslint-disable-next-line @typescript-eslint/no-require-imports
rebass = require('rebass')
} catch {
// `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
/* istanbul ignore next */
rebass = ['Box', 'Flex', 'Text', 'Heading', 'Link', 'Button', 'Image', 'Card']
}

export const overrides = {
...base,
globals: getGlobals(rebass, {
Expand Down
5 changes: 3 additions & 2 deletions packages/eslint-plugin-mdx/src/configs/recommended.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ export const recommended = {
},
}

const OVERRIDES_AVAILABLE_VERSION = 6.4

// overrides in npm pkg is supported after v6.4.0
// istanbul ignore else
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
if (minorVersion >= 6.4) {
if (minorVersion >= OVERRIDES_AVAILABLE_VERSION) {
const overrides: Array<{
files: string | string[]
extends?: string | string[]
Expand Down
3 changes: 2 additions & 1 deletion packages/eslint-plugin-mdx/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.base",
"compilerOptions": {
"baseUrl": ".",
"composite": true,
"rootDir": "src",
"outDir": "lib"
Expand Down
6 changes: 6 additions & 0 deletions packages/eslint-plugin-mdx/typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ declare module 'eslint-plugin-react/lib/rules/no-unescaped-entities' {
const reactNoUnescapedEntities: Rule.RuleModule
export = reactNoUnescapedEntities
}

declare module 'remark-mdx' {
import * as unified from 'unified'
const mdx: unified.Attacher
export = mdx
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "./tsconfig.base.json",
"extends": "./tsconfig.base",
"references": [
{
"path": "packages/eslint-mdx"
Expand Down
5 changes: 3 additions & 2 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"extends": "@1stg/tslint-config",
"rules": {
"no-reference": false
"no-reference": false,
"no-var-requires": false
},
"linterOptions": {
"exclude": ["node_modules/**", "**/lib/**"]
"exclude": ["node_modules/**", "**/lib/**", "**/*.d.ts"]
}
}
53 changes: 26 additions & 27 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4479,7 +4479,7 @@ eslint-plugin-react-hooks@^2.0.1:
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-2.0.1.tgz#e898ec26a0a335af6f7b0ad1f0bedda7143ed756"
integrity sha512-xir+3KHKo86AasxlCV8AHRtIZPHljqCRRUYgASkbatmt0fad4+5GgC7zkT7o/06hdKM6MIwp8giHVXqBPaarHQ==

eslint-plugin-react@^7.14.3:
eslint-plugin-react@>=7.0.0, eslint-plugin-react@^7.14.3:
version "7.14.3"
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.14.3.tgz#911030dd7e98ba49e1b2208599571846a66bdf13"
integrity sha512-EzdyyBWC4Uz2hPYBiEJrKCUi2Fn+BJ9B/pJQcjw5X+x/H2Nm59S4MJIvL4O5NEE0+WbnQwEBxWY03oUk+Bc3FA==
Expand Down Expand Up @@ -5212,9 +5212,9 @@ glob-parent@^3.1.0:
path-dirname "^1.0.0"

glob-parent@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.0.0.tgz#1dc99f0f39b006d3e92c2c284068382f0c20e954"
integrity sha512-Z2RwiujPRGluePM6j699ktJYxmPpJKCfpGA13jz2hmFZC7gKetzrWvg5KN3+OsIFmydGyZ1AVwERCq1w/ZZwRg==
version "5.1.0"
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.0.tgz#5f4c1d1e748d30cd73ad2944b3577a81b081e8c2"
integrity sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==
dependencies:
is-glob "^4.0.1"

Expand Down Expand Up @@ -6596,10 +6596,10 @@ lines-and-columns@^1.1.6:
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00"
integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=

lint-staged@^9.2.5:
version "9.2.5"
resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-9.2.5.tgz#5a3e1e0a539a403bd7f88542bc3d34ce52efdbb3"
integrity sha512-d99gTBFMJ29159+9iRvaMEQstmNcPAbQbhHSYw6D/1FncvFdIj8lWHztaq3Uq+tbZPABHXQ/fyN7Rp1QwF8HIw==
lint-staged@^9.3.0:
version "9.3.0"
resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-9.3.0.tgz#522a79f166050ab5777887348f2cbdb03f71acac"
integrity sha512-OuL3xo6XpBErl16+3W9PdnFmgeGp12lM8I1Ii/B56S8Edy1kyrf4W8VD4IBn9v17QlutRQEWUJ54YF/VVQ7J2A==
dependencies:
chalk "^2.4.2"
commander "^2.20.0"
Expand Down Expand Up @@ -7149,9 +7149,9 @@ minimist@~0.0.1:
integrity sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=

minipass@^2.2.1, minipass@^2.3.5, minipass@^2.6.0, minipass@^2.6.4:
version "2.6.5"
resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.6.5.tgz#1c245f9f2897f70fd4a219066261ce6c29f80b18"
integrity sha512-ewSKOPFH9blOLXx0YSE+mbrNMBFPS+11a2b03QZ+P4LVrUHW/GAlqeYC7DBknDyMWkHzrzTpDhUvy7MUxqyrPA==
version "2.8.1"
resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.8.1.tgz#a73bdc84cad62e8e6c8d56eba1302a5fe04c5910"
integrity sha512-QCG523ParRcE2+9A6wYh9UI3uy2FFLw4DQaVYQrY5HPfszc5M6VDD+j0QCwHm19LI2imes4RB+NBD8cOJccyCg==
dependencies:
safe-buffer "^5.1.2"
yallist "^3.0.0"
Expand Down Expand Up @@ -8278,7 +8278,7 @@ react-is@^16.8.1, react-is@^16.8.4:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.9.0.tgz#21ca9561399aad0ff1a7701c01683e8ca981edcb"
integrity sha512-tJBzzzIgnnRfEm046qRcURvwQnZVXmuCbscxUO5RWrGTXpon2d4c8mI0D8WE6ydVIm29JiLB6+RslkIvym9Rjw==

react@^16.8.6, react@^16.9.0:
react@^16.9.0:
version "16.9.0"
resolved "https://registry.yarnpkg.com/react/-/react-16.9.0.tgz#40ba2f9af13bc1a38d75dbf2f4359a5185c4f7aa"
integrity sha512-+7LQnFBwkiw+BobzOF6N//BdoNw0ouwmSJTEm9cglOOmsg/TMiFHZLe2sEoN5M7LgJTj9oHH0gxklfnQe66S1w==
Expand Down Expand Up @@ -8430,12 +8430,12 @@ realpath-native@^1.1.0:
dependencies:
util.promisify "^1.0.0"

rebass@^4.0.5:
version "4.0.5"
resolved "https://registry.yarnpkg.com/rebass/-/rebass-4.0.5.tgz#87bf5b0cc53e530ce0939611637d01aeb989df57"
integrity sha512-8MZngk/AmbC8u8pGmI1WelbsKYjmN9Z91C11G4ESB9QZnoppWsI+OAqio1/4/l6dxHmwZ/hR8Q4UApF+IVEprA==
rebass@^4.0.6:
version "4.0.6"
resolved "https://registry.yarnpkg.com/rebass/-/rebass-4.0.6.tgz#eaded5d0d99f68e69cd6b1e9e645f391c15d90dd"
integrity sha512-O4eSG4vhboiI00R5YmrRTuKiehpLkB3gDBWp00qymEbPxJPjkXoQVkOEhbWaRNRqBv/bMlvLczqarvCno1JORw==
dependencies:
reflexbox "^4.0.5"
reflexbox "^4.0.6"

redent@^1.0.0:
version "1.0.0"
Expand All @@ -8453,16 +8453,15 @@ redent@^2.0.0:
indent-string "^3.0.0"
strip-indent "^2.0.0"

reflexbox@^4.0.5:
version "4.0.5"
resolved "https://registry.yarnpkg.com/reflexbox/-/reflexbox-4.0.5.tgz#63a53702a111d16df6b1f0d6363b86be8ebc1fc6"
integrity sha512-SFWlrlKusgQVqjEimlLGNls3khjMlaTLrrF1H7YY7FfXv/mKK5mREDOW4l95D6Qa1kGoyM3hF+H5RLb3N6bCCA==
reflexbox@^4.0.6:
version "4.0.6"
resolved "https://registry.yarnpkg.com/reflexbox/-/reflexbox-4.0.6.tgz#fc756d2cc1ca493baf9b96bb27dd640ad8154cf1"
integrity sha512-UNUL4YoJEXAPjRKHuty1tuOk+LV1nDJ2KYViDcH7lYm5yU3AQ+EKNXxPU3E14bQNK/pE09b1hYl+ZKdA94tWLQ==
dependencies:
"@emotion/core" "^10.0.0"
"@emotion/styled" "^10.0.0"
"@styled-system/css" "^5.0.0"
"@styled-system/should-forward-prop" "^5.0.0"
react "^16.8.6"
styled-system "^5.0.0"

regenerate-unicode-properties@^8.1.0:
Expand Down Expand Up @@ -9074,7 +9073,7 @@ remark-lint@^6.0.0, remark-lint@^6.0.5:
dependencies:
remark-message-control "^4.0.0"

remark-mdx@^1.4.4:
remark-mdx@^1.4.5:
version "1.4.5"
resolved "https://registry.yarnpkg.com/remark-mdx/-/remark-mdx-1.4.5.tgz#4701cad33c6a4a0465514f39a7dbe9ee7715139f"
integrity sha512-Njjly0I6l7WAe+ob2qQ3K393rtkyJLjbaZOn84CE2P6nQRzei5PlNRn6DH5SfCzdzP7llHZbW+CVsj989kd/Wg==
Expand Down Expand Up @@ -9211,9 +9210,9 @@ remark-preset-lint-recommended@^3.0.3:
remark-lint-ordered-list-marker-style "^1.0.0"

remark-preset-prettier@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/remark-preset-prettier/-/remark-preset-prettier-0.2.0.tgz#cb369b86ce7d7980e90879fe468bae501fc06969"
integrity sha512-JC79MERKMoOrokjCsnMe1RXxH5KrZ2veg5eGRDzUbfKliXSTVMMvvw3PoZ5Gng8MhPrpOd+DkE+jpu937aS/wQ==
version "0.2.1"
resolved "https://registry.yarnpkg.com/remark-preset-prettier/-/remark-preset-prettier-0.2.1.tgz#00de65b8f3817428ba79aa535ee230530d0afd70"
integrity sha512-CH3CQi9sU1vrJGGmW4/+JlazpRsXJMaZYjmNmKyk58e7TUfKjE2VNVLJI8AIhA3G5sKZhEgD7FgmdIdp9Bxrsw==

remark-stringify@^7.0.3:
version "7.0.3"
Expand Down Expand Up @@ -10502,7 +10501,7 @@ unified@8.3.2:
trough "^1.0.0"
vfile "^4.0.0"

unified@^8.3.2:
unified@^8.4.0:
version "8.4.0"
resolved "https://registry.yarnpkg.com/unified/-/unified-8.4.0.tgz#5bb8a05c2a0b9dcc56152312ad8e4578a0d90af7"
integrity sha512-hQqeCrzqqS3vk8WbvbjYgaxe9WqmZF32Y3lz/kY5A8/5RdJbxoa4yOIAYpSEvqii9n2MTI2OL1+ByoVJYLhlUg==
Expand Down

0 comments on commit 0281fb3

Please sign in to comment.