-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify build #1035
Merged
Merged
Simplify build #1035
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ca97465
remove unnecessary plotly.js external from renderer webpack config
alexcjohnson 199a3fa
:hocho: raw-loader - just turn werkzeug css into a js string
alexcjohnson 832e2cf
:hocho: uniqid
alexcjohnson 36d0c71
pull in checkPropTypes
alexcjohnson 3f5bc18
changelog for build simplification
alexcjohnson 26f9bca
update checkPropTypes comments
alexcjohnson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* Copied out of prop-types and modified - inspired by check-prop-types, but | ||
* simplified and tweaked to our needs: we don't need the NODE_ENV check, | ||
* we report all errors, not just the first one, and we don't need the throwing | ||
* variant `assertPropTypes`. | ||
*/ | ||
import ReactPropTypesSecret from 'prop-types/lib/ReactPropTypesSecret'; | ||
|
||
/** | ||
* Assert that the values match with the type specs. | ||
* | ||
* @param {object} typeSpecs Map of name to a ReactPropType | ||
* @param {object} values Runtime values that need to be type-checked | ||
* @param {string} location e.g. "prop", "context", "child context" | ||
* @param {string} componentName Name of the component for error messages. | ||
* @param {?Function} getStack Returns the component stack. | ||
* @return {string} Any error messsage resulting from checking the types | ||
*/ | ||
export default function checkPropTypes( | ||
typeSpecs, | ||
values, | ||
location, | ||
componentName, | ||
getStack | ||
) { | ||
const errors = []; | ||
for (const typeSpecName in typeSpecs) { | ||
if (typeSpecs.hasOwnProperty(typeSpecName)) { | ||
let error; | ||
// Prop type validation may throw. In case they do, we don't want to | ||
// fail the render phase where it didn't fail before. So we log it. | ||
// After these have been cleaned up, we'll let them throw. | ||
try { | ||
// This is intentionally an invariant that gets caught. It's the same | ||
// behavior as without this statement except with a better message. | ||
if (typeof typeSpecs[typeSpecName] !== 'function') { | ||
error = Error( | ||
(componentName || 'React class') + | ||
': ' + | ||
location + | ||
' type `' + | ||
typeSpecName + | ||
'` is invalid; ' + | ||
'it must be a function, usually from the `prop-types` package, but received `' + | ||
typeof typeSpecs[typeSpecName] + | ||
'`.' | ||
); | ||
error.name = 'Invariant Violation'; | ||
} else { | ||
error = typeSpecs[typeSpecName]( | ||
values, | ||
typeSpecName, | ||
componentName, | ||
location, | ||
null, | ||
ReactPropTypesSecret | ||
); | ||
} | ||
} catch (ex) { | ||
error = ex; | ||
} | ||
if (error && !(error instanceof Error)) { | ||
errors.push( | ||
(componentName || 'React class') + | ||
': type specification of ' + | ||
location + | ||
' `' + | ||
typeSpecName + | ||
'` is invalid; the type checker ' + | ||
'function must return `null` or an `Error` but returned a ' + | ||
typeof error + | ||
'. ' + | ||
'You may have forgotten to pass an argument to the type checker ' + | ||
'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + | ||
'shape all require an argument).' | ||
); | ||
} | ||
if (error instanceof Error) { | ||
var stack = (getStack && getStack()) || ''; | ||
|
||
errors.push( | ||
'Failed ' + location + ' type: ' + error.message + stack | ||
); | ||
} | ||
} | ||
} | ||
return errors.join('\n\n'); | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the original file is under a BSD license, we should make sure that we either retain the original disclaimer as done in check-prop-type (https://github.com/ratehub/check-prop-types/blob/master/index.js#L7) or make sure the disclaimer for React is included explicitly in our bundled code -- which it wouldn't right now as we externalize React dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current
prop-types
license is MIT (it was changed from BSD shortly after check-prop-types was published), as is check-prop-types - that presumably means this concern is moot, yes?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moot as moot can be