eslint-plugin-qwik
Advanced tools
Comparing version 0.18.1 to 0.19.0
17
index.js
@@ -1,5 +0,16 @@ | ||
"use strict";var q=Object.create;var I=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var _=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var z=(t,e)=>{for(var n in e)I(t,n,{get:e[n],enumerable:!0})},v=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of X(e))!j.call(t,s)&&s!==n&&I(t,s,{get:()=>e[s],enumerable:!(o=P(e,s))||o.enumerable});return t};var M=(t,e,n)=>(n=t!=null?q(_(t)):{},v(e||!t||!t.__esModule?I(n,"default",{value:t,enumerable:!0}):n,t)),U=t=>v(I({},"__esModule",{value:!0}),t);var ne={};z(ne,{configs:()=>te,rules:()=>ee});module.exports=U(ne);var E=require("@typescript-eslint/utils"),h=M(require("typescript")),B=E.ESLintUtils.RuleCreator(t=>`https://typescript-eslint.io/rules/${t}`),L=B({name:"valid-lexical-scope",defaultOptions:[{allowAny:!0}],meta:{type:"problem",docs:{description:"Used the tsc typechecker to detect the capture of unserializable data in dollar ($) scopes.",recommended:"error"},schema:[{type:"object",properties:{allowAny:{type:"boolean"}},default:{allowAny:!0}}],messages:{referencesOutside:'Identifier ("{{varName}}") can not be captured inside the scope ({{dollarName}}) because {{reason}}. Check out https://qwik.builder.io/docs/advanced/dollar/ for more details.',unvalidJsxDollar:"JSX attributes that end with $ can only take an inlined arrow function of a QRL identifier. Make sure the value is created using $()",mutableIdentifier:'The value of the identifier ("{{varName}}") can not be changed once it is captured the scope ({{dollarName}}). Check out https://qwik.builder.io/docs/advanced/dollar/ for more details.'}},create(t){var A;let n={allowAny:((A=t.options[0])==null?void 0:A.allowAny)??!0},o=t.getSourceCode().scopeManager,s=E.ESLintUtils.getParserServices(t),a=s.esTreeNodeToTSNodeMap,r=s.program.getTypeChecker(),l=new Map,p=[];function S(f){f.references.forEach(i=>{var y,b;let c=i.resolved,d=(y=i.resolved)==null?void 0:y.scope;if(c&&d){let m=(b=c.defs.at(0))==null?void 0:b.type;if(m==="Type"||m==="ImportBinding")return;let u=i.from,g;for(;u&&(g=l.get(u),!g);)u=u.upper;if(u&&g){let k=d.type;if(k==="global")return;if(k==="module"){let N=c.identifiers.length===1?c.identifiers[0]:i.identifier,J=a.get(N),C=r.getSymbolAtLocation(J);if(C&&p.includes(C))return;t.report({messageId:"referencesOutside",node:i.identifier,data:{varName:i.identifier.name,dollarName:g,reason:`it's declared at the root of the module and it is not exported. Make sure "${i.identifier.name}" is an exported identifier: | ||
"use strict";var B=Object.create;var I=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var V=Object.getPrototypeOf,W=Object.prototype.hasOwnProperty;var Q=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),X=(e,t)=>{for(var n in t)I(e,n,{get:t[n],enumerable:!0})},L=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of J(t))!W.call(e,i)&&i!==n&&I(e,i,{get:()=>t[i],enumerable:!(r=j(t,i))||r.enumerable});return e};var R=(e,t,n)=>(n=e!=null?B(V(e)):{},L(t||!e||!e.__esModule?I(n,"default",{value:e,enumerable:!0}):n,e)),Z=e=>L(I({},"__esModule",{value:!0}),e);var D=Q((ce,O)=>{"use strict";O.exports=e=>{let t=e.match(/^[ \t]*(?=\S)/gm);return t?t.reduce((n,r)=>Math.min(n,r.length),1/0):0}});var ae={};X(ae,{configs:()=>se,rules:()=>ie});module.exports=Z(ae);var v=require("@typescript-eslint/utils"),w=R(require("typescript"));var q=R(D(),1);function N(e){let t=(0,q.default)(e);if(t===0)return e;let n=new RegExp(`^[ \\t]{${t}}`,"gm");return e.replace(n,"")}function A(e,t=1,n={}){let{indent:r=" ",includeEmptyLines:i=!1}=n;if(typeof e!="string")throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof e}\``);if(typeof t!="number")throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof t}\``);if(t<0)throw new RangeError(`Expected \`count\` to be at least 0, got \`${t}\``);if(typeof r!="string")throw new TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof r}\``);if(t===0)return e;let l=i?/^/gm:/^(?!\s*$)/gm;return e.replace(l,r.repeat(t))}function $(e,t=0,n={}){return A(N(e),t,n)}var G=v.ESLintUtils.RuleCreator(()=>"https://qwik.builder.io/docs/advanced/dollar/"),P=G({name:"valid-lexical-scope",defaultOptions:[{allowAny:!0}],meta:{type:"problem",docs:{description:"Used the tsc typechecker to detect the capture of unserializable data in dollar ($) scopes.",recommended:"error"},schema:[{type:"object",properties:{allowAny:{type:"boolean"}},default:{allowAny:!0}}],messages:{referencesOutside:`Seems like you are referencing "{{varName}}" inside a different scope ({{dollarName}}), when this happens, Qwik needs to serialize the value, however {{reason}}. | ||
Check out https://qwik.builder.io/docs/advanced/dollar/ for more details.`,invalidJsxDollar:`Seems like you are using "{{varName}}" as an event handler, however functions are not serializable. | ||
Did you mean to wrap it in \`$()\`? | ||
export const ${i.identifier.name} = ... | ||
{{solution}} | ||
Check out https://qwik.builder.io/docs/advanced/dollar/ for more details.`,mutableIdentifier:`Seems like you are mutating the value of ("{{varName}}"), but this is not possible when captured by the ({{dollarName}}) closure, instead create an object and mutate one of its properties. | ||
Check out https://qwik.builder.io/docs/advanced/dollar/ for more details.`}},create(e){var C;let n={allowAny:((C=e.options[0])==null?void 0:C.allowAny)??!0},r=e.getSourceCode().scopeManager,i=v.ESLintUtils.getParserServices(e),l=i.esTreeNodeToTSNodeMap,o=i.program.getTypeChecker(),s=new Map,c=[];function h(m){m.references.forEach(a=>{var u,g;let y=a.resolved,d=(u=a.resolved)==null?void 0:u.scope;if(y&&d){let b=(g=y.defs.at(0))==null?void 0:g.type;if(b==="Type"||b==="ImportBinding")return;let p=a.from,f;for(;p&&(f=s.get(p),!f);)p=p.upper;if(p&&f){let T=d.type;if(T==="global"||T==="module")return;let S=a.identifier,M=l.get(S),x=d;for(;x&&!s.has(x);)x=x.upper;if(x!==p){S.parent&&S.parent.type==="AssignmentExpression"&&S.parent.left===S&&e.report({messageId:"mutableIdentifier",node:a.identifier,data:{varName:a.identifier.name,dollarName:f}});let k=H(e,o,M,a.identifier,n);k&&e.report({messageId:"referencesOutside",node:a.identifier,data:{varName:a.identifier.name,dollarName:f,reason:K(k)}})}}}}),m.childScopes.forEach(h)}return{CallExpression(m){if(m.callee.type==="Identifier"&&m.callee.name.endsWith("$")){let a=m.arguments.at(0);if(a&&a.type==="ArrowFunctionExpression"){let y=r.acquire(a);y&&s.set(y,m.callee.name)}}},JSXAttribute(m){let a=m.name,y=a.type==="JSXIdentifier"?a.name:a.name.name;if(y.endsWith("$")){let d=m.value;if(d&&d.type==="JSXExpressionContainer"){let u=r.acquire(d.expression);if(u)s.set(u,y);else if(d.expression.type==="Identifier"){let g=l.get(d.expression),b=o.getTypeAtLocation(g);if(!F(b)){if(b.symbol.name==="PropFnInterface")return;e.report({messageId:"invalidJsxDollar",node:d.expression,data:{varName:d.expression.name,solution:`const ${d.expression.name} = $( | ||
${_(b.symbol,e.getSourceCode().text)} | ||
); | ||
`}})}}}}},Program(m){let a=l.get(m),y=o.getSymbolAtLocation(a);y&&(c=o.getExportsOfModule(y))},"Program:exit"(){h(r.globalScope)}}}});function H(e,t,n,r,i){let l=t.getTypeAtLocation(n);return Y(e,t,l,n,r,i,new Set)}function K(e){let t="";return e.location?t+=`"${e.location}" `:t+="it ",t+=`${e.reason}`,t}function Y(e,t,n,r,i,l,o){let s=E(e,t,n,r,l,0,o);if(s){let c=s.location;return c&&(s.location=`${i.name}.${c}`),s}return s}function E(e,t,n,r,i,l,o){if(o.has(n)||(o.add(n),n.getProperty("__no_serialize__")))return;if(n.flags&w.default.TypeFlags.Unknown)return{type:n,typeStr:t.typeToString(n),reason:"is unknown, which could be serializable or not, please make the type for specific"};let c=n.flags&w.default.TypeFlags.Any;if(!i.allowAny&&c)return{type:n,typeStr:t.typeToString(n),reason:"is any, which is not serializable"};if(n.flags&w.default.TypeFlags.BigIntLike)return{type:n,typeStr:t.typeToString(n),reason:"is BigInt and it is not supported yet, use a number instead"};if(n.flags&w.default.TypeFlags.ESSymbolLike)return{type:n,typeStr:t.typeToString(n),reason:"is Symbol, which is not serializable"};if(n.flags&w.default.TypeFlags.EnumLike)return{type:n,typeStr:t.typeToString(n),reason:"is an enum, use an string or a number instead"};if(F(n))return;if(n.getCallSignatures().length>0){if(n.symbol.name==="PropFnInterface")return;let u="is a function, which is not serializable";if(l===0&&w.default.isIdentifier(r)){let g=`const ${r.text} = $( | ||
${_(n.symbol,e.getSourceCode().text)} | ||
);`;u+=`. | ||
Did you mean to wrap it in \`$()\`? | ||
`}});return}let w=i.identifier,D=a.get(w),T=d;for(;T&&!l.has(T);)T=T.upper;if(T!==u){w.parent&&w.parent.type==="AssignmentExpression"&&w.parent.left===w&&t.report({messageId:"mutableIdentifier",node:i.identifier,data:{varName:i.identifier.name,dollarName:g}});let N=V(r,D,i.identifier,n);N&&t.report({messageId:"referencesOutside",node:i.identifier,data:{varName:i.identifier.name,dollarName:g,reason:W(N)}})}}}}),f.childScopes.forEach(S)}return{CallExpression(f){if(f.callee.type==="Identifier"&&f.callee.name.endsWith("$")){let i=f.arguments.at(0);if(i&&i.type==="ArrowFunctionExpression"){let c=o.acquire(i);c&&l.set(c,f.callee.name)}}},JSXAttribute(f){let i=f.name,c=i.type==="JSXIdentifier"?i.name:i.name.name;if(c.endsWith("$")){let d=f.value;if(d&&d.type==="JSXExpressionContainer"){let y=o.acquire(d.expression);if(y)l.set(y,c);else if(d.expression.type==="Identifier"){let b=a.get(d.expression),m=r.getTypeAtLocation(b);if(!R(m)){if(m.symbol.name==="PropFnInterface")return;t.report({messageId:"unvalidJsxDollar",node:d.expression})}}}}},Program(f){let i=a.get(f),c=r.getSymbolAtLocation(i);c&&(p=r.getExportsOfModule(c))},"Program:exit"(){S(o.globalScope)}}}});function V(t,e,n,o){let s=t.getTypeAtLocation(e);return Q(t,s,e,n,o,new Set)}function W(t){let e="";return t.location?e+=`"${t.location}" `:e+="it ",e+=`${t.reason}`,e}function Q(t,e,n,o,s,a){let r=x(t,e,n,s,0,a);if(r){let l=r.location;return l&&(r.location=`${o.name}.${l}`),r}return r}function x(t,e,n,o,s,a){if(a.has(e)||(a.add(e),e.getProperty("__no_serialize__")))return;if(e.flags&h.default.TypeFlags.Unknown)return{type:e,typeStr:t.typeToString(e),reason:"is unknown, which could be serializable or not, please make the type for specific"};let l=e.flags&h.default.TypeFlags.Any;if(!o.allowAny&&l)return{type:e,typeStr:t.typeToString(e),reason:"is any, which is not serializable"};if(e.flags&h.default.TypeFlags.BigIntLike)return{type:e,typeStr:t.typeToString(e),reason:"is BigInt and it is not supported yet, use a number instead"};if(e.flags&h.default.TypeFlags.ESSymbolLike)return{type:e,typeStr:t.typeToString(e),reason:"is Symbol, which is not serializable"};if(e.flags&h.default.TypeFlags.EnumLike)return{type:e,typeStr:t.typeToString(e),reason:"is an enum, use an string or a number instead"};if(R(e))return;if(e.getCallSignatures().length>0)return e.symbol.name==="PropFnInterface"?void 0:{type:e,typeStr:t.typeToString(e),reason:"is a function, which is not serializable"};if(e.isUnion()){for(let c of e.types){let d=x(t,c,n,o,s+1,a);if(d)return d}return}if((e.flags&h.default.TypeFlags.Object)!==0){let c=Z(e,t);if(c)return x(t,c,n,o,s+1,a);let d=G(e,t);if(d){for(let m of d){let u=x(t,m,n,o,s+1,a);if(u)return u}return}let y=e.symbol.name;if(e.getProperty("nextElementSibling")||e.getProperty("activeElement")||H[y])return;if(e.isClass())return{type:e,typeStr:t.typeToString(e),reason:`is an instance of the "${e.symbol.name}" class, which is not serializable. Use a simple object literal instead`};let b=e.getProperty("prototype");if(b){let m=t.getTypeOfSymbolAtLocation(b,n);if(m.isClass())return{type:m,typeStr:t.typeToString(m),reason:"is a class constructor, which is not serializable"}}if(!y.startsWith("__")&&e.symbol.valueDeclaration)return{type:e,typeStr:t.typeToString(e),reason:`is an instance of the "${e.symbol.name}" class, which is not serializable`};for(let m of e.getProperties()){let u=Y(t,m,n,o,s+1,a);if(u){let g=u.location;return u.location=`${m.name}${g?`.${g}`:""}`,u}}}}function Y(t,e,n,o,s,a){let r=t.getTypeOfSymbolAtLocation(e,n);return x(t,r,n,o,s,a)}function Z(t,e){return e.getElementTypeOfArrayType(t)}function G(t,e){return e.isTupleType(t)?e.getTypeArguments(t):void 0}function R(t){return!!(t.flags&h.default.TypeFlags.Any)||!!t.getProperty("__brand__QRL__")}var H={Promise:!0,URL:!0,RegExp:!0,Date:!0,FormData:!0,URLSearchParams:!0,Error:!0};var O={meta:{type:"problem",docs:{description:"Object destructuring is not recommended for component$",category:"Variables",recommended:!0,url:"https://github.com/BuilderIO/qwik"}},create(t){let e=[];return{ArrowFunctionExpression(){e.push({await:!1})},"ArrowFunctionExpression:exit"(){e.pop()},AwaitExpression(){let n=e[e.length-1];n&&(n.await=!0)},"CallExpression[callee.name=/^use[A-Z]/]"(n){let o=e[e.length-1];o&&o.await&&t.report({node:n,message:"Calling use* methods after await is not safe."})}}}};var $={meta:{type:"problem",docs:{description:"Detect multiple JSX roots inside a component",recommended:!0,url:"https://github.com/BuilderIO/qwik"},messages:{multipleJsxRoots:"Components in Qwik must have a single JSX root element. Your component has multiple roots on lines: {{lines}}. Rewrite your component with a single root such as (`return <>{...}</>`.) and keep all JSX within"}},create(t){let e=[];return{ArrowFunctionExpression(){e.push({rootNodes:[],depth:0})},"ArrowFunctionExpression:exit"(){let n=e[e.length-1];if(n&&n.rootNodes.length>1){let o=n.rootNodes.map(s=>{var a;return((a=s.loc)==null?void 0:a.start.line)??0}).join(", ");t.report({node:n.rootNodes[0],messageId:"multipleJsxRoots",data:{lines:o}})}e.pop()},FunctionDeclaration(){e.push({rootNodes:[],depth:0})},"FunctionDeclaration:exit"(){e.pop()},"JSXElement,JSXFragment"(n){let o=e[e.length-1];o&&(o.depth===0&&o.rootNodes.push(n),o.depth++)},"JSXElement:exit"(){let n=e[e.length-1];n&&n.depth--},"JSXFragment:exit"(){let n=e[e.length-1];n&&n.depth--}}}};var F={meta:{type:"problem",docs:{description:"Detect declaration location of loader$",recommended:!0,url:"https://github.com/BuilderIO/qwik"},messages:{invalidLoaderLocation:'`{{fnName}}()` can only be declared in `layout.tsx`, `index.tsx` and `plugin.tsx` inside the `src/routes` directory, instead it was declared in "{{path}}".\nPlease check the docs: https://qwik.builder.io/qwikcity/loader',missingExport:"The return of `{{fnName}}()` needs to be exported in the same module, like this\n```\nexport const {{id}} = {{fnName}}(() => { ... });\n```",wrongName:"The named export of `{{fnName}}()` needs to follow the `use*` naming convention. It must start with `use`, like this:\n```\nexport const {{fixed}} = {{fnName}}(() => { ... });\n```\nInstead it was named:\n```\nexport const {{id}} = ...\n```",recommendedValue:"For `{{fnName}}()` it is recommended to inline the arrow function. Instead of:\n```\nexport const {{id}} = {{fnName}}({{arg}});\n```\nDo this:\n```\nexport const {{id}} = {{fnName}}(() => { ...logic here... });\n```\nThis will help the optimizer make sure that no server code is leaked to the client build."}},create(t){let e=K(t.getFilename()),n=/\/layout(|!|-.+)\.tsx?$/.test(e),o=/\/index(|!|@.+)\.tsx?$/.test(e),a=/\/src\/routes\//.test(e)&&(o||n);return{CallExpression(r){if(r.callee.type!=="Identifier")return;let l=r.callee.name;if(l!=="loader$"&&l!=="action$")return;if(!a&&l==="loader$"){t.report({node:r.callee,messageId:"invalidLoaderLocation",data:{fnName:l,path:e}});return}let p=r.parent;if(p.type!=="VariableDeclarator"){t.report({node:r.callee,messageId:"missingExport",data:{fnName:l,id:"useStuff"}});return}if(p.id.type!=="Identifier"){t.report({node:r.callee,messageId:"missingExport",data:{fnName:l,id:"useStuff"}});return}if(!/^use/.test(p.id.name)){let S="use"+p.id.name[0].toUpperCase()+p.id.name.slice(1);t.report({node:p.id,messageId:"wrongName",data:{fnName:l,id:p.id.name,fixed:S}});return}if(p.parent.parent.type!=="ExportNamedDeclaration"){t.report({node:p.id,messageId:"missingExport",data:{fnName:l,id:p.id.name}});return}if(r.arguments.length>0&&r.arguments[0].type==="Identifier"){t.report({node:r.arguments[0],messageId:"recommendedValue",data:{fnName:l,id:p.id.name,arg:r.arguments[0].name}});return}}}}};function K(t){let e=/^\\\\\?\\/.test(t),n=/[^\u0000-\u0080]+/.test(t);return e||n||(t=t.replace(/\\/g,"/"),t.endsWith("/")&&(t=t.slice(0,t.length-1))),t}var ee={"no-use-after-await":O,"valid-lexical-scope":L,"single-jsx-root":$,"loader-location":F},te={recommended:{plugins:["qwik"],rules:{"qwik/no-use-after-await":"error","qwik/valid-lexical-scope":"error","qwik/loader-location":"warn","qwik/single-jsx-root":"warn"}},strict:{plugins:["qwik"],rules:{"qwik/valid-lexical-scope":"error","qwik/no-use-after-await":"error","qwik/single-jsx-root":"error","qwik/loader-location":"error"}}};0&&(module.exports={configs,rules}); | ||
${g} | ||
`}return{type:n,typeStr:t.typeToString(n),reason:u}}if(n.isUnion()){for(let d of n.types){let u=E(e,t,d,r,i,l+1,o);if(u)return u}return}if((n.flags&w.default.TypeFlags.Object)!==0){let d=te(n,t);if(d)return E(e,t,d,r,i,l+1,o);let u=ne(n,t);if(u){for(let p of u){let f=E(e,t,p,r,i,l+1,o);if(f)return f}return}let g=n.symbol.name;if(n.getProperty("nextElementSibling")||n.getProperty("activeElement")||re[g])return;if(n.isClass())return{type:n,typeStr:t.typeToString(n),reason:`is an instance of the "${n.symbol.name}" class, which is not serializable. Use a simple object literal instead`};let b=n.getProperty("prototype");if(b){let p=t.getTypeOfSymbolAtLocation(b,r);if(p.isClass())return{type:p,typeStr:t.typeToString(p),reason:"is a class constructor, which is not serializable"}}if(!g.startsWith("__")&&n.symbol.valueDeclaration)return{type:n,typeStr:t.typeToString(n),reason:`is an instance of the "${n.symbol.name}" class, which is not serializable`};for(let p of n.getProperties()){let f=ee(e,t,p,r,i,l+1,o);if(f){let T=f.location;return f.location=`${p.name}${T?`.${T}`:""}`,f}}}}function ee(e,t,n,r,i,l,o){let s=t.getTypeOfSymbolAtLocation(n,r);return E(e,t,s,r,i,l,o)}function te(e,t){return t.getElementTypeOfArrayType(e)}function ne(e,t){return t.isTupleType(e)?t.getTypeArguments(e):void 0}function F(e){return!!(e.flags&w.default.TypeFlags.Any)||!!e.getProperty("__brand__QRL__")}function _(e,t){if(e.declarations&&e.declarations.length>0){let n=e.declarations[0],r=t.slice(n.pos,n.end).replace(/^\s*$/gm,"");return $(r,2)}return""}var re={Promise:!0,URL:!0,RegExp:!0,Date:!0,FormData:!0,URLSearchParams:!0,Error:!0};var z={meta:{type:"problem",docs:{description:"Object destructuring is not recommended for component$",category:"Variables",recommended:!0,url:"https://github.com/BuilderIO/qwik"}},create(e){let t=[];return{ArrowFunctionExpression(){t.push({await:!1})},"ArrowFunctionExpression:exit"(){t.pop()},AwaitExpression(){let n=t[t.length-1];n&&(n.await=!0)},"CallExpression[callee.name=/^use[A-Z]/]"(n){let r=t[t.length-1];r&&r.await&&e.report({node:n,message:"Calling use* methods after await is not safe."})}}}};var U={meta:{type:"problem",docs:{description:"Detect declaration location of loader$",recommended:!0,url:"https://github.com/BuilderIO/qwik"},messages:{invalidLoaderLocation:'`{{fnName}}()` can only be declared in `layout.tsx`, `index.tsx` and `plugin.tsx` inside the `src/routes` directory, instead it was declared in "{{path}}".\nPlease check the docs: https://qwik.builder.io/qwikcity/loader',missingExport:"The return of `{{fnName}}()` needs to be exported in the same module, like this\n```\nexport const {{id}} = {{fnName}}(() => { ... });\n```",wrongName:"The named export of `{{fnName}}()` needs to follow the `use*` naming convention. It must start with `use`, like this:\n```\nexport const {{fixed}} = {{fnName}}(() => { ... });\n```\nInstead it was named:\n```\nexport const {{id}} = ...\n```",recommendedValue:"For `{{fnName}}()` it is recommended to inline the arrow function. Instead of:\n```\nexport const {{id}} = {{fnName}}({{arg}});\n```\nDo this:\n```\nexport const {{id}} = {{fnName}}(() => { ...logic here... });\n```\nThis will help the optimizer make sure that no server code is leaked to the client build."}},create(e){let t=oe(e.getFilename()),n=/\/layout(|!|-.+)\.tsx?$/.test(t),r=/\/index(|!|@.+)\.tsx?$/.test(t),l=/\/src\/routes\//.test(t)&&(r||n);return{CallExpression(o){if(o.callee.type!=="Identifier")return;let s=o.callee.name;if(s!=="loader$"&&s!=="action$")return;if(!l&&s==="loader$"){e.report({node:o.callee,messageId:"invalidLoaderLocation",data:{fnName:s,path:t}});return}let c=o.parent;if(c.type!=="VariableDeclarator"){e.report({node:o.callee,messageId:"missingExport",data:{fnName:s,id:"useStuff"}});return}if(c.id.type!=="Identifier"){e.report({node:o.callee,messageId:"missingExport",data:{fnName:s,id:"useStuff"}});return}if(!/^use/.test(c.id.name)){let h="use"+c.id.name[0].toUpperCase()+c.id.name.slice(1);e.report({node:c.id,messageId:"wrongName",data:{fnName:s,id:c.id.name,fixed:h}});return}if(c.parent.parent.type!=="ExportNamedDeclaration"){e.report({node:c.id,messageId:"missingExport",data:{fnName:s,id:c.id.name}});return}if(o.arguments.length>0&&o.arguments[0].type==="Identifier"){e.report({node:o.arguments[0],messageId:"recommendedValue",data:{fnName:s,id:c.id.name,arg:o.arguments[0].name}});return}}}}};function oe(e){let t=/^\\\\\?\\/.test(e),n=/[^\u0000-\u0080]+/.test(e);return t||n||(e=e.replace(/\\/g,"/"),e.endsWith("/")&&(e=e.slice(0,e.length-1))),e}var ie={"no-use-after-await":z,"valid-lexical-scope":P,"loader-location":U},se={recommended:{plugins:["qwik"],rules:{"qwik/no-use-after-await":"error","qwik/valid-lexical-scope":"error","qwik/loader-location":"warn"}},strict:{plugins:["qwik"],rules:{"qwik/valid-lexical-scope":"error","qwik/no-use-after-await":"error","qwik/loader-location":"error"}}};0&&(module.exports={configs,rules}); |
{ | ||
"name": "eslint-plugin-qwik", | ||
"version": "0.18.1", | ||
"version": "0.19.0", | ||
"description": "An Open-Source sub-framework designed with a focus on server-side-rendering, lazy-loading, and styling/animation.", | ||
@@ -29,5 +29,6 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@types/eslint": "8.21.0", | ||
"@types/estree": "^1.0.0" | ||
"@types/eslint": "8.21.1", | ||
"@types/estree": "^1.0.0", | ||
"redent": "^4.0.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11852
51
3