eslint-plugin-react-hooks
Advanced tools
Comparing version 0.0.0-experimental-3f3fe0874 to 0.0.0-experimental-57333ca33
{ | ||
"branch": "pull/17418", | ||
"buildNumber": "61614", | ||
"checksum": "4ae6549", | ||
"commit": "3f3fe0874", | ||
"branch": "master", | ||
"buildNumber": "80519", | ||
"checksum": "fcf66d8", | ||
"commit": "57333ca33", | ||
"environment": "ci", | ||
"reactVersion": "16.12.0-experimental-3f3fe0874" | ||
"reactVersion": "16.12.0-experimental-57333ca33" | ||
} |
@@ -1,2 +0,2 @@ | ||
/** @license React v0.0.0-experimental-3f3fe0874 | ||
/** @license React v0.0.0-experimental-57333ca33 | ||
* eslint-plugin-react-hooks.production.min.js | ||
@@ -34,3 +34,3 @@ * | ||
g.resolved,z=K(w)||W(w);y.set(p,{isStatic:z,references:[g]})}}}}catch(Z){f=!0,c=Z}finally{try{b||null==e.return||e.return()}finally{if(f)throw c;}}b=!0;f=!1;c=void 0;try{for(var v=a.childScopes[Symbol.iterator](),x;!(b=(x=v.next()).done);b=!0)k(x.value)}catch(Z){f=!0,c=Z}finally{try{b||null==v.return||v.return()}finally{if(f)throw c;}}}function F(a,n,f,c){return 0===a.size?null:(1<a.size?"":n+" ")+f+" "+(1<a.size?"dependencies":"dependency")+": "+pa(Array.from(a).sort().map(function(a){return"'"+ | ||
a+"'"}))+(". Either "+c+" "+(1<a.size?"them":"it")+" or remove the dependency array.")}if(("FunctionExpression"===d.type||"ArrowFunctionExpression"===d.type)&&"CallExpression"===d.parent.type){var g=na(d.parent.callee,h);if(d.parent.arguments[g]===d){var u=d.parent.callee,x=ma(u).name,A=x.endsWith("Effect"),m=d.parent.arguments[g+1];if(m||A){A&&d.async&&a.report({node:d,message:"Effect callbacks are synchronous to prevent race conditions. Put the async function inside:\n\nuseEffect(() => {\n async function fetchData() {\n // You can await here\n const response = await MyAPI.getData(someId);\n // ...\n }\n fetchData();\n}, [someId]); // Or [] if effect doesn't need props or state\n\nLearn more about data fetching with Hooks: https://fb.me/react-hooks-data-fetching"}); | ||
a+"'"}))+(". Either "+c+" "+(1<a.size?"them":"it")+" or remove the dependency array.")}if(("FunctionExpression"===d.type||"ArrowFunctionExpression"===d.type)&&"CallExpression"===d.parent.type){var g=na(d.parent.callee,h);if(d.parent.arguments[g]===d){var u=d.parent.callee,x=ma(u).name,A=/Effect($|[^a-z])/g.test(x),m=d.parent.arguments[g+1];if(m||A){A&&d.async&&a.report({node:d,message:"Effect callbacks are synchronous to prevent race conditions. Put the async function inside:\n\nuseEffect(() => {\n async function fetchData() {\n // You can await here\n const response = await MyAPI.getData(someId);\n // ...\n }\n fetchData();\n}, [someId]); // Or [] if effect doesn't need props or state\n\nLearn more about data fetching with Hooks: https://fb.me/react-hooks-data-fetching"}); | ||
var p=a.getScope(),I=new Set,t=null;for(g=p.upper;g;){I.add(g);if("function"===g.type)break;g=g.upper}if(g){t=g;var K=e(function(a){if(!Array.isArray(a.defs))return!1;var b=a.defs[0];if(null==b||"VariableDeclarator"!==b.node.type)return!1;var f=b.node.init;if(null==f)return!1;var d=b.node.parent;if(null==d&&(Y(t.block,b.node.id),d=b.node.parent,null==d))return!1;if("const"===d.kind&&"Literal"===f.type&&("string"===typeof f.value||"number"===typeof f.value||null===f.value))return!0;if("CallExpression"!== | ||
@@ -37,0 +37,0 @@ f.type)return!1;f=f.callee;"MemberExpression"!==f.type||"React"!==f.object.name||null==f.property||f.computed||(f=f.property);if("Identifier"!==f.type)return!1;b=b.node.id;f=f.name;if("useRef"===f&&"Identifier"===b.type)return!0;if(("useState"===f||"useReducer"===f)&&"ArrayPattern"===b.type&&2===b.elements.length&&Array.isArray(a.identifiers)){if(b.elements[1]===a.identifiers[0]){if("useState"===f)for(a=a.references,f=0;f<a.length;f++)c.set(a[f].identifier,b.elements[0]);return!0}if(b.elements[0]=== |
{ | ||
"name": "eslint-plugin-react-hooks", | ||
"description": "ESLint rules for React Hooks", | ||
"version": "0.0.0-experimental-3f3fe0874", | ||
"version": "0.0.0-experimental-57333ca33", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
@@ -9,3 +9,3 @@ # `eslint-plugin-react-hooks` | ||
**Note: If you're using Create React App, please wait for a corresponding release of `react-scripts` that includes this rule instead of adding it directly.** | ||
**Note: If you're using Create React App, please use `react-scripts` >= 3 instead of adding it directly.** | ||
@@ -12,0 +12,0 @@ Assuming you already have ESLint installed, run: |
Sorry, the diff of this file is too big to display
102458