Skip to content

Commit

Permalink
Additional ESLint rules & Fix typo in factoryWithTypeCheckers.js
Browse files Browse the repository at this point in the history
I've improved the documentation to fix some minor typos in this PR

Additional ESLint rules: "no-multi-spaces": ["error"], "key-spacing": ["error"]
"no-multi-spaces" - Disallow multiple spaces;
"key-spacing" - Enforce consistent spacing between keys and values in object literal properties;
  • Loading branch information
KonstHardy committed Nov 4, 2021
1 parent 4de0644 commit 6622659
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
},
"rules": {
"no-console": "off",
"no-multi-spaces": ["error"],
"key-spacing": ["error"],
},
"overrides": [
{
Expand Down
7 changes: 3 additions & 4 deletions factoryWithTypeCheckers.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) {
) {
printWarning(
'You are manually calling a React.PropTypes validation ' +
'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
'and will throw in the standalone `prop-types` package. ' +
'You may be seeing this warning due to a third-party PropTypes ' +
'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
Expand Down Expand Up @@ -445,8 +445,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) {
if (propType !== 'object') {
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
}
// We need to check all keys in case some are required but missing from
// props.
// We need to check all keys in case some are required but missing from props.
var allKeys = assign({}, props[propName], shapeTypes);
for (var key in allKeys) {
var checker = shapeTypes[key];
Expand All @@ -457,7 +456,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) {
return new PropTypeError(
'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
'\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
'\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
'\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
);
}
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
Expand Down

0 comments on commit 6622659

Please sign in to comment.