@salty-css/eslint-config-core 0.0.1-alpha.268 → 0.0.1-alpha.269

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