eslint-plugin-qwik 0.0.19-0 → 0.0.20-7
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/eslint-plugin-qwik +1 -0
- package/package.json +3 -2
- package/index.js +0 -15
- package/lib/noUseAfterAwait.js +0 -40
- package/qwik.unit.js +0 -37
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var u=(t,e)=>{for(var o in e)a(t,o,{get:e[o],enumerable:!0})},p=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of l(e))!c.call(t,s)&&s!==o&&a(t,s,{get:()=>e[s],enumerable:!(r=i(e,s))||r.enumerable});return t};var m=t=>p(a({},"__esModule",{value:!0}),t);var d={};u(d,{configs:()=>f,rules:()=>w});module.exports=m(d);var n={meta:{type:"problem",docs:{description:"Object destructuring is not recomended 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 o=e[e.length-1];o&&(o.await=!0)},"CallExpression[callee.name=/^use/]"(o){let r=e[e.length-1];r&&r.await&&t.report({node:o,message:"Calling use* methods after await is not safe."})}}}};var w={"no-use-after-await":n},f={recommended:{plugins:["qwik"],rules:{"qwik/no-use-after-await":"error"}}};0&&(module.exports={configs,rules});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-qwik",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20-7",
|
|
4
4
|
"description": "An Open-Source sub-framework designed with a focus on server-side-rendering, lazy-loading, and styling/animation.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"homepage": "https://github.com/BuilderIO/qwik#readme",
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "https://github.com/BuilderIO/qwik.git"
|
|
14
|
+
"url": "https://github.com/BuilderIO/qwik.git",
|
|
15
|
+
"directory": "packages/eslint-rules"
|
|
15
16
|
},
|
|
16
17
|
"bugs": {
|
|
17
18
|
"url": "https://github.com/BuilderIO/qwik/issues"
|
package/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.configs = exports.rules = void 0;
|
|
4
|
-
var noUseAfterAwait_1 = require("./lib/noUseAfterAwait");
|
|
5
|
-
exports.rules = {
|
|
6
|
-
'no-use-after-await': noUseAfterAwait_1.noUseAfterAwait
|
|
7
|
-
};
|
|
8
|
-
exports.configs = {
|
|
9
|
-
recommended: {
|
|
10
|
-
plugins: ['qwik'],
|
|
11
|
-
rules: {
|
|
12
|
-
'qwik/no-use-after-await': 'error'
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
};
|
package/lib/noUseAfterAwait.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.noUseAfterAwait = void 0;
|
|
4
|
-
exports.noUseAfterAwait = {
|
|
5
|
-
meta: {
|
|
6
|
-
type: 'problem',
|
|
7
|
-
docs: {
|
|
8
|
-
description: 'Object destructuring is not recomended for component$',
|
|
9
|
-
category: 'Variables',
|
|
10
|
-
recommended: true,
|
|
11
|
-
url: 'https://github.com/BuilderIO/qwik'
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
create: function (context) {
|
|
15
|
-
var stack = [];
|
|
16
|
-
return {
|
|
17
|
-
ArrowFunctionExpression: function () {
|
|
18
|
-
stack.push({ await: false });
|
|
19
|
-
},
|
|
20
|
-
'ArrowFunctionExpression:exit': function () {
|
|
21
|
-
stack.pop();
|
|
22
|
-
},
|
|
23
|
-
AwaitExpression: function () {
|
|
24
|
-
var last = stack[stack.length - 1];
|
|
25
|
-
if (last) {
|
|
26
|
-
last.await = true;
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
'CallExpression[callee.name=/^use/]': function (node) {
|
|
30
|
-
var last = stack[stack.length - 1];
|
|
31
|
-
if (last && last.await) {
|
|
32
|
-
context.report({
|
|
33
|
-
node: node,
|
|
34
|
-
message: 'Calling use* methods after await is not safe.'
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
};
|
package/qwik.unit.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
/* eslint-disable */
|
|
4
|
-
// @ts-ignore
|
|
5
|
-
var RuleTester = require('eslint').RuleTester;
|
|
6
|
-
var index_1 = require("./index");
|
|
7
|
-
var testConfig = {
|
|
8
|
-
env: {
|
|
9
|
-
es6: true
|
|
10
|
-
},
|
|
11
|
-
parserOptions: {
|
|
12
|
-
ecmaFeatures: {
|
|
13
|
-
jsx: true
|
|
14
|
-
},
|
|
15
|
-
ecmaVersion: 2021,
|
|
16
|
-
sourceType: 'module'
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
describe('no-use-after-await', function () {
|
|
20
|
-
var ruleTester = new RuleTester(testConfig);
|
|
21
|
-
ruleTester.run('my-rule', index_1.rules['no-use-after-await'], {
|
|
22
|
-
valid: [
|
|
23
|
-
"export const HelloWorld = component$(async () => {\n useMethod();\n await something();\n return $(() => {\n return <Host></Host>\n });\n });",
|
|
24
|
-
"export const HelloWorld = component$(async () => {\n useMethod();\n await something();\n await stuff();\n return $(() => {\n useHostElement();\n return <Host></Host>\n });\n });",
|
|
25
|
-
],
|
|
26
|
-
invalid: [
|
|
27
|
-
{
|
|
28
|
-
code: "export const HelloWorld = component$(async () => {\n await something();\n useMethod();\n return $(() => {\n return (\n <Host>\n {prop}\n </Host>\n );\n });\n });",
|
|
29
|
-
errors: ['Calling use* methods after await is not safe.']
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
code: "export const HelloWorld = component$(async () => {\n if (stuff) {\n await something();\n }\n useMethod();\n return $(() => {\n return (\n <Host>\n {prop}\n </Host>\n );\n });\n });",
|
|
33
|
-
errors: ['Calling use* methods after await is not safe.']
|
|
34
|
-
},
|
|
35
|
-
]
|
|
36
|
-
});
|
|
37
|
-
});
|