eslint-plugin-qwik 2.0.0-beta.14 → 2.0.0-beta.16

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
@@ -407,4 +407,4 @@ export default component$(() => {
407
407
  }));
408
408
 
409
409
  return <div>{myClass.count}</div>;
410
- });`.trim();var _n={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-beta.14",author:"Qwik Team",bugs:"https://github.com/QwikDev/qwik/issues",dependencies:{"@typescript-eslint/utils":"^8.38.0","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.38.0",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"},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 T=require("@typescript-eslint/utils"),$b="isServer";function Fn(r,e){if(!e)return!1;let t=r.parent;for(;t;){if(t===e)return!0;t=t.parent}return!1}var Lp={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).",category:"Best Practices",recommended:!0,url:""},fixable:void 0,schema:[{type:"object",properties:{forbiddenApis:{type:"array",items:{type:"string"},default:["process","fs","os","path","child_process","http","https","Buffer","__dirname","__filename"]}},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||["process","fs","os","path","child_process","http","https","Buffer","__dirname","__filename"]),n=$b,o=r.sourceCode,i=null;function a(u,f){let m=u.parent;for(;m&&m!==f.body&&m!==f;){if(m.type===T.AST_NODE_TYPES.IfStatement){let y=m;if(Fn(u,y.consequent)||u===y.consequent){let d=y.test;if(d.type===T.AST_NODE_TYPES.Identifier&&d.name===n||d.type===T.AST_NODE_TYPES.BinaryExpression&&d.operator==="==="&&(d.left.type===T.AST_NODE_TYPES.Identifier&&d.left.name===n&&d.right.type===T.AST_NODE_TYPES.Literal&&d.right.value===!0||d.right.type===T.AST_NODE_TYPES.Identifier&&d.right.name===n&&d.left.type===T.AST_NODE_TYPES.Literal&&d.left.value===!0)||d.type===T.AST_NODE_TYPES.UnaryExpression&&d.operator==="!"&&d.argument.type===T.AST_NODE_TYPES.UnaryExpression&&d.argument.operator==="!"&&d.argument.argument.type===T.AST_NODE_TYPES.Identifier&&d.argument.argument.name===n)return!0}}m=m.parent}return!1}function l(u){let f=o.getScope(u),m=null,y=f;for(;y;){let d=y.variables.find(v=>v.name===u.name);if(d){m=d;break}if(y.type==="global"){m=y.variables.find(v=>v.name===u.name);break}y=y.upper}return!m||m.defs.length===0?!1:m.defs.some(d=>d.type==="Variable"||d.type==="Parameter"||d.type==="FunctionName"||d.type==="ClassName"||d.type==="ImportBinding")}function p(u,f,m){function y(d){if(!d)return!1;if(d.type===T.AST_NODE_TYPES.Identifier&&t.has(d.name)&&!l(d)&&!a(d,f))return r.report({node:m,messageId:"unsafeApiUsageInCalledFunction",data:{apiName:d.name,calledFunctionName:f.id?.name||(m.type===T.AST_NODE_TYPES.Identifier?m.name:"[anonymous]"),guardName:n}}),!0;for(let v in d){if(v==="parent"||v==="range"||v==="loc")continue;let c=d[v];if(Array.isArray(c)){for(let g of c)if(g&&typeof g=="object"&&"type"in g&&y(g))return!0}else if(c&&typeof c=="object"&&"type"in c&&y(c))return!0}return!1}y(u)}return{":function"(u){let f=u.parent;f&&f.type===T.AST_NODE_TYPES.CallExpression&&f.callee.type===T.AST_NODE_TYPES.Identifier&&f.callee.name==="useTask$"&&f.arguments.length>0&&f.arguments[0]===u&&(i=u)},":function:exit"(u){i===u&&(i=null)},Identifier(u){if(i&&!(i.body!==u&&!Fn(u,i.body))&&!(u.parent&&u.parent.type===T.AST_NODE_TYPES.CallExpression&&u.parent.callee===u)&&t.has(u.name)){if(l(u))return;a(u,i)||r.report({node:u,messageId:"unsafeApiUsage",data:{apiName:u.name,guardName:n}})}},CallExpression(u){if(i&&Fn(u,i.body)&&!a(u,i)&&u.callee.type===T.AST_NODE_TYPES.Identifier){let f=u.callee,m=o.getScope(f),y=null,d=m.references.find(c=>c.identifier===f);if(d&&d.resolved)y=d.resolved;else{let c=m;for(;c;){let g=c.variables.find(h=>h.name===f.name);if(g&&g.defs.length>0){y=g;break}if(c.type==="global"&&!g){let h=c.type==="global"?c.variables.find(E=>E.name===f.name):null;h&&(y=h);break}if(!c.upper)break;c=c.upper}}let v=y;if(v&&v.defs.length>0){let c=v.defs[0],g=null;if(c.node.type===T.AST_NODE_TYPES.FunctionDeclaration?g=c.node:c.node.type===T.AST_NODE_TYPES.VariableDeclarator&&c.node.init&&(c.node.init.type===T.AST_NODE_TYPES.FunctionExpression||c.node.init.type===T.AST_NODE_TYPES.ArrowFunctionExpression)&&(g=c.node.init),g){let h=(g.body.type===T.AST_NODE_TYPES.BlockStatement,g.body);p(h,g,u)}}}}}}};var x=require("@typescript-eslint/utils"),H=Z(require("typescript"));function Nn(r){return r?.defs?.some(e=>{if(e.type!=="ImportBinding")return!1;let t=e.parent.source.value;return t.startsWith("@qwik.dev/core")||t.startsWith("@qwik.dev/router")||t.startsWith("@builder.io/qwik")||t.startsWith("@builder.io/qwik-city")})}function Le(r,e){let t=r.sourceCode.getScope(e),n=t.references.find(i=>i.identifier===e);if(n&&n.resolved)return n.resolved;let o=t;for(;o;){let i=o.variables.find(a=>a.name===e.name);if(i)return i;o=o.upper}return null}function kb(r,e){if(!e||e.type!==x.AST_NODE_TYPES.Identifier||!e.name.endsWith("$"))return!1;let t=Le(r,e);return Nn(t)}function _b(r){let e=r.body[0];if(!e||e.type!==x.AST_NODE_TYPES.ExpressionStatement)return null;let t=e.expression;return t.type===x.AST_NODE_TYPES.MemberExpression&&!t.computed&&t.property.type===x.AST_NODE_TYPES.Identifier&&t.property.name==="value"?e:null}function Fb(r,e){let t=Le(r,e);if(!t||t.defs&&t.defs.length===0)return!1;let n=r.sourceCode.parserServices,o=n?.program?.getTypeChecker(),i=n?.esTreeNodeToTSNodeMap;function a(l){if(!l)return!1;if(H.default.isVariableDeclaration(l)&&l.initializer&&H.default.isCallExpression(l.initializer)){let p=l.initializer.expression;if(H.default.isIdentifier(p)){let u=p.text;return u==="createAsyncComputed$"||u==="useAsyncComputed$"||u==="routeLoader$"}}return H.default.isExportSpecifier(l)||H.default.isImportSpecifier(l),!1}for(let l of t.defs){if(l.type==="Variable"&&l.node.type===x.AST_NODE_TYPES.VariableDeclarator){let p=l.node.init;if(p&&p.type===x.AST_NODE_TYPES.CallExpression){let u=p.callee;if(u.type===x.AST_NODE_TYPES.Identifier){let f=u.name;if((f==="useAsyncComputed$"||f==="createAsyncComputed$"||f==="routeLoader$")&&Nn(Le(r,u)))return!0;let m=Le(r,u);if(m&&m.defs){for(let y of m.defs)if(y.type==="Variable"&&y.node.type===x.AST_NODE_TYPES.VariableDeclarator){let d=y.node.init;if(d&&d.type===x.AST_NODE_TYPES.CallExpression){let v=d.callee;if(v.type===x.AST_NODE_TYPES.Identifier&&v.name==="routeLoader$"&&Nn(Le(r,v)))return!0}}}}}}if(l.type==="ImportBinding"&&o&&i)try{let p=i.get(e);if(p){let u=o.getSymbolAtLocation(p);if(u&&u.flags&H.default.SymbolFlags.Alias&&(u=o.getAliasedSymbol(u)),u){for(let y of u.declarations??[]){if(a(y))return!0;if(H.default.isVariableStatement(y)){for(let d of y.declarationList.declarations)if(a(d))return!0}}let f=o.getTypeOfSymbolAtLocation(u,p),m=o.typeToString(f.getNonNullableType());if(/AsyncComputed/i.test(m))return!0}}}catch{}}if(o&&i)try{let l=i.get(e),p=o.getTypeAtLocation(l),u=o.typeToString(p.getNonNullableType());if(/AsyncComputed|LoaderSignal/i.test(u))return!0}catch{}return!1}function Nb(r,e,t){for(let n of r.body){if(n===e)break;if(n.type!==x.AST_NODE_TYPES.ExpressionStatement)continue;let o=n.expression;if(o.type!==x.AST_NODE_TYPES.AwaitExpression)continue;let i=o.argument;if(i.type===x.AST_NODE_TYPES.CallExpression&&(i=i.callee),i.type===x.AST_NODE_TYPES.MemberExpression&&!i.computed&&i.object.type===x.AST_NODE_TYPES.Identifier&&i.object.name===t&&i.property.type===x.AST_NODE_TYPES.Identifier&&i.property.name==="promise")return!0}return!1}function Rb(r){let e=r;for(;e;){if(e.type===x.AST_NODE_TYPES.FunctionDeclaration||e.type===x.AST_NODE_TYPES.FunctionExpression||e.type===x.AST_NODE_TYPES.ArrowFunctionExpression)return e;e=e.parent}return null}function jb(r,e,t){let n=e.parent;if(n&&n.type===x.AST_NODE_TYPES.CallExpression&&n.callee.type===x.AST_NODE_TYPES.Identifier&&kb(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===x.AST_NODE_TYPES.Identifier&&o.name===t.name)return!0}return!1}var Vp={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!==x.AST_NODE_TYPES.Identifier||e.property.name!=="value")return;let t=e.object;if(t.type!==x.AST_NODE_TYPES.Identifier||!Fb(r,t))return;let n=Rb(e);if(!n||!jb(r,n,t))return;let o=e.parent;if(!o||o.type!==x.AST_NODE_TYPES.ExpressionStatement&&o.type!==x.AST_NODE_TYPES.ReturnStatement)return;let i=n.body&&n.body.type===x.AST_NODE_TYPES.BlockStatement?n.body:null;if(!i)return n.body.type===x.AST_NODE_TYPES.MemberExpression&&n.body===e,void 0;o.parent!==i||i.body[0]===o||_b(i)===o||(o.type===x.AST_NODE_TYPES.ExpressionStatement||o.type===x.AST_NODE_TYPES.ReturnStatement)&&Nb(i,o,t.name)||r.report({node:e,messageId:"asyncComputedNotTop",data:{name:t.name}})}}}};var Dp={"valid-lexical-scope":Fp,"use-method-usage":_p,"no-react-props":Op,"loader-location":Ip,"prefer-classlist":$p,"jsx-no-script-url":Ap,"jsx-key":qp,"unused-server":kp,"jsx-img":Wn,"jsx-a":Bn,"no-use-visible-task":Cp,"serializer-signal-usage":Mp,"scope-use-task":Lp,"async-computed-top":Vp},Up={"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/async-computed-top":"warn"},Bp={"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/async-computed-top":"warn"},Mb={recommended:{plugins:["qwik"],rules:Up},strict:{plugins:["qwik"],rules:Bp}},Rn={configs:{get recommended(){return Lb},get strict(){return Vb}},meta:{name:_n.name,version:_n.version},rules:Dp},Lb=[{plugins:{qwik:Rn},rules:Up}],Vb=[{plugins:{qwik:Rn},rules:Bp}];0&&(module.exports={configs,qwikEslint9Plugin,rules});
410
+ });`.trim();var _n={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-beta.16",author:"Qwik Team",bugs:"https://github.com/QwikDev/qwik/issues",dependencies:{"@typescript-eslint/utils":"^8.38.0","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.38.0",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"},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 T=require("@typescript-eslint/utils"),$b="isServer";function Fn(r,e){if(!e)return!1;let t=r.parent;for(;t;){if(t===e)return!0;t=t.parent}return!1}var Lp={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).",category:"Best Practices",recommended:!0,url:""},fixable:void 0,schema:[{type:"object",properties:{forbiddenApis:{type:"array",items:{type:"string"},default:["process","fs","os","path","child_process","http","https","Buffer","__dirname","__filename"]}},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||["process","fs","os","path","child_process","http","https","Buffer","__dirname","__filename"]),n=$b,o=r.sourceCode,i=null;function a(u,f){let m=u.parent;for(;m&&m!==f.body&&m!==f;){if(m.type===T.AST_NODE_TYPES.IfStatement){let y=m;if(Fn(u,y.consequent)||u===y.consequent){let d=y.test;if(d.type===T.AST_NODE_TYPES.Identifier&&d.name===n||d.type===T.AST_NODE_TYPES.BinaryExpression&&d.operator==="==="&&(d.left.type===T.AST_NODE_TYPES.Identifier&&d.left.name===n&&d.right.type===T.AST_NODE_TYPES.Literal&&d.right.value===!0||d.right.type===T.AST_NODE_TYPES.Identifier&&d.right.name===n&&d.left.type===T.AST_NODE_TYPES.Literal&&d.left.value===!0)||d.type===T.AST_NODE_TYPES.UnaryExpression&&d.operator==="!"&&d.argument.type===T.AST_NODE_TYPES.UnaryExpression&&d.argument.operator==="!"&&d.argument.argument.type===T.AST_NODE_TYPES.Identifier&&d.argument.argument.name===n)return!0}}m=m.parent}return!1}function l(u){let f=o.getScope(u),m=null,y=f;for(;y;){let d=y.variables.find(v=>v.name===u.name);if(d){m=d;break}if(y.type==="global"){m=y.variables.find(v=>v.name===u.name);break}y=y.upper}return!m||m.defs.length===0?!1:m.defs.some(d=>d.type==="Variable"||d.type==="Parameter"||d.type==="FunctionName"||d.type==="ClassName"||d.type==="ImportBinding")}function p(u,f,m){function y(d){if(!d)return!1;if(d.type===T.AST_NODE_TYPES.Identifier&&t.has(d.name)&&!l(d)&&!a(d,f))return r.report({node:m,messageId:"unsafeApiUsageInCalledFunction",data:{apiName:d.name,calledFunctionName:f.id?.name||(m.type===T.AST_NODE_TYPES.Identifier?m.name:"[anonymous]"),guardName:n}}),!0;for(let v in d){if(v==="parent"||v==="range"||v==="loc")continue;let c=d[v];if(Array.isArray(c)){for(let g of c)if(g&&typeof g=="object"&&"type"in g&&y(g))return!0}else if(c&&typeof c=="object"&&"type"in c&&y(c))return!0}return!1}y(u)}return{":function"(u){let f=u.parent;f&&f.type===T.AST_NODE_TYPES.CallExpression&&f.callee.type===T.AST_NODE_TYPES.Identifier&&f.callee.name==="useTask$"&&f.arguments.length>0&&f.arguments[0]===u&&(i=u)},":function:exit"(u){i===u&&(i=null)},Identifier(u){if(i&&!(i.body!==u&&!Fn(u,i.body))&&!(u.parent&&u.parent.type===T.AST_NODE_TYPES.CallExpression&&u.parent.callee===u)&&t.has(u.name)){if(l(u))return;a(u,i)||r.report({node:u,messageId:"unsafeApiUsage",data:{apiName:u.name,guardName:n}})}},CallExpression(u){if(i&&Fn(u,i.body)&&!a(u,i)&&u.callee.type===T.AST_NODE_TYPES.Identifier){let f=u.callee,m=o.getScope(f),y=null,d=m.references.find(c=>c.identifier===f);if(d&&d.resolved)y=d.resolved;else{let c=m;for(;c;){let g=c.variables.find(h=>h.name===f.name);if(g&&g.defs.length>0){y=g;break}if(c.type==="global"&&!g){let h=c.type==="global"?c.variables.find(E=>E.name===f.name):null;h&&(y=h);break}if(!c.upper)break;c=c.upper}}let v=y;if(v&&v.defs.length>0){let c=v.defs[0],g=null;if(c.node.type===T.AST_NODE_TYPES.FunctionDeclaration?g=c.node:c.node.type===T.AST_NODE_TYPES.VariableDeclarator&&c.node.init&&(c.node.init.type===T.AST_NODE_TYPES.FunctionExpression||c.node.init.type===T.AST_NODE_TYPES.ArrowFunctionExpression)&&(g=c.node.init),g){let h=(g.body.type===T.AST_NODE_TYPES.BlockStatement,g.body);p(h,g,u)}}}}}}};var x=require("@typescript-eslint/utils"),H=Z(require("typescript"));function Nn(r){return r?.defs?.some(e=>{if(e.type!=="ImportBinding")return!1;let t=e.parent.source.value;return t.startsWith("@qwik.dev/core")||t.startsWith("@qwik.dev/router")||t.startsWith("@builder.io/qwik")||t.startsWith("@builder.io/qwik-city")})}function Le(r,e){let t=r.sourceCode.getScope(e),n=t.references.find(i=>i.identifier===e);if(n&&n.resolved)return n.resolved;let o=t;for(;o;){let i=o.variables.find(a=>a.name===e.name);if(i)return i;o=o.upper}return null}function kb(r,e){if(!e||e.type!==x.AST_NODE_TYPES.Identifier||!e.name.endsWith("$"))return!1;let t=Le(r,e);return Nn(t)}function _b(r){let e=r.body[0];if(!e||e.type!==x.AST_NODE_TYPES.ExpressionStatement)return null;let t=e.expression;return t.type===x.AST_NODE_TYPES.MemberExpression&&!t.computed&&t.property.type===x.AST_NODE_TYPES.Identifier&&t.property.name==="value"?e:null}function Fb(r,e){let t=Le(r,e);if(!t||t.defs&&t.defs.length===0)return!1;let n=r.sourceCode.parserServices,o=n?.program?.getTypeChecker(),i=n?.esTreeNodeToTSNodeMap;function a(l){if(!l)return!1;if(H.default.isVariableDeclaration(l)&&l.initializer&&H.default.isCallExpression(l.initializer)){let p=l.initializer.expression;if(H.default.isIdentifier(p)){let u=p.text;return u==="createAsyncComputed$"||u==="useAsyncComputed$"||u==="routeLoader$"}}return H.default.isExportSpecifier(l)||H.default.isImportSpecifier(l),!1}for(let l of t.defs){if(l.type==="Variable"&&l.node.type===x.AST_NODE_TYPES.VariableDeclarator){let p=l.node.init;if(p&&p.type===x.AST_NODE_TYPES.CallExpression){let u=p.callee;if(u.type===x.AST_NODE_TYPES.Identifier){let f=u.name;if((f==="useAsyncComputed$"||f==="createAsyncComputed$"||f==="routeLoader$")&&Nn(Le(r,u)))return!0;let m=Le(r,u);if(m&&m.defs){for(let y of m.defs)if(y.type==="Variable"&&y.node.type===x.AST_NODE_TYPES.VariableDeclarator){let d=y.node.init;if(d&&d.type===x.AST_NODE_TYPES.CallExpression){let v=d.callee;if(v.type===x.AST_NODE_TYPES.Identifier&&v.name==="routeLoader$"&&Nn(Le(r,v)))return!0}}}}}}if(l.type==="ImportBinding"&&o&&i)try{let p=i.get(e);if(p){let u=o.getSymbolAtLocation(p);if(u&&u.flags&H.default.SymbolFlags.Alias&&(u=o.getAliasedSymbol(u)),u){for(let y of u.declarations??[]){if(a(y))return!0;if(H.default.isVariableStatement(y)){for(let d of y.declarationList.declarations)if(a(d))return!0}}let f=o.getTypeOfSymbolAtLocation(u,p),m=o.typeToString(f.getNonNullableType());if(/AsyncComputed/i.test(m))return!0}}}catch{}}if(o&&i)try{let l=i.get(e),p=o.getTypeAtLocation(l),u=o.typeToString(p.getNonNullableType());if(/AsyncComputed|LoaderSignal/i.test(u))return!0}catch{}return!1}function Nb(r,e,t){for(let n of r.body){if(n===e)break;if(n.type!==x.AST_NODE_TYPES.ExpressionStatement)continue;let o=n.expression;if(o.type!==x.AST_NODE_TYPES.AwaitExpression)continue;let i=o.argument;if(i.type===x.AST_NODE_TYPES.CallExpression&&(i=i.callee),i.type===x.AST_NODE_TYPES.MemberExpression&&!i.computed&&i.object.type===x.AST_NODE_TYPES.Identifier&&i.object.name===t&&i.property.type===x.AST_NODE_TYPES.Identifier&&i.property.name==="promise")return!0}return!1}function Rb(r){let e=r;for(;e;){if(e.type===x.AST_NODE_TYPES.FunctionDeclaration||e.type===x.AST_NODE_TYPES.FunctionExpression||e.type===x.AST_NODE_TYPES.ArrowFunctionExpression)return e;e=e.parent}return null}function jb(r,e,t){let n=e.parent;if(n&&n.type===x.AST_NODE_TYPES.CallExpression&&n.callee.type===x.AST_NODE_TYPES.Identifier&&kb(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===x.AST_NODE_TYPES.Identifier&&o.name===t.name)return!0}return!1}var Vp={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!==x.AST_NODE_TYPES.Identifier||e.property.name!=="value")return;let t=e.object;if(t.type!==x.AST_NODE_TYPES.Identifier||!Fb(r,t))return;let n=Rb(e);if(!n||!jb(r,n,t))return;let o=e.parent;if(!o||o.type!==x.AST_NODE_TYPES.ExpressionStatement&&o.type!==x.AST_NODE_TYPES.ReturnStatement)return;let i=n.body&&n.body.type===x.AST_NODE_TYPES.BlockStatement?n.body:null;if(!i)return n.body.type===x.AST_NODE_TYPES.MemberExpression&&n.body===e,void 0;o.parent!==i||i.body[0]===o||_b(i)===o||(o.type===x.AST_NODE_TYPES.ExpressionStatement||o.type===x.AST_NODE_TYPES.ReturnStatement)&&Nb(i,o,t.name)||r.report({node:e,messageId:"asyncComputedNotTop",data:{name:t.name}})}}}};var Dp={"valid-lexical-scope":Fp,"use-method-usage":_p,"no-react-props":Op,"loader-location":Ip,"prefer-classlist":$p,"jsx-no-script-url":Ap,"jsx-key":qp,"unused-server":kp,"jsx-img":Wn,"jsx-a":Bn,"no-use-visible-task":Cp,"serializer-signal-usage":Mp,"scope-use-task":Lp,"async-computed-top":Vp},Up={"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/async-computed-top":"warn"},Bp={"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/async-computed-top":"warn"},Mb={recommended:{plugins:["qwik"],rules:Up},strict:{plugins:["qwik"],rules:Bp}},Rn={configs:{get recommended(){return Lb},get strict(){return Vb}},meta:{name:_n.name,version:_n.version},rules:Dp},Lb=[{plugins:{qwik:Rn},rules:Up}],Vb=[{plugins:{qwik:Rn},rules:Bp}];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-beta.14",
4
+ "version": "2.0.0-beta.16",
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.38.0",
14
14
  "redent": "4.0.0",
15
- "@qwik.dev/core": "2.0.0-beta.14",
16
- "@qwik.dev/router": "2.0.0-beta.14"
15
+ "@qwik.dev/core": "2.0.0-beta.16",
16
+ "@qwik.dev/router": "2.0.0-beta.16"
17
17
  },
18
18
  "engines": {
19
19
  "node": "^18.17.0 || ^20.3.0 || >=21.0.0"