eslint-plugin-qwik 2.0.0-beta.36 → 2.0.0-beta.37
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.
- package/dist/index.js +1 -1
- 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 Xp={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 Vh=new Set(["useTask$","useTaskQrl"]);function Uh(r){return r.callee.type==="Identifier"&&Vh.has(r.callee.name)}function Bh(r){let e=r.arguments[0];return e?.type==="ArrowFunctionExpression"||e?.type==="FunctionExpression"?e:null}function Un(r){return r?r.type==="AssignmentPattern"?Un(r.right):r.type==="Literal"&&r.value===!1?!0:r.type==="TSAsExpression"?Un(r.expression):!1:!1}function Jh(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"&&Un(t.value))return!0}return!1}function Gp(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 Wh(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 Gp(t))e.add(o)}if(t.type==="Program"){for(let n of Gp(t))e.add(n);break}t=t.parent??null}return e}function Xh(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 Hp={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(!Uh(e)||Jh(e))return;let t=Bh(e);if(!t)return;let n=Wh(e);n.size&&Xh(r,t.body,n)}}}};var Bn={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.36",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 x=require("@typescript-eslint/utils");var Hh="isServer",zp=["process","__dirname","__filename","module"],Kp=["fs","os","path","child_process","http","https","Buffer"],Qp={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:Kp}},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||Kp.concat(zp)),n=Hh,o=r.sourceCode,i=null;function a(l,m){let p=l.parent;for(;p&&p!==m.body&&p!==m;){if(p.type===x.AST_NODE_TYPES.IfStatement){let f=p;if(We(l,f.consequent)||l===f.consequent){let d=f.test;if(d.type===x.AST_NODE_TYPES.Identifier&&d.name===n||d.type===x.AST_NODE_TYPES.BinaryExpression&&d.operator==="==="&&(d.left.type===x.AST_NODE_TYPES.Identifier&&d.left.name===n&&d.right.type===x.AST_NODE_TYPES.Literal&&d.right.value===!0||d.right.type===x.AST_NODE_TYPES.Identifier&&d.right.name===n&&d.left.type===x.AST_NODE_TYPES.Literal&&d.left.value===!0)||d.type===x.AST_NODE_TYPES.UnaryExpression&&d.operator==="!"&&d.argument.type===x.AST_NODE_TYPES.UnaryExpression&&d.argument.operator==="!"&&d.argument.argument.type===x.AST_NODE_TYPES.Identifier&&d.argument.argument.name===n)return!0}}p=p.parent}return!1}function u(l){let m=o.getScope(l),p=null,f=m;if(!zp.includes(l.name))return!0;for(;f;){let d=f.variables.find(y=>y.name===l.name);if(d){p=d;break}if(f.type==="global"){p=f.variables.find(y=>y.name===l.name);break}f=f.upper}return!p||p.defs.length===0?!1:p.defs.some(d=>d.type==="Variable"||d.type==="Parameter"||d.type==="FunctionName"||d.type==="ClassName"||d.type==="ImportBinding")}function c(l,m,p){te(l,f=>f.type===x.AST_NODE_TYPES.Identifier&&t.has(f.name)&&!u(f)&&!a(f,m)?(r.report({node:p,messageId:"unsafeApiUsageInCalledFunction",data:{apiName:f.name,calledFunctionName:m.id?.name||(p.type===x.AST_NODE_TYPES.Identifier?p.name:"[anonymous]"),guardName:n}}),!0):!1)}return{":function"(l){let m=l.parent;m&&m.type===x.AST_NODE_TYPES.CallExpression&&m.callee.type===x.AST_NODE_TYPES.Identifier&&m.callee.name==="useTask$"&&m.arguments.length>0&&m.arguments[0]===l&&(i=l)},":function:exit"(l){i===l&&(i=null)},Identifier(l){if(i&&!(i.body!==l&&!We(l,i.body))&&!(l.parent&&l.parent.type===x.AST_NODE_TYPES.CallExpression&&l.parent.callee===l)&&t.has(l.name)){if(u(l))return;a(l,i)||r.report({node:l,messageId:"unsafeApiUsage",data:{apiName:l.name,guardName:n}})}},CallExpression(l){if(i&&We(l,i.body)&&!a(l,i)&&l.callee.type===x.AST_NODE_TYPES.Identifier){let m=l.callee,p=D(r,m);if(p&&p.defs.length>0){let f=p.defs[0],d=null;if(f.node.type===x.AST_NODE_TYPES.FunctionDeclaration?d=f.node:f.node.type===x.AST_NODE_TYPES.VariableDeclarator&&f.node.init&&(f.node.init.type===x.AST_NODE_TYPES.FunctionExpression||f.node.init.type===x.AST_NODE_TYPES.ArrowFunctionExpression)&&(d=f.node.init),d){let y=(d.body.type===x.AST_NODE_TYPES.BlockStatement,d.body);c(y,d,l)}}}}}}};var h=require("@typescript-eslint/utils"),K=re(require("typescript"));function zh(r,e){return Qn(r,e)}function Kh(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 Qh(r,e){let t=D(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){if(!u)return!1;if(K.default.isVariableDeclaration(u)&&u.initializer&&K.default.isCallExpression(u.initializer)){let c=u.initializer.expression;if(K.default.isIdentifier(c)){let l=c.text;return l==="createAsync$"||l==="useAsync$"||l==="routeLoader$"}}return K.default.isExportSpecifier(u)||K.default.isImportSpecifier(u),!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 l=c.callee;if(l.type===h.AST_NODE_TYPES.Identifier){let m=l.name;if((m==="useAsync$"||m==="createAsync$"||m==="routeLoader$")&&Xe(D(r,l)))return!0;let p=D(r,l);if(p&&p.defs){for(let f of p.defs)if(f.type==="Variable"&&f.node.type===h.AST_NODE_TYPES.VariableDeclarator){let d=f.node.init;if(d&&d.type===h.AST_NODE_TYPES.CallExpression){let y=d.callee;if(y.type===h.AST_NODE_TYPES.Identifier&&y.name==="routeLoader$"&&Xe(D(r,y)))return!0}}}}}}if(u.type==="ImportBinding"&&o&&i)try{let c=i.get(e);if(c){let l=o.getSymbolAtLocation(c);if(l&&l.flags&K.default.SymbolFlags.Alias&&(l=o.getAliasedSymbol(l)),l){for(let f of l.declarations??[]){if(a(f))return!0;if(K.default.isVariableStatement(f)){for(let d of f.declarationList.declarations)if(a(d))return!0}}let m=o.getTypeOfSymbolAtLocation(l,c),p=o.typeToString(m.getNonNullableType());if(/Async/i.test(p))return!0}}}catch{}}if(o&&i)try{let u=i.get(e),c=o.getTypeAtLocation(u),l=o.typeToString(c.getNonNullableType());if(/Async|LoaderSignal/i.test(l))return!0}catch{}return!1}function Yh(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 Zh(r,e,t){let n=e.parent;if(n&&n.type===h.AST_NODE_TYPES.CallExpression&&n.callee.type===h.AST_NODE_TYPES.Identifier&&zh(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 Yp={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||!Qh(r,t))return;let n=Yn(e);if(!n||!Zh(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||Kh(i)===o||(o.type===h.AST_NODE_TYPES.ExpressionStatement||o.type===h.AST_NODE_TYPES.ReturnStatement)&&Yh(i,o,t.name)||r.report({node:e,messageId:"asyncComputedNotTop",data:{name:t.name}})}}}};var Zp={"valid-lexical-scope":Vp,"use-method-usage":Dp,"no-react-props":Rp,"loader-location":Np,"prefer-classlist":jp,"jsx-no-script-url":Fp,"jsx-key":Cp,"unused-server":Mp,"jsx-img":to,"jsx-a":eo,"no-use-visible-task":Lp,"serializer-signal-usage":Wp,"scope-use-task":Qp,"use-async-top":Yp,"no-async-prevent-default":Xp,"no-await-navigate-in-use-task":Hp},ec={"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"},rc={"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"},eb={recommended:{plugins:["qwik"],rules:ec},strict:{plugins:["qwik"],rules:rc}},tc={configs:{get recommended(){return rb},get strict(){return tb}},meta:{name:Bn.name,version:Bn.version},rules:Zp},nc=r=>[{plugins:{qwik:tc},rules:r}],rb=nc(ec),tb=nc(rc);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 Vh=new Set(["useTask$","useTaskQrl"]);function Uh(r){return r.callee.type==="Identifier"&&Vh.has(r.callee.name)}function Bh(r){let e=r.arguments[0];return e?.type==="ArrowFunctionExpression"||e?.type==="FunctionExpression"?e:null}function Un(r){return r?r.type==="AssignmentPattern"?Un(r.right):r.type==="Literal"&&r.value===!1?!0:r.type==="TSAsExpression"?Un(r.expression):!1:!1}function Jh(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"&&Un(t.value))return!0}return!1}function Gp(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 Wh(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 Gp(t))e.add(o)}if(t.type==="Program"){for(let n of Gp(t))e.add(n);break}t=t.parent??null}return e}function Xh(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 Hp={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(!Uh(e)||Jh(e))return;let t=Bh(e);if(!t)return;let n=Wh(e);n.size&&Xh(r,t.body,n)}}}};var Bn={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.37",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 x=require("@typescript-eslint/utils");var Hh="isServer",zp=["process","__dirname","__filename","module"],Kp=["fs","os","path","child_process","http","https","Buffer"],Qp={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:Kp}},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||Kp.concat(zp)),n=Hh,o=r.sourceCode,i=null;function a(l,m){let p=l.parent;for(;p&&p!==m.body&&p!==m;){if(p.type===x.AST_NODE_TYPES.IfStatement){let f=p;if(We(l,f.consequent)||l===f.consequent){let d=f.test;if(d.type===x.AST_NODE_TYPES.Identifier&&d.name===n||d.type===x.AST_NODE_TYPES.BinaryExpression&&d.operator==="==="&&(d.left.type===x.AST_NODE_TYPES.Identifier&&d.left.name===n&&d.right.type===x.AST_NODE_TYPES.Literal&&d.right.value===!0||d.right.type===x.AST_NODE_TYPES.Identifier&&d.right.name===n&&d.left.type===x.AST_NODE_TYPES.Literal&&d.left.value===!0)||d.type===x.AST_NODE_TYPES.UnaryExpression&&d.operator==="!"&&d.argument.type===x.AST_NODE_TYPES.UnaryExpression&&d.argument.operator==="!"&&d.argument.argument.type===x.AST_NODE_TYPES.Identifier&&d.argument.argument.name===n)return!0}}p=p.parent}return!1}function u(l){let m=o.getScope(l),p=null,f=m;if(!zp.includes(l.name))return!0;for(;f;){let d=f.variables.find(y=>y.name===l.name);if(d){p=d;break}if(f.type==="global"){p=f.variables.find(y=>y.name===l.name);break}f=f.upper}return!p||p.defs.length===0?!1:p.defs.some(d=>d.type==="Variable"||d.type==="Parameter"||d.type==="FunctionName"||d.type==="ClassName"||d.type==="ImportBinding")}function c(l,m,p){te(l,f=>f.type===x.AST_NODE_TYPES.Identifier&&t.has(f.name)&&!u(f)&&!a(f,m)?(r.report({node:p,messageId:"unsafeApiUsageInCalledFunction",data:{apiName:f.name,calledFunctionName:m.id?.name||(p.type===x.AST_NODE_TYPES.Identifier?p.name:"[anonymous]"),guardName:n}}),!0):!1)}return{":function"(l){let m=l.parent;m&&m.type===x.AST_NODE_TYPES.CallExpression&&m.callee.type===x.AST_NODE_TYPES.Identifier&&m.callee.name==="useTask$"&&m.arguments.length>0&&m.arguments[0]===l&&(i=l)},":function:exit"(l){i===l&&(i=null)},Identifier(l){if(i&&!(i.body!==l&&!We(l,i.body))&&!(l.parent&&l.parent.type===x.AST_NODE_TYPES.CallExpression&&l.parent.callee===l)&&t.has(l.name)){if(u(l))return;a(l,i)||r.report({node:l,messageId:"unsafeApiUsage",data:{apiName:l.name,guardName:n}})}},CallExpression(l){if(i&&We(l,i.body)&&!a(l,i)&&l.callee.type===x.AST_NODE_TYPES.Identifier){let m=l.callee,p=D(r,m);if(p&&p.defs.length>0){let f=p.defs[0],d=null;if(f.node.type===x.AST_NODE_TYPES.FunctionDeclaration?d=f.node:f.node.type===x.AST_NODE_TYPES.VariableDeclarator&&f.node.init&&(f.node.init.type===x.AST_NODE_TYPES.FunctionExpression||f.node.init.type===x.AST_NODE_TYPES.ArrowFunctionExpression)&&(d=f.node.init),d){let y=(d.body.type===x.AST_NODE_TYPES.BlockStatement,d.body);c(y,d,l)}}}}}}};var h=require("@typescript-eslint/utils"),K=re(require("typescript"));function zh(r,e){return Qn(r,e)}function Kh(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 Qh(r,e){let t=D(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){if(!u)return!1;if(K.default.isVariableDeclaration(u)&&u.initializer&&K.default.isCallExpression(u.initializer)){let c=u.initializer.expression;if(K.default.isIdentifier(c)){let l=c.text;return l==="createAsync$"||l==="useAsync$"||l==="routeLoader$"}}return K.default.isExportSpecifier(u)||K.default.isImportSpecifier(u),!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 l=c.callee;if(l.type===h.AST_NODE_TYPES.Identifier){let m=l.name;if((m==="useAsync$"||m==="createAsync$"||m==="routeLoader$")&&Xe(D(r,l)))return!0;let p=D(r,l);if(p&&p.defs){for(let f of p.defs)if(f.type==="Variable"&&f.node.type===h.AST_NODE_TYPES.VariableDeclarator){let d=f.node.init;if(d&&d.type===h.AST_NODE_TYPES.CallExpression){let y=d.callee;if(y.type===h.AST_NODE_TYPES.Identifier&&y.name==="routeLoader$"&&Xe(D(r,y)))return!0}}}}}}if(u.type==="ImportBinding"&&o&&i)try{let c=i.get(e);if(c){let l=o.getSymbolAtLocation(c);if(l&&l.flags&K.default.SymbolFlags.Alias&&(l=o.getAliasedSymbol(l)),l){for(let f of l.declarations??[]){if(a(f))return!0;if(K.default.isVariableStatement(f)){for(let d of f.declarationList.declarations)if(a(d))return!0}}let m=o.getTypeOfSymbolAtLocation(l,c),p=o.typeToString(m.getNonNullableType());if(/Async/i.test(p))return!0}}}catch{}}if(o&&i)try{let u=i.get(e),c=o.getTypeAtLocation(u),l=o.typeToString(c.getNonNullableType());if(/Async|LoaderSignal/i.test(l))return!0}catch{}return!1}function Yh(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 Zh(r,e,t){let n=e.parent;if(n&&n.type===h.AST_NODE_TYPES.CallExpression&&n.callee.type===h.AST_NODE_TYPES.Identifier&&zh(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 Yp={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||!Qh(r,t))return;let n=Yn(e);if(!n||!Zh(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||Kh(i)===o||(o.type===h.AST_NODE_TYPES.ExpressionStatement||o.type===h.AST_NODE_TYPES.ReturnStatement)&&Yh(i,o,t.name)||r.report({node:e,messageId:"asyncComputedNotTop",data:{name:t.name}})}}}};var Zp={"valid-lexical-scope":Vp,"use-method-usage":Dp,"no-react-props":Rp,"loader-location":Np,"prefer-classlist":jp,"jsx-no-script-url":Fp,"jsx-key":Cp,"unused-server":Mp,"jsx-img":to,"jsx-a":eo,"no-use-visible-task":Lp,"serializer-signal-usage":Wp,"scope-use-task":Qp,"use-async-top":Yp,"no-async-prevent-default":Xp,"no-await-navigate-in-use-task":Hp},ec={"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"},rc={"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"},eb={recommended:{plugins:["qwik"],rules:ec},strict:{plugins:["qwik"],rules:rc}},tc={configs:{get recommended(){return rb},get strict(){return tb}},meta:{name:Bn.name,version:Bn.version},rules:Zp},nc=r=>[{plugins:{qwik:tc},rules:r}],rb=nc(ec),tb=nc(rc);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.
|
|
4
|
+
"version": "2.0.0-beta.37",
|
|
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-beta.
|
|
16
|
-
"@qwik.dev/router": "2.0.0-beta.
|
|
15
|
+
"@qwik.dev/core": "2.0.0-beta.37",
|
|
16
|
+
"@qwik.dev/router": "2.0.0-beta.37"
|
|
17
17
|
},
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|