From 51282ab24d4b585912317b92f9b347879dd157db Mon Sep 17 00:00:00 2001 From: Konstantin Popov Date: Fri, 5 Nov 2021 02:44:19 +0300 Subject: [PATCH] [eslint] enable some rules 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; --- .eslintignore | 1 + .eslintrc | 2 ++ factoryWithTypeCheckers.js | 7 +++---- 3 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..cc1f706 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +prop-types.min.js 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);