@solvro/config 1.0.4 → 1.0.5

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.
@@ -1,258 +0,0 @@
1
- import {
2
- __commonJS,
3
- init_esm_shims
4
- } from "./chunk-4C4AR77R.js";
5
-
6
- // node_modules/eslint-plugin-react-refresh/index.js
7
- var require_eslint_plugin_react_refresh = __commonJS({
8
- "node_modules/eslint-plugin-react-refresh/index.js"(exports, module) {
9
- init_esm_shims();
10
- var __defProp = Object.defineProperty;
11
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
- var __getOwnPropNames = Object.getOwnPropertyNames;
13
- var __hasOwnProp = Object.prototype.hasOwnProperty;
14
- var __export = (target, all) => {
15
- for (var name in all)
16
- __defProp(target, name, { get: all[name], enumerable: true });
17
- };
18
- var __copyProps = (to, from, except, desc) => {
19
- if (from && typeof from === "object" || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from))
21
- if (!__hasOwnProp.call(to, key) && key !== except)
22
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
- }
24
- return to;
25
- };
26
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
- var src_exports = {};
28
- __export(src_exports, {
29
- default: () => src_default,
30
- rules: () => rules
31
- });
32
- module.exports = __toCommonJS(src_exports);
33
- var possibleReactExportRE = /^[A-Z][a-zA-Z0-9]*$/u;
34
- var strictReactExportRE = /^[A-Z][a-zA-Z0-9]*[a-z]+[a-zA-Z0-9]*$/u;
35
- var onlyExportComponents = {
36
- meta: {
37
- messages: {
38
- exportAll: "This rule can't verify that `export *` only exports components.",
39
- namedExport: "Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components.",
40
- anonymousExport: "Fast refresh can't handle anonymous components. Add a name to your export.",
41
- localComponents: "Fast refresh only works when a file only exports components. Move your component(s) to a separate file.",
42
- noExport: "Fast refresh only works when a file has exports. Move your component(s) to a separate file.",
43
- reactContext: "Fast refresh only works when a file only exports components. Move your React context(s) to a separate file."
44
- },
45
- type: "problem",
46
- schema: [
47
- {
48
- type: "object",
49
- properties: {
50
- allowConstantExport: { type: "boolean" },
51
- checkJS: { type: "boolean" },
52
- allowExportNames: { type: "array", items: { type: "string" } }
53
- },
54
- additionalProperties: false
55
- }
56
- ]
57
- },
58
- defaultOptions: [],
59
- create: (context) => {
60
- const {
61
- allowConstantExport = false,
62
- checkJS = false,
63
- allowExportNames
64
- } = context.options[0] ?? {};
65
- const filename = context.filename;
66
- if (filename.includes(".test.") || filename.includes(".spec.") || filename.includes(".cy.") || filename.includes(".stories.")) {
67
- return {};
68
- }
69
- const shouldScan = filename.endsWith(".jsx") || filename.endsWith(".tsx") || checkJS && filename.endsWith(".js");
70
- if (!shouldScan)
71
- return {};
72
- const allowExportNamesSet = allowExportNames ? new Set(allowExportNames) : void 0;
73
- return {
74
- Program(program) {
75
- let hasExports = false;
76
- let mayHaveReactExport = false;
77
- let reactIsInScope = false;
78
- const localComponents = [];
79
- const nonComponentExports = [];
80
- const reactContextExports = [];
81
- const handleLocalIdentifier = (identifierNode) => {
82
- if (identifierNode.type !== "Identifier")
83
- return;
84
- if (possibleReactExportRE.test(identifierNode.name)) {
85
- localComponents.push(identifierNode);
86
- }
87
- };
88
- const handleExportIdentifier = (identifierNode, isFunction, init) => {
89
- if (identifierNode.type !== "Identifier") {
90
- nonComponentExports.push(identifierNode);
91
- return;
92
- }
93
- if (allowExportNamesSet == null ? void 0 : allowExportNamesSet.has(identifierNode.name))
94
- return;
95
- if (allowConstantExport && init && (init.type === "Literal" || // 1, "foo"
96
- init.type === "UnaryExpression" || // -1
97
- init.type === "TemplateLiteral" || // `Some ${template}`
98
- init.type === "BinaryExpression")) {
99
- return;
100
- }
101
- if (isFunction) {
102
- if (possibleReactExportRE.test(identifierNode.name)) {
103
- mayHaveReactExport = true;
104
- } else {
105
- nonComponentExports.push(identifierNode);
106
- }
107
- } else {
108
- if (init && init.type === "CallExpression" && // createContext || React.createContext
109
- (init.callee.type === "Identifier" && init.callee.name === "createContext" || init.callee.type === "MemberExpression" && init.callee.property.type === "Identifier" && init.callee.property.name === "createContext")) {
110
- reactContextExports.push(identifierNode);
111
- return;
112
- }
113
- if (init && // Switch to allowList?
114
- notReactComponentExpression.has(init.type)) {
115
- nonComponentExports.push(identifierNode);
116
- return;
117
- }
118
- if (!mayHaveReactExport && possibleReactExportRE.test(identifierNode.name)) {
119
- mayHaveReactExport = true;
120
- }
121
- if (!strictReactExportRE.test(identifierNode.name)) {
122
- nonComponentExports.push(identifierNode);
123
- }
124
- }
125
- };
126
- const handleExportDeclaration = (node) => {
127
- var _a, _b;
128
- if (node.type === "VariableDeclaration") {
129
- for (const variable of node.declarations) {
130
- handleExportIdentifier(
131
- variable.id,
132
- canBeReactFunctionComponent(variable.init),
133
- variable.init
134
- );
135
- }
136
- } else if (node.type === "FunctionDeclaration") {
137
- if (node.id === null) {
138
- context.report({ messageId: "anonymousExport", node });
139
- } else {
140
- handleExportIdentifier(node.id, true);
141
- }
142
- } else if (node.type === "CallExpression") {
143
- if (node.callee.type === "CallExpression" && node.callee.callee.type === "Identifier" && node.callee.callee.name === "connect") {
144
- mayHaveReactExport = true;
145
- } else if (node.callee.type !== "Identifier") {
146
- if (node.callee.type === "MemberExpression" && node.callee.property.type === "Identifier" && reactHOCs.has(node.callee.property.name)) {
147
- mayHaveReactExport = true;
148
- } else {
149
- context.report({ messageId: "anonymousExport", node });
150
- }
151
- } else if (!reactHOCs.has(node.callee.name)) {
152
- context.report({ messageId: "anonymousExport", node });
153
- } else if (((_a = node.arguments[0]) == null ? void 0 : _a.type) === "FunctionExpression" && node.arguments[0].id) {
154
- handleExportIdentifier(node.arguments[0].id, true);
155
- } else if (((_b = node.arguments[0]) == null ? void 0 : _b.type) === "Identifier") {
156
- mayHaveReactExport = true;
157
- } else {
158
- context.report({ messageId: "anonymousExport", node });
159
- }
160
- } else if (node.type === "TSEnumDeclaration") {
161
- nonComponentExports.push(node.id);
162
- }
163
- };
164
- for (const node of program.body) {
165
- if (node.type === "ExportAllDeclaration") {
166
- if (node.exportKind === "type")
167
- continue;
168
- hasExports = true;
169
- context.report({ messageId: "exportAll", node });
170
- } else if (node.type === "ExportDefaultDeclaration") {
171
- hasExports = true;
172
- const declaration = node.declaration.type === "TSAsExpression" || node.declaration.type === "TSSatisfiesExpression" ? node.declaration.expression : node.declaration;
173
- if (declaration.type === "VariableDeclaration" || declaration.type === "FunctionDeclaration" || declaration.type === "CallExpression") {
174
- handleExportDeclaration(declaration);
175
- }
176
- if (declaration.type === "Identifier") {
177
- handleExportIdentifier(declaration);
178
- }
179
- if (declaration.type === "ArrowFunctionExpression") {
180
- context.report({ messageId: "anonymousExport", node });
181
- }
182
- } else if (node.type === "ExportNamedDeclaration") {
183
- if (node.exportKind === "type")
184
- continue;
185
- hasExports = true;
186
- if (node.declaration)
187
- handleExportDeclaration(node.declaration);
188
- for (const specifier of node.specifiers) {
189
- handleExportIdentifier(
190
- specifier.exported.type === "Identifier" && specifier.exported.name === "default" ? specifier.local : specifier.exported
191
- );
192
- }
193
- } else if (node.type === "VariableDeclaration") {
194
- for (const variable of node.declarations) {
195
- handleLocalIdentifier(variable.id);
196
- }
197
- } else if (node.type === "FunctionDeclaration") {
198
- handleLocalIdentifier(node.id);
199
- } else if (node.type === "ImportDeclaration" && node.source.value === "react") {
200
- reactIsInScope = true;
201
- }
202
- }
203
- if (checkJS && !reactIsInScope)
204
- return;
205
- if (hasExports) {
206
- if (mayHaveReactExport) {
207
- for (const node of nonComponentExports) {
208
- context.report({ messageId: "namedExport", node });
209
- }
210
- for (const node of reactContextExports) {
211
- context.report({ messageId: "reactContext", node });
212
- }
213
- } else if (localComponents.length) {
214
- for (const node of localComponents) {
215
- context.report({ messageId: "localComponents", node });
216
- }
217
- }
218
- } else if (localComponents.length) {
219
- for (const node of localComponents) {
220
- context.report({ messageId: "noExport", node });
221
- }
222
- }
223
- }
224
- };
225
- }
226
- };
227
- var reactHOCs = /* @__PURE__ */ new Set(["memo", "forwardRef"]);
228
- var canBeReactFunctionComponent = (init) => {
229
- if (!init)
230
- return false;
231
- if (init.type === "ArrowFunctionExpression")
232
- return true;
233
- if (init.type === "CallExpression" && init.callee.type === "Identifier") {
234
- return reactHOCs.has(init.callee.name);
235
- }
236
- return false;
237
- };
238
- var notReactComponentExpression = /* @__PURE__ */ new Set([
239
- "ArrayExpression",
240
- "AwaitExpression",
241
- "BinaryExpression",
242
- "ChainExpression",
243
- "ConditionalExpression",
244
- "Literal",
245
- "LogicalExpression",
246
- "ObjectExpression",
247
- "TemplateLiteral",
248
- "ThisExpression",
249
- "UnaryExpression",
250
- "UpdateExpression"
251
- ]);
252
- var rules = {
253
- "only-export-components": onlyExportComponents
254
- };
255
- var src_default = { rules };
256
- }
257
- });
258
- export default require_eslint_plugin_react_refresh();