eslint-plugin-qwik 2.0.0-beta.8 → 2.0.0-beta.9
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 In={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 In={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.9",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 q=require("@typescript-eslint/utils"),bb="isServer";function Cn(r,e){if(!e)return!1;let t=r.parent;for(;t;){if(t===e)return!0;t=t.parent}return!1}var Fp={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=bb,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 y=f;if(Cn(l,y.consequent)||l===y.consequent){let m=y.test;if(m.type===q.AST_NODE_TYPES.Identifier&&m.name===n||m.type===q.AST_NODE_TYPES.BinaryExpression&&m.operator==="==="&&(m.left.type===q.AST_NODE_TYPES.Identifier&&m.left.name===n&&m.right.type===q.AST_NODE_TYPES.Literal&&m.right.value===!0||m.right.type===q.AST_NODE_TYPES.Identifier&&m.right.name===n&&m.left.type===q.AST_NODE_TYPES.Literal&&m.left.value===!0)||m.type===q.AST_NODE_TYPES.UnaryExpression&&m.operator==="!"&&m.argument.type===q.AST_NODE_TYPES.UnaryExpression&&m.argument.operator==="!"&&m.argument.argument.type===q.AST_NODE_TYPES.Identifier&&m.argument.argument.name===n)return!0}}f=f.parent}return!1}function u(l){let d=o.getScope(l),f=null,y=d;for(;y;){let m=y.variables.find(v=>v.name===l.name);if(m){f=m;break}if(y.type==="global"){f=y.variables.find(v=>v.name===l.name);break}y=y.upper}return!f||f.defs.length===0?!1:f.defs.some(m=>m.type==="Variable"||m.type==="Parameter"||m.type==="FunctionName"||m.type==="ClassName"||m.type==="ImportBinding")}function c(l,d,f){function y(m){var v;if(!m)return!1;if(m.type===q.AST_NODE_TYPES.Identifier&&t.has(m.name)&&!u(m)&&!a(m,d))return r.report({node:f,messageId:"unsafeApiUsageInCalledFunction",data:{apiName:m.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 p in m){if(p==="parent"||p==="range"||p==="loc")continue;let g=m[p];if(Array.isArray(g)){for(let h of g)if(h&&typeof h=="object"&&"type"in h&&y(h))return!0}else if(g&&typeof g=="object"&&"type"in g&&y(g))return!0}return!1}y(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&&!Cn(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&&Cn(l,i.body)&&!a(l,i)&&l.callee.type===q.AST_NODE_TYPES.Identifier){let d=l.callee,f=o.getScope(d),y=null,m=f.references.find(p=>p.identifier===d);if(m&&m.resolved)y=m.resolved;else{let p=f;for(;p;){let g=p.variables.find(h=>h.name===d.name);if(g&&g.defs.length>0){y=g;break}if(p.type==="global"&&!g){let h=p.type==="global"?p.variables.find(b=>b.name===d.name):null;h&&(y=h);break}if(!p.upper)break;p=p.upper}}let v=y;if(v&&v.defs.length>0){let p=v.defs[0],g=null;if(p.node.type===q.AST_NODE_TYPES.FunctionDeclaration?g=p.node:p.node.type===q.AST_NODE_TYPES.VariableDeclarator&&p.node.init&&(p.node.init.type===q.AST_NODE_TYPES.FunctionExpression||p.node.init.type===q.AST_NODE_TYPES.ArrowFunctionExpression)&&(g=p.node.init),g){let h=(g.body.type===q.AST_NODE_TYPES.BlockStatement,g.body);c(h,g,l)}}}}}}};var Np={"valid-lexical-scope":$p,"use-method-usage":Tp,"no-react-props":xp,"loader-location":Sp,"prefer-classlist":wp,"jsx-no-script-url":hp,"jsx-key":gp,"unused-server":qp,"jsx-img":Un,"jsx-a":Vn,"no-use-visible-task":Ep,"serializer-signal-usage":Cp,"scope-use-task":Fp},Rp={"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"},jp={"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"},Sb={recommended:{plugins:["qwik"],rules:Rp},strict:{plugins:["qwik"],rules:jp}},Fn={configs:{get recommended(){return xb},get strict(){return Eb}},meta:{name:In.name,version:In.version},rules:Np},xb=[{plugins:{qwik:Fn},rules:Rp}],Eb=[{plugins:{qwik:Fn},rules:jp}];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.9",
|
|
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.
|
|
16
|
-
"@qwik.dev/router": "2.0.0-beta.
|
|
15
|
+
"@qwik.dev/core": "2.0.0-beta.9",
|
|
16
|
+
"@qwik.dev/router": "2.0.0-beta.9"
|
|
17
17
|
},
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|