eslint-plugin-qwik 2.0.0-beta.4 → 2.0.0-beta.6
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 +2 -2
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -291,7 +291,7 @@ export const useCounter = () => {
|
|
|
291
291
|
export const Counter = (() => {
|
|
292
292
|
const count = useSignal(0);
|
|
293
293
|
});
|
|
294
|
-
`.trim();var fr=ee(require("@typescript-eslint/utils/eslint-utils")),G=ee(require("typescript"));var kl=ee($l(),1);function bn(r){let e=(0,kl.default)(r);if(e===0)return r;let t=new RegExp(`^[ \\t]{${e}}`,"gm");return r.replace(t,"")}function Sn(r,e=1,t={}){let{indent:n=" ",includeEmptyLines:o=!1}=t;if(typeof r!="string")throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof r}\``);if(typeof e!="number")throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof e}\``);if(e<0)throw new RangeError(`Expected \`count\` to be at least 0, got \`${e}\``);if(typeof n!="string")throw new TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof n}\``);if(e===0)return r;let i=o?/^/gm:/^(?!\s*$)/gm;return r.replace(i,n.repeat(e))}function xn(r,e=0,t={}){return Sn(bn(r),e,t)}var Uv=fr.RuleCreator(r=>`https://qwik.dev/docs/advanced/eslint/#${r}`),Cl=Uv({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:"recommended"},schema:[{type:"object",properties:{allowAny:{type:"boolean"}},default:{allowAny:!0}}],messages:{referencesOutside:`When referencing "{{varName}}" inside a different scope ({{dollarName}}), Qwik needs to serialize the value, however {{reason}}.
|
|
294
|
+
`.trim();var fr=ee(require("@typescript-eslint/utils/eslint-utils")),G=ee(require("typescript"));var kl=ee($l(),1);function bn(r){let e=(0,kl.default)(r);if(e===0)return r;let t=new RegExp(`^[ \\t]{${e}}`,"gm");return r.replace(t,"")}function Sn(r,e=1,t={}){let{indent:n=" ",includeEmptyLines:o=!1}=t;if(typeof r!="string")throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof r}\``);if(typeof e!="number")throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof e}\``);if(e<0)throw new RangeError(`Expected \`count\` to be at least 0, got \`${e}\``);if(typeof n!="string")throw new TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof n}\``);if(e===0)return r;let i=o?/^/gm:/^(?!\s*$)/gm;return r.replace(i,n.repeat(e))}function xn(r,e=0,t={}){return Sn(bn(r),e,t)}var Uv=fr.RuleCreator(r=>`https://qwik.dev/docs/advanced/eslint/#${r}`),Cl=Uv({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:"recommended"},schema:[{type:"object",properties:{allowAny:{type:"boolean"}},additionalProperties:!1,default:{allowAny:!0}}],messages:{referencesOutside:`When referencing "{{varName}}" inside a different scope ({{dollarName}}), Qwik needs to serialize the value, however {{reason}}.
|
|
295
295
|
Check out https://qwik.dev/docs/advanced/dollar/ for more details.`,invalidJsxDollar:`Using "{{varName}}" as an event handler, however functions are not serializable.
|
|
296
296
|
Did you mean to wrap it in \`$()\`?
|
|
297
297
|
|
|
@@ -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.6",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.6",
|
|
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/
|
|
16
|
-
"@qwik.dev/
|
|
15
|
+
"@qwik.dev/core": "2.0.0-beta.6",
|
|
16
|
+
"@qwik.dev/router": "2.0.0-beta.6"
|
|
17
17
|
},
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|