eslint-plugin-qwik 1.3.1 → 1.3.2
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/index.js +9 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -152,7 +152,15 @@ export const ColorList = component$(() => {
|
|
|
152
152
|
);
|
|
153
153
|
});`.trim();var al=require("@typescript-eslint/utils");var{getStaticValue:uv}=al.ASTUtils,lv=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i,sl={meta:{type:"problem",docs:{recommended:"error",description:"Disallow javascript: URLs.",url:"https://qwik.builder.io/docs/advanced/eslint/#jsx-no-script-url"},schema:[],messages:{noJSURL:"For security, don't use javascript: URLs. Use event handlers instead if you can."}},create(r){return{JSXAttribute(e){if(e.name.type==="JSXIdentifier"&&e.value){let t=uv(e.value.type==="JSXExpressionContainer"?e.value.expression:e.value,r.getScope());t&&typeof t.value=="string"&&lv.test(t.value)&&r.report({node:e.value,messageId:"noJSURL"})}}}}},yx=`
|
|
154
154
|
<button onClick$={() => alert('open the door please')>ring</button>`.trim(),mx=`
|
|
155
|
-
<button onClick$="javascript:alert('open the door please')">ring</button>`.trim();var ul={loader$:!0,routeLoader$:!0,routeAction$:!0,routeHandler$:!0},pv={...ul,action$:!0,globalAction$:!0},ll={meta:{type:"problem",docs:{description:"Detect declaration location of loader$.",recommended:!0,url:"https://qwik.builder.io/docs/advanced/eslint/#loader-location"},schema:[{type:"object",properties:{routesDir:{type:"string",default:"src/routes"}},additionalProperties:!1}],messages:{invalidLoaderLocation
|
|
155
|
+
<button onClick$="javascript:alert('open the door please')">ring</button>`.trim();var ul={loader$:!0,routeLoader$:!0,routeAction$:!0,routeHandler$:!0},pv={...ul,action$:!0,globalAction$:!0},ll={meta:{type:"problem",docs:{description:"Detect declaration location of loader$.",recommended:!0,url:"https://qwik.builder.io/docs/advanced/eslint/#loader-location"},schema:[{type:"object",properties:{routesDir:{type:"string",default:"src/routes"}},additionalProperties:!1}],messages:{invalidLoaderLocation:`'{{fnName}}() are typically declared in route boundary files such as layout.tsx, index.tsx and plugin.tsx inside the {{routesDir}} directory
|
|
156
|
+
(docs: https://qwik.builder.io/docs/route-loader/).
|
|
157
|
+
|
|
158
|
+
This {{fnName}}() is declared outside of the route boundaries. This may be useful when you want to create reusable logic or a library. In such a case, it is essential that this function is re-exported from within the router boundary otherwise it will not run.
|
|
159
|
+
(docs: https://qwik.builder.io/docs/cookbook/re-exporting-loaders/).
|
|
160
|
+
|
|
161
|
+
If you understand this, you can disable this warning with:
|
|
162
|
+
// eslint-disable-next-line qwik/loader-location
|
|
163
|
+
`,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(r){var c,y;let e=((y=(c=r.options)==null?void 0:c[0])==null?void 0:y.routesDir)??"src/routes",t=cv(r.getFilename()),n=/\/layout(|!|-.+)\.tsx?$/.test(t),o=/\/index(|!|@.+)\.tsx?$/.test(t),i=/\/plugin(|@.+)\.tsx?$/.test(t),u=new RegExp(`/${e}/`).test(t)&&(o||n||i);return{CallExpression(m){if(m.callee.type!=="Identifier")return;let f=m.callee.name;if(!pv[f])return;if(!u&&ul[f]){r.report({node:m.callee,messageId:"invalidLoaderLocation",data:{routesDir:e,fnName:f,path:t}});return}let p=m.parent;if(p.type!=="VariableDeclarator"){r.report({node:m.callee,messageId:"missingExport",data:{fnName:f,id:"useStuff"}});return}if(p.id.type!=="Identifier"){r.report({node:m.callee,messageId:"missingExport",data:{fnName:f,id:"useStuff"}});return}if(!/^use/.test(p.id.name)){let g="use"+p.id.name[0].toUpperCase()+p.id.name.slice(1);r.report({node:p.id,messageId:"wrongName",data:{fnName:f,id:p.id.name,fixed:g}});return}if(!fv(p)){r.report({node:p.id,messageId:"missingExport",data:{fnName:f,id:p.id.name}});return}if(m.arguments.length>0&&m.arguments[0].type==="Identifier"){r.report({node:m.arguments[0],messageId:"recommendedValue",data:{fnName:f,id:p.id.name,arg:m.arguments[0].name}});return}}}}};function cv(r){let e=/^\\\\\?\\/.test(r),t=/[^\u0000-\u0080]+/.test(r);return e||t||(r=r.replace(/\\/g,"/"),r.endsWith("/")&&(r=r.slice(0,r.length-1))),r}var bx=`
|
|
156
164
|
import { routeLoader$ } from '@builder.io/qwik-city';
|
|
157
165
|
|
|
158
166
|
export const useProductDetails = routeLoader$(async (requestEvent) => {
|
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": "1.3.
|
|
4
|
+
"version": "1.3.2",
|
|
5
5
|
"author": "Builder Team",
|
|
6
6
|
"bugs": "https://github.com/BuilderIO/qwik/issues",
|
|
7
7
|
"dependencies": {
|