eslint-plugin-react-hooks 2.0.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ {
2
+ "branch": "master",
3
+ "buildNumber": "54423",
4
+ "checksum": "3b849cc",
5
+ "commit": "5faf377df",
6
+ "environment": "ci",
7
+ "reactVersion": "16.10.2-5faf377df"
8
+ }
@@ -1,4 +1,4 @@
1
- /** @license React vundefined
1
+ /** @license React v2.2.0
2
2
  * eslint-plugin-react-hooks.development.js
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -550,7 +550,7 @@ var RuleOfHooks = {
550
550
  // call in a class, if it works, is unambiguously *not* a hook.
551
551
  } else if (codePathFunctionName) {
552
552
  // Custom message if we found an invalid function name.
553
- var _message = "React Hook \"" + context.getSource(hook) + "\" is called in " + ("function \"" + context.getSource(codePathFunctionName) + "\" ") + 'which is neither a React function component or a custom ' + 'React Hook function.';
553
+ var _message = "React Hook \"" + context.getSource(hook) + "\" is called in " + ("function \"" + context.getSource(codePathFunctionName) + "\" ") + 'that is neither a React function component nor a custom ' + 'React Hook function.';
554
554
 
555
555
  context.report({
556
556
  node: hook,
@@ -1,4 +1,4 @@
1
- /** @license React vundefined
1
+ /** @license React v2.2.0
2
2
  * eslint-plugin-react-hooks.production.min.js
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -25,7 +25,7 @@ d=!0;c=!1;var n=void 0;try{for(var f=a.nextSegments[Symbol.iterator](),B;!(d=(B=
25
25
  }}}d.set(a.id,c);return c}function v(a){var d=v.cache,c=d.get(a.id);if(null===c)return Infinity;if(void 0!==c)return c;d.set(a.id,null);if(0===a.prevSegments.length)c=1;else{c=Infinity;var n=!0,f=!1,B=void 0;try{for(var b=a.prevSegments[Symbol.iterator](),e;!(n=(e=b.next()).done);n=!0){var k=v(e.value);k<c&&(c=k)}}catch(na){f=!0,B=na}finally{try{n||null==b.return||b.return()}finally{if(f)throw B;}}c+=1}d.set(a.id,c);return c}var k=e.pop();if(0!==k.size){var C=new Set;h.cache=new Map;l.cache=new Map;
26
26
  v.cache=new Map;var F=l(b.initialSegment),g=ca(d),u=ba(d),x=g?aa(g)||S(g):!1,A=Infinity,m=!0,p=!1,I=void 0;try{for(var t=b.finalSegments[Symbol.iterator](),K;!(m=(K=t.next()).done);m=!0){var W=K.value;if(W.reachable){var R=v(W);R<A&&(A=R)}}}catch(G){p=!0,I=G}finally{try{m||null==t.return||t.return()}finally{if(p)throw I;}}m=!0;p=!1;I=void 0;try{for(var y=k[Symbol.iterator](),P;!(m=(P=y.next()).done);m=!0){var E=P.value,D=E[0],M=E[1];if(D.reachable){var J=0===D.nextSegments.length?A<=v(D):A<v(D),T=
27
27
  h(D)*l(D),H=C.has(D.id);k=!0;t=!1;K=void 0;try{for(var w=M[Symbol.iterator](),N;!(k=(N=w.next()).done);k=!0){var r=N.value;H&&a.report({node:r,message:'React Hook "'+a.getSource(r)+'" may be executed more than once. Possibly because it is called in a loop. React Hooks must be called in the exact same order in every component render.'});if(x){if(!H&&T!==F){var U='React Hook "'+a.getSource(r)+'" is called conditionally. React Hooks must be called in the exact same order in every component render.'+
28
- (J?" Did you accidentally call a React Hook after an early return?":"");a.report({node:r,message:U})}}else if(!d.parent||"MethodDefinition"!==d.parent.type&&"ClassProperty"!==d.parent.type||d.parent.value!==d)if(g){var O='React Hook "'+a.getSource(r)+'" is called in '+('function "'+a.getSource(g)+'" ')+"which is neither a React function component or a custom React Hook function.";a.report({node:r,message:O})}else if("Program"===d.type){var Q='React Hook "'+a.getSource(r)+'" cannot be called at the top level. React Hooks must be called in a React function component or a custom React Hook function.';
28
+ (J?" Did you accidentally call a React Hook after an early return?":"");a.report({node:r,message:U})}}else if(!d.parent||"MethodDefinition"!==d.parent.type&&"ClassProperty"!==d.parent.type||d.parent.value!==d)if(g){var O='React Hook "'+a.getSource(r)+'" is called in '+('function "'+a.getSource(g)+'" ')+"that is neither a React function component nor a custom React Hook function.";a.report({node:r,message:O})}else if("Program"===d.type){var Q='React Hook "'+a.getSource(r)+'" cannot be called at the top level. React Hooks must be called in a React function component or a custom React Hook function.';
29
29
  a.report({node:r,message:Q})}else if(u){var q='React Hook "'+a.getSource(r)+'" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function.';a.report({node:r,message:q})}}}catch(G){t=!0,K=G}finally{try{k||null==w.return||w.return()}finally{if(t)throw K;}}}}}catch(G){p=!0,I=G}finally{try{m||null==y.return||y.return()}finally{if(p)throw I;}}}},CallExpression:function(a){if(S(a.callee)){var d=e[e.length-1],h=b[b.length-1],l=d.get(h);l||
30
30
  (l=[],d.set(h,l));l.push(a.callee)}}}}},"exhaustive-deps":{meta:{fixable:"code",schema:[{type:"object",additionalProperties:!1,properties:{additionalHooks:{type:"string"}}}]},create:function(a){function e(a,d){return function(b){if(d.has(b))return d.get(b);var e=a(b);d.set(b,e);return e}}function b(b){function k(a){var c=!0,f=!1,d=void 0;try{for(var e=a.references[Symbol.iterator](),h;!(c=(h=e.next()).done);c=!0){var g=h.value;if(g.resolved&&I.has(g.resolved.scope)){var m=Y(b,g.identifier),l=fa(m),
31
31
  p=X(l),r;if(r=A&&"Identifier"===l.type&&"MemberExpression"===l.parent.type&&!l.parent.computed&&"Identifier"===l.parent.property.type&&"current"===l.parent.property.name){for(var q=g.from,u=!1;q.block!==b;)"function"===q.type&&(u=null!=q.block.parent&&"ReturnStatement"===q.block.parent.type),q=q.upper;r=u}r&&R.set(p,{reference:g,dependencyNode:l});var t=g.resolved.defs[0];if(null!=t&&(null==t.node||t.node.init!==b.parent)&&"TypeParameter"!==t.type)if(y.has(p))y.get(p).references.push(g);else{var w=
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-hooks",
3
3
  "description": "ESLint rules for React Hooks",
4
- "version": "2.0.1",
4
+ "version": "2.2.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/facebook/react.git",