@salty-css/eslint-plugin-core 0.0.1-alpha.285 → 0.0.1-alpha.287
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.cjs +1 -1
- package/index.js +9 -9
- package/package.json +2 -2
package/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";const
|
1
|
+
"use strict";const d=require("@salty-css/core/compiler"),S={meta:{type:"problem",fixable:"code",docs:{description:"Ensure `variants` are not nested inside `base` in styled calls",category:"Errors",recommended:!0},messages:{nestedVariants:"`variants` should not be nested inside `base`."}},create(a){return d.isSaltyFile(a.filename)?{CallExpression:o=>{try{const{callee:s,arguments:l}=o;if(!(s.type==="Identifier"&&s.name==="styled"))return;const t=l[1];if(!t||!(t.type==="ObjectExpression"))return;const i=t.properties.find(r=>r.type==="Property"&&r.key.type==="Identifier"&&r.key.name==="base");if(!i)return;const{value:u}=i;if(!(u.type==="ObjectExpression"))return;const n=u.properties.find(r=>r.type==="Property"&&r.key.type==="Identifier"&&r.key.name==="variants");if(!n)return;a.report({node:n,messageId:"nestedVariants",fix:r=>{if(!n.range)return null;const{sourceCode:p}=a,b=p.getText(n),x=t.properties.indexOf(i),f=t.properties[x];if(!f.range)return null;const I=[f.range[1],f.range[1]],y=[n.range[0]-1,n.range[1]];if(u.properties.at(-1)===n){const m=p.text.slice(n.range[1]).match(/^\s*,/);m&&(y[1]+=m[0].length)}return[r.removeRange(y),r.insertTextAfterRange(I,`, ${b}`)]}})}catch(s){console.log("ESlint error",s);return}}}:{}}},v={meta:{type:"problem",fixable:"code",docs:{description:"Salty CSS related function calls or other values must be exported",category:"Errors",recommended:!0},messages:{mustBeExported:"ipsum"}},create(a){if(!d.isSaltyFile(a.filename))return{};function o(e){if(!e)return!1;if((e==null?void 0:e.type)!=="CallExpression")return;const t=["styled","keyframes","className"];if(e.callee.type==="Identifier"&&t.includes(e.callee.name))return!0;const c=/^define[A-Z]/;return!!(e.callee.type==="Identifier"&&c.test(e.callee.name))}function s(e){if(e.type==="VariableDeclaration"){const t=e.declarations[0];return t.type!=="VariableDeclarator"?void 0:o(t.init)}return!1}function l(e){const t=e.parent;return t.type==="ExportNamedDeclaration"||t.type==="ExportDefaultDeclaration"}return{VariableDeclaration:e=>{s(e)&&(l(e)||a.report({node:e,messageId:"mustBeExported",fix:t=>t.insertTextBefore(e,"export ")}))},ExpressionStatement(e){e.type!=="ExpressionStatement"||!o(e.expression)||!(e.parent.type==="Program")||a.report({node:e,messageId:"mustBeExported",fix:i=>i.insertTextBefore(e,"export default ")})}}}},F={rules:{"no-variants-in-base":S,"must-be-exported":v}};module.exports=F;
|
package/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { isSaltyFile as
|
2
|
-
const
|
1
|
+
import { isSaltyFile as d } from "@salty-css/core/compiler";
|
2
|
+
const v = {
|
3
3
|
meta: {
|
4
4
|
type: "problem",
|
5
5
|
fixable: "code",
|
@@ -13,7 +13,7 @@ const S = {
|
|
13
13
|
}
|
14
14
|
},
|
15
15
|
create(a) {
|
16
|
-
return
|
16
|
+
return d(a.filename) ? {
|
17
17
|
CallExpression: (o) => {
|
18
18
|
try {
|
19
19
|
const { callee: s, arguments: l } = o;
|
@@ -41,8 +41,8 @@ const S = {
|
|
41
41
|
n.range[1]
|
42
42
|
];
|
43
43
|
if (u.properties.at(-1) === n) {
|
44
|
-
const
|
45
|
-
|
44
|
+
const m = p.text.slice(n.range[1]).match(/^\s*,/);
|
45
|
+
m && (y[1] += m[0].length);
|
46
46
|
}
|
47
47
|
return [r.removeRange(y), r.insertTextAfterRange(I, `, ${b}`)];
|
48
48
|
}
|
@@ -54,7 +54,7 @@ const S = {
|
|
54
54
|
}
|
55
55
|
} : {};
|
56
56
|
}
|
57
|
-
},
|
57
|
+
}, S = {
|
58
58
|
meta: {
|
59
59
|
type: "problem",
|
60
60
|
fixable: "code",
|
@@ -68,7 +68,7 @@ const S = {
|
|
68
68
|
}
|
69
69
|
},
|
70
70
|
create(a) {
|
71
|
-
if (!
|
71
|
+
if (!d(a.filename)) return {};
|
72
72
|
function o(e) {
|
73
73
|
if (!e) return !1;
|
74
74
|
if ((e == null ? void 0 : e.type) !== "CallExpression") return;
|
@@ -107,8 +107,8 @@ const S = {
|
|
107
107
|
}
|
108
108
|
}, V = {
|
109
109
|
rules: {
|
110
|
-
"no-variants-in-base":
|
111
|
-
"must-be-exported":
|
110
|
+
"no-variants-in-base": v,
|
111
|
+
"must-be-exported": S
|
112
112
|
}
|
113
113
|
};
|
114
114
|
export {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@salty-css/eslint-plugin-core",
|
3
|
-
"version": "0.0.1-alpha.
|
3
|
+
"version": "0.0.1-alpha.287",
|
4
4
|
"main": "./dist/index.js",
|
5
5
|
"module": "./dist/index.mjs",
|
6
6
|
"typings": "./dist/index.d.ts",
|
@@ -34,7 +34,7 @@
|
|
34
34
|
}
|
35
35
|
},
|
36
36
|
"dependencies": {
|
37
|
-
"@salty-css/core": "^0.0.1-alpha.
|
37
|
+
"@salty-css/core": "^0.0.1-alpha.287",
|
38
38
|
"eslint": ">=9.x || >=8.x || >=7.x"
|
39
39
|
}
|
40
40
|
}
|