Socket
Socket
Sign inDemoInstall

eslint-plugin-react-hooks

Package Overview
Dependencies
Maintainers
6
Versions
1836
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-react-hooks - npm Package Compare versions

Comparing version 0.0.0-experimental-8d7535e54 to 0.0.0-experimental-aae83a4b9

8

build-info.json
{
"branch": "master",
"buildNumber": "90723",
"checksum": "348207c",
"commit": "8d7535e54",
"buildNumber": "105612",
"checksum": "b755e17",
"commit": "aae83a4b9",
"environment": "ci",
"reactVersion": "16.12.0-experimental-8d7535e54"
"reactVersion": "16.13.0-experimental-aae83a4b9"
}

@@ -1,2 +0,2 @@

/** @license React v0.0.0-experimental-8d7535e54
/** @license React v0.0.0-experimental-aae83a4b9
* eslint-plugin-react-hooks.production.min.js

@@ -22,9 +22,9 @@ *

function Z(a,e){for(var b=[a],g=null;b.length;){g=b.shift();if("Identifier"===g.type&&g.name===e.name&&g.range[0]===e.range[0]&&g.range[1]===e.range[1])return g;if(ka(g,e)){a=0;for(var d=Object.entries(g);a<d.length;a++){var x=d[a],n=x[1];"parent"!==x[0]&&(oa(n)?(n.parent=g,b.push(n)):Array.isArray(n)&&n.forEach(function(a){oa(a)&&(a.parent=g,b.push(a))}))}}}return null}
function pa(a){for(var e="",b=0;b<a.length;b++)e+=a[b],0===b&&2===a.length?e+=" and ":b===a.length-2&&2<a.length?e+=", and ":b<a.length-1&&(e+=", ");return e}function oa(a){return"object"===typeof a&&null!==a&&!Array.isArray(a)&&"string"===typeof a.type}function ka(a,e){return a.range[0]<=e.range[0]&&a.range[1]>=e.range[1]}
module.exports={__proto__:null,rules:{"rules-of-hooks":{create:function(a){var e=[],b=[];return{onCodePathSegmentStart:function(a){return b.push(a)},onCodePathSegmentEnd:function(){return b.pop()},onCodePathStart:function(){return e.push(new Map)},onCodePathEnd:function(b,d){function g(a,d){var c=g.cache,h=c.get(a.id);d=new Set(d);if(d.has(a.id)){c=[].concat(d);a=c.slice(c.indexOf(a.id)+1);c=!0;h=!1;var f=void 0;try{for(var r=a[Symbol.iterator](),M;!(c=(M=r.next()).done);c=!0)E.add(M.value)}catch(J){h=
!0,f=J}finally{try{c||null==r.return||r.return()}finally{if(h)throw f;}}return 0}d.add(a.id);if(void 0!==h)return h;if(b.thrownSegments.includes(a))h=0;else if(0===a.prevSegments.length)h=1;else{h=0;r=!0;M=!1;var e=void 0;try{f=a.prevSegments[Symbol.iterator]();for(var l;!(r=(l=f.next()).done);r=!0)h+=g(l.value,d)}catch(J){M=!0,e=J}finally{try{r||null==f.return||f.return()}finally{if(M)throw e;}}}a.reachable&&0===h?c.delete(a.id):c.set(a.id,h);return h}function n(a,d){var c=n.cache,h=c.get(a.id);
d=new Set(d);if(d.has(a.id)){c=Array.from(d);a=c.slice(c.indexOf(a.id)+1);c=!0;h=!1;var f=void 0;try{for(var r=a[Symbol.iterator](),e;!(c=(e=r.next()).done);c=!0)E.add(e.value)}catch(J){h=!0,f=J}finally{try{c||null==r.return||r.return()}finally{if(h)throw f;}}return 0}d.add(a.id);if(void 0!==h)return h;if(b.thrownSegments.includes(a))h=0;else if(0===a.nextSegments.length)h=1;else{h=0;r=!0;e=!1;var l=void 0;try{f=a.nextSegments[Symbol.iterator]();for(var g;!(r=(g=f.next()).done);r=!0)h+=n(g.value,
d)}catch(J){e=!0,l=J}finally{try{r||null==f.return||f.return()}finally{if(e)throw l;}}}c.set(a.id,h);return h}function y(a){var d=y.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 h=!0,f=!1,r=void 0;try{for(var e=a.prevSegments[Symbol.iterator](),b;!(h=(b=e.next()).done);h=!0){var l=y(b.value);l<c&&(c=l)}}catch(J){f=!0,r=J}finally{try{h||null==e.return||e.return()}finally{if(f)throw r;}}c+=1}d.set(a.id,c);
return c}var l=e.pop();if(0!==l.size){var E=new Set;g.cache=new Map;n.cache=new Map;y.cache=new Map;var F=n(b.initialSegment),m=ia(d),t=ha(d),A=m?ca(m)||U(m):ea(d)||fa(d),B=Infinity,k=!0,q=!1,I=void 0;try{for(var w=b.finalSegments[Symbol.iterator](),L;!(k=(L=w.next()).done);k=!0){var X=L.value;if(X.reachable){var T=y(X);T<B&&(B=T)}}}catch(G){q=!0,I=G}finally{try{k||null==w.return||w.return()}finally{if(q)throw I;}}k=!0;q=!1;I=void 0;try{for(var z=l[Symbol.iterator](),Q;!(k=(Q=z.next()).done);k=!0){var D=
Q.value,C=D[0],N=D[1];if(C.reachable){var K=0===C.nextSegments.length?B<=y(C):B<y(C),R=g(C)*n(C),H=E.has(C.id);l=!0;w=!1;L=void 0;try{for(var v=N[Symbol.iterator](),O;!(l=(O=v.next()).done);l=!0){var p=O.value;H&&a.report({node:p,message:'React Hook "'+a.getSource(p)+'" 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(A){if(!H&&R!==F){var V='React Hook "'+a.getSource(p)+'" is called conditionally. React Hooks must be called in the exact same order in every component render.'+
function pa(a){for(var e="",b=0;b<a.length;b++)e+=a[b],0===b&&2===a.length?e+=" and ":b===a.length-2&&2<a.length?e+=", and ":b<a.length-1&&(e+=", ");return e}function oa(a){return"object"===typeof a&&null!==a&&!Array.isArray(a)&&"string"===typeof a.type}function ka(a,e){return a.range[0]<=e.range[0]&&a.range[1]>=e.range[1]}exports.configs={recommended:{plugins:["react-hooks"],rules:{"react-hooks/rules-of-hooks":"error","react-hooks/exhaustive-deps":"warn"}}};
exports.rules={"rules-of-hooks":{create:function(a){var e=[],b=[];return{onCodePathSegmentStart:function(a){return b.push(a)},onCodePathSegmentEnd:function(){return b.pop()},onCodePathStart:function(){return e.push(new Map)},onCodePathEnd:function(b,d){function g(a,d){var c=g.cache,h=c.get(a.id);d=new Set(d);if(d.has(a.id)){c=[].concat(d);a=c.slice(c.indexOf(a.id)+1);c=!0;h=!1;var f=void 0;try{for(var r=a[Symbol.iterator](),M;!(c=(M=r.next()).done);c=!0)E.add(M.value)}catch(J){h=!0,f=J}finally{try{c||
null==r.return||r.return()}finally{if(h)throw f;}}return 0}d.add(a.id);if(void 0!==h)return h;if(b.thrownSegments.includes(a))h=0;else if(0===a.prevSegments.length)h=1;else{h=0;r=!0;M=!1;var e=void 0;try{f=a.prevSegments[Symbol.iterator]();for(var l;!(r=(l=f.next()).done);r=!0)h+=g(l.value,d)}catch(J){M=!0,e=J}finally{try{r||null==f.return||f.return()}finally{if(M)throw e;}}}a.reachable&&0===h?c.delete(a.id):c.set(a.id,h);return h}function n(a,d){var c=n.cache,h=c.get(a.id);d=new Set(d);if(d.has(a.id)){c=
Array.from(d);a=c.slice(c.indexOf(a.id)+1);c=!0;h=!1;var f=void 0;try{for(var r=a[Symbol.iterator](),e;!(c=(e=r.next()).done);c=!0)E.add(e.value)}catch(J){h=!0,f=J}finally{try{c||null==r.return||r.return()}finally{if(h)throw f;}}return 0}d.add(a.id);if(void 0!==h)return h;if(b.thrownSegments.includes(a))h=0;else if(0===a.nextSegments.length)h=1;else{h=0;r=!0;e=!1;var l=void 0;try{f=a.nextSegments[Symbol.iterator]();for(var g;!(r=(g=f.next()).done);r=!0)h+=n(g.value,d)}catch(J){e=!0,l=J}finally{try{r||
null==f.return||f.return()}finally{if(e)throw l;}}}c.set(a.id,h);return h}function y(a){var d=y.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 h=!0,f=!1,r=void 0;try{for(var e=a.prevSegments[Symbol.iterator](),b;!(h=(b=e.next()).done);h=!0){var l=y(b.value);l<c&&(c=l)}}catch(J){f=!0,r=J}finally{try{h||null==e.return||e.return()}finally{if(f)throw r;}}c+=1}d.set(a.id,c);return c}var l=e.pop();if(0!==l.size){var E=
new Set;g.cache=new Map;n.cache=new Map;y.cache=new Map;var F=n(b.initialSegment),m=ia(d),t=ha(d),A=m?ca(m)||U(m):ea(d)||fa(d),B=Infinity,k=!0,q=!1,I=void 0;try{for(var w=b.finalSegments[Symbol.iterator](),L;!(k=(L=w.next()).done);k=!0){var X=L.value;if(X.reachable){var T=y(X);T<B&&(B=T)}}}catch(G){q=!0,I=G}finally{try{k||null==w.return||w.return()}finally{if(q)throw I;}}k=!0;q=!1;I=void 0;try{for(var z=l[Symbol.iterator](),Q;!(k=(Q=z.next()).done);k=!0){var D=Q.value,C=D[0],N=D[1];if(C.reachable){var K=
0===C.nextSegments.length?B<=y(C):B<y(C),R=g(C)*n(C),H=E.has(C.id);l=!0;w=!1;L=void 0;try{for(var v=N[Symbol.iterator](),O;!(l=(O=v.next()).done);l=!0){var p=O.value;H&&a.report({node:p,message:'React Hook "'+a.getSource(p)+'" 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(A){if(!H&&R!==F){var V='React Hook "'+a.getSource(p)+'" is called conditionally. React Hooks must be called in the exact same order in every component render.'+
(K?" Did you accidentally call a React Hook after an early return?":"");a.report({node:p,message:V})}}else if(!d.parent||"MethodDefinition"!==d.parent.type&&"ClassProperty"!==d.parent.type||d.parent.value!==d)if(m){var P='React Hook "'+a.getSource(p)+'" is called in function "'+(a.getSource(m)+'" that is neither a React function component nor a custom React Hook function.');a.report({node:p,message:P})}else if("Program"===d.type){var S='React Hook "'+a.getSource(p)+'" cannot be called at the top level. React Hooks must be called in a React function component or a custom React Hook function.';

@@ -53,2 +53,2 @@ a.report({node:p,message:S})}else if(t){var u='React Hook "'+a.getSource(p)+'" 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:p,message:u})}}}catch(G){w=!0,L=G}finally{try{l||null==v.return||v.return()}finally{if(w)throw L;}}}}}catch(G){q=!0,I=G}finally{try{k||null==z.return||z.return()}finally{if(q)throw I;}}}},CallExpression:function(a){if(U(a.callee)){var d=e[e.length-1],g=b[b.length-1],n=d.get(g);n||

isEffect:!0}).suggestedDependencies;a.report({node:b.parent.callee,message:"React Hook "+A+" contains a call to '"+G+"'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass ["+aa.join(", ")+("] as a second argument to the "+A+" Hook."),suggest:[{desc:"Add dependencies array: ["+aa.join(", ")+"]",fix:function(a){return a.insertTextAfter(b,", ["+aa.join(", ")+"]")}}]})}}}}else"useMemo"!==A&&"useCallback"!==A||a.report({node:b.parent.callee,message:"React Hook "+
A+" does nothing when called with only one argument. Did you forget to pass an array of dependencies?"})}}}var g={additionalHooks:a.options&&a.options[0]&&a.options[0].additionalHooks?new RegExp(a.options[0].additionalHooks):void 0},d=new WeakMap,x=new WeakSet,n=new WeakMap,y=new WeakMap;return{FunctionExpression:b,ArrowFunctionExpression:b}}}}};
A+" does nothing when called with only one argument. Did you forget to pass an array of dependencies?"})}}}var g={additionalHooks:a.options&&a.options[0]&&a.options[0].additionalHooks?new RegExp(a.options[0].additionalHooks):void 0},d=new WeakMap,x=new WeakSet,n=new WeakMap,y=new WeakMap;return{FunctionExpression:b,ArrowFunctionExpression:b}}}};
{
"name": "eslint-plugin-react-hooks",
"description": "ESLint rules for React Hooks",
"version": "0.0.0-experimental-8d7535e54",
"version": "0.0.0-experimental-aae83a4b9",
"repository": {

@@ -6,0 +6,0 @@ "type": "git",

@@ -37,2 +37,13 @@ # `eslint-plugin-react-hooks`

Or use the recommended config:
```js
{
"extends": [
// ...
"plugin:react-hooks/recommended"
]
}
```
## Valid and Invalid Examples

@@ -39,0 +50,0 @@

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc