Skip to content

Commit

Permalink
Merge pull request #4 from sandersn/do-not-fail-on-500
Browse files Browse the repository at this point in the history
Do not error for 500 or 524 errors
  • Loading branch information
sandersn committed Nov 29, 2021
1 parent 1a57082 commit dd1d58d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/dts-critic/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ of the Definitely Typed header to
*/
function checkSource(name, dts, src) {
if (dts.indexOf("export default") > -1 && !/declare module ['"]/.test(dts) &&
src.indexOf("524: A timeout occurred") === -1 && src.indexOf("500 Server Error") === -1 &&
!isRealExportDefault(name) && src.indexOf("default") === -1 && src.indexOf("__esModule") === -1 && src.indexOf("react-side-effect") === -1 && src.indexOf("@flow") === -1 && src.indexOf("module.exports = require") === -1) {
throw new Error(`The types for ${name} specify 'export default' but the source does not mention 'default' anywhere.
Here is the source:
Expand Down
12 changes: 12 additions & 0 deletions packages/dts-critic/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,16 @@ suite("checkSource", {
`module.exports = function () {};`)).toThrow(
"The types for foo specify 'export default' but the source does not mention 'default' anywhere.");
},
serverError500() {
expect(checkSource(
"foo",
`function f() {}; export default f;`,
`<title>500 Server Error</title>`)).toBeUndefined();
},
serverError524() {
expect(checkSource(
"foo",
`function f() {}; export default f;`,
`<title>unpkg.com | 524: A timeout occurred</title>`)).toBeUndefined();
},
});

0 comments on commit dd1d58d

Please sign in to comment.