@salty-css/eslint-plugin-core 0.0.1-alpha.14 → 0.0.1-alpha.15

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
@@ -5,7 +5,7 @@
5
5
  ### Initial requirements
6
6
 
7
7
  1. Add `saltyPlugin` to vite or webpack config from `@salty-css/vite` or `@salty-css/webpack`
8
- 2. Create `salty-config.ts` to the root of your project
8
+ 2. Create `salty.config.ts` to the root of your project
9
9
  3. Import global styles to any regular .css file from `saltygen/index.css` (does not exist during first run, cli command coming later)
10
10
  4. Create salty components with styled only inside files that end with `.css.ts`, `.salty.ts` `.styled.ts` or `.styles.ts`
11
11
 
package/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";require("esbuild");const x=require("winston");require("child_process");require("path");require("fs");require("fs/promises");function P(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(n,a,s.get?s:{enumerable:!0,get:()=>e[a]})}}return n.default=e,Object.freeze(n)}const i=P(x);i.createLogger({level:"info",format:i.format.combine(i.format.colorize(),i.format.cli()),transports:[new i.transports.Console({})]});const v=["salty","css","styles","styled"],E=(e=[])=>new RegExp(`\\.(${[...v,...e].join("|")})\\.`),O=(e,n=[])=>E(n).test(e),h={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(e){return O(e.filename)?{CallExpression:a=>{try{const{callee:s,arguments:p}=a;if(!(s.type==="Identifier"&&s.name==="styled"))return;const o=p[1];if(!o||!(o.type==="ObjectExpression"))return;const c=o.properties.find(t=>t.type==="Property"&&t.key.type==="Identifier"&&t.key.name==="base");if(!c)return;const{value:l}=c;if(!(l.type==="ObjectExpression"))return;const r=l.properties.find(t=>t.type==="Property"&&t.key.type==="Identifier"&&t.key.name==="variants");if(!r)return;e.report({node:r,messageId:"nestedVariants",fix:t=>{if(!r.range)return null;const{sourceCode:f}=e,m=f.getText(r),g=o.properties.indexOf(c),u=o.properties[g];if(!u.range)return null;const b=[u.range[1],u.range[1]],d=[r.range[0]-1,r.range[1]];if(l.properties.at(-1)===r){const y=f.text.slice(r.range[1]).match(/^\s*,/);y&&(d[1]+=y[0].length)}return[t.removeRange(d),t.insertTextAfterRange(b,`, ${m}`)]}})}catch(s){console.log("ESlint error",s);return}}}:{}}},j={rules:{"no-variants-in-base":h}};module.exports=j;
1
+ "use strict";require("esbuild");require("child_process");require("path");require("fs");require("fs/promises");const x=["salty","css","styles","styled"],b=(s=[])=>new RegExp(`\\.(${[...x,...s].join("|")})\\.`),P=(s,c=[])=>b(c).test(s),v={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(s){return P(s.filename)?{CallExpression:u=>{try{const{callee:n,arguments:p}=u;if(!(n.type==="Identifier"&&n.name==="styled"))return;const r=p[1];if(!r||!(r.type==="ObjectExpression"))return;const a=r.properties.find(e=>e.type==="Property"&&e.key.type==="Identifier"&&e.key.name==="base");if(!a)return;const{value:i}=a;if(!(i.type==="ObjectExpression"))return;const t=i.properties.find(e=>e.type==="Property"&&e.key.type==="Identifier"&&e.key.name==="variants");if(!t)return;s.report({node:t,messageId:"nestedVariants",fix:e=>{if(!t.range)return null;const{sourceCode:l}=s,f=l.getText(t),g=r.properties.indexOf(a),o=r.properties[g];if(!o.range)return null;const m=[o.range[1],o.range[1]],y=[t.range[0]-1,t.range[1]];if(i.properties.at(-1)===t){const d=l.text.slice(t.range[1]).match(/^\s*,/);d&&(y[1]+=d[0].length)}return[e.removeRange(y),e.insertTextAfterRange(m,`, ${f}`)]}})}catch(n){console.log("ESlint error",n);return}}}:{}}},E={rules:{"no-variants-in-base":v}};module.exports=E;
package/index.js CHANGED
@@ -1,15 +1,9 @@
1
1
  import "esbuild";
2
- import * as n from "winston";
3
2
  import "child_process";
4
3
  import "path";
5
4
  import "fs";
6
5
  import "fs/promises";
7
- n.createLogger({
8
- level: "info",
9
- format: n.format.combine(n.format.colorize(), n.format.cli()),
10
- transports: [new n.transports.Console({})]
11
- });
12
- const x = ["salty", "css", "styles", "styled"], v = (s = []) => new RegExp(`\\.(${[...x, ...s].join("|")})\\.`), P = (s, c = []) => v(c).test(s), E = {
6
+ const x = ["salty", "css", "styles", "styled"], b = (s = []) => new RegExp(`\\.(${[...x, ...s].join("|")})\\.`), P = (s, l = []) => b(l).test(s), v = {
13
7
  meta: {
14
8
  type: "problem",
15
9
  fixable: "code",
@@ -24,15 +18,15 @@ const x = ["salty", "css", "styles", "styled"], v = (s = []) => new RegExp(`\\.(
24
18
  },
25
19
  create(s) {
26
20
  return P(s.filename) ? {
27
- CallExpression: (y) => {
21
+ CallExpression: (p) => {
28
22
  try {
29
- const { callee: a, arguments: f } = y;
30
- if (!(a.type === "Identifier" && a.name === "styled")) return;
31
- const r = f[1];
23
+ const { callee: n, arguments: m } = p;
24
+ if (!(n.type === "Identifier" && n.name === "styled")) return;
25
+ const r = m[1];
32
26
  if (!r || !(r.type === "ObjectExpression")) return;
33
- const o = r.properties.find((e) => e.type === "Property" && e.key.type === "Identifier" && e.key.name === "base");
34
- if (!o) return;
35
- const { value: i } = o;
27
+ const a = r.properties.find((e) => e.type === "Property" && e.key.type === "Identifier" && e.key.name === "base");
28
+ if (!a) return;
29
+ const { value: i } = a;
36
30
  if (!(i.type === "ObjectExpression")) return;
37
31
  const t = i.properties.find(
38
32
  (e) => e.type === "Property" && e.key.type === "Identifier" && e.key.name === "variants"
@@ -43,32 +37,32 @@ const x = ["salty", "css", "styles", "styled"], v = (s = []) => new RegExp(`\\.(
43
37
  messageId: "nestedVariants",
44
38
  fix: (e) => {
45
39
  if (!t.range) return null;
46
- const { sourceCode: m } = s, g = m.getText(t), u = r.properties.indexOf(o), l = r.properties[u];
47
- if (!l.range) return null;
48
- const b = [l.range[1], l.range[1]], p = [
40
+ const { sourceCode: c } = s, f = c.getText(t), u = r.properties.indexOf(a), o = r.properties[u];
41
+ if (!o.range) return null;
42
+ const g = [o.range[1], o.range[1]], d = [
49
43
  t.range[0] - 1,
50
44
  // Include the preceding comma (if any)
51
45
  t.range[1]
52
46
  ];
53
47
  if (i.properties.at(-1) === t) {
54
- const d = m.text.slice(t.range[1]).match(/^\s*,/);
55
- d && (p[1] += d[0].length);
48
+ const y = c.text.slice(t.range[1]).match(/^\s*,/);
49
+ y && (d[1] += y[0].length);
56
50
  }
57
- return [e.removeRange(p), e.insertTextAfterRange(b, `, ${g}`)];
51
+ return [e.removeRange(d), e.insertTextAfterRange(g, `, ${f}`)];
58
52
  }
59
53
  });
60
- } catch (a) {
61
- console.log("ESlint error", a);
54
+ } catch (n) {
55
+ console.log("ESlint error", n);
62
56
  return;
63
57
  }
64
58
  }
65
59
  } : {};
66
60
  }
67
- }, T = {
61
+ }, j = {
68
62
  rules: {
69
- "no-variants-in-base": E
63
+ "no-variants-in-base": v
70
64
  }
71
65
  };
72
66
  export {
73
- T as default
67
+ j as default
74
68
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/eslint-plugin-core",
3
- "version": "0.0.1-alpha.14",
3
+ "version": "0.0.1-alpha.15",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",