@salty-css/eslint-config-core 0.0.1-alpha.84 → 0.0.1-alpha.85

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.
Files changed (3) hide show
  1. package/flat.cjs +1 -1
  2. package/flat.js +32 -26
  3. package/package.json +3 -3
package/flat.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";require("esbuild");require("child_process");require("path");require("fs");require("fs/promises");const v=["salty","css","styles","styled"],h=(r=[])=>new RegExp(`\\.(${[...v,...r].join("|")})\\.`),g=(r,o=[])=>h(o).test(r),P={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 g(r.filename)?{CallExpression:l=>{try{const{callee:i,arguments:e}=l;if(!(i.type==="Identifier"&&i.name==="styled"))return;const t=e[1];if(!t||!(t.type==="ObjectExpression"))return;const c=t.properties.find(s=>s.type==="Property"&&s.key.type==="Identifier"&&s.key.name==="base");if(!c)return;const{value:u}=c;if(!(u.type==="ObjectExpression"))return;const n=u.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:f}=r,x=f.getText(n),b=t.properties.indexOf(c),y=t.properties[b];if(!y.range)return null;const E=[y.range[1],y.range[1]],d=[n.range[0]-1,n.range[1]];if(u.properties.at(-1)===n){const m=f.text.slice(n.range[1]).match(/^\s*,/);m&&(d[1]+=m[0].length)}return[s.removeRange(d),s.insertTextAfterRange(E,`, ${x}`)]}})}catch(i){console.log("ESlint error",i);return}}}:{}}},S={meta:{type:"problem",fixable:"code",docs:{description:"Salty CSS related function calls or other values must be exported",category:"Errors",recommended:!0},messages:{mustBeExported:"Salty CSS related function calls or other values must be exported"}},create(r){if(!g(r.filename))return{};function l(e){if(e.type==="VariableDeclaration"){const a=e.declarations[0];if(a.type!=="VariableDeclarator")return;const t=a.init;if((t==null?void 0:t.type)!=="CallExpression")return;const p=["styled","keyframes"];if(t.callee.type==="Identifier"&&p.includes(t.callee.name))return!0}return!1}function i(e){const a=e.parent;return a.type==="ExportNamedDeclaration"||a.type==="ExportDefaultDeclaration"}return{VariableDeclaration:e=>{l(e)&&(i(e)||r.report({node:e,messageId:"mustBeExported",fix:a=>a.insertTextBefore(e,"export ")}))}}}},C={rules:{"no-variants-in-base":P,"must-be-exported":S}},I={files:["**/*.ts","**/*.tsx"],plugins:{"@salty-css/core":C},rules:{"@salty-css/core/no-variants-in-base":"error","@salty-css/core/must-be-exported":"error"}};module.exports=I;
1
+ "use strict";require("esbuild");require("child_process");require("path");require("fs");require("fs/promises");const i=require("winston");i.createLogger({level:"debug",format:i.format.combine(i.format.colorize(),i.format.cli()),transports:[new i.transports.Console({})]});const h=["salty","css","styles","styled"],C=(r=[])=>new RegExp(`\\.(${[...h,...r].join("|")})\\.`),x=(r,l=[])=>C(l).test(r),P={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:c=>{try{const{callee:o,arguments:e}=c;if(!(o.type==="Identifier"&&o.name==="styled"))return;const t=e[1];if(!t||!(t.type==="ObjectExpression"))return;const u=t.properties.find(s=>s.type==="Property"&&s.key.type==="Identifier"&&s.key.name==="base");if(!u)return;const{value:f}=u;if(!(f.type==="ObjectExpression"))return;const n=f.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:d}=r,b=d.getText(n),E=t.properties.indexOf(u),p=t.properties[E];if(!p.range)return null;const v=[p.range[1],p.range[1]],m=[n.range[0]-1,n.range[1]];if(f.properties.at(-1)===n){const g=d.text.slice(n.range[1]).match(/^\s*,/);g&&(m[1]+=g[0].length)}return[s.removeRange(m),s.insertTextAfterRange(v,`, ${b}`)]}})}catch(o){console.log("ESlint error",o);return}}}:{}}},S={meta:{type:"problem",fixable:"code",docs:{description:"Salty CSS related function calls or other values must be exported",category:"Errors",recommended:!0},messages:{mustBeExported:"Salty CSS related function calls or other values must be exported"}},create(r){if(!x(r.filename))return{};function c(e){if(e.type==="VariableDeclaration"){const a=e.declarations[0];if(a.type!=="VariableDeclarator")return;const t=a.init;if((t==null?void 0:t.type)!=="CallExpression")return;const y=["styled","keyframes"];if(t.callee.type==="Identifier"&&y.includes(t.callee.name))return!0}return!1}function o(e){const a=e.parent;return a.type==="ExportNamedDeclaration"||a.type==="ExportDefaultDeclaration"}return{VariableDeclaration:e=>{c(e)&&(o(e)||r.report({node:e,messageId:"mustBeExported",fix:a=>a.insertTextBefore(e,"export ")}))}}}},I={rules:{"no-variants-in-base":P,"must-be-exported":S}},V={files:["**/*.ts","**/*.tsx"],plugins:{"@salty-css/core":I},rules:{"@salty-css/core/no-variants-in-base":"error","@salty-css/core/must-be-exported":"error"}};module.exports=V;
package/flat.js CHANGED
@@ -3,7 +3,13 @@ import "child_process";
3
3
  import "path";
4
4
  import "fs";
5
5
  import "fs/promises";
6
- const v = ["salty", "css", "styles", "styled"], h = (r = []) => new RegExp(`\\.(${[...v, ...r].join("|")})\\.`), g = (r, o = []) => h(o).test(r), P = {
6
+ import { createLogger as h, format as f, transports as C } from "winston";
7
+ h({
8
+ level: "debug",
9
+ format: f.combine(f.colorize(), f.cli()),
10
+ transports: [new C.Console({})]
11
+ });
12
+ const P = ["salty", "css", "styles", "styled"], S = (r = []) => new RegExp(`\\.(${[...P, ...r].join("|")})\\.`), x = (r, i = []) => S(i).test(r), I = {
7
13
  meta: {
8
14
  type: "problem",
9
15
  fixable: "code",
@@ -17,18 +23,18 @@ const v = ["salty", "css", "styles", "styled"], h = (r = []) => new RegExp(`\\.(
17
23
  }
18
24
  },
19
25
  create(r) {
20
- return g(r.filename) ? {
26
+ return x(r.filename) ? {
21
27
  CallExpression: (l) => {
22
28
  try {
23
- const { callee: i, arguments: e } = l;
24
- if (!(i.type === "Identifier" && i.name === "styled")) return;
29
+ const { callee: o, arguments: e } = l;
30
+ if (!(o.type === "Identifier" && o.name === "styled")) return;
25
31
  const t = e[1];
26
32
  if (!t || !(t.type === "ObjectExpression")) return;
27
33
  const c = t.properties.find((s) => s.type === "Property" && s.key.type === "Identifier" && s.key.name === "base");
28
34
  if (!c) return;
29
- const { value: u } = c;
30
- if (!(u.type === "ObjectExpression")) return;
31
- const n = u.properties.find(
35
+ const { value: p } = c;
36
+ if (!(p.type === "ObjectExpression")) return;
37
+ const n = p.properties.find(
32
38
  (s) => s.type === "Property" && s.key.type === "Identifier" && s.key.name === "variants"
33
39
  );
34
40
  if (!n) return;
@@ -37,28 +43,28 @@ const v = ["salty", "css", "styles", "styled"], h = (r = []) => new RegExp(`\\.(
37
43
  messageId: "nestedVariants",
38
44
  fix: (s) => {
39
45
  if (!n.range) return null;
40
- const { sourceCode: f } = r, x = f.getText(n), b = t.properties.indexOf(c), p = t.properties[b];
41
- if (!p.range) return null;
42
- const E = [p.range[1], p.range[1]], d = [
46
+ const { sourceCode: d } = r, b = d.getText(n), E = t.properties.indexOf(c), u = t.properties[E];
47
+ if (!u.range) return null;
48
+ const v = [u.range[1], u.range[1]], m = [
43
49
  n.range[0] - 1,
44
50
  // Include the preceding comma (if any)
45
51
  n.range[1]
46
52
  ];
47
- if (u.properties.at(-1) === n) {
48
- const m = f.text.slice(n.range[1]).match(/^\s*,/);
49
- m && (d[1] += m[0].length);
53
+ if (p.properties.at(-1) === n) {
54
+ const g = d.text.slice(n.range[1]).match(/^\s*,/);
55
+ g && (m[1] += g[0].length);
50
56
  }
51
- return [s.removeRange(d), s.insertTextAfterRange(E, `, ${x}`)];
57
+ return [s.removeRange(m), s.insertTextAfterRange(v, `, ${b}`)];
52
58
  }
53
59
  });
54
- } catch (i) {
55
- console.log("ESlint error", i);
60
+ } catch (o) {
61
+ console.log("ESlint error", o);
56
62
  return;
57
63
  }
58
64
  }
59
65
  } : {};
60
66
  }
61
- }, S = {
67
+ }, V = {
62
68
  meta: {
63
69
  type: "problem",
64
70
  fixable: "code",
@@ -72,7 +78,7 @@ const v = ["salty", "css", "styles", "styled"], h = (r = []) => new RegExp(`\\.(
72
78
  }
73
79
  },
74
80
  create(r) {
75
- if (!g(r.filename)) return {};
81
+ if (!x(r.filename)) return {};
76
82
  function l(e) {
77
83
  if (e.type === "VariableDeclaration") {
78
84
  const a = e.declarations[0];
@@ -85,13 +91,13 @@ const v = ["salty", "css", "styles", "styled"], h = (r = []) => new RegExp(`\\.(
85
91
  }
86
92
  return !1;
87
93
  }
88
- function i(e) {
94
+ function o(e) {
89
95
  const a = e.parent;
90
96
  return a.type === "ExportNamedDeclaration" || a.type === "ExportDefaultDeclaration";
91
97
  }
92
98
  return {
93
99
  VariableDeclaration: (e) => {
94
- l(e) && (i(e) || r.report({
100
+ l(e) && (o(e) || r.report({
95
101
  node: e,
96
102
  messageId: "mustBeExported",
97
103
  fix: (a) => a.insertTextBefore(e, "export ")
@@ -99,15 +105,15 @@ const v = ["salty", "css", "styles", "styled"], h = (r = []) => new RegExp(`\\.(
99
105
  }
100
106
  };
101
107
  }
102
- }, C = {
108
+ }, F = {
103
109
  rules: {
104
- "no-variants-in-base": P,
105
- "must-be-exported": S
110
+ "no-variants-in-base": I,
111
+ "must-be-exported": V
106
112
  }
107
- }, T = {
113
+ }, O = {
108
114
  files: ["**/*.ts", "**/*.tsx"],
109
115
  plugins: {
110
- "@salty-css/core": C
116
+ "@salty-css/core": F
111
117
  },
112
118
  rules: {
113
119
  "@salty-css/core/no-variants-in-base": "error",
@@ -115,5 +121,5 @@ const v = ["salty", "css", "styles", "styled"], h = (r = []) => new RegExp(`\\.(
115
121
  }
116
122
  };
117
123
  export {
118
- T as default
124
+ O as default
119
125
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/eslint-config-core",
3
- "version": "0.0.1-alpha.84",
3
+ "version": "0.0.1-alpha.85",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -38,8 +38,8 @@
38
38
  }
39
39
  },
40
40
  "dependencies": {
41
- "@salty-css/core": "^0.0.1-alpha.84",
42
- "@salty-css/eslint-plugin-core": "^0.0.1-alpha.84",
41
+ "@salty-css/core": "^0.0.1-alpha.85",
42
+ "@salty-css/eslint-plugin-core": "^0.0.1-alpha.85",
43
43
  "eslint": ">=9.x || >=8.x || >=7.x"
44
44
  }
45
45
  }