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

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