@salty-css/eslint-plugin-core 0.0.1-alpha.75 → 0.0.1-alpha.76

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 CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("esbuild");require("child_process");require("path");require("fs");require("fs/promises");const x=["salty","css","styles","styled"],P=(r=[])=>new RegExp(`\\.(${[...x,...r].join("|")})\\.`),v=(r,l=[])=>P(l).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 v(r.filename)?{CallExpression:g=>{try{const{callee:n,arguments:f}=g;if(!(n.type==="Identifier"&&n.name==="styled"))return;const s=f[1];if(!s||!(s.type==="ObjectExpression"))return;const a=s.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;r.report({node:t,messageId:"nestedVariants",fix:e=>{if(!t.range)return null;const{sourceCode:c}=r,p=c.getText(t),m=s.properties.indexOf(a),o=s.properties[m];if(!o.range)return null;const b=[o.range[1],o.range[1]],u=[t.range[0]-1,t.range[1]];if(i.properties.at(-1)===t){const d=c.text.slice(t.range[1]).match(/^\s*,/);d&&(u[1]+=d[0].length)}return[e.removeRange(u),e.insertTextAfterRange(b,`, ${p}`)]}})}catch(n){console.log("ESlint error",n);return}}}:{}}},y={rules:{"no-variants-in-base":E},configs:{recommended:{rules:{"core/no-variants-in-base":"error"}}}};exports.default=y;exports.eslintPluginCore=y;
1
+ "use strict";require("esbuild");require("child_process");require("path");require("fs");require("fs/promises");const x=["salty","css","styles","styled"],P=(t=[])=>new RegExp(`\\.(${[...x,...t].join("|")})\\.`),v=(t,l=[])=>P(l).test(t),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(t){return v(t.filename)?{CallExpression:g=>{try{const{callee:n,arguments:p}=g;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 s=i.properties.find(e=>e.type==="Property"&&e.key.type==="Identifier"&&e.key.name==="variants");if(!s)return;t.report({node:s,messageId:"nestedVariants",fix:e=>{if(!s.range)return null;const{sourceCode:d}=t,f=d.getText(s),m=r.properties.indexOf(a),o=r.properties[m];if(!o.range)return null;const b=[o.range[1],o.range[1]],y=[s.range[0]-1,s.range[1]];if(i.properties.at(-1)===s){const u=d.text.slice(s.range[1]).match(/^\s*,/);u&&(y[1]+=u[0].length)}return[e.removeRange(y),e.insertTextAfterRange(b,`, ${f}`)]}})}catch(n){console.log("ESlint error",n);return}}}:{}}},c={configs:{},rules:{"no-variants-in-base":E}};Object.assign(c.configs,{recommended:{plugins:{core:c},rules:{"core/no-variants-in-base":"error"}}});module.exports=c;
package/index.d.ts CHANGED
@@ -1,3 +1,7 @@
1
- import { ESLint } from 'eslint';
2
- export declare const eslintPluginCore: ESLint.Plugin;
1
+ declare const eslintPluginCore: {
2
+ configs: {};
3
+ rules: {
4
+ 'no-variants-in-base': import("eslint").Rule.RuleModule;
5
+ };
6
+ };
3
7
  export default eslintPluginCore;
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
- const b = ["salty", "css", "styles", "styled"], x = (s = []) => new RegExp(`\\.(${[...b, ...s].join("|")})\\.`), P = (s, l = []) => x(l).test(s), v = {
6
+ const x = ["salty", "css", "styles", "styled"], P = (s = []) => new RegExp(`\\.(${[...x, ...s].join("|")})\\.`), v = (s, c = []) => P(c).test(s), E = {
7
7
  meta: {
8
8
  type: "problem",
9
9
  fixable: "code",
@@ -17,12 +17,12 @@ const b = ["salty", "css", "styles", "styled"], x = (s = []) => new RegExp(`\\.(
17
17
  }
18
18
  },
19
19
  create(s) {
20
- return P(s.filename) ? {
21
- CallExpression: (p) => {
20
+ return v(s.filename) ? {
21
+ CallExpression: (m) => {
22
22
  try {
23
- const { callee: n, arguments: m } = p;
23
+ const { callee: n, arguments: g } = m;
24
24
  if (!(n.type === "Identifier" && n.name === "styled")) return;
25
- const r = m[1];
25
+ const r = g[1];
26
26
  if (!r || !(r.type === "ObjectExpression")) return;
27
27
  const a = r.properties.find((e) => e.type === "Property" && e.key.type === "Identifier" && e.key.name === "base");
28
28
  if (!a) return;
@@ -37,18 +37,18 @@ const b = ["salty", "css", "styles", "styled"], x = (s = []) => new RegExp(`\\.(
37
37
  messageId: "nestedVariants",
38
38
  fix: (e) => {
39
39
  if (!t.range) return null;
40
- const { sourceCode: c } = s, f = c.getText(t), u = r.properties.indexOf(a), o = r.properties[u];
40
+ const { sourceCode: l } = s, f = l.getText(t), u = r.properties.indexOf(a), o = r.properties[u];
41
41
  if (!o.range) return null;
42
- const g = [o.range[1], o.range[1]], d = [
42
+ const b = [o.range[1], o.range[1]], d = [
43
43
  t.range[0] - 1,
44
44
  // Include the preceding comma (if any)
45
45
  t.range[1]
46
46
  ];
47
47
  if (i.properties.at(-1) === t) {
48
- const y = c.text.slice(t.range[1]).match(/^\s*,/);
48
+ const y = l.text.slice(t.range[1]).match(/^\s*,/);
49
49
  y && (d[1] += y[0].length);
50
50
  }
51
- return [e.removeRange(d), e.insertTextAfterRange(g, `, ${f}`)];
51
+ return [e.removeRange(d), e.insertTextAfterRange(b, `, ${f}`)];
52
52
  }
53
53
  });
54
54
  } catch (n) {
@@ -58,19 +58,22 @@ const b = ["salty", "css", "styles", "styled"], x = (s = []) => new RegExp(`\\.(
58
58
  }
59
59
  } : {};
60
60
  }
61
- }, T = {
61
+ }, p = {
62
+ configs: {},
62
63
  rules: {
63
- "no-variants-in-base": v
64
- },
65
- configs: {
66
- recommended: {
67
- rules: {
68
- "core/no-variants-in-base": "error"
69
- }
70
- }
64
+ "no-variants-in-base": E
71
65
  }
72
66
  };
67
+ Object.assign(p.configs, {
68
+ recommended: {
69
+ plugins: {
70
+ core: p
71
+ },
72
+ rules: {
73
+ "core/no-variants-in-base": "error"
74
+ }
75
+ }
76
+ });
73
77
  export {
74
- T as default,
75
- T as eslintPluginCore
78
+ p as default
76
79
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/eslint-plugin-core",
3
- "version": "0.0.1-alpha.75",
3
+ "version": "0.0.1-alpha.76",
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.75",
37
+ "@salty-css/core": "^0.0.1-alpha.76",
38
38
  "eslint": ">=9.x || >=8.x || >=7.x"
39
39
  }
40
40
  }