Skip to content

Commit

Permalink
feat: catch remark process error
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed Apr 30, 2020
1 parent a16ebb0 commit 80686eb
Show file tree
Hide file tree
Showing 5 changed files with 1,360 additions and 1,279 deletions.
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
"type-coverage": "type-coverage --cache --detail --ignore-catch --ignore-files '**/*.d.ts' --strict"
},
"devDependencies": {
"@1stg/lib-config": "^0.4.5",
"@1stg/tslint-config": "^0.8.3",
"@1stg/lib-config": "^0.5.1",
"@1stg/tslint-config": "^0.8.4",
"@types/eslint": "^6.8.0",
"@types/jest": "^25.2.1",
"@types/node": "^13.13.0",
"@types/node": "^13.13.4",
"@types/react": "^16.9.34",
"@types/rebass": "^4.0.5",
"@types/unist": "^2.0.3",
Expand All @@ -42,15 +42,15 @@
"npm-run-all": "^4.1.5",
"react": "^16.13.1",
"ts-jest": "^25.4.0",
"ts-node": "^8.8.2",
"tslint": "^6.1.1",
"ts-node": "^8.9.1",
"tslint": "^6.1.2",
"type-coverage": "^2.4.2",
"yarn-deduplicate": "^2.0.0"
},
"resolutions": {
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.5",
"eslint-plugin-prettier": "^3.1.3",
"@babel/core": "^7.9.6",
"@babel/preset-env": "^7.9.6",
"@types/estree": "^0.0.44",
"typescript": "^3.8.3"
},
"commitlint": {
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
},
"dependencies": {
"espree": "^6.2.1",
"remark-mdx": "^1.5.8",
"remark-parse": "^8.0.1",
"remark-mdx": "^1.6.0",
"remark-parse": "^8.0.2",
"tslib": "^1.11.1",
"unified": "^9.0.0"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin-mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
"cosmiconfig": "^6.0.0",
"eslint-mdx": "^1.6.9",
"eslint-plugin-react": "^7.19.0",
"remark-mdx": "^1.5.8",
"remark-parse": "^8.0.1",
"remark-mdx": "^1.6.0",
"remark-parse": "^8.0.2",
"remark-stringify": "^8.0.0",
"tslib": "^1.11.1",
"unified": "^9.0.0",
Expand Down
20 changes: 14 additions & 6 deletions packages/eslint-plugin-mdx/src/rules/remark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,20 @@ export const remark: Rule.RuleModule = {
}
const sourceText = sourceCode.getText(node)
const remarkProcessor = getRemarkProcessor(filename)
const file = remarkProcessor.processSync(
vfile({
path: filename,
contents: sourceText,
}),
)
const file = vfile({
path: filename,
contents: sourceText,
})

try {
remarkProcessor.processSync(file)
} catch (err) {
/* istanbul ignore next */
if (!file.messages.includes(err)) {
file.message(err).fatal = true
}
}

file.messages.forEach(
({ source, reason, ruleId, location: { start, end } }) =>
context.report({
Expand Down
Loading

1 comment on commit 80686eb

@JounQin
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wooorm A new version of eslint-mdx is ready.

Please sign in to comment.