@salty-css/eslint-plugin-core 0.0.1-alpha.253 → 0.0.1-alpha.255

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/README.md CHANGED
@@ -242,7 +242,7 @@ Example usage:
242
242
  styled('span', {
243
243
  base: {
244
244
  // Use of static font family variable
245
- fontFamily: '{colors.fontFamily.heading}',
245
+ fontFamily: '{fontFamily.heading}',
246
246
  // Use of responsive font size variable
247
247
  fontSize: '{fontSize.heading.regular}',
248
248
  // Use of conditional theme text color variable
package/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";require("esbuild");require("child_process");require("path");require("fs");require("fs/promises");const o=require("winston");require("typescript");o.createLogger({level:"debug",format:o.format.combine(o.format.colorize(),o.format.cli()),transports:[new o.transports.Console({})]});const F=["salty","css","styles","styled"],S=(r=[])=>new RegExp(`\\.(${[...F,...r].join("|")})\\.`),x=(r,c=[])=>S(c).test(r),E={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(r){return x(r.filename)?{CallExpression:l=>{try{const{callee:a,arguments:u}=l;if(!(a.type==="Identifier"&&a.name==="styled"))return;const t=u[1];if(!t||!(t.type==="ObjectExpression"))return;const i=t.properties.find(n=>n.type==="Property"&&n.key.type==="Identifier"&&n.key.name==="base");if(!i)return;const{value:y}=i;if(!(y.type==="ObjectExpression"))return;const s=y.properties.find(n=>n.type==="Property"&&n.key.type==="Identifier"&&n.key.name==="variants");if(!s)return;r.report({node:s,messageId:"nestedVariants",fix:n=>{if(!s.range)return null;const{sourceCode:m}=r,b=m.getText(s),I=t.properties.indexOf(i),p=t.properties[I];if(!p.range)return null;const v=[p.range[1],p.range[1]],d=[s.range[0]-1,s.range[1]];if(y.properties.at(-1)===s){const g=m.text.slice(s.range[1]).match(/^\s*,/);g&&(d[1]+=g[0].length)}return[n.removeRange(d),n.insertTextAfterRange(v,`, ${b}`)]}})}catch(a){console.log("ESlint error",a);return}}}:{}}},P={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(r){if(!x(r.filename))return{};function l(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 f=/^define[A-Z]/;return!!(e.callee.type==="Identifier"&&f.test(e.callee.name))}function a(e){if(e.type==="VariableDeclaration"){const t=e.declarations[0];return t.type!=="VariableDeclarator"?void 0:l(t.init)}return!1}function u(e){const t=e.parent;return t.type==="ExportNamedDeclaration"||t.type==="ExportDefaultDeclaration"}return{VariableDeclaration:e=>{a(e)&&(u(e)||r.report({node:e,messageId:"mustBeExported",fix:t=>t.insertTextBefore(e,"export ")}))},ExpressionStatement(e){e.type!=="ExpressionStatement"||!l(e.expression)||!(e.parent.type==="Program")||r.report({node:e,messageId:"mustBeExported",fix:i=>i.insertTextBefore(e,"export default ")})}}}},h={rules:{"no-variants-in-base":E,"must-be-exported":P}};module.exports=h;
1
+ "use strict";require("esbuild");require("child_process");require("path");require("fs");require("fs/promises");const o=require("winston");require("typescript");o.createLogger({level:"debug",format:o.format.combine(o.format.colorize(),o.format.cli()),transports:[new o.transports.Console({})]});const F=["salty","css","styles","styled"],S=(r=[])=>new RegExp(`\\.(${[...F,...r].join("|")})\\.`),x=(r,c=[])=>S(c).test(r),E={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(r){return x(r.filename)?{CallExpression:l=>{try{const{callee:a,arguments:u}=l;if(!(a.type==="Identifier"&&a.name==="styled"))return;const t=u[1];if(!t||!(t.type==="ObjectExpression"))return;const i=t.properties.find(s=>s.type==="Property"&&s.key.type==="Identifier"&&s.key.name==="base");if(!i)return;const{value:y}=i;if(!(y.type==="ObjectExpression"))return;const n=y.properties.find(s=>s.type==="Property"&&s.key.type==="Identifier"&&s.key.name==="variants");if(!n)return;r.report({node:n,messageId:"nestedVariants",fix:s=>{if(!n.range)return null;const{sourceCode:m}=r,b=m.getText(n),v=t.properties.indexOf(i),p=t.properties[v];if(!p.range)return null;const I=[p.range[1],p.range[1]],d=[n.range[0]-1,n.range[1]];if(y.properties.at(-1)===n){const g=m.text.slice(n.range[1]).match(/^\s*,/);g&&(d[1]+=g[0].length)}return[s.removeRange(d),s.insertTextAfterRange(I,`, ${b}`)]}})}catch(a){console.log("ESlint error",a);return}}}:{}}},P={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(r){if(!x(r.filename))return{};function l(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 f=/^define[A-Z]/;return!!(e.callee.type==="Identifier"&&f.test(e.callee.name))}function a(e){if(e.type==="VariableDeclaration"){const t=e.declarations[0];return t.type!=="VariableDeclarator"?void 0:l(t.init)}return!1}function u(e){const t=e.parent;return t.type==="ExportNamedDeclaration"||t.type==="ExportDefaultDeclaration"}return{VariableDeclaration:e=>{a(e)&&(u(e)||r.report({node:e,messageId:"mustBeExported",fix:t=>t.insertTextBefore(e,"export ")}))},ExpressionStatement(e){e.type!=="ExpressionStatement"||!l(e.expression)||!(e.parent.type==="Program")||r.report({node:e,messageId:"mustBeExported",fix:i=>i.insertTextBefore(e,"export default ")})}}}},h={rules:{"no-variants-in-base":E,"must-be-exported":P}};module.exports=h;
package/index.js CHANGED
@@ -3,7 +3,7 @@ import "child_process";
3
3
  import "path";
4
4
  import "fs";
5
5
  import "fs/promises";
6
- import { createLogger as F, format as m, transports as S } from "winston";
6
+ import { createLogger as F, transports as S, format as m } from "winston";
7
7
  import "typescript";
8
8
  F({
9
9
  level: "debug",
@@ -44,9 +44,9 @@ const E = ["salty", "css", "styles", "styled"], P = (r = []) => new RegExp(`\\.(
44
44
  messageId: "nestedVariants",
45
45
  fix: (n) => {
46
46
  if (!s.range) return null;
47
- const { sourceCode: y } = r, b = y.getText(s), I = t.properties.indexOf(i), p = t.properties[I];
47
+ const { sourceCode: y } = r, b = y.getText(s), v = t.properties.indexOf(i), p = t.properties[v];
48
48
  if (!p.range) return null;
49
- const v = [p.range[1], p.range[1]], d = [
49
+ const I = [p.range[1], p.range[1]], d = [
50
50
  s.range[0] - 1,
51
51
  // Include the preceding comma (if any)
52
52
  s.range[1]
@@ -55,7 +55,7 @@ const E = ["salty", "css", "styles", "styled"], P = (r = []) => new RegExp(`\\.(
55
55
  const g = y.text.slice(s.range[1]).match(/^\s*,/);
56
56
  g && (d[1] += g[0].length);
57
57
  }
58
- return [n.removeRange(d), n.insertTextAfterRange(v, `, ${b}`)];
58
+ return [n.removeRange(d), n.insertTextAfterRange(I, `, ${b}`)];
59
59
  }
60
60
  });
61
61
  } catch (a) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/eslint-plugin-core",
3
- "version": "0.0.1-alpha.253",
3
+ "version": "0.0.1-alpha.255",
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.253",
37
+ "@salty-css/core": "^0.0.1-alpha.255",
38
38
  "eslint": ">=9.x || >=8.x || >=7.x"
39
39
  }
40
40
  }