Skip to content
This repository was archived by the owner on Nov 21, 2025. It is now read-only.

Commit 4805737

Browse files
JounQinrakannimer
authored andcommitted
feat: integrate with eslint-mdx to lint .mdx with ESLint (#1195)
* feat: add eslint-mdx support to lint mdx files * chore: lint examples
1 parent b0caf5e commit 4805737

File tree

31 files changed

+600
-91
lines changed

31 files changed

+600
-91
lines changed

.eslintignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
**/**/dist/**
1+
dist
2+
node_modules

core/docz-core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"build": "yarn cross-env NODE_ENV=production rollup -c",
1616
"dev": "yarn cross-env NODE_ENV=development yarn build -w",
1717
"fix": "yarn lint --fix",
18-
"lint": "yarn eslint . --ext .ts,.tsx",
18+
"lint": "yarn eslint . --ext mdx,ts,tsx",
1919
"precommit": "lint-staged",
2020
"prepare": "yarn build",
2121
"test": "yarn jest"
@@ -61,7 +61,7 @@
6161
"cpy": "^7.3.0",
6262
"cross-env": "^5.2.1",
6363
"docz-rollup": "2.0.0-rc.54",
64-
"eslint": "^6.3.0",
64+
"eslint": "^6.5.1",
6565
"eslint-config-docz-ts": "^2.0.0-rc.1",
6666
"jest": "^24.9.0"
6767
}

core/docz-core/src/bundler/server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ export const server = (args: Args) => async () => {
99
const doczrcFilepath = await findUp(finds('docz'))
1010
const machine = devServerMachine.withContext({ args, doczrcFilepath })
1111
const service = interpret(machine).onTransition(state => {
12-
args.debug && console.log(state.value)
12+
if (args.debug) {
13+
console.log(state.value)
14+
}
1315
})
1416

1517
return {

core/docz-core/src/lib/DataServer.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ export class DataServer {
5454

5555
public close(): void {
5656
for (const state of this.states) {
57-
isFunction(state.close) && state.close()
57+
if (isFunction(state.close)) {
58+
state.close()
59+
}
5860
}
5961
}
6062

core/docz-core/src/lib/Plugin.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ export class Plugin<C = any> implements PluginFactory {
3737
if (plugins && plugins.length > 0) {
3838
for (const plugin of plugins) {
3939
const fn = get<Plugin, any>(method, plugin)
40-
isFunction(fn) && fn(...args)
40+
if (isFunction(fn)) {
41+
fn(...args)
42+
}
4143
}
4244
}
4345
}

core/docz-core/src/utils/docgen/externalProptypesHandler.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,11 @@ function filterSpecifiers(specifiers: any, computedPropNames: any) {
353353
if (HOP.call(computedPropNames, cp)) {
354354
for (const sp in specifiers) {
355355
if (HOP.call(specifiers, sp) && specifiers[sp].indexOf(cp) > -1) {
356-
filteredSpecifiers[sp]
357-
? filteredSpecifiers[sp].push(cp)
358-
: (filteredSpecifiers[sp] = [cp])
356+
if (filteredSpecifiers[sp]) {
357+
filteredSpecifiers[sp].push(cp)
358+
} else {
359+
filteredSpecifiers[sp] = [cp]
360+
}
359361
}
360362
}
361363
}

core/docz-utils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"dev": "cross-env NODE_ENV=development yarn build -w",
1616
"build": "trash lib && cross-env NODE_ENV=production rollup -c",
1717
"fix": "yarn lint --fix",
18-
"lint": "eslint . --ext .ts,.tsx",
18+
"lint": "eslint . --ext mdx,ts,tsx",
1919
"precommit": "lint-staged"
2020
},
2121
"dependencies": {

core/docz/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"dev": "cross-env NODE_ENV=development yarn build -w",
2020
"build": "cross-env NODE_ENV=production rollup -c",
2121
"fix": "yarn lint --fix",
22-
"lint": "eslint . --ext .ts,.tsx",
22+
"lint": "eslint . --ext mdx,ts,tsx",
2323
"precommit": "lint-staged"
2424
},
2525
"dependencies": {
@@ -53,6 +53,7 @@
5353
"@types/react": "^16.8.23",
5454
"@types/react-dom": "^16.8.4",
5555
"docz-rollup": "2.0.0-rc.54",
56+
"eslint": "^6.5.1",
5657
"eslint-config-docz-ts": "^2.0.0-rc.1"
5758
}
5859
}

core/gatsby-theme-docz/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
},
5555
"devDependencies": {
5656
"babel-eslint": "10.0.2",
57-
"eslint": "^6.0.1",
57+
"eslint": "^6.5.1",
5858
"eslint-config-docz-js": "^2.0.0-rc.1"
5959
},
6060
"peerDependencies": {
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import * as React from 'react'
22

3-
const Wrapper = ({ children }) => (
4-
<React.Fragment>{children}</React.Fragment>
5-
)
3+
const Wrapper = ({ children }) => <React.Fragment>{children}</React.Fragment>
64
export default Wrapper

0 commit comments

Comments
 (0)