eslint-plugin-qwik 2.0.0-rc.2 → 2.0.0-rc.3

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -406,4 +406,4 @@ export default component$(() => {
406
406
 
407
407
  return <div>{myClass.count}</div>;
408
408
  });`.trim();var tc={meta:{type:"suggestion",docs:{description:"Detect preventDefault in $(()=>{}) Async Functions.",recommended:!0,url:"https://qwik.dev/docs/components/events/#preventdefault--stoppropagation"},messages:{noAsyncPreventDefault:`This is an asynchronous function and does not support preventDefault.
409
- Use preventDefault attributes instead`}},create(r){return{"CallExpression[callee.property.name='preventDefault']"(e){let t=e.parent;for(;t;){if(t.type==="CallExpression"&&t.callee&&t.callee.type==="Identifier"&&t.callee.name==="$"){r.report({node:e,messageId:"noAsyncPreventDefault"});break}t=t.parent}}}}};var cb=new Set(["useTask$","useTaskQrl"]);function fb(r){return r.callee.type==="Identifier"&&cb.has(r.callee.name)}function db(r){let e=r.arguments[0];return e?.type==="ArrowFunctionExpression"||e?.type==="FunctionExpression"?e:null}function Wn(r){return r?r.type==="AssignmentPattern"?Wn(r.right):r.type==="Literal"&&r.value===!1?!0:r.type==="TSAsExpression"?Wn(r.expression):!1:!1}function mb(r){let e=r.arguments[1];if(!e||e.type!=="ObjectExpression")return!1;for(let t of e.properties){if(t.type!=="Property"||t.computed)continue;let n=t.key;if((n.type==="Identifier"?n.name:n.type==="Literal"?String(n.value):null)==="deferUpdates"&&Wn(t.value))return!0}return!1}function nc(r){let e=new Set;return te(r,t=>{t.type==="VariableDeclarator"&&t.id.type==="Identifier"&&t.init&&t.init.type==="CallExpression"&&t.init.callee.type==="Identifier"&&t.init.callee.name==="useNavigate"&&e.add(t.id.name)}),e}function yb(r){let e=new Set,t=r.parent;for(;t;){if(t.type==="ArrowFunctionExpression"||t.type==="FunctionExpression"){let n=t.parent;if(n?.type==="CallExpression"&&n.callee.type==="Identifier"&&n.callee.name==="component$")for(let o of nc(t))e.add(o)}if(t.type==="Program"){for(let n of nc(t))e.add(n);break}t=t.parent??null}return e}function gb(r,e,t){te(e,n=>{if(n.type==="AwaitExpression"){let o=n.argument;o.type==="CallExpression"&&o.callee.type==="Identifier"&&t.has(o.callee.name)&&r.report({node:n,messageId:"noAwaitBlocking",data:{name:o.callee.name}})}})}var oc={meta:{type:"problem",docs:{description:"Disallow awaiting the function returned by `useNavigate()` inside blocking `useTask$` callbacks.",recommended:!0,url:"https://qwik.dev/docs/advanced/eslint/"},messages:{noAwaitBlocking:"Awaiting `{{name}}()` from `useNavigate()` inside a blocking `useTask$` can deadlock. Remove `await`, or pass `{ deferUpdates: false }` as the second argument to `useTask$`."}},create(r){return{CallExpression(e){if(!fb(e)||mb(e))return;let t=db(e);if(!t)return;let n=yb(e);n.size&&gb(r,t.body,n)}}}};var Gn={name:"eslint-plugin-qwik",description:"An Open-Source sub-framework designed with a focus on server-side-rendering, lazy-loading, and styling/animation.",version:"2.0.0-rc.2",author:"Qwik Team",bugs:"https://github.com/QwikDev/qwik/issues",dependencies:{"@typescript-eslint/utils":"^8.59.2","jsx-ast-utils":"^3.3.5"},devDependencies:{"@qwik.dev/core":"workspace:*","@qwik.dev/router":"workspace:*","@types/estree":"1.0.8","@typescript-eslint/rule-tester":"8.59.2",redent:"4.0.0"},engines:{node:"^18.17.0 || ^20.3.0 || >=21.0.0"},files:["README.md","dist"],homepage:"https://github.com/QwikDev/qwik#readme",keywords:["eslint","qwik"],license:"MIT",main:"dist/index.js",peerDependencies:{eslint:"^8.57.0 || ^9.0.0 || ^10.0.0"},repository:{type:"git",url:"https://github.com/QwikDev/qwik.git",directory:"packages/eslint-rules"},scripts:{test:"cd ../..; ./node_modules/.bin/vitest packages/eslint-plugin-qwik/qwik.unit.ts"}};var E=require("@typescript-eslint/utils");var Sb="isServer",ic=["process","__dirname","__filename","module"],ac=["fs","os","path","child_process","http","https","Buffer"],sc={meta:{type:"problem",docs:{description:"Disallow direct or indirect (via one-level function call) Node.js API usage in useTask$ without a server guard (e.g., isServer).",url:""},fixable:void 0,schema:[{type:"object",properties:{forbiddenApis:{type:"array",items:{type:"string"},default:ac}},additionalProperties:!1}],messages:{unsafeApiUsage:"Node.js API '{{apiName}}' should only be used inside an '{{guardName}}' block within useTask$. Example: if ({{guardName}}) { {{apiName}}.call(); }",unsafeApiUsageInCalledFunction:"Node.js API '{{apiName}}' used in function '{{calledFunctionName}}' (called from useTask$) needs '{{guardName}}' protection. Either guard the call site or protect the API usage within '{{calledFunctionName}}'."}},create(r){let e=r.options[0]||{},t=new Set(e.forbiddenApis||ac.concat(ic)),n=Sb,o=r.sourceCode,i=null;function a(p,m){let l=p.parent;for(;l&&l!==m.body&&l!==m;){if(l.type===E.AST_NODE_TYPES.IfStatement){let f=l;if(We(p,f.consequent)||p===f.consequent){let d=f.test;if(d.type===E.AST_NODE_TYPES.Identifier&&d.name===n||d.type===E.AST_NODE_TYPES.BinaryExpression&&d.operator==="==="&&(d.left.type===E.AST_NODE_TYPES.Identifier&&d.left.name===n&&d.right.type===E.AST_NODE_TYPES.Literal&&d.right.value===!0||d.right.type===E.AST_NODE_TYPES.Identifier&&d.right.name===n&&d.left.type===E.AST_NODE_TYPES.Literal&&d.left.value===!0)||d.type===E.AST_NODE_TYPES.UnaryExpression&&d.operator==="!"&&d.argument.type===E.AST_NODE_TYPES.UnaryExpression&&d.argument.operator==="!"&&d.argument.argument.type===E.AST_NODE_TYPES.Identifier&&d.argument.argument.name===n)return!0}}l=l.parent}return!1}function u(p){let m=o.getScope(p),l=null,f=m;if(!ic.includes(p.name))return!0;for(;f;){let d=f.variables.find(y=>y.name===p.name);if(d){l=d;break}if(f.type==="global"){l=f.variables.find(y=>y.name===p.name);break}f=f.upper}return!l||l.defs.length===0?!1:l.defs.some(d=>d.type==="Variable"||d.type==="Parameter"||d.type==="FunctionName"||d.type==="ClassName"||d.type==="ImportBinding")}function c(p,m,l){te(p,f=>f.type===E.AST_NODE_TYPES.Identifier&&t.has(f.name)&&!u(f)&&!a(f,m)?(r.report({node:l,messageId:"unsafeApiUsageInCalledFunction",data:{apiName:f.name,calledFunctionName:m.id?.name||(l.type===E.AST_NODE_TYPES.Identifier?l.name:"[anonymous]"),guardName:n}}),!0):!1)}return{":function"(p){let m=p.parent;m&&m.type===E.AST_NODE_TYPES.CallExpression&&m.callee.type===E.AST_NODE_TYPES.Identifier&&m.callee.name==="useTask$"&&m.arguments.length>0&&m.arguments[0]===p&&(i=p)},":function:exit"(p){i===p&&(i=null)},Identifier(p){if(i&&!(i.body!==p&&!We(p,i.body))&&!(p.parent&&p.parent.type===E.AST_NODE_TYPES.CallExpression&&p.parent.callee===p)&&t.has(p.name)){if(u(p))return;a(p,i)||r.report({node:p,messageId:"unsafeApiUsage",data:{apiName:p.name,guardName:n}})}},CallExpression(p){if(i&&We(p,i.body)&&!a(p,i)&&p.callee.type===E.AST_NODE_TYPES.Identifier){let m=p.callee,l=V(r,m);if(l&&l.defs.length>0){let f=l.defs[0],d=null;if(f.node.type===E.AST_NODE_TYPES.FunctionDeclaration?d=f.node:f.node.type===E.AST_NODE_TYPES.VariableDeclarator&&f.node.init&&(f.node.init.type===E.AST_NODE_TYPES.FunctionExpression||f.node.init.type===E.AST_NODE_TYPES.ArrowFunctionExpression)&&(d=f.node.init),d){let y=(d.body.type===E.AST_NODE_TYPES.BlockStatement,d.body);c(y,d,p)}}}}}}};var h=require("@typescript-eslint/utils"),$=re(require("typescript"));function hb(r,e){return eo(r,e)}function uc(r,e){return r==="routeLoader$"||(r==="useComputed$"||r==="createComputed$")&&e}function bb(r){if(r.callee.type!==h.AST_NODE_TYPES.Identifier)return!1;let e=r.arguments[0],t=!!e&&(e.type===h.AST_NODE_TYPES.ArrowFunctionExpression||e.type===h.AST_NODE_TYPES.FunctionExpression)&&e.async;return uc(r.callee.name,t)}function xb(r){if(!$.default.isIdentifier(r.expression))return!1;let e=r.arguments[0],t=!!e&&($.default.isArrowFunction(e)||$.default.isFunctionExpression(e))&&!!e.modifiers?.some(n=>n.kind===$.default.SyntaxKind.AsyncKeyword);return uc(r.expression.text,t)}function Eb(r){let e=r.body[0];if(!e||e.type!==h.AST_NODE_TYPES.ExpressionStatement)return null;let t=e.expression;return t.type===h.AST_NODE_TYPES.MemberExpression&&!t.computed&&t.property.type===h.AST_NODE_TYPES.Identifier&&t.property.name==="value"?e:null}function wb(r,e){let t=V(r,e);if(!t||t.defs&&t.defs.length===0)return!1;let n=h.ESLintUtils.getParserServices(r),o=n?.program?.getTypeChecker(),i=n?.esTreeNodeToTSNodeMap;function a(u){return u?$.default.isVariableDeclaration(u)&&u.initializer&&$.default.isCallExpression(u.initializer)?xb(u.initializer):($.default.isExportSpecifier(u)||$.default.isImportSpecifier(u),!1):!1}for(let u of t.defs){if(u.type==="Variable"&&u.node.type===h.AST_NODE_TYPES.VariableDeclarator){let c=u.node.init;if(c&&c.type===h.AST_NODE_TYPES.CallExpression){let p=c.callee;if(p.type===h.AST_NODE_TYPES.Identifier){if(bb(c)&&Ge(V(r,p)))return!0;let m=V(r,p);if(m&&m.defs){for(let l of m.defs)if(l.type==="Variable"&&l.node.type===h.AST_NODE_TYPES.VariableDeclarator){let f=l.node.init;if(f&&f.type===h.AST_NODE_TYPES.CallExpression){let d=f.callee;if(d.type===h.AST_NODE_TYPES.Identifier&&d.name==="routeLoader$"&&Ge(V(r,d)))return!0}}}}}}if(u.type==="ImportBinding"&&o&&i)try{let c=i.get(e);if(c){let p=o.getSymbolAtLocation(c);if(p&&p.flags&$.default.SymbolFlags.Alias&&(p=o.getAliasedSymbol(p)),p){for(let f of p.declarations??[]){if(a(f))return!0;if($.default.isVariableStatement(f)){for(let d of f.declarationList.declarations)if(a(d))return!0}}let m=o.getTypeOfSymbolAtLocation(p,c),l=o.typeToString(m.getNonNullableType());if(/Async/i.test(l))return!0}}}catch{}}if(o&&i)try{let u=i.get(e),c=o.getTypeAtLocation(u),p=o.typeToString(c.getNonNullableType());if(/Async|LoaderSignal/i.test(p))return!0}catch{}return!1}function Tb(r,e,t){for(let n of r.body){if(n===e)break;if(n.type!==h.AST_NODE_TYPES.ExpressionStatement)continue;let o=n.expression;if(o.type!==h.AST_NODE_TYPES.AwaitExpression)continue;let i=o.argument;if(i.type===h.AST_NODE_TYPES.CallExpression&&(i=i.callee),i.type===h.AST_NODE_TYPES.MemberExpression&&!i.computed&&i.object.type===h.AST_NODE_TYPES.Identifier&&i.object.name===t&&i.property.type===h.AST_NODE_TYPES.Identifier&&i.property.name==="promise")return!0}return!1}function qb(r,e,t){let n=e.parent;if(n&&n.type===h.AST_NODE_TYPES.CallExpression&&n.callee.type===h.AST_NODE_TYPES.Identifier&&hb(r,n.callee)){for(let o of n.arguments)if(o===e)return!0}if(e.async){for(let o of e.params)if(o.type===h.AST_NODE_TYPES.Identifier&&o.name===t.name)return!0}return!1}var lc={meta:{type:"problem",docs:{description:"Warn when an async computed signal '.value' is read not at the top of a QRL callback.",recommended:!1,url:""},schema:[],messages:{asyncComputedNotTop:"Async computed '{{name}}.value' must be first, or use 'await {{name}}.promise()' beforehand."}},create(r){return{MemberExpression(e){if(e.computed||e.property.type!==h.AST_NODE_TYPES.Identifier||e.property.name!=="value")return;let t=e.object;if(t.type!==h.AST_NODE_TYPES.Identifier||!wb(r,t))return;let n=ro(e);if(!n||!qb(r,n,t))return;let o=e.parent;if(!o||o.type!==h.AST_NODE_TYPES.ExpressionStatement&&o.type!==h.AST_NODE_TYPES.ReturnStatement)return;let i=n.body&&n.body.type===h.AST_NODE_TYPES.BlockStatement?n.body:null;if(!i)return n.body.type===h.AST_NODE_TYPES.MemberExpression&&n.body===e,void 0;o.parent!==i||i.body[0]===o||Eb(i)===o||(o.type===h.AST_NODE_TYPES.ExpressionStatement||o.type===h.AST_NODE_TYPES.ReturnStatement)&&Tb(i,o,t.name)||r.report({node:e,messageId:"asyncComputedNotTop",data:{name:t.name}})}}}};var pc={"valid-lexical-scope":Qp,"use-method-usage":Kp,"no-react-props":Gp,"loader-location":Wp,"prefer-classlist":Hp,"jsx-no-script-url":Bp,"jsx-key":Vp,"unused-server":zp,"jsx-img":io,"jsx-a":no,"no-use-visible-task":Xp,"serializer-signal-usage":rc,"scope-use-task":sc,"use-async-top":lc,"no-async-prevent-default":tc,"no-await-navigate-in-use-task":oc},cc={"qwik/valid-lexical-scope":"error","qwik/use-method-usage":"error","qwik/no-react-props":"error","qwik/loader-location":"warn","qwik/prefer-classlist":"warn","qwik/jsx-no-script-url":"warn","qwik/jsx-key":"warn","qwik/unused-server":"error","qwik/jsx-img":"warn","qwik/jsx-a":"warn","qwik/no-use-visible-task":"warn","qwik/serializer-signal-usage":"error","qwik/scope-use-task":"error","qwik/use-async-top":"warn","qwik/no-async-prevent-default":"warn","qwik/no-await-navigate-in-use-task":"warn"},fc={"qwik/valid-lexical-scope":"error","qwik/use-method-usage":"error","qwik/no-react-props":"error","qwik/loader-location":"error","qwik/prefer-classlist":"error","qwik/jsx-no-script-url":"error","qwik/jsx-key":"error","qwik/unused-server":"error","qwik/jsx-img":"error","qwik/jsx-a":"error","qwik/no-use-visible-task":"warn","qwik/serializer-signal-usage":"error","qwik/scope-use-task":"error","qwik/use-async-top":"warn","qwik/no-async-prevent-default":"warn","qwik/no-await-navigate-in-use-task":"warn"},Ab={recommended:{plugins:["qwik"],rules:cc},strict:{plugins:["qwik"],rules:fc}},dc={configs:{get recommended(){return Pb},get strict(){return Ib}},meta:{name:Gn.name,version:Gn.version},rules:pc},mc=r=>[{plugins:{qwik:dc},rules:r}],Pb=mc(cc),Ib=mc(fc);0&&(module.exports={configs,qwikEslint9Plugin,rules});
409
+ Use preventDefault attributes instead`}},create(r){return{"CallExpression[callee.property.name='preventDefault']"(e){let t=e.parent;for(;t;){if(t.type==="CallExpression"&&t.callee&&t.callee.type==="Identifier"&&t.callee.name==="$"){r.report({node:e,messageId:"noAsyncPreventDefault"});break}t=t.parent}}}}};var cb=new Set(["useTask$","useTaskQrl"]);function fb(r){return r.callee.type==="Identifier"&&cb.has(r.callee.name)}function db(r){let e=r.arguments[0];return e?.type==="ArrowFunctionExpression"||e?.type==="FunctionExpression"?e:null}function Wn(r){return r?r.type==="AssignmentPattern"?Wn(r.right):r.type==="Literal"&&r.value===!1?!0:r.type==="TSAsExpression"?Wn(r.expression):!1:!1}function mb(r){let e=r.arguments[1];if(!e||e.type!=="ObjectExpression")return!1;for(let t of e.properties){if(t.type!=="Property"||t.computed)continue;let n=t.key;if((n.type==="Identifier"?n.name:n.type==="Literal"?String(n.value):null)==="deferUpdates"&&Wn(t.value))return!0}return!1}function nc(r){let e=new Set;return te(r,t=>{t.type==="VariableDeclarator"&&t.id.type==="Identifier"&&t.init&&t.init.type==="CallExpression"&&t.init.callee.type==="Identifier"&&t.init.callee.name==="useNavigate"&&e.add(t.id.name)}),e}function yb(r){let e=new Set,t=r.parent;for(;t;){if(t.type==="ArrowFunctionExpression"||t.type==="FunctionExpression"){let n=t.parent;if(n?.type==="CallExpression"&&n.callee.type==="Identifier"&&n.callee.name==="component$")for(let o of nc(t))e.add(o)}if(t.type==="Program"){for(let n of nc(t))e.add(n);break}t=t.parent??null}return e}function gb(r,e,t){te(e,n=>{if(n.type==="AwaitExpression"){let o=n.argument;o.type==="CallExpression"&&o.callee.type==="Identifier"&&t.has(o.callee.name)&&r.report({node:n,messageId:"noAwaitBlocking",data:{name:o.callee.name}})}})}var oc={meta:{type:"problem",docs:{description:"Disallow awaiting the function returned by `useNavigate()` inside blocking `useTask$` callbacks.",recommended:!0,url:"https://qwik.dev/docs/advanced/eslint/"},messages:{noAwaitBlocking:"Awaiting `{{name}}()` from `useNavigate()` inside a blocking `useTask$` can deadlock. Remove `await`, or pass `{ deferUpdates: false }` as the second argument to `useTask$`."}},create(r){return{CallExpression(e){if(!fb(e)||mb(e))return;let t=db(e);if(!t)return;let n=yb(e);n.size&&gb(r,t.body,n)}}}};var Gn={name:"eslint-plugin-qwik",description:"An Open-Source sub-framework designed with a focus on server-side-rendering, lazy-loading, and styling/animation.",version:"2.0.0-rc.3",author:"Qwik Team",bugs:"https://github.com/QwikDev/qwik/issues",dependencies:{"@typescript-eslint/utils":"^8.59.2","jsx-ast-utils":"^3.3.5"},devDependencies:{"@qwik.dev/core":"workspace:*","@qwik.dev/router":"workspace:*","@types/estree":"1.0.8","@typescript-eslint/rule-tester":"8.59.2",redent:"4.0.0"},engines:{node:"^18.17.0 || ^20.3.0 || >=21.0.0"},files:["README.md","dist"],homepage:"https://github.com/QwikDev/qwik#readme",keywords:["eslint","qwik"],license:"MIT",main:"dist/index.js",peerDependencies:{eslint:"^8.57.0 || ^9.0.0 || ^10.0.0"},repository:{type:"git",url:"https://github.com/QwikDev/qwik.git",directory:"packages/eslint-rules"},scripts:{test:"cd ../..; ./node_modules/.bin/vitest packages/eslint-plugin-qwik/qwik.unit.ts"}};var E=require("@typescript-eslint/utils");var Sb="isServer",ic=["process","__dirname","__filename","module"],ac=["fs","os","path","child_process","http","https","Buffer"],sc={meta:{type:"problem",docs:{description:"Disallow direct or indirect (via one-level function call) Node.js API usage in useTask$ without a server guard (e.g., isServer).",url:""},fixable:void 0,schema:[{type:"object",properties:{forbiddenApis:{type:"array",items:{type:"string"},default:ac}},additionalProperties:!1}],messages:{unsafeApiUsage:"Node.js API '{{apiName}}' should only be used inside an '{{guardName}}' block within useTask$. Example: if ({{guardName}}) { {{apiName}}.call(); }",unsafeApiUsageInCalledFunction:"Node.js API '{{apiName}}' used in function '{{calledFunctionName}}' (called from useTask$) needs '{{guardName}}' protection. Either guard the call site or protect the API usage within '{{calledFunctionName}}'."}},create(r){let e=r.options[0]||{},t=new Set(e.forbiddenApis||ac.concat(ic)),n=Sb,o=r.sourceCode,i=null;function a(p,m){let l=p.parent;for(;l&&l!==m.body&&l!==m;){if(l.type===E.AST_NODE_TYPES.IfStatement){let f=l;if(We(p,f.consequent)||p===f.consequent){let d=f.test;if(d.type===E.AST_NODE_TYPES.Identifier&&d.name===n||d.type===E.AST_NODE_TYPES.BinaryExpression&&d.operator==="==="&&(d.left.type===E.AST_NODE_TYPES.Identifier&&d.left.name===n&&d.right.type===E.AST_NODE_TYPES.Literal&&d.right.value===!0||d.right.type===E.AST_NODE_TYPES.Identifier&&d.right.name===n&&d.left.type===E.AST_NODE_TYPES.Literal&&d.left.value===!0)||d.type===E.AST_NODE_TYPES.UnaryExpression&&d.operator==="!"&&d.argument.type===E.AST_NODE_TYPES.UnaryExpression&&d.argument.operator==="!"&&d.argument.argument.type===E.AST_NODE_TYPES.Identifier&&d.argument.argument.name===n)return!0}}l=l.parent}return!1}function u(p){let m=o.getScope(p),l=null,f=m;if(!ic.includes(p.name))return!0;for(;f;){let d=f.variables.find(y=>y.name===p.name);if(d){l=d;break}if(f.type==="global"){l=f.variables.find(y=>y.name===p.name);break}f=f.upper}return!l||l.defs.length===0?!1:l.defs.some(d=>d.type==="Variable"||d.type==="Parameter"||d.type==="FunctionName"||d.type==="ClassName"||d.type==="ImportBinding")}function c(p,m,l){te(p,f=>f.type===E.AST_NODE_TYPES.Identifier&&t.has(f.name)&&!u(f)&&!a(f,m)?(r.report({node:l,messageId:"unsafeApiUsageInCalledFunction",data:{apiName:f.name,calledFunctionName:m.id?.name||(l.type===E.AST_NODE_TYPES.Identifier?l.name:"[anonymous]"),guardName:n}}),!0):!1)}return{":function"(p){let m=p.parent;m&&m.type===E.AST_NODE_TYPES.CallExpression&&m.callee.type===E.AST_NODE_TYPES.Identifier&&m.callee.name==="useTask$"&&m.arguments.length>0&&m.arguments[0]===p&&(i=p)},":function:exit"(p){i===p&&(i=null)},Identifier(p){if(i&&!(i.body!==p&&!We(p,i.body))&&!(p.parent&&p.parent.type===E.AST_NODE_TYPES.CallExpression&&p.parent.callee===p)&&t.has(p.name)){if(u(p))return;a(p,i)||r.report({node:p,messageId:"unsafeApiUsage",data:{apiName:p.name,guardName:n}})}},CallExpression(p){if(i&&We(p,i.body)&&!a(p,i)&&p.callee.type===E.AST_NODE_TYPES.Identifier){let m=p.callee,l=V(r,m);if(l&&l.defs.length>0){let f=l.defs[0],d=null;if(f.node.type===E.AST_NODE_TYPES.FunctionDeclaration?d=f.node:f.node.type===E.AST_NODE_TYPES.VariableDeclarator&&f.node.init&&(f.node.init.type===E.AST_NODE_TYPES.FunctionExpression||f.node.init.type===E.AST_NODE_TYPES.ArrowFunctionExpression)&&(d=f.node.init),d){let y=(d.body.type===E.AST_NODE_TYPES.BlockStatement,d.body);c(y,d,p)}}}}}}};var h=require("@typescript-eslint/utils"),$=re(require("typescript"));function hb(r,e){return eo(r,e)}function uc(r,e){return r==="routeLoader$"||(r==="useComputed$"||r==="createComputed$")&&e}function bb(r){if(r.callee.type!==h.AST_NODE_TYPES.Identifier)return!1;let e=r.arguments[0],t=!!e&&(e.type===h.AST_NODE_TYPES.ArrowFunctionExpression||e.type===h.AST_NODE_TYPES.FunctionExpression)&&e.async;return uc(r.callee.name,t)}function xb(r){if(!$.default.isIdentifier(r.expression))return!1;let e=r.arguments[0],t=!!e&&($.default.isArrowFunction(e)||$.default.isFunctionExpression(e))&&!!e.modifiers?.some(n=>n.kind===$.default.SyntaxKind.AsyncKeyword);return uc(r.expression.text,t)}function Eb(r){let e=r.body[0];if(!e||e.type!==h.AST_NODE_TYPES.ExpressionStatement)return null;let t=e.expression;return t.type===h.AST_NODE_TYPES.MemberExpression&&!t.computed&&t.property.type===h.AST_NODE_TYPES.Identifier&&t.property.name==="value"?e:null}function wb(r,e){let t=V(r,e);if(!t||t.defs&&t.defs.length===0)return!1;let n=h.ESLintUtils.getParserServices(r),o=n?.program?.getTypeChecker(),i=n?.esTreeNodeToTSNodeMap;function a(u){return u?$.default.isVariableDeclaration(u)&&u.initializer&&$.default.isCallExpression(u.initializer)?xb(u.initializer):($.default.isExportSpecifier(u)||$.default.isImportSpecifier(u),!1):!1}for(let u of t.defs){if(u.type==="Variable"&&u.node.type===h.AST_NODE_TYPES.VariableDeclarator){let c=u.node.init;if(c&&c.type===h.AST_NODE_TYPES.CallExpression){let p=c.callee;if(p.type===h.AST_NODE_TYPES.Identifier){if(bb(c)&&Ge(V(r,p)))return!0;let m=V(r,p);if(m&&m.defs){for(let l of m.defs)if(l.type==="Variable"&&l.node.type===h.AST_NODE_TYPES.VariableDeclarator){let f=l.node.init;if(f&&f.type===h.AST_NODE_TYPES.CallExpression){let d=f.callee;if(d.type===h.AST_NODE_TYPES.Identifier&&d.name==="routeLoader$"&&Ge(V(r,d)))return!0}}}}}}if(u.type==="ImportBinding"&&o&&i)try{let c=i.get(e);if(c){let p=o.getSymbolAtLocation(c);if(p&&p.flags&$.default.SymbolFlags.Alias&&(p=o.getAliasedSymbol(p)),p){for(let f of p.declarations??[]){if(a(f))return!0;if($.default.isVariableStatement(f)){for(let d of f.declarationList.declarations)if(a(d))return!0}}let m=o.getTypeOfSymbolAtLocation(p,c),l=o.typeToString(m.getNonNullableType());if(/Async/i.test(l))return!0}}}catch{}}if(o&&i)try{let u=i.get(e),c=o.getTypeAtLocation(u),p=o.typeToString(c.getNonNullableType());if(/Async|LoaderSignal/i.test(p))return!0}catch{}return!1}function Tb(r,e,t){for(let n of r.body){if(n===e)break;if(n.type!==h.AST_NODE_TYPES.ExpressionStatement)continue;let o=n.expression;if(o.type!==h.AST_NODE_TYPES.AwaitExpression)continue;let i=o.argument;if(i.type===h.AST_NODE_TYPES.CallExpression&&(i=i.callee),i.type===h.AST_NODE_TYPES.MemberExpression&&!i.computed&&i.object.type===h.AST_NODE_TYPES.Identifier&&i.object.name===t&&i.property.type===h.AST_NODE_TYPES.Identifier&&i.property.name==="promise")return!0}return!1}function qb(r,e,t){let n=e.parent;if(n&&n.type===h.AST_NODE_TYPES.CallExpression&&n.callee.type===h.AST_NODE_TYPES.Identifier&&hb(r,n.callee)){for(let o of n.arguments)if(o===e)return!0}if(e.async){for(let o of e.params)if(o.type===h.AST_NODE_TYPES.Identifier&&o.name===t.name)return!0}return!1}var lc={meta:{type:"problem",docs:{description:"Warn when an async computed signal '.value' is read not at the top of a QRL callback.",recommended:!1,url:""},schema:[],messages:{asyncComputedNotTop:"Async computed '{{name}}.value' must be first, or use 'await {{name}}.promise()' beforehand."}},create(r){return{MemberExpression(e){if(e.computed||e.property.type!==h.AST_NODE_TYPES.Identifier||e.property.name!=="value")return;let t=e.object;if(t.type!==h.AST_NODE_TYPES.Identifier||!wb(r,t))return;let n=ro(e);if(!n||!qb(r,n,t))return;let o=e.parent;if(!o||o.type!==h.AST_NODE_TYPES.ExpressionStatement&&o.type!==h.AST_NODE_TYPES.ReturnStatement)return;let i=n.body&&n.body.type===h.AST_NODE_TYPES.BlockStatement?n.body:null;if(!i)return n.body.type===h.AST_NODE_TYPES.MemberExpression&&n.body===e,void 0;o.parent!==i||i.body[0]===o||Eb(i)===o||(o.type===h.AST_NODE_TYPES.ExpressionStatement||o.type===h.AST_NODE_TYPES.ReturnStatement)&&Tb(i,o,t.name)||r.report({node:e,messageId:"asyncComputedNotTop",data:{name:t.name}})}}}};var pc={"valid-lexical-scope":Qp,"use-method-usage":Kp,"no-react-props":Gp,"loader-location":Wp,"prefer-classlist":Hp,"jsx-no-script-url":Bp,"jsx-key":Vp,"unused-server":zp,"jsx-img":io,"jsx-a":no,"no-use-visible-task":Xp,"serializer-signal-usage":rc,"scope-use-task":sc,"use-async-top":lc,"no-async-prevent-default":tc,"no-await-navigate-in-use-task":oc},cc={"qwik/valid-lexical-scope":"error","qwik/use-method-usage":"error","qwik/no-react-props":"error","qwik/loader-location":"warn","qwik/prefer-classlist":"warn","qwik/jsx-no-script-url":"warn","qwik/jsx-key":"warn","qwik/unused-server":"error","qwik/jsx-img":"warn","qwik/jsx-a":"warn","qwik/no-use-visible-task":"warn","qwik/serializer-signal-usage":"error","qwik/scope-use-task":"error","qwik/use-async-top":"warn","qwik/no-async-prevent-default":"warn","qwik/no-await-navigate-in-use-task":"warn"},fc={"qwik/valid-lexical-scope":"error","qwik/use-method-usage":"error","qwik/no-react-props":"error","qwik/loader-location":"error","qwik/prefer-classlist":"error","qwik/jsx-no-script-url":"error","qwik/jsx-key":"error","qwik/unused-server":"error","qwik/jsx-img":"error","qwik/jsx-a":"error","qwik/no-use-visible-task":"warn","qwik/serializer-signal-usage":"error","qwik/scope-use-task":"error","qwik/use-async-top":"warn","qwik/no-async-prevent-default":"warn","qwik/no-await-navigate-in-use-task":"warn"},Ab={recommended:{plugins:["qwik"],rules:cc},strict:{plugins:["qwik"],rules:fc}},dc={configs:{get recommended(){return Pb},get strict(){return Ib}},meta:{name:Gn.name,version:Gn.version},rules:pc},mc=r=>[{plugins:{qwik:dc},rules:r}],Pb=mc(cc),Ib=mc(fc);0&&(module.exports={configs,qwikEslint9Plugin,rules});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "eslint-plugin-qwik",
3
3
  "description": "An Open-Source sub-framework designed with a focus on server-side-rendering, lazy-loading, and styling/animation.",
4
- "version": "2.0.0-rc.2",
4
+ "version": "2.0.0-rc.3",
5
5
  "author": "Qwik Team",
6
6
  "bugs": "https://github.com/QwikDev/qwik/issues",
7
7
  "dependencies": {
@@ -12,8 +12,8 @@
12
12
  "@types/estree": "1.0.8",
13
13
  "@typescript-eslint/rule-tester": "8.59.2",
14
14
  "redent": "4.0.0",
15
- "@qwik.dev/core": "2.0.0-rc.2",
16
- "@qwik.dev/router": "2.0.0-rc.2"
15
+ "@qwik.dev/router": "2.0.0-rc.3",
16
+ "@qwik.dev/core": "2.0.0-rc.3"
17
17
  },
18
18
  "engines": {
19
19
  "node": "^18.17.0 || ^20.3.0 || >=21.0.0"