From 66226599be89dbe7d49c3c4f81163f2ae86766f2 Mon Sep 17 00:00:00 2001 From: Konstantin Popov Date: Fri, 5 Nov 2021 02:44:19 +0300 Subject: [PATCH] Additional ESLint rules & Fix typo in factoryWithTypeCheckers.js 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; --- .eslintrc | 2 ++ factoryWithTypeCheckers.js | 7 +++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.eslintrc b/.eslintrc index 988da41..e166fe9 100644 --- a/.eslintrc +++ b/.eslintrc @@ -9,6 +9,8 @@ }, "rules": { "no-console": "off", + "no-multi-spaces": ["error"], + "key-spacing": ["error"], }, "overrides": [ { diff --git a/factoryWithTypeCheckers.js b/factoryWithTypeCheckers.js index adbd752..09441a2 100644 --- a/factoryWithTypeCheckers.js +++ b/factoryWithTypeCheckers.js @@ -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.' @@ -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]; @@ -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);