eslint-plugin-qwik 2.0.0-beta.4 → 2.0.0-beta.5
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
|
@@ -407,4 +407,4 @@ export default component$(() => {
|
|
|
407
407
|
}));
|
|
408
408
|
|
|
409
409
|
return <div>{myClass.count}</div>;
|
|
410
|
-
});`.trim();var En={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.
|
|
410
|
+
});`.trim();var En={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.5",author:"Qwik Team",bugs:"https://github.com/QwikDev/qwik/issues",dependencies:{"@typescript-eslint/utils":"^8.31.0","jsx-ast-utils":"^3.3.5"},devDependencies:{"@qwik.dev/core":"workspace:*","@qwik.dev/router":"workspace:*","@types/estree":"1.0.5","@typescript-eslint/rule-tester":"8.14.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 q=require("@typescript-eslint/utils"),Yv="isServer";function wn(r,e){if(!e)return!1;let t=r.parent;for(;t;){if(t===e)return!0;t=t.parent}return!1}var Rl={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=Yv,o=r.sourceCode,i=null;function a(l,d){let f=l.parent;for(;f&&f!==d.body&&f!==d;){if(f.type===q.AST_NODE_TYPES.IfStatement){let m=f;if(wn(l,m.consequent)||l===m.consequent){let y=m.test;if(y.type===q.AST_NODE_TYPES.Identifier&&y.name===n||y.type===q.AST_NODE_TYPES.BinaryExpression&&y.operator==="==="&&(y.left.type===q.AST_NODE_TYPES.Identifier&&y.left.name===n&&y.right.type===q.AST_NODE_TYPES.Literal&&y.right.value===!0||y.right.type===q.AST_NODE_TYPES.Identifier&&y.right.name===n&&y.left.type===q.AST_NODE_TYPES.Literal&&y.left.value===!0)||y.type===q.AST_NODE_TYPES.UnaryExpression&&y.operator==="!"&&y.argument.type===q.AST_NODE_TYPES.UnaryExpression&&y.argument.operator==="!"&&y.argument.argument.type===q.AST_NODE_TYPES.Identifier&&y.argument.argument.name===n)return!0}}f=f.parent}return!1}function u(l){let d=o.getScope(l),f=null,m=d;for(;m;){let y=m.variables.find(v=>v.name===l.name);if(y){f=y;break}if(m.type==="global"){f=m.variables.find(v=>v.name===l.name);break}m=m.upper}return!f||f.defs.length===0?!1:f.defs.some(y=>y.type==="Variable"||y.type==="Parameter"||y.type==="FunctionName"||y.type==="ClassName"||y.type==="ImportBinding")}function p(l,d,f){function m(y){var v;if(!y)return!1;if(y.type===q.AST_NODE_TYPES.Identifier&&t.has(y.name)&&!u(y)&&!a(y,d))return r.report({node:f,messageId:"unsafeApiUsageInCalledFunction",data:{apiName:y.name,calledFunctionName:((v=d.id)==null?void 0:v.name)||(f.type===q.AST_NODE_TYPES.Identifier?f.name:"[anonymous]"),guardName:n}}),!0;for(let c in y){if(c==="parent"||c==="range"||c==="loc")continue;let g=y[c];if(Array.isArray(g)){for(let h of g)if(h&&typeof h=="object"&&"type"in h&&m(h))return!0}else if(g&&typeof g=="object"&&"type"in g&&m(g))return!0}return!1}m(l)}return{":function"(l){let d=l.parent;d&&d.type===q.AST_NODE_TYPES.CallExpression&&d.callee.type===q.AST_NODE_TYPES.Identifier&&d.callee.name==="useTask$"&&d.arguments.length>0&&d.arguments[0]===l&&(i=l)},":function:exit"(l){i===l&&(i=null)},Identifier(l){if(i&&!(i.body!==l&&!wn(l,i.body))&&!(l.parent&&l.parent.type===q.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&&wn(l,i.body)&&!a(l,i)&&l.callee.type===q.AST_NODE_TYPES.Identifier){let d=l.callee,f=o.getScope(d),m=null,y=f.references.find(c=>c.identifier===d);if(y&&y.resolved)m=y.resolved;else{let c=f;for(;c;){let g=c.variables.find(h=>h.name===d.name);if(g&&g.defs.length>0){m=g;break}if(c.type==="global"&&!g){let h=c.type==="global"?c.variables.find(b=>b.name===d.name):null;h&&(m=h);break}if(!c.upper)break;c=c.upper}}let v=m;if(v&&v.defs.length>0){let c=v.defs[0],g=null;if(c.node.type===q.AST_NODE_TYPES.FunctionDeclaration?g=c.node:c.node.type===q.AST_NODE_TYPES.VariableDeclarator&&c.node.init&&(c.node.init.type===q.AST_NODE_TYPES.FunctionExpression||c.node.init.type===q.AST_NODE_TYPES.ArrowFunctionExpression)&&(g=c.node.init),g){let h=(g.body.type===q.AST_NODE_TYPES.BlockStatement,g.body);p(h,g,l)}}}}}}};var Ml={"valid-lexical-scope":Cl,"use-method-usage":Il,"no-react-props":ql,"loader-location":wl,"prefer-classlist":Al,"jsx-no-script-url":xl,"jsx-key":bl,"unused-server":Pl,"jsx-img":Cn,"jsx-a":$n,"no-use-visible-task":Tl,"serializer-signal-usage":jl,"scope-use-task":Rl},Ll={"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"},Ul={"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"},Zv={recommended:{plugins:["qwik"],rules:Ll},strict:{plugins:["qwik"],rules:Ul}},qn={configs:{get recommended(){return eh},get strict(){return rh}},meta:{name:En.name,version:En.version},rules:Ml},eh=[{plugins:{qwik:qn},rules:Ll}],rh=[{plugins:{qwik:qn},rules:Ul}];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.5",
|
|
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.5",
|
|
13
13
|
"@typescript-eslint/rule-tester": "8.14.0",
|
|
14
14
|
"redent": "4.0.0",
|
|
15
|
-
"@qwik.dev/router": "2.0.0-beta.
|
|
16
|
-
"@qwik.dev/core": "2.0.0-beta.
|
|
15
|
+
"@qwik.dev/router": "2.0.0-beta.5",
|
|
16
|
+
"@qwik.dev/core": "2.0.0-beta.5"
|
|
17
17
|
},
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|