@borela-tech/eslint-config 2.2.1 → 2.3.0

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 (107) hide show
  1. package/README.md +308 -19
  2. package/dist/index.d.ts +5 -0
  3. package/dist/index.mjs +3589 -811
  4. package/dist/index.mjs.map +1 -1
  5. package/jest.config.ts +19 -0
  6. package/package.json +17 -8
  7. package/vite.config.ts +41 -0
  8. package/bin/build +0 -9
  9. package/bin/lint +0 -14
  10. package/bin/publish +0 -12
  11. package/bin/test +0 -12
  12. package/bin/typecheck +0 -8
  13. package/dist/index.d.mts +0 -5226
  14. package/src/index.ts +0 -149
  15. package/src/lib/ReExportDeclaration.ts +0 -5
  16. package/src/lib/ReplacementRange.ts +0 -4
  17. package/src/lib/compare.ts +0 -3
  18. package/src/rules/__tests__/dedent/countLeadingSpaces.ts +0 -4
  19. package/src/rules/__tests__/dedent/findMinIndent.ts +0 -7
  20. package/src/rules/__tests__/dedent/index.ts +0 -17
  21. package/src/rules/__tests__/dedent/interpolate.ts +0 -11
  22. package/src/rules/__tests__/dedent/removeEmptyPrefix.ts +0 -6
  23. package/src/rules/__tests__/dedent/removeEmptySuffix.ts +0 -6
  24. package/src/rules/__tests__/dedent/removeIndent.ts +0 -3
  25. package/src/rules/__tests__/importsAndReExportsAtTop.test.ts +0 -88
  26. package/src/rules/__tests__/individualImports.test.ts +0 -44
  27. package/src/rules/__tests__/individualReExports.test.ts +0 -64
  28. package/src/rules/__tests__/multilineUnionTypes.test.ts +0 -75
  29. package/src/rules/__tests__/singleLineImports.test.ts +0 -129
  30. package/src/rules/__tests__/singleLineReExports.test.ts +0 -100
  31. package/src/rules/__tests__/sortedImports.test.ts +0 -227
  32. package/src/rules/__tests__/sortedReExports.test.ts +0 -220
  33. package/src/rules/importsAndReExportsAtTop/CategorizedStatements.ts +0 -8
  34. package/src/rules/importsAndReExportsAtTop/StatementIndices.ts +0 -5
  35. package/src/rules/importsAndReExportsAtTop/categorizeStatements.ts +0 -28
  36. package/src/rules/importsAndReExportsAtTop/findStatementIndices.ts +0 -25
  37. package/src/rules/importsAndReExportsAtTop/generateSortedText.ts +0 -16
  38. package/src/rules/importsAndReExportsAtTop/getStatementType.ts +0 -17
  39. package/src/rules/importsAndReExportsAtTop/hasViolation.ts +0 -25
  40. package/src/rules/importsAndReExportsAtTop/index.ts +0 -45
  41. package/src/rules/importsAndReExportsAtTop/isImportDeclaration.ts +0 -7
  42. package/src/rules/importsAndReExportsAtTop/isReExport.ts +0 -12
  43. package/src/rules/importsAndReExportsAtTop/statementType.ts +0 -4
  44. package/src/rules/individualImports.ts +0 -38
  45. package/src/rules/individualReExports.ts +0 -51
  46. package/src/rules/multilineUnionTypes/createFix.ts +0 -13
  47. package/src/rules/multilineUnionTypes/index.ts +0 -52
  48. package/src/rules/multilineUnionTypes/isMultiline.ts +0 -6
  49. package/src/rules/singleLineImports/createFix.ts +0 -23
  50. package/src/rules/singleLineImports/formatAttributes.ts +0 -20
  51. package/src/rules/singleLineImports/formatNamed.ts +0 -9
  52. package/src/rules/singleLineImports/formatSpecifiers.ts +0 -32
  53. package/src/rules/singleLineImports/index.ts +0 -34
  54. package/src/rules/singleLineImports/isMultiline.ts +0 -6
  55. package/src/rules/singleLineReExports/createFix.ts +0 -29
  56. package/src/rules/singleLineReExports/index.ts +0 -48
  57. package/src/rules/singleLineReExports/isMultiline.ts +0 -6
  58. package/src/rules/sortedImports/CategorizedImport.ts +0 -8
  59. package/src/rules/sortedImports/ImportError.ts +0 -9
  60. package/src/rules/sortedImports/ImportGroup.ts +0 -6
  61. package/src/rules/sortedImports/ImportGroupOrder.ts +0 -9
  62. package/src/rules/sortedImports/areSpecifiersSorted.ts +0 -9
  63. package/src/rules/sortedImports/categorizeImport.ts +0 -23
  64. package/src/rules/sortedImports/categorizeImports.ts +0 -12
  65. package/src/rules/sortedImports/checkAlphabeticalSorting.ts +0 -23
  66. package/src/rules/sortedImports/checkGroupOrdering.ts +0 -21
  67. package/src/rules/sortedImports/checkSpecifiersSorting.ts +0 -21
  68. package/src/rules/sortedImports/createFix/buildSortedCode.ts +0 -23
  69. package/src/rules/sortedImports/createFix/findLastImportIndex.ts +0 -12
  70. package/src/rules/sortedImports/createFix/formatNamedImport.ts +0 -21
  71. package/src/rules/sortedImports/createFix/getReplacementRange.ts +0 -14
  72. package/src/rules/sortedImports/createFix/groupImportsByType.ts +0 -19
  73. package/src/rules/sortedImports/createFix/index.ts +0 -47
  74. package/src/rules/sortedImports/createFix/sortImportGroups.ts +0 -13
  75. package/src/rules/sortedImports/getImportGroups.ts +0 -23
  76. package/src/rules/sortedImports/getNamedSpecifiers.ts +0 -7
  77. package/src/rules/sortedImports/getSortKey.ts +0 -26
  78. package/src/rules/sortedImports/getSpecifierName.ts +0 -7
  79. package/src/rules/sortedImports/index.ts +0 -63
  80. package/src/rules/sortedImports/sortSpecifiersText.ts +0 -16
  81. package/src/rules/sortedReExports/CategorizedNamedReExport.ts +0 -6
  82. package/src/rules/sortedReExports/CategorizedReExport.ts +0 -26
  83. package/src/rules/sortedReExports/ReExportError.ts +0 -9
  84. package/src/rules/sortedReExports/ReExportGroup.ts +0 -5
  85. package/src/rules/sortedReExports/ReExportGroupOrder.ts +0 -8
  86. package/src/rules/sortedReExports/areSpecifiersSorted.ts +0 -9
  87. package/src/rules/sortedReExports/categorizeReExport.ts +0 -21
  88. package/src/rules/sortedReExports/categorizeReExports.ts +0 -14
  89. package/src/rules/sortedReExports/checkAlphabeticalSorting.ts +0 -25
  90. package/src/rules/sortedReExports/checkGroupOrdering.ts +0 -21
  91. package/src/rules/sortedReExports/checkSpecifiersSorting.ts +0 -23
  92. package/src/rules/sortedReExports/createFix/buildSortedCode.ts +0 -29
  93. package/src/rules/sortedReExports/createFix/findFirstExportIndex.ts +0 -11
  94. package/src/rules/sortedReExports/createFix/findLastExportIndex.ts +0 -12
  95. package/src/rules/sortedReExports/createFix/formatNamedReExport.ts +0 -21
  96. package/src/rules/sortedReExports/createFix/getReplacementRange.ts +0 -22
  97. package/src/rules/sortedReExports/createFix/groupReExportsByType.ts +0 -18
  98. package/src/rules/sortedReExports/createFix/index.ts +0 -47
  99. package/src/rules/sortedReExports/createFix/sortExportGroups.ts +0 -12
  100. package/src/rules/sortedReExports/getNamedSpecifiers.ts +0 -9
  101. package/src/rules/sortedReExports/getReExportGroups.ts +0 -33
  102. package/src/rules/sortedReExports/getSortKey.ts +0 -22
  103. package/src/rules/sortedReExports/getSpecifierName.ts +0 -7
  104. package/src/rules/sortedReExports/index.ts +0 -63
  105. package/src/rules/sortedReExports/isNamedReExport.ts +0 -6
  106. package/src/rules/sortedReExports/sortSpecifiersText.ts +0 -16
  107. package/tsdown.config.ts +0 -19
package/dist/index.mjs CHANGED
@@ -1,872 +1,3650 @@
1
1
  import eslint from "@eslint/js";
2
2
  import react from "eslint-plugin-react";
3
- import reactHooks from "eslint-plugin-react-hooks";
4
3
  import stylistic from "@stylistic/eslint-plugin";
5
4
  import typescript from "typescript-eslint";
6
- //#region src/rules/importsAndReExportsAtTop/getStatementType.ts
5
+ import * as path from "path";
6
+ import perfectionist from "eslint-plugin-perfectionist";
7
+ import rule from "eslint-plugin-react-hooks";
8
+ import eslintPluginUnicorn from "eslint-plugin-unicorn";
9
+ function getLineIndent$1(sourceCode, line) {
10
+ const text = sourceCode.getText();
11
+ const lines = text.split("\n");
12
+ const lineText = lines[line - 1] ?? "";
13
+ const match = lineText.match(/^(\s*)/);
14
+ return match?.[1] ?? "";
15
+ }
16
+ function buildMultilineFix$1(fixer, brackets, elements, sourceCode) {
17
+ const openingLine = brackets.openingBracket.loc.start.line;
18
+ const baseIndent = getLineIndent$1(sourceCode, openingLine);
19
+ const itemIndent = baseIndent + " ";
20
+ const nonNullElements = elements.filter((el) => el !== null);
21
+ const formattedItems = nonNullElements.map((element) => {
22
+ const text = sourceCode.getText(element);
23
+ return `${itemIndent}${text}`;
24
+ }).join(",\n");
25
+ const newText = `
26
+ ${formattedItems},
27
+ ${baseIndent}`;
28
+ return fixer.replaceTextRange(
29
+ [brackets.openingBracket.range[1], brackets.closingBracket.range[0]],
30
+ newText
31
+ );
32
+ }
33
+ const defaultOptions$6 = {
34
+ maxLength: 80
35
+ };
36
+ function getBrackets(sourceCode, node2) {
37
+ const elements = node2.elements;
38
+ if (elements.length === 0)
39
+ return null;
40
+ const firstElement = elements.find((el) => el !== null);
41
+ if (!firstElement)
42
+ return null;
43
+ const lastElement = [...elements].reverse().find((el) => el !== null);
44
+ if (!lastElement)
45
+ return null;
46
+ const openingBracket = sourceCode.getTokenBefore(firstElement);
47
+ const closingBracket = sourceCode.getTokenAfter(lastElement);
48
+ if (!openingBracket || !closingBracket)
49
+ return null;
50
+ if (openingBracket.value !== "[" || closingBracket.value !== "]")
51
+ return null;
52
+ return { closingBracket, openingBracket };
53
+ }
54
+ function getLineLength(sourceCode, lineNumber) {
55
+ const line = sourceCode.getLines()[lineNumber - 1];
56
+ return line?.length ?? 0;
57
+ }
58
+ function checkArray(sourceCode, context, node2) {
59
+ const options = context.options[0] ?? {};
60
+ const maxLength = options.maxLength ?? defaultOptions$6.maxLength;
61
+ const elements = node2.elements;
62
+ if (elements.length <= 1)
63
+ return;
64
+ const brackets = getBrackets(sourceCode, node2);
65
+ if (!brackets)
66
+ return;
67
+ const firstLine = brackets.openingBracket.loc.start.line;
68
+ const lastLine = brackets.closingBracket.loc.end.line;
69
+ if (firstLine !== lastLine)
70
+ return;
71
+ const lineLength = getLineLength(sourceCode, firstLine);
72
+ if (lineLength <= maxLength)
73
+ return;
74
+ context.report({
75
+ fix: (fixer) => buildMultilineFix$1(
76
+ fixer,
77
+ brackets,
78
+ elements,
79
+ sourceCode
80
+ ),
81
+ messageId: "arrayItemsOnNewLine",
82
+ node: elements[0]
83
+ });
84
+ }
85
+ const messageIds$c = {
86
+ arrayItemsOnNewLine: "arrayItemsOnNewLine"
87
+ };
88
+ const arrayItemsLineBreak = {
89
+ create(context) {
90
+ const sourceCode = context.sourceCode ?? context.getSourceCode();
91
+ return {
92
+ ArrayExpression(node2) {
93
+ checkArray(sourceCode, context, node2);
94
+ }
95
+ };
96
+ },
97
+ meta: {
98
+ docs: {
99
+ description: "Enforce each array item to be on its own line when the array expression exceeds a configurable maximum line length."
100
+ },
101
+ fixable: "code",
102
+ messages: messageIds$c,
103
+ schema: [{
104
+ additionalProperties: false,
105
+ properties: {
106
+ maxLength: {
107
+ type: "number"
108
+ }
109
+ },
110
+ type: "object"
111
+ }],
112
+ type: "layout"
113
+ }
114
+ };
115
+ function getIndentation(node2, sourceCode) {
116
+ const tokenBeforeBody = sourceCode.getTokenBefore(node2);
117
+ if (!tokenBeforeBody)
118
+ return "";
119
+ const line = sourceCode.getText().split("\n")[tokenBeforeBody.loc.start.line - 1];
120
+ if (!line)
121
+ return "";
122
+ const match = line.match(/^(\s*)/);
123
+ return match?.[1] ?? "";
124
+ }
125
+ function createBraceStyleFix(fixer, body, sourceCode) {
126
+ if (body.type === "BlockStatement") {
127
+ const firstToken = sourceCode.getFirstToken(body);
128
+ if (!firstToken)
129
+ return null;
130
+ return fixer.insertTextBefore(firstToken, "\n");
131
+ }
132
+ const bodyText = sourceCode.getText(body);
133
+ const indentation = getIndentation(body, sourceCode);
134
+ const fixedText = `{
135
+ ${indentation} ${bodyText}
136
+ ${indentation}}`;
137
+ return fixer.replaceText(body, fixedText);
138
+ }
139
+ function isOnSameLineAsCondition(node2, sourceCode) {
140
+ const tokenBeforeBody = sourceCode.getTokenBefore(node2);
141
+ if (!tokenBeforeBody)
142
+ return false;
143
+ const firstToken = sourceCode.getFirstToken(node2);
144
+ if (!firstToken)
145
+ return false;
146
+ return tokenBeforeBody.loc.end.line === firstToken.loc.start.line;
147
+ }
148
+ function isSingleLineStatement$1(node2, sourceCode) {
149
+ const firstToken = sourceCode.getFirstToken(node2);
150
+ if (!firstToken)
151
+ return false;
152
+ const lastToken = sourceCode.getLastToken(node2);
153
+ if (!lastToken)
154
+ return false;
155
+ return firstToken.loc.start.line === lastToken.loc.end.line;
156
+ }
157
+ function reportBodyOnSameLineAsCondition(context, body) {
158
+ const sourceCode = context.sourceCode;
159
+ if (body.type !== "BlockStatement") {
160
+ if (isOnSameLineAsCondition(body, sourceCode)) {
161
+ context.report({
162
+ fix: (fixer) => createBraceStyleFix(fixer, body, sourceCode),
163
+ messageId: "singleLine",
164
+ node: body
165
+ });
166
+ }
167
+ } else {
168
+ const isOnSameLine = isOnSameLineAsCondition(body, sourceCode);
169
+ const isSingleLine = isSingleLineStatement$1(body, sourceCode);
170
+ if (isOnSameLine && isSingleLine) {
171
+ context.report({
172
+ fix: (fixer) => createBraceStyleFix(fixer, body, sourceCode),
173
+ messageId: "singleLine",
174
+ node: body
175
+ });
176
+ }
177
+ }
178
+ }
179
+ function checkDoWhileStatementBraceStyle(node2, context) {
180
+ reportBodyOnSameLineAsCondition(context, node2.body);
181
+ }
182
+ function checkForStatementBraceStyle(node2, context) {
183
+ reportBodyOnSameLineAsCondition(context, node2.body);
184
+ }
185
+ function checkIfStatementBraceStyle(node2, context) {
186
+ const sourceCode = context.sourceCode;
187
+ reportBodyOnSameLineAsCondition(context, node2.consequent);
188
+ if (!node2.alternate)
189
+ return;
190
+ if (node2.alternate.type === "BlockStatement") {
191
+ reportBodyOnSameLineAsCondition(context, node2.alternate);
192
+ return;
193
+ }
194
+ if (node2.alternate.type !== "IfStatement") {
195
+ const alternate = node2.alternate;
196
+ if (isOnSameLineAsCondition(alternate, sourceCode)) {
197
+ context.report({
198
+ fix: (fixer) => createBraceStyleFix(fixer, alternate, sourceCode),
199
+ messageId: "singleLine",
200
+ node: alternate
201
+ });
202
+ }
203
+ }
204
+ }
205
+ function checkWhileStatementBraceStyle(node2, context) {
206
+ reportBodyOnSameLineAsCondition(context, node2.body);
207
+ }
208
+ const braceStyleControlStatements = {
209
+ create(context) {
210
+ return {
211
+ DoWhileStatement: (node2) => checkDoWhileStatementBraceStyle(node2, context),
212
+ ForStatement: (node2) => checkForStatementBraceStyle(node2, context),
213
+ IfStatement: (node2) => checkIfStatementBraceStyle(node2, context),
214
+ WhileStatement: (node2) => checkWhileStatementBraceStyle(node2, context)
215
+ };
216
+ },
217
+ meta: {
218
+ docs: {
219
+ description: "Enforce control statements to have multi-line body."
220
+ },
221
+ fixable: "code",
222
+ messages: {
223
+ singleLine: "Control statement body must be on a separate line"
224
+ },
225
+ schema: [],
226
+ type: "layout"
227
+ }
228
+ };
229
+ function checkClosingBrace(sourceCode, context, node2, closingBrace) {
230
+ const lastProperty = node2.properties[node2.properties.length - 1];
231
+ const closingLine = closingBrace.loc.end.line;
232
+ const closingBraceOnOwnLine = lastProperty.loc.end.line < closingLine;
233
+ if (!closingBraceOnOwnLine) {
234
+ context.report({
235
+ fix(fixer) {
236
+ return fixer.replaceTextRange(
237
+ [lastProperty.range[1], closingBrace.range[0]],
238
+ ",\n" + getLineIndent$1(sourceCode, lastProperty.loc.end.line)
239
+ );
240
+ },
241
+ loc: closingBrace.loc,
242
+ messageId: "braceOnPropertyLine"
243
+ });
244
+ }
245
+ }
246
+ function checkNestedObjects(sourceCode, context, node2, checkObjectExpression2) {
247
+ for (const property of node2.properties) {
248
+ if (property.type === "Property" && property.value.type === "ObjectExpression")
249
+ checkObjectExpression2(sourceCode, context, property.value);
250
+ else if (property.type === "SpreadElement" && property.argument.type === "ObjectExpression")
251
+ checkObjectExpression2(sourceCode, context, property.argument);
252
+ }
253
+ }
254
+ function checkOpeningBrace(sourceCode, context, node2, openingBrace) {
255
+ const firstProperty = node2.properties[0];
256
+ const openingLine = openingBrace.loc.start.line;
257
+ const openingBraceOnOwnLine = firstProperty.loc.start.line > openingLine;
258
+ if (!openingBraceOnOwnLine) {
259
+ context.report({
260
+ fix(fixer) {
261
+ return fixer.replaceTextRange(
262
+ [openingBrace.range[1], firstProperty.range[0]],
263
+ "\n" + getLineIndent$1(sourceCode, firstProperty.loc.start.line)
264
+ );
265
+ },
266
+ loc: openingBrace.loc,
267
+ messageId: "braceOnPropertyLine"
268
+ });
269
+ }
270
+ }
271
+ function checkPropertyOnOwnLine(sourceCode, context, prevPropertyEndLine, property) {
272
+ const propStartLine = property.loc.start.line;
273
+ if (propStartLine === prevPropertyEndLine) {
274
+ context.report({
275
+ fix(fixer) {
276
+ const lastNewLineIndex = sourceCode.getText().lastIndexOf("\n", property.range[0] - 1);
277
+ return fixer.replaceTextRange(
278
+ [lastNewLineIndex, property.range[0]],
279
+ "\n" + getLineIndent$1(sourceCode, property.loc.start.line)
280
+ );
281
+ },
282
+ loc: property.loc,
283
+ messageId: "propertiesOnSameLine"
284
+ });
285
+ }
286
+ }
287
+ function checkObjectExpression(sourceCode, context, node2) {
288
+ if (node2.properties.length === 0)
289
+ return;
290
+ const openingBrace = sourceCode.getFirstToken(node2);
291
+ const closingBrace = sourceCode.getLastToken(node2);
292
+ if (!openingBrace || !closingBrace)
293
+ return;
294
+ const openingLine = openingBrace.loc.start.line;
295
+ const closingLine = closingBrace.loc.end.line;
296
+ if (openingLine === closingLine)
297
+ return;
298
+ checkOpeningBrace(sourceCode, context, node2, openingBrace);
299
+ let prevPropertyEndLine = node2.properties[0].loc.start.line;
300
+ for (const property of node2.properties) {
301
+ if (property !== node2.properties[0])
302
+ checkPropertyOnOwnLine(sourceCode, context, prevPropertyEndLine, property);
303
+ prevPropertyEndLine = property.loc.end.line;
304
+ }
305
+ checkClosingBrace(sourceCode, context, node2, closingBrace);
306
+ checkNestedObjects(sourceCode, context, node2, checkObjectExpression);
307
+ }
308
+ const messageIds$b = {
309
+ braceOnPropertyLine: "Opening brace should be on its own line",
310
+ propertiesOnSameLine: "Multi-line objects must have each property on its own line"
311
+ };
312
+ const braceStyleObjectLiteral = {
313
+ create(context) {
314
+ const sourceCode = context.sourceCode ?? context.getSourceCode();
315
+ return {
316
+ ObjectExpression(node2) {
317
+ checkObjectExpression(sourceCode, context, node2);
318
+ }
319
+ };
320
+ },
321
+ meta: {
322
+ docs: {
323
+ description: "Enforce consistent brace positioning for object literals."
324
+ },
325
+ fixable: "code",
326
+ messages: messageIds$b,
327
+ schema: [{
328
+ additionalProperties: false,
329
+ properties: {},
330
+ type: "object"
331
+ }],
332
+ type: "layout"
333
+ }
334
+ };
335
+ function buildCompactFix(fixer, openingBracket, closingBracket, elements, sourceCode) {
336
+ const nonNullElements = elements.filter(
337
+ (el) => el !== null
338
+ );
339
+ const formattedItems = nonNullElements.map((element) => sourceCode.getText(element)).join(", ");
340
+ const newText = `[${formattedItems}]`;
341
+ return fixer.replaceTextRange(
342
+ [openingBracket.range[0], closingBracket.range[1]],
343
+ newText
344
+ );
345
+ }
346
+ function findBracketByRange(tokens, range, value) {
347
+ return tokens?.find(
348
+ (t) => t.range[0] === range[0] && t.value === value
349
+ );
350
+ }
351
+ function findClosingBracketByRange(tokens, range) {
352
+ return tokens?.find(
353
+ (t) => t.range[1] === range[1] && t.value === "]"
354
+ );
355
+ }
356
+ function hasElements(elements) {
357
+ const nonNull = elements.filter(
358
+ (el) => el !== null
359
+ );
360
+ return nonNull.length >= 1;
361
+ }
362
+ function hasMultilineItems(nonNullElements) {
363
+ return nonNullElements.some(
364
+ (el) => el.loc.start.line !== el.loc.end.line
365
+ );
366
+ }
367
+ function isBracketOnOwnLine(sourceCode, openingBracket) {
368
+ const nextToken = sourceCode.getTokenAfter(openingBracket, {
369
+ includeComments: false
370
+ });
371
+ if (!nextToken)
372
+ return false;
373
+ const text = sourceCode.getText();
374
+ const openingBracketEndIndex = openingBracket.range[1];
375
+ const textBetween = text.slice(
376
+ openingBracketEndIndex,
377
+ nextToken.range[0]
378
+ );
379
+ return textBetween.includes("\n");
380
+ }
381
+ const messageIds$a = {
382
+ compactItems: "Array items should be compact when the array spans multiple lines."
383
+ };
384
+ const compactArrayItems = {
385
+ create(context) {
386
+ const sourceCode = context.sourceCode ?? context.getSourceCode();
387
+ return {
388
+ ArrayExpression(node2) {
389
+ if (!hasElements(node2.elements))
390
+ return;
391
+ const tokens = sourceCode.ast.tokens;
392
+ const openingBracket = findBracketByRange(tokens, node2.range, "[");
393
+ const closingBracket = findClosingBracketByRange(
394
+ tokens,
395
+ node2.range
396
+ );
397
+ if (!openingBracket || !closingBracket)
398
+ return;
399
+ if (!isBracketOnOwnLine(sourceCode, openingBracket))
400
+ return;
401
+ const nonNullElements = node2.elements.filter(
402
+ (el) => el !== null
403
+ );
404
+ if (!hasMultilineItems(nonNullElements))
405
+ return;
406
+ context.report({
407
+ fix: (fixer) => buildCompactFix(
408
+ fixer,
409
+ openingBracket,
410
+ closingBracket,
411
+ node2.elements,
412
+ sourceCode
413
+ ),
414
+ messageId: "compactItems",
415
+ node: node2
416
+ });
417
+ }
418
+ };
419
+ },
420
+ meta: {
421
+ docs: {
422
+ description: "Enforce arrays with multiline items to have a compact, inline bracket style."
423
+ },
424
+ fixable: "code",
425
+ messages: messageIds$a,
426
+ schema: [],
427
+ type: "layout"
428
+ }
429
+ };
430
+ function getNameFromDeclaration(node2) {
431
+ const names = [];
432
+ switch (node2.type) {
433
+ case "ClassDeclaration":
434
+ if (node2.id)
435
+ names.push(node2.id.name);
436
+ break;
437
+ case "FunctionDeclaration":
438
+ if (node2.id)
439
+ names.push(node2.id.name);
440
+ break;
441
+ case "TSInterfaceDeclaration":
442
+ names.push(node2.id.name);
443
+ break;
444
+ case "TSTypeAliasDeclaration":
445
+ names.push(node2.id.name);
446
+ break;
447
+ case "VariableDeclaration":
448
+ for (const d of node2.declarations) {
449
+ if (d.id.type === "Identifier")
450
+ names.push(d.id.name);
451
+ }
452
+ break;
453
+ }
454
+ return names;
455
+ }
456
+ function getNamesFromSpecifiers(node2) {
457
+ if (!node2.specifiers?.length)
458
+ return [];
459
+ const names = [];
460
+ for (const specifier of node2.specifiers) {
461
+ if (specifier.exported.type === "Identifier")
462
+ names.push(specifier.exported.name);
463
+ }
464
+ return names;
465
+ }
466
+ function getExportedNames(node2) {
467
+ const specifierNames = getNamesFromSpecifiers(node2);
468
+ if (!node2.declaration)
469
+ return specifierNames;
470
+ const declarationNames = getNameFromDeclaration(node2.declaration);
471
+ return [...specifierNames, ...declarationNames];
472
+ }
473
+ function stripExtension(filename) {
474
+ return path.basename(filename, path.extname(filename));
475
+ }
476
+ function isExempt$1(filename) {
477
+ const name = stripExtension(filename);
478
+ return name === "index" || name.endsWith(".test") || name.endsWith(".spec") || name.endsWith(".config");
479
+ }
480
+ const messageIds$9 = {
481
+ filenameMismatch: "File name must be '{{expectedName}}' instead of '{{currentName}}'."
482
+ };
483
+ const exportFilenameMatch = {
484
+ create(context) {
485
+ const fileName = context.filename;
486
+ const baseName = path.basename(fileName);
487
+ const ext = path.extname(baseName);
488
+ const fileNameWithoutExt = baseName.slice(0, -ext.length);
489
+ if (isExempt$1(fileName))
490
+ return {};
491
+ const exportNames = [];
492
+ return {
493
+ ExportNamedDeclaration(node2) {
494
+ const names = getExportedNames(node2);
495
+ exportNames.push(...names);
496
+ },
497
+ "Program:exit"(programNode) {
498
+ if (exportNames.length === 1) {
499
+ const [exportName] = exportNames;
500
+ if (exportName !== fileNameWithoutExt) {
501
+ context.report({
502
+ data: {
503
+ currentName: `${fileNameWithoutExt}${ext}`,
504
+ expectedName: `${exportName}${ext}`
505
+ },
506
+ messageId: "filenameMismatch",
507
+ node: programNode
508
+ });
509
+ }
510
+ }
511
+ }
512
+ };
513
+ },
514
+ meta: {
515
+ docs: {
516
+ description: "Enforce filename matches the single named export."
517
+ },
518
+ messages: messageIds$9,
519
+ schema: [],
520
+ type: "suggestion"
521
+ }
522
+ };
523
+ function findLinesWithMultipleNodes(nodes) {
524
+ const lines = [];
525
+ for (let i = 0; i < nodes.length; i++) {
526
+ const node2 = nodes[i];
527
+ const nodeLine = node2.loc.start.line;
528
+ if (i < nodes.length - 1) {
529
+ const nextNode = nodes[i + 1];
530
+ if (nextNode.loc.start.line === nodeLine)
531
+ lines.push(nodeLine);
532
+ }
533
+ }
534
+ return lines;
535
+ }
536
+ function formatArgs(sourceCode, nodes, indent) {
537
+ return nodes.map((arg, index) => {
538
+ const argText = sourceCode.getText(arg);
539
+ const isLast = index === nodes.length - 1;
540
+ if (isLast)
541
+ return argText;
542
+ const comma = sourceCode.getTokenAfter(arg, (token) => token.value === ",");
543
+ if (comma && comma.loc.end.line === arg.loc.end.line)
544
+ return argText + ",";
545
+ return argText;
546
+ }).map(
547
+ (text, index) => index === 0 ? `${indent}${text}` : `
548
+ ${indent}${text}`
549
+ ).join("");
550
+ }
551
+ function getLineStartIndex(sourceCode, line) {
552
+ const lines = sourceCode.getLines();
553
+ return lines.slice(0, line - 1).reduce(
554
+ (acc, l) => acc + l.length + 1,
555
+ 0
556
+ );
557
+ }
558
+ function checkMultilineArgs(sourceCode, context, args, maxLength) {
559
+ const linesWithMultipleArgs = findLinesWithMultipleNodes(args);
560
+ for (const line of linesWithMultipleArgs) {
561
+ const lineLength = getLineLength(sourceCode, line);
562
+ if (lineLength > maxLength) {
563
+ context.report({
564
+ data: { maxLength },
565
+ fix: (fixer) => {
566
+ const nodesOnLine = args.filter(
567
+ (arg) => arg.loc.start.line <= line && arg.loc.end.line >= line
568
+ );
569
+ const lastNode = nodesOnLine[nodesOnLine.length - 1];
570
+ const lineStartIndex = getLineStartIndex(sourceCode, line);
571
+ const baseIndent = sourceCode.getText().match(/^[\t ]*/)?.[0] ?? "";
572
+ const indent = baseIndent + " ";
573
+ const fixed = formatArgs(sourceCode, nodesOnLine, indent);
574
+ return fixer.replaceTextRange(
575
+ [lineStartIndex, lastNode.range[1]],
576
+ fixed
577
+ );
578
+ },
579
+ loc: {
580
+ end: {
581
+ column: lineLength,
582
+ line
583
+ },
584
+ start: {
585
+ column: 0,
586
+ line
587
+ }
588
+ },
589
+ messageId: "multipleOnSameLine"
590
+ });
591
+ }
592
+ }
593
+ }
594
+ function checkSingleLineArgs(sourceCode, context, args, parens, maxLength) {
595
+ const { closingParen, openingParen } = parens;
596
+ const lineLength = getLineLength(sourceCode, openingParen.loc.start.line);
597
+ if (lineLength <= maxLength)
598
+ return;
599
+ if (args.length === 1) {
600
+ context.report({
601
+ data: { maxLength },
602
+ loc: {
603
+ end: {
604
+ column: lineLength,
605
+ line: closingParen.loc.end.line
606
+ },
607
+ start: {
608
+ column: 0,
609
+ line: openingParen.loc.start.line
610
+ }
611
+ },
612
+ messageId: "exceedsMaxLength"
613
+ });
614
+ return;
615
+ }
616
+ context.report({
617
+ data: { maxLength },
618
+ fix: (fixer) => {
619
+ const indent = sourceCode.getText().match(/^[\t ]*/)?.[0] ?? "";
620
+ const argTexts = args.map((arg) => {
621
+ const argText = sourceCode.getText(arg);
622
+ const comma = sourceCode.getTokenAfter(
623
+ arg,
624
+ (token) => token.value === ","
625
+ );
626
+ if (comma && comma.loc.end.line === arg.loc.end.line)
627
+ return argText + ",";
628
+ return argText;
629
+ });
630
+ const fixed = [
631
+ "(\n",
632
+ `${indent} ${argTexts.join(`
633
+ ${indent} `)}
634
+ `,
635
+ `${indent})`
636
+ ].join("");
637
+ return fixer.replaceTextRange(
638
+ [openingParen.range[0], closingParen.range[1]],
639
+ fixed
640
+ );
641
+ },
642
+ loc: {
643
+ end: {
644
+ column: lineLength,
645
+ line: closingParen.loc.end.line
646
+ },
647
+ start: {
648
+ column: 0,
649
+ line: openingParen.loc.start.line
650
+ }
651
+ },
652
+ messageId: "multipleOnSameLine"
653
+ });
654
+ }
655
+ const defaultOptions$5 = {
656
+ maxLength: 80
657
+ };
658
+ function getParens$1(sourceCode, nodes) {
659
+ if (nodes.length === 0)
660
+ return null;
661
+ const firstNode = nodes[0];
662
+ const lastNode = nodes[nodes.length - 1];
663
+ const openingParen = sourceCode.getTokenBefore(firstNode);
664
+ const closingParen = sourceCode.getTokenAfter(lastNode);
665
+ if (!openingParen || !closingParen)
666
+ return null;
667
+ return { closingParen, openingParen };
668
+ }
669
+ function isValidParens(parens) {
670
+ if (!parens)
671
+ return false;
672
+ return parens.openingParen.value === "(" && parens.closingParen.value === ")";
673
+ }
674
+ function checkCall(sourceCode, context, node2) {
675
+ const options = context.options[0] ?? {};
676
+ const maxLength = options.maxLength ?? defaultOptions$5.maxLength;
677
+ const args = node2.arguments;
678
+ const parens = getParens$1(sourceCode, args);
679
+ if (!isValidParens(parens))
680
+ return;
681
+ const firstLine = parens.openingParen.loc.start.line;
682
+ const lastLine = parens.closingParen.loc.end.line;
683
+ if (firstLine === lastLine)
684
+ checkSingleLineArgs(sourceCode, context, args, parens, maxLength);
685
+ else
686
+ checkMultilineArgs(sourceCode, context, args, maxLength);
687
+ }
688
+ const messageIds$8 = {
689
+ exceedsMaxLength: "Refactor this function call as it exceeds {{maxLength}} characters",
690
+ multipleOnSameLine: "Each argument must be on its own line"
691
+ };
692
+ const functionCallArgumentLineBreak = {
693
+ create(context) {
694
+ const sourceCode = context.sourceCode ?? context.getSourceCode();
695
+ return {
696
+ CallExpression(node2) {
697
+ checkCall(sourceCode, context, node2);
698
+ },
699
+ OptionalCallExpression(node2) {
700
+ checkCall(sourceCode, context, node2);
701
+ }
702
+ };
703
+ },
704
+ meta: {
705
+ docs: {
706
+ description: "Enforce each function call argument to be on its own line when line exceeds max length."
707
+ },
708
+ fixable: "code",
709
+ messages: messageIds$8,
710
+ schema: [{
711
+ additionalProperties: false,
712
+ properties: {
713
+ maxLength: {
714
+ type: "number"
715
+ }
716
+ },
717
+ type: "object"
718
+ }],
719
+ type: "layout"
720
+ }
721
+ };
722
+ function isNodeWithType(value) {
723
+ return value !== null && typeof value === "object" && "type" in value;
724
+ }
725
+ const SKIP_KEYS = /* @__PURE__ */ new Set(["loc", "parent", "range"]);
726
+ function getChildNodes(node2) {
727
+ const children = [];
728
+ for (const key of Object.keys(node2)) {
729
+ if (SKIP_KEYS.has(key))
730
+ continue;
731
+ const value = node2[key];
732
+ if (Array.isArray(value)) {
733
+ for (const item of value) {
734
+ if (isNodeWithType(item))
735
+ children.push(item);
736
+ }
737
+ } else if (isNodeWithType(value))
738
+ children.push(value);
739
+ }
740
+ return children;
741
+ }
742
+ const INCREMENTABLE_TYPES = /* @__PURE__ */ new Set([
743
+ "ConditionalExpression",
744
+ "DoWhileStatement",
745
+ "ForInStatement",
746
+ "ForOfStatement",
747
+ "ForStatement",
748
+ "IfStatement",
749
+ "LogicalExpression",
750
+ "SwitchStatement",
751
+ "TryStatement",
752
+ "WhileStatement"
753
+ ]);
754
+ function isIncrementableControlFlow(node2) {
755
+ return INCREMENTABLE_TYPES.has(node2.type);
756
+ }
757
+ function traverse(node2, nestingLevel, state) {
758
+ if (isIncrementableControlFlow(node2)) {
759
+ state.complexity += 1 + nestingLevel;
760
+ nestingLevel++;
761
+ }
762
+ const children = getChildNodes(node2);
763
+ for (const child of children)
764
+ traverse(child, nestingLevel, state);
765
+ }
766
+ function calculateCognitiveComplexity(node2) {
767
+ const state = {
768
+ complexity: 0
769
+ };
770
+ const children = getChildNodes(node2);
771
+ for (const child of children)
772
+ traverse(child, 0, state);
773
+ return state.complexity;
774
+ }
775
+ function getNameFromCallExpression(node2) {
776
+ if (node2?.type === "CallExpression" && node2.callee?.type === "Identifier")
777
+ return `${node2.callee.name} callback`;
778
+ return null;
779
+ }
780
+ function getNameFromProperty(node2) {
781
+ if (node2?.type === "Property" && node2.key?.type === "Identifier")
782
+ return node2.key.name;
783
+ return null;
784
+ }
785
+ function getNameFromVariableDeclarator(node2) {
786
+ if (node2?.type === "VariableDeclarator" && node2.id?.type === "Identifier")
787
+ return node2.id.name;
788
+ return null;
789
+ }
790
+ function getArrowFunctionExpressionName(node2) {
791
+ const parent = node2.parent;
792
+ const nameFromVar = getNameFromVariableDeclarator(parent);
793
+ if (nameFromVar)
794
+ return nameFromVar;
795
+ const nameFromProp = getNameFromProperty(parent);
796
+ if (nameFromProp)
797
+ return nameFromProp;
798
+ const nameFromCall = getNameFromCallExpression(parent);
799
+ if (nameFromCall)
800
+ return nameFromCall;
801
+ return null;
802
+ }
803
+ function getNameFromMethodDefinition(node2) {
804
+ if (node2?.type === "MethodDefinition" && node2.key?.type === "Identifier")
805
+ return node2.key.name;
806
+ return null;
807
+ }
808
+ function getFunctionExpressionName(node2) {
809
+ const parent = node2.parent;
810
+ const nameFromVar = getNameFromVariableDeclarator(parent);
811
+ if (nameFromVar)
812
+ return nameFromVar;
813
+ const nameFromProp = getNameFromProperty(parent);
814
+ if (nameFromProp)
815
+ return nameFromProp;
816
+ const nameFromMethod = getNameFromMethodDefinition(parent);
817
+ if (nameFromMethod)
818
+ return nameFromMethod;
819
+ return null;
820
+ }
821
+ function getFunctionName(node2) {
822
+ if (node2.type === "FunctionDeclaration" && node2.id?.name)
823
+ return node2.id.name;
824
+ if (node2.type === "FunctionExpression")
825
+ return getFunctionExpressionName(node2);
826
+ if (node2.type === "ArrowFunctionExpression")
827
+ return getArrowFunctionExpressionName(node2);
828
+ return null;
829
+ }
830
+ const messageIds$7 = {
831
+ tooHighCognitiveComplexity: "Function '{{name}}' has cognitive complexity of {{actual}} (max: {{max}}). Consider extracting sub-functions.",
832
+ tooHighCognitiveComplexityAnonymous: "Anonymous function has cognitive complexity of {{actual}} (max: {{max}}). Consider extracting sub-functions."
833
+ };
834
+ const DEFAULT_MAX_COGNITIVE_COMPLEXITY = 15;
835
+ const functionCognitiveComplexity = {
836
+ create(context) {
837
+ const options = context.options[0] ?? {};
838
+ const maxCognitiveComplexity = options.maxCognitiveComplexity ?? DEFAULT_MAX_COGNITIVE_COMPLEXITY;
839
+ function checkFunction2(node2) {
840
+ const complexity = calculateCognitiveComplexity(node2);
841
+ if (complexity > maxCognitiveComplexity) {
842
+ const name = getFunctionName(node2);
843
+ if (name) {
844
+ context.report({
845
+ data: {
846
+ actual: complexity,
847
+ max: maxCognitiveComplexity,
848
+ name
849
+ },
850
+ messageId: "tooHighCognitiveComplexity",
851
+ node: node2
852
+ });
853
+ } else {
854
+ context.report({
855
+ data: {
856
+ actual: complexity,
857
+ max: maxCognitiveComplexity
858
+ },
859
+ messageId: "tooHighCognitiveComplexityAnonymous",
860
+ node: node2
861
+ });
862
+ }
863
+ }
864
+ }
865
+ return {
866
+ ArrowFunctionExpression(node2) {
867
+ checkFunction2(node2);
868
+ },
869
+ FunctionDeclaration(node2) {
870
+ checkFunction2(node2);
871
+ },
872
+ FunctionExpression(node2) {
873
+ checkFunction2(node2);
874
+ }
875
+ };
876
+ },
877
+ meta: {
878
+ docs: {
879
+ description: "Enforce cognitive complexity threshold for functions."
880
+ },
881
+ messages: messageIds$7,
882
+ schema: [{
883
+ additionalProperties: false,
884
+ properties: {
885
+ maxCognitiveComplexity: {
886
+ type: "number"
887
+ }
888
+ },
889
+ type: "object"
890
+ }],
891
+ type: "suggestion"
892
+ }
893
+ };
894
+ function formatParams(sourceCode, nodes, indent) {
895
+ return nodes.map((param, index) => {
896
+ const paramText = sourceCode.getText(param);
897
+ const isLast = index === nodes.length - 1;
898
+ if (isLast)
899
+ return paramText;
900
+ const comma = sourceCode.getTokenAfter(
901
+ param,
902
+ (token) => token.value === ","
903
+ );
904
+ if (comma && comma.loc.end.line === param.loc.end.line)
905
+ return paramText + ",";
906
+ return paramText;
907
+ }).map(
908
+ (text, index) => index === 0 ? `${indent}${text}` : `
909
+ ${indent}${text}`
910
+ ).join("");
911
+ }
912
+ function checkMultilineParams(sourceCode, context, params, parens, maxLength) {
913
+ const linesWithMultipleParams = findLinesWithMultipleNodes(params);
914
+ for (const line of linesWithMultipleParams) {
915
+ const lineLength = getLineLength(sourceCode, line);
916
+ if (lineLength > maxLength) {
917
+ context.report({
918
+ data: { maxLength },
919
+ fix: (fixer) => {
920
+ const nodesOnLine = params.filter(
921
+ (param) => param.loc.start.line <= line && param.loc.end.line >= line
922
+ );
923
+ const lastNode = nodesOnLine[nodesOnLine.length - 1];
924
+ const lineStartIndex = getLineStartIndex(sourceCode, line);
925
+ const baseIndent = sourceCode.getText().match(/^[\t ]*/)?.[0] ?? "";
926
+ const indent = baseIndent + " ";
927
+ const fixed = formatParams(sourceCode, nodesOnLine, indent);
928
+ return fixer.replaceTextRange(
929
+ [lineStartIndex, lastNode.range[1]],
930
+ fixed
931
+ );
932
+ },
933
+ loc: {
934
+ end: {
935
+ column: lineLength,
936
+ line
937
+ },
938
+ start: {
939
+ column: 0,
940
+ line
941
+ }
942
+ },
943
+ messageId: "multipleOnSameLine"
944
+ });
945
+ }
946
+ }
947
+ }
948
+ function checkSingleLineParams(sourceCode, context, params, parens, maxLength) {
949
+ const { closingParen, openingParen } = parens;
950
+ const lineLength = getLineLength(sourceCode, openingParen.loc.start.line);
951
+ if (lineLength <= maxLength)
952
+ return;
953
+ if (params.length === 1) {
954
+ context.report({
955
+ data: { maxLength },
956
+ loc: {
957
+ end: {
958
+ column: lineLength,
959
+ line: closingParen.loc.end.line
960
+ },
961
+ start: {
962
+ column: 0,
963
+ line: openingParen.loc.start.line
964
+ }
965
+ },
966
+ messageId: "exceedsMaxLength"
967
+ });
968
+ return;
969
+ }
970
+ context.report({
971
+ data: { maxLength },
972
+ fix: (fixer) => {
973
+ const indent = sourceCode.getText().match(/^[\t ]*/)?.[0] ?? "";
974
+ const paramTexts = params.map((param) => {
975
+ const paramText = sourceCode.getText(param);
976
+ const comma = sourceCode.getTokenAfter(
977
+ param,
978
+ (token) => token.value === ","
979
+ );
980
+ if (comma && comma.loc.end.line === param.loc.end.line)
981
+ return paramText + ",";
982
+ return paramText;
983
+ });
984
+ const fixed = [
985
+ "(\n",
986
+ `${indent} ${paramTexts.join(`
987
+ ${indent} `)}
988
+ `,
989
+ `${indent})`
990
+ ].join("");
991
+ return fixer.replaceTextRange(
992
+ [openingParen.range[0], closingParen.range[1]],
993
+ fixed
994
+ );
995
+ },
996
+ loc: {
997
+ end: {
998
+ column: lineLength,
999
+ line: closingParen.loc.end.line
1000
+ },
1001
+ start: {
1002
+ column: 0,
1003
+ line: openingParen.loc.start.line
1004
+ }
1005
+ },
1006
+ messageId: "multipleOnSameLine"
1007
+ });
1008
+ }
1009
+ const defaultOptions$4 = {
1010
+ maxLength: 80
1011
+ };
1012
+ function checkFunction$1(sourceCode, context, node2) {
1013
+ const options = context.options[0] ?? {};
1014
+ const maxLength = options.maxLength ?? defaultOptions$4.maxLength;
1015
+ const params = node2.params;
1016
+ if (params.length === 0)
1017
+ return;
1018
+ const parens = getParens$1(sourceCode, params);
1019
+ if (!isValidParens(parens))
1020
+ return;
1021
+ const firstLine = parens.openingParen.loc.start.line;
1022
+ const lastLine = parens.closingParen.loc.end.line;
1023
+ if (firstLine === lastLine)
1024
+ checkSingleLineParams(sourceCode, context, params, parens, maxLength);
1025
+ else
1026
+ checkMultilineParams(sourceCode, context, params, parens, maxLength);
1027
+ }
1028
+ const messageIds$6 = {
1029
+ exceedsMaxLength: "Refactor this function signature as it exceeds {{maxLength}} characters",
1030
+ multipleOnSameLine: "Each parameter must be on its own line"
1031
+ };
1032
+ const functionParameterLineBreak = {
1033
+ create(context) {
1034
+ const sourceCode = context.sourceCode ?? context.getSourceCode();
1035
+ return {
1036
+ ArrowFunctionExpression(node2) {
1037
+ if (node2.expression)
1038
+ return;
1039
+ checkFunction$1(sourceCode, context, node2);
1040
+ },
1041
+ FunctionDeclaration(node2) {
1042
+ checkFunction$1(sourceCode, context, node2);
1043
+ },
1044
+ FunctionExpression(node2) {
1045
+ checkFunction$1(sourceCode, context, node2);
1046
+ },
1047
+ TSCallSignatureDeclaration(node2) {
1048
+ checkFunction$1(sourceCode, context, node2);
1049
+ },
1050
+ TSFunctionType(node2) {
1051
+ checkFunction$1(sourceCode, context, node2);
1052
+ },
1053
+ TSMethodSignature(node2) {
1054
+ checkFunction$1(sourceCode, context, node2);
1055
+ }
1056
+ };
1057
+ },
1058
+ meta: {
1059
+ docs: {
1060
+ description: "Enforce each function parameter to be on its own line when line exceeds max length."
1061
+ },
1062
+ fixable: "code",
1063
+ messages: messageIds$6,
1064
+ schema: [{
1065
+ additionalProperties: false,
1066
+ properties: {
1067
+ maxLength: {
1068
+ type: "number"
1069
+ }
1070
+ },
1071
+ type: "object"
1072
+ }],
1073
+ type: "layout"
1074
+ }
1075
+ };
7
1076
  function getStatementType(statement) {
8
- if (statement.type === "ImportDeclaration") return "import";
9
- if (statement.type === "ExportAllDeclaration") return "re-export";
10
- if (statement.type === "ExportNamedDeclaration") {
11
- if (statement.source !== null) return "re-export";
12
- }
13
- return "other";
14
- }
15
- //#endregion
16
- //#region src/rules/importsAndReExportsAtTop/isImportDeclaration.ts
1077
+ if (statement.type === "ImportDeclaration")
1078
+ return "import";
1079
+ if (statement.type === "ExportAllDeclaration")
1080
+ return "re-export";
1081
+ if (statement.type === "ExportNamedDeclaration") {
1082
+ if (statement.source !== null)
1083
+ return "re-export";
1084
+ }
1085
+ return "other";
1086
+ }
17
1087
  function isImportDeclaration(statement) {
18
- return statement.type === "ImportDeclaration";
1088
+ return statement.type === "ImportDeclaration";
19
1089
  }
20
- //#endregion
21
- //#region src/rules/importsAndReExportsAtTop/isReExport.ts
22
1090
  function isReExport(statement) {
23
- if (statement.type === "ExportAllDeclaration") return true;
24
- if (statement.type === "ExportNamedDeclaration") return statement.source !== null;
25
- return false;
1091
+ if (statement.type === "ExportAllDeclaration")
1092
+ return true;
1093
+ if (statement.type === "ExportNamedDeclaration")
1094
+ return statement.source !== null;
1095
+ return false;
26
1096
  }
27
- //#endregion
28
- //#region src/rules/importsAndReExportsAtTop/categorizeStatements.ts
29
1097
  function categorizeStatements(statements) {
30
- const result = {
31
- imports: [],
32
- reExports: [],
33
- other: []
34
- };
35
- for (const statement of statements) {
36
- const type = getStatementType(statement);
37
- if (type === "import" && isImportDeclaration(statement)) result.imports.push(statement);
38
- else if (type === "re-export" && isReExport(statement)) result.reExports.push(statement);
39
- else result.other.push(statement);
40
- }
41
- return result;
42
- }
43
- //#endregion
44
- //#region src/rules/importsAndReExportsAtTop/findStatementIndices.ts
1098
+ const result = {
1099
+ imports: [],
1100
+ other: [],
1101
+ reExports: []
1102
+ };
1103
+ for (const statement of statements) {
1104
+ const type = getStatementType(statement);
1105
+ if (type === "import" && isImportDeclaration(statement))
1106
+ result.imports.push(statement);
1107
+ else if (type === "re-export" && isReExport(statement))
1108
+ result.reExports.push(statement);
1109
+ else
1110
+ result.other.push(statement);
1111
+ }
1112
+ return result;
1113
+ }
45
1114
  function findStatementIndices(statements) {
46
- let firstRegularStatement = -1;
47
- let lastImport = -1;
48
- let lastReExport = -1;
49
- for (let i = 0; i < statements.length; i++) {
50
- const type = getStatementType(statements[i]);
51
- if (type === "import") lastImport = i;
52
- else if (type === "re-export") lastReExport = i;
53
- else if (type === "other" && firstRegularStatement === -1) firstRegularStatement = i;
54
- }
55
- return {
56
- firstRegularStatement,
57
- lastImport,
58
- lastReExport
59
- };
60
- }
61
- //#endregion
62
- //#region src/rules/importsAndReExportsAtTop/generateSortedText.ts
1115
+ let firstRegularStatement = -1;
1116
+ let lastImport = -1;
1117
+ let lastReExport = -1;
1118
+ for (let i = 0; i < statements.length; i++) {
1119
+ const type = getStatementType(statements[i]);
1120
+ if (type === "import")
1121
+ lastImport = i;
1122
+ else if (type === "re-export")
1123
+ lastReExport = i;
1124
+ else if (type === "other" && firstRegularStatement === -1)
1125
+ firstRegularStatement = i;
1126
+ }
1127
+ return { firstRegularStatement, lastImport, lastReExport };
1128
+ }
63
1129
  function generateSortedText(context, categories) {
64
- return [
65
- ...categories.imports,
66
- ...categories.reExports,
67
- ...categories.other
68
- ].map((node) => context.sourceCode.getText(node)).join("\n");
69
- }
70
- //#endregion
71
- //#region src/rules/importsAndReExportsAtTop/hasViolation.ts
72
- function hasViolation(indices, categories) {
73
- const { firstRegularStatement, lastImport, lastReExport } = indices;
74
- if (categories.imports.length === 0 && categories.reExports.length === 0) return false;
75
- const hasImportAfterRegularStatement = categories.imports.length > 0 && firstRegularStatement !== -1 && lastImport > firstRegularStatement;
76
- const hasReExportAfterRegularStatement = categories.reExports.length > 0 && firstRegularStatement !== -1 && lastReExport > firstRegularStatement;
77
- return hasImportAfterRegularStatement || hasReExportAfterRegularStatement;
78
- }
79
- //#endregion
80
- //#region src/rules/importsAndReExportsAtTop/index.ts
1130
+ const allStatements = [
1131
+ ...categories.imports,
1132
+ ...categories.reExports,
1133
+ ...categories.other
1134
+ ];
1135
+ return allStatements.map(
1136
+ (node2) => context.sourceCode.getText(node2)
1137
+ ).join("\n");
1138
+ }
1139
+ function hasImportOrderViolation(indices, categories) {
1140
+ const { firstRegularStatement, lastImport, lastReExport } = indices;
1141
+ if (categories.imports.length === 0 && categories.reExports.length === 0)
1142
+ return false;
1143
+ const hasImportAfterRegularStatement = categories.imports.length > 0 && firstRegularStatement !== -1 && lastImport > firstRegularStatement;
1144
+ const hasReExportAfterRegularStatement = categories.reExports.length > 0 && firstRegularStatement !== -1 && lastReExport > firstRegularStatement;
1145
+ return hasImportAfterRegularStatement || hasReExportAfterRegularStatement;
1146
+ }
81
1147
  const importsAndReExportsAtTop = {
82
- meta: {
83
- type: "suggestion",
84
- docs: { description: "Enforce imports and re-exports at the top of the file" },
85
- fixable: "code",
86
- messages: { importsAndReExportsAtTop: "Imports and re-exports should be at the top of the file." },
87
- schema: []
88
- },
89
- create(context) {
90
- return { Program(node) {
91
- const statements = node.body;
92
- const categories = categorizeStatements(statements);
93
- if (!hasViolation(findStatementIndices(statements), categories)) return;
94
- context.report({
95
- node,
96
- messageId: "importsAndReExportsAtTop",
97
- fix(fixer) {
98
- const sortedText = generateSortedText(context, categories);
99
- return fixer.replaceText(node, sortedText);
100
- }
101
- });
102
- } };
103
- }
104
- };
105
- //#endregion
106
- //#region src/rules/individualImports.ts
1148
+ create(context) {
1149
+ return {
1150
+ Program(node2) {
1151
+ const statements = node2.body;
1152
+ const categories = categorizeStatements(statements);
1153
+ const indices = findStatementIndices(statements);
1154
+ if (!hasImportOrderViolation(indices, categories))
1155
+ return;
1156
+ context.report({
1157
+ fix(fixer) {
1158
+ const sortedText = generateSortedText(context, categories);
1159
+ return fixer.replaceText(node2, sortedText);
1160
+ },
1161
+ messageId: "importsAndReExportsAtTop",
1162
+ node: node2
1163
+ });
1164
+ }
1165
+ };
1166
+ },
1167
+ meta: {
1168
+ docs: {
1169
+ description: "Enforce imports and re-exports at the top of the file."
1170
+ },
1171
+ fixable: "code",
1172
+ messages: {
1173
+ importsAndReExportsAtTop: "Imports and re-exports should be at the top of the file."
1174
+ },
1175
+ schema: [],
1176
+ type: "suggestion"
1177
+ }
1178
+ };
107
1179
  const individualImports = {
108
- meta: {
109
- docs: { description: "Enforce individual imports instead of grouped imports" },
110
- fixable: "code",
111
- messages: { individualImports: "Use individual imports instead of grouped imports." },
112
- schema: [],
113
- type: "suggestion"
114
- },
115
- create(context) {
116
- return { ImportDeclaration(node) {
117
- if (node.specifiers.length <= 1) return;
118
- context.report({
119
- node,
120
- messageId: "individualImports",
121
- fix(fixer) {
122
- const source = node.source.raw;
123
- const specifiers = node.specifiers.filter((s) => s.type === "ImportSpecifier").map((s) => `import {${s.local.name}} from ${source}`).join("\n");
124
- return fixer.replaceText(node, specifiers);
125
- }
126
- });
127
- } };
128
- }
129
- };
130
- //#endregion
131
- //#region src/rules/individualReExports.ts
1180
+ create(context) {
1181
+ return {
1182
+ ImportDeclaration(node2) {
1183
+ if (node2.specifiers.length <= 1)
1184
+ return;
1185
+ context.report({
1186
+ fix(fixer) {
1187
+ const source = node2.source.raw;
1188
+ const specifiers = node2.specifiers.filter((s) => s.type === "ImportSpecifier").map((s) => `import {${s.local.name}} from ${source}`).join("\n");
1189
+ return fixer.replaceText(node2, specifiers);
1190
+ },
1191
+ messageId: "individualImports",
1192
+ node: node2
1193
+ });
1194
+ }
1195
+ };
1196
+ },
1197
+ meta: {
1198
+ docs: {
1199
+ description: "Enforce individual imports instead of grouped imports."
1200
+ },
1201
+ fixable: "code",
1202
+ messages: {
1203
+ individualImports: "Use individual imports instead of grouped imports."
1204
+ },
1205
+ schema: [],
1206
+ type: "suggestion"
1207
+ }
1208
+ };
132
1209
  const individualReExports = {
133
- meta: {
134
- docs: { description: "Enforce individual exports instead of grouped exports" },
135
- fixable: "code",
136
- messages: { individualReExports: "Use individual exports instead of grouped exports." },
137
- schema: [],
138
- type: "suggestion"
139
- },
140
- create(context) {
141
- return { ExportNamedDeclaration(node) {
142
- if (!node.source || node.specifiers.length <= 1) return;
143
- context.report({
144
- node,
145
- messageId: "individualReExports",
146
- fix(fixer) {
147
- const source = node.source.value;
148
- const typeKeyword = node.exportKind === "type" ? "type " : "";
149
- const specifiers = node.specifiers.map((s) => {
150
- const localName = s.local.type === "Identifier" ? s.local.name : s.local.value;
151
- const exportedName = s.exported.type === "Identifier" ? s.exported.name : s.exported.value;
152
- return `export ${typeKeyword}{${localName === exportedName ? localName : `${localName} as ${exportedName}`}} from '${source}'`;
153
- }).join("\n");
154
- return fixer.replaceText(node, specifiers);
155
- }
156
- });
157
- } };
158
- }
159
- };
160
- //#endregion
161
- //#region src/rules/multilineUnionTypes/createFix.ts
162
- function createFix$4(fixer, node, sourceCode) {
163
- const result = `\n${node.types.map((t) => sourceCode.getText(t)).map((t) => ` | ${t}`).join("\n")}`;
164
- return fixer.replaceText(node, result);
165
- }
166
- //#endregion
167
- //#region src/rules/multilineUnionTypes/isMultiline.ts
168
- function isMultiline$2(unionType) {
169
- const { start, end } = unionType.loc ?? {};
170
- return start?.line !== end?.line;
171
- }
172
- //#endregion
173
- //#region src/rules/multilineUnionTypes/index.ts
174
- const multilineUnionTypes = {
175
- meta: {
176
- docs: { description: "Enforce union types with multiple members to be on multiple lines" },
177
- fixable: "code",
178
- messages: {
179
- singleLine: "Union types with multiple members should be on multiple lines",
180
- missingPipes: "Multiline union types should have leading pipes on each member"
181
- },
182
- schema: [],
183
- type: "layout"
184
- },
185
- create(context) {
186
- return { TSUnionType(node) {
187
- if (node.types.length < 2) return;
188
- const sourceCode = context.sourceCode;
189
- if (sourceCode.getText(node).trim().startsWith("|")) return;
190
- if (!isMultiline$2(node)) {
191
- context.report({
192
- node,
193
- messageId: "singleLine",
194
- fix: (fixer) => createFix$4(fixer, node, sourceCode)
195
- });
196
- return;
197
- }
198
- context.report({
199
- node,
200
- messageId: "missingPipes",
201
- fix: (fixer) => createFix$4(fixer, node, sourceCode)
202
- });
203
- } };
204
- }
205
- };
206
- //#endregion
207
- //#region src/rules/singleLineImports/formatAttributes.ts
1210
+ create(context) {
1211
+ return {
1212
+ ExportNamedDeclaration(node2) {
1213
+ if (!node2.source || node2.specifiers.length <= 1)
1214
+ return;
1215
+ context.report({
1216
+ fix(fixer) {
1217
+ const source = node2.source.value;
1218
+ const typeKeyword = node2.exportKind === "type" ? "type " : "";
1219
+ const specifiers = node2.specifiers.map((s) => {
1220
+ const localName = s.local.type === "Identifier" ? s.local.name : s.local.value;
1221
+ const exportedName = s.exported.type === "Identifier" ? s.exported.name : s.exported.value;
1222
+ const name = localName === exportedName ? localName : `${localName} as ${exportedName}`;
1223
+ return `export ${typeKeyword}{${name}} from '${source}'`;
1224
+ }).join("\n");
1225
+ return fixer.replaceText(node2, specifiers);
1226
+ },
1227
+ messageId: "individualReExports",
1228
+ node: node2
1229
+ });
1230
+ }
1231
+ };
1232
+ },
1233
+ meta: {
1234
+ docs: {
1235
+ description: "Enforce individual exports instead of grouped exports."
1236
+ },
1237
+ fixable: "code",
1238
+ messages: {
1239
+ individualReExports: "Use individual exports instead of grouped exports."
1240
+ },
1241
+ schema: [],
1242
+ type: "suggestion"
1243
+ }
1244
+ };
1245
+ function formatTypeLiteral(sourceCode, typeLiteral, baseIndent) {
1246
+ const members = typeLiteral.members;
1247
+ if (members.length === 0)
1248
+ return "{}";
1249
+ const memberTexts = members.map((member) => {
1250
+ if (member.type === "TSPropertySignature") {
1251
+ const memberText = sourceCode.getText(member);
1252
+ return memberText.replace(/,\s*$/, "");
1253
+ }
1254
+ return sourceCode.getText(member).replace(/,\s*$/, "");
1255
+ });
1256
+ const innerIndent = baseIndent + " ";
1257
+ const lines = [
1258
+ "{",
1259
+ innerIndent + memberTexts.join(`
1260
+ ${innerIndent}`),
1261
+ `${baseIndent}}`
1262
+ ];
1263
+ return lines.join("\n");
1264
+ }
1265
+ function checkMultilineMembers(sourceCode, context, members, maxLength) {
1266
+ for (const member of members) {
1267
+ const memberLine = member.loc.start.line;
1268
+ const lineLength = getLineLength(sourceCode, memberLine);
1269
+ if (lineLength > maxLength) {
1270
+ let fix;
1271
+ if (member.type === "TSPropertySignature" && member.typeAnnotation && member.typeAnnotation.typeAnnotation.type === "TSTypeLiteral") {
1272
+ const typeLiteral = member.typeAnnotation.typeAnnotation;
1273
+ fix = (fixer) => {
1274
+ const baseIndent = getLineIndent$1(sourceCode, memberLine);
1275
+ const formatted = formatTypeLiteral(
1276
+ sourceCode,
1277
+ typeLiteral,
1278
+ baseIndent
1279
+ );
1280
+ return fixer.replaceText(typeLiteral, formatted);
1281
+ };
1282
+ }
1283
+ context.report({
1284
+ data: { maxLength },
1285
+ fix,
1286
+ loc: {
1287
+ end: {
1288
+ column: lineLength,
1289
+ line: memberLine
1290
+ },
1291
+ start: {
1292
+ column: 0,
1293
+ line: memberLine
1294
+ }
1295
+ },
1296
+ messageId: "exceedsMaxLength"
1297
+ });
1298
+ }
1299
+ }
1300
+ }
1301
+ function checkSingleLineMembers(sourceCode, context, members, parens, maxLength) {
1302
+ const { closingBrace, openingBrace } = parens;
1303
+ const lineLength = getLineLength(sourceCode, openingBrace.loc.start.line);
1304
+ if (lineLength <= maxLength)
1305
+ return;
1306
+ if (members.length === 1) {
1307
+ context.report({
1308
+ data: { maxLength },
1309
+ loc: {
1310
+ end: {
1311
+ column: lineLength,
1312
+ line: closingBrace.loc.end.line
1313
+ },
1314
+ start: {
1315
+ column: 0,
1316
+ line: openingBrace.loc.start.line
1317
+ }
1318
+ },
1319
+ messageId: "exceedsMaxLength"
1320
+ });
1321
+ return;
1322
+ }
1323
+ context.report({
1324
+ data: { maxLength },
1325
+ fix: (fixer) => {
1326
+ const indent = sourceCode.getText().match(/^[\t ]*/)?.[0] ?? "";
1327
+ const memberTexts = members.map((member, index) => {
1328
+ const memberText = sourceCode.getText(member).replace(/,\s*$/, "");
1329
+ const isLast = index === members.length - 1;
1330
+ if (!isLast)
1331
+ return memberText + ",";
1332
+ return memberText;
1333
+ });
1334
+ const fixed = [
1335
+ "{\n",
1336
+ `${indent} ${memberTexts.join(`
1337
+ ${indent} `)}
1338
+ `,
1339
+ `${indent}}`
1340
+ ].join("");
1341
+ return fixer.replaceTextRange(
1342
+ [openingBrace.range[0], closingBrace.range[1]],
1343
+ fixed
1344
+ );
1345
+ },
1346
+ loc: {
1347
+ end: {
1348
+ column: lineLength,
1349
+ line: closingBrace.loc.end.line
1350
+ },
1351
+ start: {
1352
+ column: 0,
1353
+ line: openingBrace.loc.start.line
1354
+ }
1355
+ },
1356
+ messageId: "multipleOnSameLine"
1357
+ });
1358
+ }
1359
+ const defaultOptions$3 = {
1360
+ maxLength: 80
1361
+ };
1362
+ function getBraces$1(sourceCode, body) {
1363
+ const openingBrace = sourceCode.getTokenBefore(body.body[0]);
1364
+ const closingBrace = sourceCode.getTokenAfter(body.body[body.body.length - 1]);
1365
+ if (!openingBrace || !closingBrace)
1366
+ return null;
1367
+ return { closingBrace, openingBrace };
1368
+ }
1369
+ function checkInterface(sourceCode, context, node2) {
1370
+ const options = context.options[0] ?? {};
1371
+ const maxLength = options.maxLength ?? defaultOptions$3.maxLength;
1372
+ const body = node2.body;
1373
+ if (!body || body.body.length === 0)
1374
+ return;
1375
+ const braces = getBraces$1(sourceCode, body);
1376
+ if (!braces)
1377
+ return;
1378
+ const firstLine = braces.openingBrace.loc.start.line;
1379
+ const lastLine = braces.closingBrace.loc.end.line;
1380
+ if (firstLine === lastLine)
1381
+ checkSingleLineMembers(sourceCode, context, body.body, braces, maxLength);
1382
+ else
1383
+ checkMultilineMembers(sourceCode, context, body.body, maxLength);
1384
+ }
1385
+ const messageIds$5 = {
1386
+ exceedsMaxLength: "Interface line exceeds {{maxLength}} characters",
1387
+ multipleOnSameLine: "Interface members should each be on their own line when line exceeds {{maxLength}} characters"
1388
+ };
1389
+ const interfacePropertyLineBreak = {
1390
+ create(context) {
1391
+ const sourceCode = context.sourceCode ?? context.getSourceCode();
1392
+ return {
1393
+ TSInterfaceDeclaration(node2) {
1394
+ checkInterface(sourceCode, context, node2);
1395
+ }
1396
+ };
1397
+ },
1398
+ meta: {
1399
+ docs: {
1400
+ description: "Enforce each interface member to be on its own line when line exceeds max length."
1401
+ },
1402
+ fixable: "code",
1403
+ messages: messageIds$5,
1404
+ schema: [{
1405
+ additionalProperties: false,
1406
+ properties: {
1407
+ maxLength: {
1408
+ type: "number"
1409
+ }
1410
+ },
1411
+ type: "object"
1412
+ }],
1413
+ type: "layout"
1414
+ }
1415
+ };
1416
+ function collectVariableDeclarators(node2, types) {
1417
+ for (const declarator of node2.declarations) {
1418
+ if (declarator.id.type === "Identifier" && declarator.id.name)
1419
+ types.add(declarator.id.name);
1420
+ }
1421
+ }
1422
+ function isTopLevel(node2) {
1423
+ if (node2.parent?.type === "Program")
1424
+ return true;
1425
+ if (node2.parent?.type === "ExportNamedDeclaration" && node2.parent.parent?.type === "Program")
1426
+ return true;
1427
+ return false;
1428
+ }
1429
+ function handleClassDeclaration(node2, functions) {
1430
+ if (isTopLevel(node2) && node2.id?.name)
1431
+ functions.add(node2.id.name);
1432
+ }
1433
+ function handleFunctionDeclaration(node2, functions) {
1434
+ if (isTopLevel(node2) && node2.id?.name)
1435
+ functions.add(node2.id.name);
1436
+ }
1437
+ function handleTSDeclareFunction(node2, functions) {
1438
+ if (isTopLevel(node2) && node2.id?.name)
1439
+ functions.add(node2.id.name);
1440
+ }
1441
+ function handleTSEnumDeclaration(node2, types) {
1442
+ if (isTopLevel(node2) && node2.id?.name)
1443
+ types.add(node2.id.name);
1444
+ }
1445
+ function handleTSInterfaceDeclaration(node2, types) {
1446
+ if (isTopLevel(node2) && node2.id?.name)
1447
+ types.add(node2.id.name);
1448
+ }
1449
+ function handleTSTypeAliasDeclaration(node2, types) {
1450
+ if (isTopLevel(node2) && node2.id?.name)
1451
+ types.add(node2.id.name);
1452
+ }
1453
+ function isExempt(filename) {
1454
+ const name = path.basename(filename, path.extname(filename));
1455
+ const isTest = name.endsWith(".test");
1456
+ const isSpec = name.endsWith(".spec");
1457
+ const isConfig = name.endsWith(".config");
1458
+ return isTest || isSpec || isConfig;
1459
+ }
1460
+ function isExportedDeclaration(parent) {
1461
+ return parent?.type === "ExportNamedDeclaration";
1462
+ }
1463
+ const messageIds$4 = {
1464
+ tooManyDeclarations: "File has {{count}} declarations. Put each function/class/const/type declaration in its own file."
1465
+ };
1466
+ const maxDeclarationsPerFile = {
1467
+ create(context) {
1468
+ const filename = context.filename;
1469
+ if (isExempt(filename))
1470
+ return {};
1471
+ const functions = /* @__PURE__ */ new Set();
1472
+ const types = /* @__PURE__ */ new Set();
1473
+ return {
1474
+ ClassDeclaration(node2) {
1475
+ handleClassDeclaration(node2, functions);
1476
+ },
1477
+ FunctionDeclaration(node2) {
1478
+ handleFunctionDeclaration(node2, functions);
1479
+ },
1480
+ "Program:exit"(_programNode) {
1481
+ const totalDeclarations = functions.size + types.size;
1482
+ if (totalDeclarations > 1) {
1483
+ context.report({
1484
+ data: {
1485
+ count: totalDeclarations,
1486
+ functions: functions.size,
1487
+ types: types.size
1488
+ },
1489
+ messageId: "tooManyDeclarations",
1490
+ node: _programNode
1491
+ });
1492
+ }
1493
+ },
1494
+ TSDeclareFunction(node2) {
1495
+ handleTSDeclareFunction(node2, functions);
1496
+ },
1497
+ TSEnumDeclaration(node2) {
1498
+ handleTSEnumDeclaration(node2, types);
1499
+ },
1500
+ TSInterfaceDeclaration(node2) {
1501
+ handleTSInterfaceDeclaration(node2, types);
1502
+ },
1503
+ TSTypeAliasDeclaration(node2) {
1504
+ handleTSTypeAliasDeclaration(node2, types);
1505
+ },
1506
+ VariableDeclaration(node2) {
1507
+ if (!isTopLevel(node2))
1508
+ return;
1509
+ const parent = node2.parent;
1510
+ if (!isExportedDeclaration(parent) && !node2.declare)
1511
+ return;
1512
+ collectVariableDeclarators(node2, types);
1513
+ },
1514
+ "VariableDeclaration > VariableDeclarator > ArrowFunctionExpression"(_node) {
1515
+ if (!isTopLevel(_node.parent?.parent))
1516
+ return;
1517
+ const declarator = _node.parent;
1518
+ if (declarator.id.type === "Identifier" && declarator.id.name)
1519
+ functions.add(declarator.id.name);
1520
+ }
1521
+ };
1522
+ },
1523
+ meta: {
1524
+ docs: {
1525
+ description: "Enforce single top-level declaration per file."
1526
+ },
1527
+ messages: messageIds$4,
1528
+ schema: [],
1529
+ type: "suggestion"
1530
+ }
1531
+ };
1532
+ function createFix(fixer, node2, sourceCode) {
1533
+ const types = node2.types.map((t) => sourceCode.getText(t));
1534
+ const formattedTypes = types.map((t) => ` | ${t}`).join("\n");
1535
+ const result = `
1536
+ ${formattedTypes}`;
1537
+ return fixer.replaceText(node2, result);
1538
+ }
1539
+ function isMultiline(unionType) {
1540
+ const { end, start } = unionType.loc ?? {};
1541
+ return start?.line !== end?.line;
1542
+ }
1543
+ const multilineUnionTypeAliases = {
1544
+ create(context) {
1545
+ return {
1546
+ TSUnionType(node2) {
1547
+ if (node2.types.length < 2)
1548
+ return;
1549
+ const parent = node2.parent;
1550
+ if (!parent || parent.type !== "TSTypeAliasDeclaration")
1551
+ return;
1552
+ const sourceCode = context.sourceCode;
1553
+ const text = sourceCode.getText(node2);
1554
+ if (text.trim().startsWith("|"))
1555
+ return;
1556
+ if (!isMultiline(node2)) {
1557
+ context.report({
1558
+ fix: (fixer) => createFix(fixer, node2, sourceCode),
1559
+ messageId: "singleLine",
1560
+ node: node2
1561
+ });
1562
+ return;
1563
+ }
1564
+ context.report({
1565
+ fix: (fixer) => createFix(fixer, node2, sourceCode),
1566
+ messageId: "missingPipes",
1567
+ node: node2
1568
+ });
1569
+ }
1570
+ };
1571
+ },
1572
+ meta: {
1573
+ docs: {
1574
+ description: "Enforce union type aliases with multiple members to be on multiple lines."
1575
+ },
1576
+ fixable: "code",
1577
+ messages: {
1578
+ missingPipes: "Multiline union type aliases should have leading pipes on each member",
1579
+ singleLine: "Union type aliases with multiple members should be on multiple lines"
1580
+ },
1581
+ schema: [],
1582
+ type: "layout"
1583
+ }
1584
+ };
1585
+ function checkTypeParameters(node2, containsInline) {
1586
+ if (!("typeParameters" in node2) || !node2.typeParameters)
1587
+ return null;
1588
+ for (const param of node2.typeParameters.params) {
1589
+ const result = containsInline(param);
1590
+ if (result)
1591
+ return result;
1592
+ }
1593
+ return null;
1594
+ }
1595
+ function checkUnionOrIntersectionTypes(node2, containsInline) {
1596
+ for (const type of node2.types) {
1597
+ const result = containsInline(type);
1598
+ if (result)
1599
+ return result;
1600
+ }
1601
+ return null;
1602
+ }
1603
+ function isInlineObjectType(node2) {
1604
+ return node2.type === "TSTypeLiteral";
1605
+ }
1606
+ function containsInlineObjectType(node2) {
1607
+ if (isInlineObjectType(node2))
1608
+ return node2;
1609
+ if (node2.type === "TSIntersectionType" || node2.type === "TSUnionType") {
1610
+ const result = checkUnionOrIntersectionTypes(
1611
+ node2,
1612
+ containsInlineObjectType
1613
+ );
1614
+ if (result)
1615
+ return result;
1616
+ }
1617
+ if (node2.type === "TSArrayType")
1618
+ return containsInlineObjectType(node2.elementType);
1619
+ const typeParamResult = checkTypeParameters(node2, containsInlineObjectType);
1620
+ if (typeParamResult)
1621
+ return typeParamResult;
1622
+ if (node2.type === "TSTypeAnnotation")
1623
+ return containsInlineObjectType(node2.typeAnnotation);
1624
+ return null;
1625
+ }
1626
+ function toPascalCase(str) {
1627
+ return str.charAt(0).toUpperCase() + str.slice(1);
1628
+ }
1629
+ function getInlineTypeName(usedNames, _existingInterfaces, parameterName) {
1630
+ const baseName = parameterName ? toPascalCase(parameterName) : "InlineType";
1631
+ if (!usedNames.has(baseName)) {
1632
+ usedNames.add(baseName);
1633
+ return baseName;
1634
+ }
1635
+ let counter = 2;
1636
+ while (usedNames.has(`${baseName}${counter}`))
1637
+ counter++;
1638
+ const name = `${baseName}${counter}`;
1639
+ usedNames.add(name);
1640
+ return name;
1641
+ }
1642
+ function getParameterNameFromFunction(parent) {
1643
+ if (parent.type === "ArrowFunctionExpression" || parent.type === "FunctionDeclaration" || parent.type === "FunctionExpression") {
1644
+ const funcNode = parent;
1645
+ return funcNode.id?.name;
1646
+ }
1647
+ return void 0;
1648
+ }
1649
+ function getParameterNameFromIdentifier(parent) {
1650
+ const grandParent = parent.parent;
1651
+ if (grandParent?.type === "ArrowFunctionExpression" || grandParent?.type === "FunctionDeclaration" || grandParent?.type === "FunctionExpression")
1652
+ return parent.name;
1653
+ return void 0;
1654
+ }
1655
+ function getParameterNameFromObjectPattern(parent) {
1656
+ const grandParent = parent.parent;
1657
+ if (grandParent?.type === "ArrowFunctionExpression" || grandParent?.type === "FunctionDeclaration" || grandParent?.type === "FunctionExpression")
1658
+ return "Options";
1659
+ return void 0;
1660
+ }
1661
+ function getTopLevelDeclaration(node2) {
1662
+ let current = node2;
1663
+ const topLevelTypes = /* @__PURE__ */ new Set([
1664
+ "ArrowFunctionExpression",
1665
+ "FunctionDeclaration",
1666
+ "FunctionExpression",
1667
+ "TSInterfaceDeclaration",
1668
+ "TSTypeAliasDeclaration",
1669
+ "VariableDeclaration"
1670
+ ]);
1671
+ while (current) {
1672
+ if (topLevelTypes.has(current.type)) {
1673
+ const parent = current.parent;
1674
+ const exported = parent?.type === "ExportNamedDeclaration";
1675
+ if (exported && parent) {
1676
+ return {
1677
+ insertLocation: parent,
1678
+ isExported: true,
1679
+ node: current
1680
+ };
1681
+ }
1682
+ return {
1683
+ insertLocation: current,
1684
+ isExported: false,
1685
+ node: current
1686
+ };
1687
+ }
1688
+ current = current.parent;
1689
+ }
1690
+ return void 0;
1691
+ }
1692
+ function handleInlineType(node2, typeLiteral, inlineTypes) {
1693
+ const result = getTopLevelDeclaration(node2);
1694
+ if (!result)
1695
+ return;
1696
+ let parameterName;
1697
+ const parent = node2.parent;
1698
+ if (parent?.type === "Identifier")
1699
+ parameterName = getParameterNameFromIdentifier(parent);
1700
+ else if (parent?.type === "ObjectPattern")
1701
+ parameterName = getParameterNameFromObjectPattern(parent);
1702
+ else
1703
+ parameterName = getParameterNameFromFunction(parent);
1704
+ inlineTypes.push({
1705
+ annotationNode: node2,
1706
+ insertLocation: result.insertLocation,
1707
+ isExported: result.isExported,
1708
+ location: result.node,
1709
+ parameterName,
1710
+ typeLiteral
1711
+ });
1712
+ }
1713
+ function isIdentifierInFunction(parent) {
1714
+ return parent?.type === "Identifier" && (parent.parent?.type === "FunctionDeclaration" || parent.parent?.type === "FunctionExpression" || parent.parent?.type === "ArrowFunctionExpression");
1715
+ }
1716
+ function isPropertySignatureInTypeLiteral(parent) {
1717
+ return parent?.type === "TSPropertySignature" && (parent.parent?.type === "TSTypeLiteral" || parent.parent?.type === "TSInterfaceBody");
1718
+ }
1719
+ function traverseUpForTypeLiteral(current) {
1720
+ const skipTypes = /* @__PURE__ */ new Set([
1721
+ "TSArrayType",
1722
+ "TSIntersectionType",
1723
+ "TSPropertySignature",
1724
+ "TSTypeReference",
1725
+ "TSUnionType"
1726
+ ]);
1727
+ while (current) {
1728
+ if (current.type === "TSTypeLiteral")
1729
+ return true;
1730
+ if (skipTypes.has(current.type)) {
1731
+ current = current.parent;
1732
+ continue;
1733
+ }
1734
+ break;
1735
+ }
1736
+ return false;
1737
+ }
1738
+ function isNestedTypeAnnotation(node2) {
1739
+ const parent = node2.parent;
1740
+ if (isPropertySignatureInTypeLiteral(parent))
1741
+ return true;
1742
+ if (isIdentifierInFunction(parent))
1743
+ return false;
1744
+ if (parent?.type === "ArrowFunctionExpression" || parent?.type === "FunctionDeclaration" || parent?.type === "FunctionExpression")
1745
+ return false;
1746
+ const foundTypeLiteral = traverseUpForTypeLiteral(parent);
1747
+ return foundTypeLiteral;
1748
+ }
1749
+ function prepareFix(sourceCode, inlineTypes) {
1750
+ const interfaceDeclarations = inlineTypes.map(({ name, typeLiteral }) => {
1751
+ const typeText = sourceCode.getText(typeLiteral);
1752
+ return `interface ${name} ${typeText}`;
1753
+ });
1754
+ const interfaceBlock = interfaceDeclarations.join("\n");
1755
+ const replacements = inlineTypes.map(
1756
+ ({ name, typeLiteral }) => ({ name, typeLiteral })
1757
+ );
1758
+ return {
1759
+ firstUsageLocation: inlineTypes[0].typeLiteral,
1760
+ interfaceBlock,
1761
+ replacements
1762
+ };
1763
+ }
1764
+ const noInlineObjectTypes = {
1765
+ create(context) {
1766
+ const sourceCode = context.sourceCode;
1767
+ const inlineTypes = [];
1768
+ const listener = {
1769
+ TSTypeAnnotation(node2) {
1770
+ if (isNestedTypeAnnotation(node2))
1771
+ return;
1772
+ const typeLiteral = containsInlineObjectType(node2);
1773
+ if (!typeLiteral)
1774
+ return;
1775
+ handleInlineType(node2, typeLiteral, inlineTypes);
1776
+ }
1777
+ };
1778
+ return {
1779
+ ...listener,
1780
+ "Program:exit"() {
1781
+ if (inlineTypes.length === 0)
1782
+ return;
1783
+ const usedNames = /* @__PURE__ */ new Set();
1784
+ const locations = [...new Set(inlineTypes.map((t) => t.insertLocation))];
1785
+ for (const loc of locations) {
1786
+ const typesAtLocation = inlineTypes.filter(
1787
+ (t) => t.insertLocation === loc
1788
+ );
1789
+ const typesForLocation = typesAtLocation.map((entry) => {
1790
+ const name = getInlineTypeName(usedNames, [], entry.parameterName);
1791
+ return {
1792
+ name,
1793
+ parameterName: entry.parameterName,
1794
+ typeLiteral: entry.typeLiteral
1795
+ };
1796
+ });
1797
+ const fixResult = prepareFix(
1798
+ sourceCode,
1799
+ typesForLocation
1800
+ );
1801
+ context.report({
1802
+ fix(fixer) {
1803
+ const fixes = [];
1804
+ for (const replacement of fixResult.replacements) {
1805
+ fixes.push(
1806
+ fixer.replaceText(
1807
+ replacement.typeLiteral,
1808
+ replacement.name
1809
+ )
1810
+ );
1811
+ }
1812
+ const isExported = typesAtLocation[0].isExported;
1813
+ if (isExported && typesAtLocation[0].insertLocation.type === "ExportNamedDeclaration") {
1814
+ fixes.push(
1815
+ fixer.insertTextAfter(
1816
+ typesAtLocation[0].insertLocation,
1817
+ `
1818
+ ${fixResult.interfaceBlock}`
1819
+ )
1820
+ );
1821
+ } else {
1822
+ fixes.push(
1823
+ fixer.insertTextBefore(
1824
+ loc,
1825
+ `${fixResult.interfaceBlock}
1826
+ `
1827
+ )
1828
+ );
1829
+ }
1830
+ return fixes;
1831
+ },
1832
+ messageId: "inlineObjectType",
1833
+ node: typesAtLocation[0].annotationNode
1834
+ });
1835
+ }
1836
+ }
1837
+ };
1838
+ },
1839
+ meta: {
1840
+ docs: {
1841
+ description: "Disallow inline object type literals in type annotations."
1842
+ },
1843
+ fixable: "code",
1844
+ messages: {
1845
+ inlineObjectType: "Inline object types are not allowed. Use a named interface or type instead."
1846
+ },
1847
+ schema: [],
1848
+ type: "suggestion"
1849
+ }
1850
+ };
1851
+ function getLineIndent(sourceCode, line) {
1852
+ const text = sourceCode.getText();
1853
+ const lines = text.split("\n");
1854
+ const lineText = lines[line - 1] ?? "";
1855
+ const match = lineText.match(/^(\s*)/);
1856
+ return match?.[1] ?? "";
1857
+ }
1858
+ function getReplacementText(statementText, baseIndent, hasElseAfter) {
1859
+ const statementIndent = `${baseIndent} `;
1860
+ if (hasElseAfter)
1861
+ return `
1862
+ ${statementIndent}${statementText}
1863
+ ${baseIndent}`;
1864
+ return `
1865
+ ${statementIndent}${statementText}`;
1866
+ }
1867
+ function isSingleLineStatement(node2, sourceCode) {
1868
+ const firstToken = sourceCode.getFirstToken(node2);
1869
+ const lastToken = sourceCode.getLastToken(node2);
1870
+ if (!firstToken || !lastToken)
1871
+ return false;
1872
+ return firstToken.loc.start.line === lastToken.loc.end.line;
1873
+ }
1874
+ function checkBlockStatement(node2, context) {
1875
+ if (node2.body.length !== 1)
1876
+ return;
1877
+ const statement = node2.body[0];
1878
+ const sourceCode = context.getSourceCode();
1879
+ if (isSingleLineStatement(statement, sourceCode)) {
1880
+ context.report({
1881
+ fix(fixer) {
1882
+ const statementText = sourceCode.getText(statement);
1883
+ const tokenBefore = sourceCode.getTokenBefore(node2);
1884
+ const tokenBeforeLine = tokenBefore?.loc?.start?.line ?? node2.loc?.start?.line ?? 1;
1885
+ const baseIndent = getLineIndent(sourceCode, tokenBeforeLine);
1886
+ const rangeStart = tokenBefore ? tokenBefore.range[1] : node2.range[0];
1887
+ const range = [rangeStart, node2.range[1]];
1888
+ const tokenAfter = sourceCode.getTokenAfter(node2);
1889
+ const hasElseAfter = tokenAfter && tokenAfter.value === "else";
1890
+ const replacementText = getReplacementText(
1891
+ statementText,
1892
+ baseIndent,
1893
+ hasElseAfter
1894
+ );
1895
+ return fixer.replaceTextRange(range, replacementText);
1896
+ },
1897
+ messageId: "unnecessaryBraces",
1898
+ node: node2
1899
+ });
1900
+ }
1901
+ }
1902
+ function detectIndentStep(sourceCode) {
1903
+ const text = sourceCode.getText();
1904
+ const lines = text.split("\n");
1905
+ const indentCounts = /* @__PURE__ */ new Map();
1906
+ for (const line of lines) {
1907
+ const match = line.match(/^( *)/);
1908
+ if (match) {
1909
+ const spaces = match[1].length;
1910
+ if (spaces > 0)
1911
+ indentCounts.set(spaces, (indentCounts.get(spaces) ?? 0) + 1);
1912
+ }
1913
+ }
1914
+ const sortedIndents = Array.from(indentCounts.entries()).filter(([spaces]) => spaces > 0).sort((a, b) => a[0] - b[0]);
1915
+ if (sortedIndents.length === 0)
1916
+ return 2;
1917
+ const minIndent = sortedIndents[0][0];
1918
+ for (const step of [2, 4]) {
1919
+ const isMultipleOfStep = sortedIndents.every(([n]) => n % step === 0);
1920
+ if (isMultipleOfStep)
1921
+ return step;
1922
+ }
1923
+ return minIndent;
1924
+ }
1925
+ function reindentText(text, newBaseIndent, indentStep) {
1926
+ const lines = text.split("\n");
1927
+ let minIndent = Infinity;
1928
+ for (let i = 1; i < lines.length; i++) {
1929
+ const line = lines[i];
1930
+ if (line.trim() === "")
1931
+ continue;
1932
+ const match = line.match(/^( *)/);
1933
+ if (match)
1934
+ minIndent = Math.min(minIndent, match[1].length);
1935
+ }
1936
+ if (minIndent === Infinity) {
1937
+ return lines.map((line) => {
1938
+ if (line.trim() === "")
1939
+ return "";
1940
+ return newBaseIndent + indentStep + line.trimStart();
1941
+ }).join("\n");
1942
+ }
1943
+ return lines.map((line, index) => {
1944
+ if (line.trim() === "")
1945
+ return "";
1946
+ if (index === 0)
1947
+ return newBaseIndent + indentStep + line.trimStart();
1948
+ const relativeIndent = line.slice(minIndent);
1949
+ return newBaseIndent + indentStep + relativeIndent;
1950
+ }).join("\n");
1951
+ }
1952
+ function checkNonBlockStatement(node2, context) {
1953
+ if (node2.type === "BlockStatement")
1954
+ return;
1955
+ const sourceCode = context.getSourceCode();
1956
+ if (!isSingleLineStatement(node2, sourceCode)) {
1957
+ context.report({
1958
+ fix(fixer) {
1959
+ const statementText = sourceCode.getText(node2);
1960
+ const parent = node2.parent;
1961
+ const parentLine = parent?.loc?.start?.line ?? node2.loc?.start?.line ?? 1;
1962
+ const baseIndent = getLineIndent$1(sourceCode, parentLine);
1963
+ const indentStepSize = detectIndentStep(sourceCode);
1964
+ const indentStep = " ".repeat(indentStepSize);
1965
+ const reindentedText = reindentText(
1966
+ statementText,
1967
+ baseIndent,
1968
+ indentStep
1969
+ );
1970
+ const fixed = `{
1971
+ ${reindentedText}
1972
+ ${baseIndent}}`;
1973
+ return [fixer.replaceText(node2, fixed)];
1974
+ },
1975
+ messageId: "missingBraces",
1976
+ node: node2
1977
+ });
1978
+ }
1979
+ }
1980
+ function checkDoWhileStatement(node2, context) {
1981
+ if (node2.body.type === "BlockStatement")
1982
+ checkBlockStatement(node2.body, context);
1983
+ else
1984
+ checkNonBlockStatement(node2.body, context);
1985
+ }
1986
+ function checkForInStatement(node2, context) {
1987
+ if (node2.body.type === "BlockStatement")
1988
+ checkBlockStatement(node2.body, context);
1989
+ else
1990
+ checkNonBlockStatement(node2.body, context);
1991
+ }
1992
+ function checkForOfStatement(node2, context) {
1993
+ if (node2.body.type === "BlockStatement")
1994
+ checkBlockStatement(node2.body, context);
1995
+ else
1996
+ checkNonBlockStatement(node2.body, context);
1997
+ }
1998
+ function checkForStatement(node2, context) {
1999
+ if (node2.body.type === "BlockStatement")
2000
+ checkBlockStatement(node2.body, context);
2001
+ else
2002
+ checkNonBlockStatement(node2.body, context);
2003
+ }
2004
+ function checkIfStatement(node2, context) {
2005
+ if (node2.consequent.type === "BlockStatement")
2006
+ checkBlockStatement(node2.consequent, context);
2007
+ else
2008
+ checkNonBlockStatement(node2.consequent, context);
2009
+ if (!node2.alternate)
2010
+ return;
2011
+ if (node2.alternate.type === "IfStatement")
2012
+ return;
2013
+ if (node2.alternate.type === "BlockStatement")
2014
+ checkBlockStatement(node2.alternate, context);
2015
+ else
2016
+ checkNonBlockStatement(node2.alternate, context);
2017
+ }
2018
+ function checkWhileStatement(node2, context) {
2019
+ if (node2.body.type === "BlockStatement")
2020
+ checkBlockStatement(node2.body, context);
2021
+ else
2022
+ checkNonBlockStatement(node2.body, context);
2023
+ }
2024
+ const noUnnecessaryBraces = {
2025
+ create(context) {
2026
+ return {
2027
+ DoWhileStatement: (node2) => checkDoWhileStatement(node2, context),
2028
+ ForInStatement: (node2) => checkForInStatement(node2, context),
2029
+ ForOfStatement: (node2) => checkForOfStatement(node2, context),
2030
+ ForStatement: (node2) => checkForStatement(node2, context),
2031
+ IfStatement: (node2) => checkIfStatement(node2, context),
2032
+ WhileStatement: (node2) => checkWhileStatement(node2, context)
2033
+ };
2034
+ },
2035
+ meta: {
2036
+ docs: {
2037
+ description: "Enforce consistent brace usage for single-statement control bodies."
2038
+ },
2039
+ fixable: "code",
2040
+ messages: {
2041
+ missingBraces: "Multi-line statement must be wrapped in braces",
2042
+ unnecessaryBraces: "Unnecessary braces around single-line statement"
2043
+ },
2044
+ schema: [],
2045
+ type: "suggestion"
2046
+ }
2047
+ };
2048
+ function isShorthandProperty(property) {
2049
+ return property.shorthand;
2050
+ }
2051
+ function areAllShorthand(properties) {
2052
+ return properties.every(isShorthandProperty);
2053
+ }
2054
+ function getPropertyText(sourceCode, property) {
2055
+ return sourceCode.getText(property);
2056
+ }
2057
+ function getInlineObjectLength(sourceCode, properties) {
2058
+ if (properties.length === 0)
2059
+ return 2;
2060
+ const propLengths = properties.map((p) => getPropertyText(sourceCode, p).length);
2061
+ const propsTotal = propLengths.reduce((a, b) => a + b, 0);
2062
+ const commas = Math.max(0, properties.length - 1);
2063
+ return 2 + propsTotal + commas;
2064
+ }
2065
+ function checkMultiline(sourceCode, context, node2, braces, maxLength) {
2066
+ const properties = node2.properties;
2067
+ const allShorthand = areAllShorthand(properties);
2068
+ if (!allShorthand)
2069
+ return;
2070
+ const inlineLength = getInlineObjectLength(sourceCode, properties);
2071
+ if (inlineLength > maxLength)
2072
+ return;
2073
+ context.report({
2074
+ fix(fixer) {
2075
+ const names = [];
2076
+ for (const prop of properties) {
2077
+ if (prop.key.type === "Identifier")
2078
+ names.push(prop.key.name);
2079
+ else
2080
+ names.push(sourceCode.getText(prop));
2081
+ }
2082
+ return fixer.replaceText(node2, `{${names.join(", ")}}`);
2083
+ },
2084
+ messageId: "multilineCanBeSingleLine",
2085
+ node: properties[0]
2086
+ });
2087
+ }
2088
+ function buildMultilineFix(fixer, braces, properties, sourceCode) {
2089
+ const indentStep = detectIndentStep(sourceCode);
2090
+ const lineIndent = sourceCode.getLines()[braces.openingBrace.loc.start.line - 1].match(/^\s*/)?.[0] ?? "";
2091
+ const indent = lineIndent + " ".repeat(indentStep);
2092
+ const lines = ["{"];
2093
+ for (const prop of properties) {
2094
+ const propText = sourceCode.getText(prop);
2095
+ lines.push(`${indent}${propText},`);
2096
+ }
2097
+ lines.push(`${lineIndent}}`);
2098
+ return fixer.replaceTextRange(
2099
+ [braces.openingBrace.range[0], braces.closingBrace.range[1]],
2100
+ lines.join("\n")
2101
+ );
2102
+ }
2103
+ function getPropertyName(sourceCode, prop) {
2104
+ if (prop.key.type === "Identifier")
2105
+ return prop.key.name;
2106
+ return sourceCode.getText(prop);
2107
+ }
2108
+ function buildShorthandFix(fixer, braces, properties, sourceCode) {
2109
+ const names = properties.map((p) => getPropertyName(sourceCode, p));
2110
+ return fixer.replaceTextRange(
2111
+ [braces.openingBrace.range[0], braces.closingBrace.range[1]],
2112
+ `{${names.join(", ")}}`
2113
+ );
2114
+ }
2115
+ function canConvertToShorthand(property) {
2116
+ if (property.shorthand)
2117
+ return true;
2118
+ if (property.kind !== "init")
2119
+ return false;
2120
+ if (property.key.type !== "Identifier")
2121
+ return false;
2122
+ if (property.value.type !== "Identifier")
2123
+ return false;
2124
+ return property.key.name === property.value.name;
2125
+ }
2126
+ function shouldCollapseToShorthand(properties, sourceCode, maxLength) {
2127
+ const anyShorthand = properties.some((p) => p.shorthand);
2128
+ const allCanConvert = properties.every(canConvertToShorthand);
2129
+ const shorthandLength = allCanConvert ? getInlineObjectLength(sourceCode, properties) : Infinity;
2130
+ return !anyShorthand && allCanConvert && shorthandLength <= maxLength;
2131
+ }
2132
+ function checkSingleLine(sourceCode, context, properties, braces, maxLength) {
2133
+ if (properties.length === 1)
2134
+ return;
2135
+ const allShorthand = areAllShorthand(properties);
2136
+ const inlineLength = getInlineObjectLength(sourceCode, properties);
2137
+ if (allShorthand && inlineLength <= maxLength)
2138
+ return;
2139
+ if (!allShorthand) {
2140
+ if (shouldCollapseToShorthand(properties, sourceCode, maxLength)) {
2141
+ context.report({
2142
+ fix: (fixer) => buildShorthandFix(fixer, braces, properties, sourceCode),
2143
+ messageId: "mixedPropertiesNotAllowed",
2144
+ node: properties[0]
2145
+ });
2146
+ return;
2147
+ }
2148
+ context.report({
2149
+ fix: (fixer) => buildMultilineFix(fixer, braces, properties, sourceCode),
2150
+ messageId: "mixedPropertiesNotAllowed",
2151
+ node: properties[0]
2152
+ });
2153
+ return;
2154
+ }
2155
+ context.report({
2156
+ fix: (fixer) => buildMultilineFix(fixer, braces, properties, sourceCode),
2157
+ messageId: "singleLineExceedsMaxLength",
2158
+ node: properties[0]
2159
+ });
2160
+ }
2161
+ const defaultOptions$2 = {
2162
+ maxLength: 80
2163
+ };
2164
+ function getBraces(sourceCode, node2) {
2165
+ const properties = node2.properties;
2166
+ if (properties.length === 0)
2167
+ return null;
2168
+ const firstProp = properties[0];
2169
+ const lastProp = properties[properties.length - 1];
2170
+ const openingBrace = sourceCode.getTokenBefore(firstProp);
2171
+ const closingBrace = sourceCode.getTokenAfter(lastProp);
2172
+ if (!openingBrace || !closingBrace)
2173
+ return null;
2174
+ return { closingBrace, openingBrace };
2175
+ }
2176
+ function checkObject(sourceCode, context, node2) {
2177
+ const options = context.options[0] ?? {};
2178
+ const maxLength = options.maxLength ?? defaultOptions$2.maxLength;
2179
+ const properties = node2.properties;
2180
+ if (properties.length === 0)
2181
+ return;
2182
+ const braces = getBraces(sourceCode, node2);
2183
+ if (!braces)
2184
+ return;
2185
+ const firstLine = braces.openingBrace.loc.start.line;
2186
+ const lastLine = braces.closingBrace.loc.end.line;
2187
+ if (firstLine === lastLine)
2188
+ checkSingleLine(sourceCode, context, properties, braces, maxLength);
2189
+ else
2190
+ checkMultiline(sourceCode, context, node2, braces, maxLength);
2191
+ }
2192
+ const messageIds$3 = {
2193
+ mixedPropertiesNotAllowed: "mixedPropertiesNotAllowed",
2194
+ multilineCanBeSingleLine: "multilineCanBeSingleLine",
2195
+ singleLineExceedsMaxLength: "singleLineExceedsMaxLength"
2196
+ };
2197
+ const objectPropertyLineBreak = {
2198
+ create(context) {
2199
+ const sourceCode = context.sourceCode ?? context.getSourceCode();
2200
+ return {
2201
+ ObjectExpression(node2) {
2202
+ checkObject(sourceCode, context, node2);
2203
+ }
2204
+ };
2205
+ },
2206
+ meta: {
2207
+ docs: {
2208
+ description: "Enforce object literal formatting based on complexity and line length."
2209
+ },
2210
+ fixable: "code",
2211
+ messages: messageIds$3,
2212
+ schema: [{
2213
+ additionalProperties: false,
2214
+ properties: {
2215
+ maxLength: {
2216
+ type: "number"
2217
+ }
2218
+ },
2219
+ type: "object"
2220
+ }],
2221
+ type: "layout"
2222
+ }
2223
+ };
2224
+ const messageIds$2 = {
2225
+ tooManyExports: "Only one export is allowed per file. Found {{count}} exports."
2226
+ };
2227
+ const oneExportPerFile = {
2228
+ create(context) {
2229
+ const filename = context.filename;
2230
+ if (isExempt$1(filename))
2231
+ return {};
2232
+ let exportCount = 0;
2233
+ return {
2234
+ ExportDefaultDeclaration(_node) {
2235
+ exportCount++;
2236
+ },
2237
+ ExportNamedDeclaration(_node) {
2238
+ exportCount++;
2239
+ },
2240
+ "Program:exit"(programNode) {
2241
+ if (exportCount > 1) {
2242
+ context.report({
2243
+ data: { count: exportCount },
2244
+ messageId: "tooManyExports",
2245
+ node: programNode
2246
+ });
2247
+ }
2248
+ }
2249
+ };
2250
+ },
2251
+ meta: {
2252
+ docs: {
2253
+ description: "Enforce single export per file."
2254
+ },
2255
+ messages: messageIds$2,
2256
+ schema: [],
2257
+ type: "suggestion"
2258
+ }
2259
+ };
2260
+ function isValidExportSpecifier(specifier, localDeclarations) {
2261
+ if (specifier.local.type !== "Identifier")
2262
+ return false;
2263
+ if (specifier.exported.type !== "Identifier")
2264
+ return false;
2265
+ if (specifier.local.name !== specifier.exported.name)
2266
+ return false;
2267
+ return localDeclarations.has(specifier.local.name);
2268
+ }
2269
+ function canInlineSpecifiers(specifiers, localDeclarations) {
2270
+ return specifiers.every(
2271
+ (spec) => isValidExportSpecifier(spec, localDeclarations)
2272
+ );
2273
+ }
2274
+ function getDeclarationName(node2) {
2275
+ if (node2.type !== "VariableDeclaration")
2276
+ return node2.id?.name ?? null;
2277
+ const declarations = node2.declarations;
2278
+ if (declarations.length === 1) {
2279
+ const id = declarations[0].id;
2280
+ if (id.type === "Identifier")
2281
+ return id.name;
2282
+ }
2283
+ return null;
2284
+ }
2285
+ function isExportableDeclaration(node2) {
2286
+ const type = node2.type;
2287
+ return type === "TSInterfaceDeclaration" || type === "TSTypeAliasDeclaration" || type === "ClassDeclaration" || type === "FunctionDeclaration" || type === "VariableDeclaration";
2288
+ }
2289
+ const preferInlineExport = {
2290
+ create(context) {
2291
+ const localDeclarations = /* @__PURE__ */ new Map();
2292
+ function visitDeclaration(node2) {
2293
+ if (!isExportableDeclaration(node2))
2294
+ return;
2295
+ const name = getDeclarationName(node2);
2296
+ if (name)
2297
+ localDeclarations.set(name, { name, node: node2 });
2298
+ }
2299
+ return {
2300
+ ClassDeclaration: visitDeclaration,
2301
+ ExportNamedDeclaration(node2) {
2302
+ if (node2.source)
2303
+ return;
2304
+ if (!node2.specifiers || node2.specifiers.length === 0)
2305
+ return;
2306
+ if (!canInlineSpecifiers(node2.specifiers, localDeclarations))
2307
+ return;
2308
+ context.report({
2309
+ fix(fixer) {
2310
+ const fixes = [];
2311
+ for (const specifier of node2.specifiers) {
2312
+ const name = specifier.local.name;
2313
+ const decl = localDeclarations.get(name);
2314
+ if (decl)
2315
+ fixes.push(fixer.insertTextBefore(decl.node, "export "));
2316
+ }
2317
+ fixes.push(fixer.remove(node2));
2318
+ return fixes;
2319
+ },
2320
+ messageId: "preferInline",
2321
+ node: node2
2322
+ });
2323
+ },
2324
+ FunctionDeclaration: visitDeclaration,
2325
+ TSInterfaceDeclaration: visitDeclaration,
2326
+ TSTypeAliasDeclaration: visitDeclaration,
2327
+ VariableDeclaration: visitDeclaration
2328
+ };
2329
+ },
2330
+ meta: {
2331
+ docs: {
2332
+ description: "Enforce using inline export syntax instead of separate export statements."
2333
+ },
2334
+ fixable: "code",
2335
+ messages: {
2336
+ preferInline: "Use inline export instead of separate export statement"
2337
+ },
2338
+ schema: [],
2339
+ type: "suggestion"
2340
+ }
2341
+ };
2342
+ function buildCollapsedParams(sourceCode, params) {
2343
+ const paramsText = params.map((param, index) => {
2344
+ const text = sourceCode.getText(param);
2345
+ const isLastParam = index === params.length - 1;
2346
+ return isLastParam ? text : text + ",";
2347
+ }).join(" ");
2348
+ return `(${paramsText})`;
2349
+ }
2350
+ function calculateCollapsedLength(sourceCode, openingParen, collapsedParams, returnType) {
2351
+ let returnTypeText = "";
2352
+ if (returnType)
2353
+ returnTypeText = sourceCode.getText(returnType);
2354
+ const allLines = sourceCode.getText().split("\n");
2355
+ const closingLine = allLines[openingParen.loc.start.line - 1];
2356
+ const textAfterClosingParen = closingLine.slice(openingParen.loc.start.column);
2357
+ return openingParen.loc.start.column + collapsedParams.length + returnTypeText.length + textAfterClosingParen.length;
2358
+ }
2359
+ const defaultOptions$1 = {
2360
+ maxLength: 80
2361
+ };
2362
+ function getArrowFunctionParens(sourceCode, params) {
2363
+ if (params.length === 0)
2364
+ return null;
2365
+ const firstParam = params[0];
2366
+ const lastParam = params[params.length - 1];
2367
+ const openingParen = sourceCode.getTokenBefore(firstParam);
2368
+ let closingParen = sourceCode.getTokenAfter(lastParam);
2369
+ while (closingParen && closingParen.value === ",")
2370
+ closingParen = sourceCode.getTokenAfter(closingParen);
2371
+ if (!openingParen || !closingParen)
2372
+ return null;
2373
+ if (openingParen.value !== "(" || closingParen.value !== ")")
2374
+ return null;
2375
+ return { closingParen, openingParen };
2376
+ }
2377
+ function isShorthand(sourceCode, node2) {
2378
+ if (node2.params.length !== 1)
2379
+ return false;
2380
+ const firstParam = node2.params[0];
2381
+ const tokenBefore = sourceCode.getTokenBefore(firstParam);
2382
+ return !tokenBefore || tokenBefore.value !== "(";
2383
+ }
2384
+ function reportViolation(context, node2, collapsedParams, returnTypeText, arrowToken, openingParen) {
2385
+ context.report({
2386
+ fix: (fixer) => fixer.replaceTextRange(
2387
+ [openingParen.range[0], arrowToken.range[1]],
2388
+ collapsedParams + returnTypeText + " =>"
2389
+ ),
2390
+ messageId: "singleLine",
2391
+ node: node2
2392
+ });
2393
+ }
2394
+ function checkArrowFunction(sourceCode, context, node2) {
2395
+ const options = context.options[0] ?? {};
2396
+ const maxLength = options.maxLength ?? defaultOptions$1.maxLength;
2397
+ if (isShorthand(sourceCode, node2))
2398
+ return;
2399
+ const parens = getArrowFunctionParens(sourceCode, node2.params);
2400
+ if (!parens)
2401
+ return;
2402
+ const { closingParen, openingParen } = parens;
2403
+ if (openingParen.loc.start.line === closingParen.loc.end.line)
2404
+ return;
2405
+ const arrowToken = sourceCode.getTokenAfter(
2406
+ closingParen,
2407
+ (token) => token.value === "=>"
2408
+ );
2409
+ if (!arrowToken)
2410
+ return;
2411
+ const collapsedParams = buildCollapsedParams(sourceCode, node2.params);
2412
+ const collapsedLength = calculateCollapsedLength(
2413
+ sourceCode,
2414
+ openingParen,
2415
+ collapsedParams,
2416
+ node2.returnType
2417
+ );
2418
+ if (collapsedLength <= maxLength) {
2419
+ const returnTypeText = node2.returnType ? sourceCode.getText(node2.returnType) : "";
2420
+ reportViolation(
2421
+ context,
2422
+ node2,
2423
+ collapsedParams,
2424
+ returnTypeText,
2425
+ arrowToken,
2426
+ openingParen
2427
+ );
2428
+ }
2429
+ }
2430
+ const messageIds$1 = {
2431
+ singleLine: "Arrow function parameters can be on a single line"
2432
+ };
2433
+ const singleLineArrowFunctionParameters = {
2434
+ create(context) {
2435
+ const sourceCode = context.sourceCode ?? context.getSourceCode();
2436
+ return {
2437
+ ArrowFunctionExpression(node2) {
2438
+ if (node2.params.length === 0)
2439
+ return;
2440
+ checkArrowFunction(sourceCode, context, node2);
2441
+ }
2442
+ };
2443
+ },
2444
+ meta: {
2445
+ docs: {
2446
+ description: "Enforce arrow function parameters to be on a single line when they fit."
2447
+ },
2448
+ fixable: "code",
2449
+ messages: messageIds$1,
2450
+ schema: [{
2451
+ additionalProperties: false,
2452
+ properties: {
2453
+ maxLength: {
2454
+ type: "number"
2455
+ }
2456
+ },
2457
+ type: "object"
2458
+ }],
2459
+ type: "layout"
2460
+ }
2461
+ };
2462
+ const defaultOptions = {
2463
+ maxLength: 80
2464
+ };
2465
+ function getParens(sourceCode, nodes) {
2466
+ if (nodes.length === 0)
2467
+ return null;
2468
+ const firstNode = nodes[0];
2469
+ const lastNode = nodes[nodes.length - 1];
2470
+ const openingParen = sourceCode.getTokenBefore(
2471
+ firstNode,
2472
+ (token) => token.value === "("
2473
+ );
2474
+ const closingParen = sourceCode.getTokenAfter(
2475
+ lastNode,
2476
+ (token) => token.value === ")"
2477
+ );
2478
+ if (!openingParen || !closingParen)
2479
+ return null;
2480
+ return { closingParen, openingParen };
2481
+ }
2482
+ function checkFunction(sourceCode, context, node2) {
2483
+ const options = context.options[0] ?? {};
2484
+ const maxLength = options.maxLength ?? defaultOptions.maxLength;
2485
+ const params = node2.params;
2486
+ if (params.length === 0)
2487
+ return;
2488
+ const parens = getParens(sourceCode, params);
2489
+ if (!isValidParens(parens))
2490
+ return;
2491
+ if (parens.openingParen.loc.start.line === parens.closingParen.loc.end.line)
2492
+ return;
2493
+ const paramsText = params.map((param, index) => {
2494
+ const text = sourceCode.getText(param);
2495
+ const isLastParam = index === params.length - 1;
2496
+ if (isLastParam)
2497
+ return text;
2498
+ const comma = sourceCode.getTokenAfter(
2499
+ param,
2500
+ (token) => token.value === ","
2501
+ );
2502
+ if (comma && comma.loc.end.line === param.loc.end.line)
2503
+ return text + ",";
2504
+ return text;
2505
+ }).join(" ");
2506
+ const closingLine = parens.closingParen.loc.end.line;
2507
+ const closingCol = parens.closingParen.loc.end.column;
2508
+ const closingLineText = getLineLength(sourceCode, closingLine) > closingCol ? sourceCode.getText().split("\n")[closingLine - 1].slice(closingCol) : "";
2509
+ const singleLineLength = parens.openingParen.loc.start.column + 1 + paramsText.length + 1 + closingLineText.length;
2510
+ if (singleLineLength <= maxLength) {
2511
+ context.report({
2512
+ fix: (fixer) => fixer.replaceTextRange(
2513
+ [parens.openingParen.range[0], parens.closingParen.range[1]],
2514
+ `(${paramsText})`
2515
+ ),
2516
+ messageId: "singleLine",
2517
+ node: node2
2518
+ });
2519
+ }
2520
+ }
2521
+ const messageIds = {
2522
+ singleLine: "Function parameters can be on a single line"
2523
+ };
2524
+ const singleLineFunctionParameters = {
2525
+ create(context) {
2526
+ const sourceCode = context.sourceCode ?? context.getSourceCode();
2527
+ return {
2528
+ FunctionDeclaration(node2) {
2529
+ checkFunction(sourceCode, context, node2);
2530
+ },
2531
+ FunctionExpression(node2) {
2532
+ checkFunction(sourceCode, context, node2);
2533
+ },
2534
+ TSCallSignatureDeclaration(node2) {
2535
+ checkFunction(sourceCode, context, node2);
2536
+ },
2537
+ TSFunctionType(node2) {
2538
+ checkFunction(sourceCode, context, node2);
2539
+ },
2540
+ TSMethodSignature(node2) {
2541
+ checkFunction(sourceCode, context, node2);
2542
+ }
2543
+ };
2544
+ },
2545
+ meta: {
2546
+ docs: {
2547
+ description: "Enforce function parameters to be on a single line when they fit."
2548
+ },
2549
+ fixable: "code",
2550
+ messages: messageIds,
2551
+ schema: [{
2552
+ additionalProperties: false,
2553
+ properties: {
2554
+ maxLength: {
2555
+ type: "number"
2556
+ }
2557
+ },
2558
+ type: "object"
2559
+ }],
2560
+ type: "layout"
2561
+ }
2562
+ };
208
2563
  function formatAttributes(attributes) {
209
- if (attributes.length === 0) return "";
210
- return ` with {${attributes.map((attr) => {
211
- return `${attr.key.type === "Identifier" ? attr.key.name : attr.key.value}: '${attr.value.value}'`;
212
- }).join(", ")}}`;
2564
+ if (attributes.length === 0)
2565
+ return "";
2566
+ const formatted = attributes.map(
2567
+ (attr) => {
2568
+ const key = attr.key.type === "Identifier" ? attr.key.name : attr.key.value;
2569
+ const value = attr.value.value;
2570
+ return `${key}: '${value}'`;
2571
+ }
2572
+ ).join(", ");
2573
+ return ` with {${formatted}}`;
213
2574
  }
214
- //#endregion
215
- //#region src/rules/singleLineImports/formatNamed.ts
216
2575
  function formatNamed(specifiers, sourceCode) {
217
- return specifiers.map((s) => sourceCode.getText(s)).join(", ");
2576
+ return specifiers.map((s) => sourceCode.getText(s)).join(", ");
218
2577
  }
219
- //#endregion
220
- //#region src/rules/singleLineImports/formatSpecifiers.ts
221
2578
  function formatSpecifiers(declaration, sourceCode) {
222
- const defaultSpecifier = declaration.specifiers.find((s) => s.type === "ImportDefaultSpecifier");
223
- const namespaceSpecifier = declaration.specifiers.find((s) => s.type === "ImportNamespaceSpecifier");
224
- const namedSpecifiers = declaration.specifiers.filter((s) => s.type === "ImportSpecifier");
225
- if (namespaceSpecifier) return `* as ${namespaceSpecifier.local.name}`;
226
- if (defaultSpecifier && namedSpecifiers.length > 0) return `${defaultSpecifier.local.name}, {${formatNamed(namedSpecifiers, sourceCode)}}`;
227
- if (defaultSpecifier) return defaultSpecifier.local.name;
228
- if (namedSpecifiers.length === 0) return "";
229
- return `{${formatNamed(namedSpecifiers, sourceCode)}}`;
230
- }
231
- //#endregion
232
- //#region src/rules/singleLineImports/createFix.ts
233
- function createFix$3(fixer, declaration, sourceCode) {
234
- const source = declaration.source.value;
235
- const prefix = declaration.importKind === "type" ? "import type " : "import ";
236
- const specifiers = formatSpecifiers(declaration, sourceCode);
237
- const attributes = formatAttributes(declaration.attributes);
238
- if (specifiers === "") {
239
- const result = `${prefix}'${source}'${attributes}`;
240
- return fixer.replaceText(declaration, result);
241
- }
242
- const result = `${prefix}${specifiers} from '${source}'${attributes}`;
243
- return fixer.replaceText(declaration, result);
244
- }
245
- //#endregion
246
- //#region src/rules/singleLineImports/isMultiline.ts
247
- function isMultiline$1(declaration) {
248
- const { start, end } = declaration.loc ?? {};
249
- return start?.line !== end?.line;
250
- }
251
- //#endregion
252
- //#region src/rules/singleLineImports/index.ts
2579
+ const defaultSpecifier = declaration.specifiers.find(
2580
+ (s) => s.type === "ImportDefaultSpecifier"
2581
+ );
2582
+ const namespaceSpecifier = declaration.specifiers.find(
2583
+ (s) => s.type === "ImportNamespaceSpecifier"
2584
+ );
2585
+ const namedSpecifiers = declaration.specifiers.filter(
2586
+ (s) => s.type === "ImportSpecifier"
2587
+ );
2588
+ if (namespaceSpecifier)
2589
+ return `* as ${namespaceSpecifier.local.name}`;
2590
+ if (defaultSpecifier && namedSpecifiers.length > 0) {
2591
+ return `${defaultSpecifier.local.name}, {${formatNamed(
2592
+ namedSpecifiers,
2593
+ sourceCode
2594
+ )}}`;
2595
+ }
2596
+ if (defaultSpecifier)
2597
+ return defaultSpecifier.local.name;
2598
+ if (namedSpecifiers.length === 0)
2599
+ return "";
2600
+ return `{${formatNamed(namedSpecifiers, sourceCode)}}`;
2601
+ }
2602
+ function createImportFix$1(fixer, declaration, sourceCode) {
2603
+ const source = declaration.source.value;
2604
+ const prefix = declaration.importKind === "type" ? "import type " : "import ";
2605
+ const specifiers = formatSpecifiers(declaration, sourceCode);
2606
+ const attributes = formatAttributes(declaration.attributes);
2607
+ if (specifiers === "") {
2608
+ const result2 = `${prefix}'${source}'${attributes}`;
2609
+ return fixer.replaceText(declaration, result2);
2610
+ }
2611
+ const result = `${prefix}${specifiers} from '${source}'${attributes}`;
2612
+ return fixer.replaceText(declaration, result);
2613
+ }
2614
+ function isMultilineImport(declaration) {
2615
+ const { end, start } = declaration.loc ?? {};
2616
+ return start?.line !== end?.line;
2617
+ }
253
2618
  const singleLineImports = {
254
- meta: {
255
- docs: { description: "Enforce imports to be on a single line" },
256
- fixable: "code",
257
- messages: { multiline: "Import should be on a single line" },
258
- schema: [],
259
- type: "layout"
260
- },
261
- create(context) {
262
- return { ImportDeclaration(node) {
263
- if (!isMultiline$1(node)) return;
264
- context.report({
265
- node,
266
- messageId: "multiline",
267
- fix: (fixer) => createFix$3(fixer, node, context.sourceCode)
268
- });
269
- } };
270
- }
271
- };
272
- //#endregion
273
- //#region src/rules/singleLineReExports/createFix.ts
274
- function createFix$2(fixer, declaration, sourceCode) {
275
- const source = declaration.source.value;
276
- if (declaration.type === "ExportAllDeclaration") {
277
- const result = `export ${declaration.exported ? `* as ${sourceCode.getText(declaration.exported)}` : "*"} from '${source}'${formatAttributes(declaration.attributes)}`;
278
- return fixer.replaceText(declaration, result);
279
- }
280
- const result = `${declaration.exportKind === "type" ? "export type " : "export "}{${declaration.specifiers.map((s) => sourceCode.getText(s)).join(", ")}} from '${source}'${formatAttributes(declaration.attributes)}`;
281
- return fixer.replaceText(declaration, result);
282
- }
283
- //#endregion
284
- //#region src/rules/singleLineReExports/isMultiline.ts
285
- function isMultiline(declaration) {
286
- const { start, end } = declaration.loc ?? {};
287
- return start?.line !== end?.line;
288
- }
289
- //#endregion
290
- //#region src/rules/singleLineReExports/index.ts
2619
+ create(context) {
2620
+ return {
2621
+ ImportDeclaration(node2) {
2622
+ if (!isMultilineImport(node2))
2623
+ return;
2624
+ context.report({
2625
+ fix: (fixer) => createImportFix$1(fixer, node2, context.sourceCode),
2626
+ messageId: "multiline",
2627
+ node: node2
2628
+ });
2629
+ }
2630
+ };
2631
+ },
2632
+ meta: {
2633
+ docs: {
2634
+ description: "Enforce imports to be on a single line."
2635
+ },
2636
+ fixable: "code",
2637
+ messages: {
2638
+ multiline: "Import should be on a single line"
2639
+ },
2640
+ schema: [],
2641
+ type: "layout"
2642
+ }
2643
+ };
2644
+ function createReExportFix$1(fixer, declaration, sourceCode) {
2645
+ const source = declaration.source.value;
2646
+ if (declaration.type === "ExportAllDeclaration") {
2647
+ const exported = declaration.exported ? `* as ${sourceCode.getText(declaration.exported)}` : "*";
2648
+ const attributes2 = formatAttributes(declaration.attributes);
2649
+ const result2 = `export ${exported} from '${source}'${attributes2}`;
2650
+ return fixer.replaceText(declaration, result2);
2651
+ }
2652
+ const prefix = declaration.exportKind === "type" ? "export type " : "export ";
2653
+ const specifiers = declaration.specifiers.map(
2654
+ (s) => sourceCode.getText(s)
2655
+ ).join(", ");
2656
+ const attributes = formatAttributes(declaration.attributes);
2657
+ const result = `${prefix}{${specifiers}} from '${source}'${attributes}`;
2658
+ return fixer.replaceText(declaration, result);
2659
+ }
2660
+ function isMultilineReExport(declaration) {
2661
+ const { end, start } = declaration.loc ?? {};
2662
+ return start?.line !== end?.line;
2663
+ }
291
2664
  const singleLineReExports = {
292
- meta: {
293
- docs: { description: "Enforce re-exports to be on a single line" },
294
- fixable: "code",
295
- messages: { multiline: "Re-export should be on a single line" },
296
- schema: [],
297
- type: "layout"
298
- },
299
- create(context) {
300
- const checkDeclaration = (node, declaration) => {
301
- if (!declaration.source) return;
302
- if (!isMultiline(declaration)) return;
303
- context.report({
304
- node,
305
- messageId: "multiline",
306
- fix: (fixer) => createFix$2(fixer, declaration, context.sourceCode)
307
- });
308
- };
309
- return {
310
- ExportNamedDeclaration: (node) => checkDeclaration(node, node),
311
- ExportAllDeclaration: (node) => checkDeclaration(node, node)
312
- };
313
- }
314
- };
315
- //#endregion
316
- //#region src/rules/sortedImports/categorizeImport.ts
2665
+ create(context) {
2666
+ const checkDeclaration = (node2, declaration) => {
2667
+ if (!declaration.source)
2668
+ return;
2669
+ if (!isMultilineReExport(declaration))
2670
+ return;
2671
+ context.report({
2672
+ fix: (fixer) => createReExportFix$1(fixer, declaration, context.sourceCode),
2673
+ messageId: "multiline",
2674
+ node: node2
2675
+ });
2676
+ };
2677
+ return {
2678
+ ExportAllDeclaration: (node2) => {
2679
+ checkDeclaration(node2, node2);
2680
+ },
2681
+ ExportNamedDeclaration: (node2) => {
2682
+ checkDeclaration(node2, node2);
2683
+ }
2684
+ };
2685
+ },
2686
+ meta: {
2687
+ docs: {
2688
+ description: "Enforce re-exports to be on a single line."
2689
+ },
2690
+ fixable: "code",
2691
+ messages: {
2692
+ multiline: "Re-export should be on a single line"
2693
+ },
2694
+ schema: [],
2695
+ type: "layout"
2696
+ }
2697
+ };
317
2698
  function categorizeImport(declaration) {
318
- if (declaration.importKind === "type") return "type";
319
- if (declaration.specifiers.length === 0) return "side-effect";
320
- if (declaration.specifiers.some((s) => s.type === "ImportNamespaceSpecifier")) return "namespace";
321
- if (declaration.specifiers.some((s) => s.type === "ImportDefaultSpecifier")) return "default";
322
- return "named";
323
- }
324
- //#endregion
325
- //#region src/rules/sortedImports/getSortKey.ts
326
- function getSortKey$1(declaration) {
327
- const group = categorizeImport(declaration);
328
- if (group === "side-effect") return declaration.source.value;
329
- if (group === "namespace") return `*${declaration.specifiers.find((s) => s.type === "ImportNamespaceSpecifier")?.local.name ?? ""}`;
330
- if (group === "default") return declaration.specifiers.find((s) => s.type === "ImportDefaultSpecifier")?.local.name ?? "";
331
- return declaration.specifiers[0].local.name;
332
- }
333
- //#endregion
334
- //#region src/rules/sortedImports/categorizeImports.ts
2699
+ if (declaration.specifiers.some((s) => s.type === "ImportNamespaceSpecifier")) {
2700
+ return declaration.importKind === "type" ? "type-namespace" : "namespace";
2701
+ }
2702
+ if (declaration.specifiers.some((s) => s.type === "ImportDefaultSpecifier")) {
2703
+ return declaration.importKind === "type" ? "type-default" : "default";
2704
+ }
2705
+ if (declaration.importKind === "type")
2706
+ return "type-named";
2707
+ if (declaration.specifiers.length === 0)
2708
+ return "side-effect";
2709
+ return "named";
2710
+ }
2711
+ function getImportSortKey(declaration) {
2712
+ const group = categorizeImport(declaration);
2713
+ if (group === "side-effect")
2714
+ return declaration.source.value;
2715
+ if (group === "namespace" || group === "type-namespace") {
2716
+ const namespaceSpecifier = declaration.specifiers.find(
2717
+ (s) => s.type === "ImportNamespaceSpecifier"
2718
+ );
2719
+ return `*${namespaceSpecifier?.local.name ?? ""}`;
2720
+ }
2721
+ if (group === "default" || group === "type-default") {
2722
+ const defaultSpecifier = declaration.specifiers.find(
2723
+ (s) => s.type === "ImportDefaultSpecifier"
2724
+ );
2725
+ return defaultSpecifier?.local.name ?? "";
2726
+ }
2727
+ const specifier = declaration.specifiers[0];
2728
+ return specifier.local.name;
2729
+ }
335
2730
  function categorizeImports(declarations) {
336
- return declarations.map((declaration) => ({
337
- declaration,
338
- group: categorizeImport(declaration),
339
- sortKey: getSortKey$1(declaration)
340
- }));
341
- }
342
- //#endregion
343
- //#region src/lib/compare.ts
2731
+ return declarations.map((declaration) => ({
2732
+ declaration,
2733
+ group: categorizeImport(declaration),
2734
+ sortKey: getImportSortKey(declaration)
2735
+ }));
2736
+ }
344
2737
  function compare(a, b) {
345
- return a.localeCompare(b, "en", { sensitivity: "case" });
2738
+ return a.localeCompare(b, "en", { sensitivity: "case" });
346
2739
  }
347
- //#endregion
348
- //#region src/rules/sortedImports/ImportGroupOrder.ts
349
2740
  const importGroupOrder = [
350
- "side-effect",
351
- "namespace",
352
- "default",
353
- "named",
354
- "type"
2741
+ "side-effect",
2742
+ "namespace",
2743
+ "default",
2744
+ "named",
2745
+ "type-namespace",
2746
+ "type-default",
2747
+ "type-named"
355
2748
  ];
356
- //#endregion
357
- //#region src/rules/sortedImports/checkAlphabeticalSorting.ts
358
- function checkAlphabeticalSorting$1(categorized) {
359
- const errors = [];
360
- for (const group of importGroupOrder) {
361
- const groupImports = categorized.filter((c) => c.group === group);
362
- const sorted = [...groupImports].sort((a, b) => compare(a.sortKey, b.sortKey));
363
- for (let i = 0; i < groupImports.length; i++) if (groupImports[i] !== sorted[i]) errors.push({
364
- node: groupImports[i].declaration,
365
- messageId: "sortedImports"
366
- });
367
- }
368
- return errors;
369
- }
370
- //#endregion
371
- //#region src/rules/sortedImports/checkGroupOrdering.ts
372
- function checkGroupOrdering$1(categorized) {
373
- const errors = [];
374
- let currentGroupIndex = -1;
375
- for (const { declaration, group } of categorized) {
376
- const groupIndex = importGroupOrder.indexOf(group);
377
- if (groupIndex < currentGroupIndex) errors.push({
378
- node: declaration,
379
- messageId: "wrongGroup"
380
- });
381
- else currentGroupIndex = groupIndex;
382
- }
383
- return errors;
384
- }
385
- //#endregion
386
- //#region src/rules/sortedImports/getSpecifierName.ts
387
- function getSpecifierName$1(specifier) {
388
- return specifier.imported.type === "Identifier" ? specifier.imported.name : String(specifier.imported.value);
389
- }
390
- //#endregion
391
- //#region src/rules/sortedImports/areSpecifiersSorted.ts
2749
+ function checkAlphabeticalSorting$1(categorizedImports) {
2750
+ const errors = [];
2751
+ for (const importGroup of importGroupOrder) {
2752
+ const groupImports = categorizedImports.filter((c) => c.group === importGroup);
2753
+ const expectedSortedImports = [...groupImports].sort((a, b) => compare(
2754
+ a.sortKey,
2755
+ b.sortKey
2756
+ ));
2757
+ for (let i = 0; i < groupImports.length; i++) {
2758
+ if (groupImports[i] !== expectedSortedImports[i]) {
2759
+ errors.push({
2760
+ messageId: "sortedImports",
2761
+ node: groupImports[i].declaration
2762
+ });
2763
+ }
2764
+ }
2765
+ }
2766
+ return errors;
2767
+ }
2768
+ function checkGroupOrdering$1(categorizedImports) {
2769
+ const errors = [];
2770
+ let currentGroupIndex = -1;
2771
+ for (const { declaration, group: importGroup } of categorizedImports) {
2772
+ const groupIndex = importGroupOrder.indexOf(importGroup);
2773
+ if (groupIndex < currentGroupIndex) {
2774
+ errors.push({
2775
+ messageId: "wrongGroup",
2776
+ node: declaration
2777
+ });
2778
+ } else
2779
+ currentGroupIndex = groupIndex;
2780
+ }
2781
+ return errors;
2782
+ }
2783
+ function getImportSpecifierName(specifier) {
2784
+ return specifier.imported.type === "Identifier" ? specifier.imported.name : String(specifier.imported.value);
2785
+ }
392
2786
  function areSpecifiersSorted$1(specifiers) {
393
- const names = specifiers.map((s) => getSpecifierName$1(s));
394
- const sorted = [...names].sort((a, b) => compare(a, b));
395
- return names.every((name, i) => name === sorted[i]);
2787
+ const names = specifiers.map((s) => getImportSpecifierName(s));
2788
+ const sorted = [...names].sort((a, b) => compare(a, b));
2789
+ return names.every((name, i) => name === sorted[i]);
396
2790
  }
397
- //#endregion
398
- //#region src/rules/sortedImports/getNamedSpecifiers.ts
399
- function getNamedSpecifiers$1(declaration) {
400
- return declaration.specifiers.filter((s) => s.type === "ImportSpecifier");
2791
+ function getImportNamedSpecifiers(declaration) {
2792
+ return declaration.specifiers.filter(
2793
+ (s) => s.type === "ImportSpecifier"
2794
+ );
401
2795
  }
402
- //#endregion
403
- //#region src/rules/sortedImports/checkSpecifiersSorting.ts
404
2796
  function checkSpecifiersSorting$1(categorized) {
405
- const errors = [];
406
- const namedImports = categorized.filter((c) => c.group === "named");
407
- for (const { declaration } of namedImports) {
408
- const specifiers = getNamedSpecifiers$1(declaration);
409
- if (specifiers.length > 1 && !areSpecifiersSorted$1(specifiers)) errors.push({
410
- node: declaration,
411
- messageId: "sortedNames"
412
- });
413
- }
414
- return errors;
415
- }
416
- //#endregion
417
- //#region src/rules/sortedImports/sortSpecifiersText.ts
418
- function sortSpecifiersText$1(specifiers, sourceCode) {
419
- return [...specifiers].sort((a, b) => {
420
- return compare(getSpecifierName$1(a), getSpecifierName$1(b));
421
- }).map((s) => sourceCode.getText(s)).join(", ");
422
- }
423
- //#endregion
424
- //#region src/rules/sortedImports/createFix/formatNamedImport.ts
425
- function formatNamedImport(declaration, sourceCode) {
426
- const specifiers = getNamedSpecifiers$1(declaration);
427
- if (specifiers.length > 1 && !areSpecifiersSorted$1(specifiers)) {
428
- const sortedSpecifiers = sortSpecifiersText$1(specifiers, sourceCode);
429
- const source = declaration.source.value;
430
- return `${declaration.importKind === "type" ? "import type " : "import "}{${sortedSpecifiers}} from '${source}'`;
431
- }
432
- return sourceCode.getText(declaration);
433
- }
434
- //#endregion
435
- //#region src/rules/sortedImports/createFix/buildSortedCode.ts
436
- function buildSortedCode$1(grouped, sourceCode) {
437
- const sortedCode = [];
438
- for (const group of importGroupOrder) for (const { declaration } of grouped[group]) if (group === "named" || group === "type") sortedCode.push(formatNamedImport(declaration, sourceCode));
439
- else sortedCode.push(sourceCode.getText(declaration));
440
- return sortedCode;
441
- }
442
- //#endregion
443
- //#region src/rules/sortedImports/createFix/groupImportsByType.ts
2797
+ const errors = [];
2798
+ const namedImportDeclarations = categorized.filter((c) => c.group === "named");
2799
+ for (const { declaration } of namedImportDeclarations) {
2800
+ const namedSpecifiers = getImportNamedSpecifiers(declaration);
2801
+ if (namedSpecifiers.length > 1 && !areSpecifiersSorted$1(namedSpecifiers)) {
2802
+ errors.push({
2803
+ messageId: "sortedNames",
2804
+ node: declaration
2805
+ });
2806
+ }
2807
+ }
2808
+ return errors;
2809
+ }
2810
+ function sortImportSpecifiersText(specifiers, sourceCode) {
2811
+ const sorted = [...specifiers].sort((a, b) => {
2812
+ const nameA = getImportSpecifierName(a);
2813
+ const nameB = getImportSpecifierName(b);
2814
+ return compare(nameA, nameB);
2815
+ });
2816
+ return sorted.map((s) => sourceCode.getText(s)).join(", ");
2817
+ }
2818
+ function formatNamedImportSpecifiers(declaration, sourceCode) {
2819
+ const specifiers = getImportNamedSpecifiers(declaration);
2820
+ if (specifiers.length > 1 && !areSpecifiersSorted$1(specifiers)) {
2821
+ const sortedSpecifiers = sortImportSpecifiersText(specifiers, sourceCode);
2822
+ const source = declaration.source.value;
2823
+ const prefix = declaration.importKind === "type" ? "import type " : "import ";
2824
+ return `${prefix}{${sortedSpecifiers}} from '${source}'`;
2825
+ }
2826
+ return sourceCode.getText(declaration);
2827
+ }
2828
+ function buildSortedImportCode(grouped, sourceCode) {
2829
+ const sortedCode = [];
2830
+ for (const group of importGroupOrder) {
2831
+ for (const { declaration } of grouped[group] ?? []) {
2832
+ if (group === "named" || group === "type-named")
2833
+ sortedCode.push(formatNamedImportSpecifiers(declaration, sourceCode));
2834
+ else
2835
+ sortedCode.push(sourceCode.getText(declaration));
2836
+ }
2837
+ }
2838
+ return sortedCode;
2839
+ }
444
2840
  function groupImportsByType(categorized) {
445
- const grouped = {
446
- "side-effect": [],
447
- namespace: [],
448
- default: [],
449
- named: [],
450
- type: []
451
- };
452
- for (const item of categorized) grouped[item.group].push(item);
453
- return grouped;
454
- }
455
- //#endregion
456
- //#region src/rules/sortedImports/createFix/sortImportGroups.ts
2841
+ const grouped = {
2842
+ default: [],
2843
+ named: [],
2844
+ namespace: [],
2845
+ "side-effect": [],
2846
+ "type-default": [],
2847
+ "type-named": [],
2848
+ "type-namespace": []
2849
+ };
2850
+ for (const item of categorized)
2851
+ grouped[item.group].push(item);
2852
+ return grouped;
2853
+ }
457
2854
  function sortImportGroups(grouped) {
458
- grouped["side-effect"].sort((a, b) => compare(a.sortKey, b.sortKey));
459
- grouped["namespace"].sort((a, b) => compare(a.sortKey, b.sortKey));
460
- grouped["default"].sort((a, b) => compare(a.sortKey, b.sortKey));
461
- grouped["named"].sort((a, b) => compare(a.sortKey, b.sortKey));
462
- grouped["type"].sort((a, b) => compare(a.sortKey, b.sortKey));
463
- }
464
- //#endregion
465
- //#region src/rules/sortedImports/createFix/index.ts
2855
+ grouped["side-effect"].sort((a, b) => compare(a.sortKey, b.sortKey));
2856
+ grouped["namespace"].sort((a, b) => compare(a.sortKey, b.sortKey));
2857
+ grouped["default"].sort((a, b) => compare(a.sortKey, b.sortKey));
2858
+ grouped["named"].sort((a, b) => compare(a.sortKey, b.sortKey));
2859
+ grouped["type-namespace"].sort((a, b) => compare(a.sortKey, b.sortKey));
2860
+ grouped["type-default"].sort((a, b) => compare(a.sortKey, b.sortKey));
2861
+ grouped["type-named"].sort((a, b) => compare(a.sortKey, b.sortKey));
2862
+ }
466
2863
  function createFixForGroup$1(fixer, importDeclarations, sourceCode) {
467
- if (importDeclarations.length === 0) return null;
468
- const grouped = groupImportsByType(categorizeImports(importDeclarations));
469
- sortImportGroups(grouped);
470
- const sortedCode = buildSortedCode$1(grouped, sourceCode).join("\n");
471
- const firstImport = importDeclarations[0];
472
- const lastImport = importDeclarations[importDeclarations.length - 1];
473
- return fixer.replaceTextRange([firstImport.range[0], lastImport.range[1]], sortedCode);
474
- }
475
- function createFix$1(fixer, importGroups, sourceCode) {
476
- const fixes = [];
477
- for (const group of importGroups) {
478
- const fix = createFixForGroup$1(fixer, group, sourceCode);
479
- if (fix) fixes.push(fix);
480
- }
481
- return fixes;
482
- }
483
- //#endregion
484
- //#region src/rules/sortedImports/getImportGroups.ts
2864
+ if (importDeclarations.length === 0)
2865
+ return null;
2866
+ const categorized = categorizeImports(importDeclarations);
2867
+ const grouped = groupImportsByType(categorized);
2868
+ sortImportGroups(grouped);
2869
+ const sortedCode = buildSortedImportCode(grouped, sourceCode).join("\n");
2870
+ const firstImport = importDeclarations[0];
2871
+ const lastImport = importDeclarations[importDeclarations.length - 1];
2872
+ return fixer.replaceTextRange(
2873
+ [firstImport.range[0], lastImport.range[1]],
2874
+ sortedCode
2875
+ );
2876
+ }
2877
+ function createImportFix(fixer, importGroups, sourceCode) {
2878
+ const fixes = [];
2879
+ for (const group of importGroups) {
2880
+ const fix = createFixForGroup$1(fixer, group, sourceCode);
2881
+ if (fix)
2882
+ fixes.push(fix);
2883
+ }
2884
+ return fixes;
2885
+ }
485
2886
  function getImportGroups(programBody) {
486
- const groups = [];
487
- let currentGroup = [];
488
- for (const statement of programBody) {
489
- if (statement.type === "ImportDeclaration") {
490
- currentGroup.push(statement);
491
- continue;
492
- }
493
- if (currentGroup.length > 0) {
494
- groups.push(currentGroup);
495
- currentGroup = [];
496
- }
497
- }
498
- if (currentGroup.length > 0) groups.push(currentGroup);
499
- return groups;
500
- }
501
- //#endregion
502
- //#region src/rules/sortedImports/index.ts
2887
+ const groups = [];
2888
+ let currentImportGroup = [];
2889
+ for (const statement of programBody) {
2890
+ if (statement.type === "ImportDeclaration") {
2891
+ currentImportGroup.push(statement);
2892
+ continue;
2893
+ }
2894
+ if (currentImportGroup.length > 0) {
2895
+ groups.push(currentImportGroup);
2896
+ currentImportGroup = [];
2897
+ }
2898
+ }
2899
+ if (currentImportGroup.length > 0)
2900
+ groups.push(currentImportGroup);
2901
+ return groups;
2902
+ }
503
2903
  const sortedImports = {
504
- meta: {
505
- docs: { description: "Enforce sorted imports alphabetically" },
506
- fixable: "code",
507
- messages: {
508
- sortedImports: "Imports should be sorted alphabetically",
509
- sortedNames: "Named imports should be sorted alphabetically",
510
- wrongGroup: "Import is in wrong group"
511
- },
512
- schema: [],
513
- type: "suggestion"
514
- },
515
- create(context) {
516
- return { Program(node) {
517
- const body = node.body;
518
- const importGroups = getImportGroups(body);
519
- if (importGroups.length === 0) return;
520
- const allErrors = [];
521
- for (const group of importGroups) {
522
- const categorized = categorizeImports(group);
523
- const errors = [
524
- ...checkGroupOrdering$1(categorized),
525
- ...checkAlphabeticalSorting$1(categorized),
526
- ...checkSpecifiersSorting$1(categorized)
527
- ];
528
- allErrors.push(...errors);
529
- }
530
- for (const error of allErrors) context.report({
531
- node: error.node,
532
- messageId: error.messageId,
533
- fix(fixer) {
534
- const sourceCode = context.sourceCode;
535
- return createFix$1(fixer, importGroups, sourceCode);
536
- }
537
- });
538
- } };
539
- }
540
- };
541
- //#endregion
542
- //#region src/rules/sortedReExports/categorizeReExport.ts
2904
+ create(context) {
2905
+ return {
2906
+ Program(node2) {
2907
+ const programBody = node2.body;
2908
+ const importGroups = getImportGroups(programBody);
2909
+ if (importGroups.length === 0)
2910
+ return;
2911
+ const allImportErrors = [];
2912
+ for (const group of importGroups) {
2913
+ const categorized = categorizeImports(group);
2914
+ const errors = [
2915
+ ...checkGroupOrdering$1(categorized),
2916
+ ...checkAlphabeticalSorting$1(categorized),
2917
+ ...checkSpecifiersSorting$1(categorized)
2918
+ ];
2919
+ allImportErrors.push(...errors);
2920
+ }
2921
+ for (const error of allImportErrors) {
2922
+ context.report({
2923
+ fix(fixer) {
2924
+ const sourceCode = context.sourceCode;
2925
+ return createImportFix(fixer, importGroups, sourceCode);
2926
+ },
2927
+ messageId: error.messageId,
2928
+ node: error.node
2929
+ });
2930
+ }
2931
+ }
2932
+ };
2933
+ },
2934
+ meta: {
2935
+ docs: {
2936
+ description: "Enforce sorted imports alphabetically."
2937
+ },
2938
+ fixable: "code",
2939
+ messages: {
2940
+ sortedImports: "Imports should be sorted alphabetically",
2941
+ sortedNames: "Named imports should be sorted alphabetically",
2942
+ wrongGroup: "Import is in wrong group"
2943
+ },
2944
+ schema: [],
2945
+ type: "suggestion"
2946
+ }
2947
+ };
543
2948
  function categorizeReExport(declaration) {
544
- if (declaration.type === "ExportAllDeclaration") {
545
- if (declaration.exported) return "re-export-namespace";
546
- return "re-export-all";
547
- }
548
- if (declaration.exportKind === "type") return "re-export-type";
549
- return "re-export-named";
550
- }
551
- //#endregion
552
- //#region src/rules/sortedReExports/getSortKey.ts
553
- function getSortKey(declaration) {
554
- const group = categorizeReExport(declaration);
555
- if (declaration.type === "ExportAllDeclaration") {
556
- if (group === "re-export-namespace") {
557
- if (declaration.exported?.type === "Identifier") return `*${declaration.exported.name}`;
558
- }
559
- return declaration.source.value;
560
- }
561
- const specifier = declaration.specifiers[0];
562
- if (!specifier) return "";
563
- return specifier.local.type === "Identifier" ? specifier.local.name : specifier.local.value;
564
- }
565
- //#endregion
566
- //#region src/rules/sortedReExports/categorizeReExports.ts
2949
+ if (declaration.type === "ExportAllDeclaration") {
2950
+ if (declaration.exportKind === "type") {
2951
+ if (declaration.exported)
2952
+ return "type-namespace";
2953
+ return "type-all";
2954
+ }
2955
+ if (declaration.exported)
2956
+ return "re-export-namespace";
2957
+ return "re-export-all";
2958
+ }
2959
+ if (declaration.exportKind === "type")
2960
+ return "type-named";
2961
+ if (declaration.specifiers?.some((s) => s.exportKind === "type"))
2962
+ return "type-named";
2963
+ return "re-export-named";
2964
+ }
2965
+ function getReExportSortKey(declaration) {
2966
+ const group = categorizeReExport(declaration);
2967
+ if (declaration.type === "ExportAllDeclaration") {
2968
+ if (group === "re-export-namespace") {
2969
+ if (declaration.exported?.type === "Identifier")
2970
+ return `*${declaration.exported.name}`;
2971
+ }
2972
+ return declaration.source.value;
2973
+ }
2974
+ const specifier = declaration.specifiers[0];
2975
+ if (!specifier)
2976
+ return "";
2977
+ return specifier.local.type === "Identifier" ? specifier.local.name : specifier.local.value;
2978
+ }
567
2979
  function categorizeReExports(declarations) {
568
- return declarations.map((declaration) => {
569
- return {
570
- declaration,
571
- group: categorizeReExport(declaration),
572
- sortKey: getSortKey(declaration)
573
- };
574
- });
575
- }
576
- //#endregion
577
- //#region src/rules/sortedReExports/ReExportGroupOrder.ts
2980
+ return declarations.map((declaration) => {
2981
+ return {
2982
+ declaration,
2983
+ group: categorizeReExport(declaration),
2984
+ sortKey: getReExportSortKey(declaration)
2985
+ };
2986
+ });
2987
+ }
578
2988
  const reExportGroupOrder = [
579
- "re-export-all",
580
- "re-export-namespace",
581
- "re-export-named",
582
- "re-export-type"
2989
+ "re-export-all",
2990
+ "re-export-namespace",
2991
+ "re-export-named",
2992
+ "type-all",
2993
+ "type-namespace",
2994
+ "type-named"
583
2995
  ];
584
- //#endregion
585
- //#region src/rules/sortedReExports/checkAlphabeticalSorting.ts
586
2996
  function checkAlphabeticalSorting(categorized) {
587
- const errors = [];
588
- for (const group of reExportGroupOrder) {
589
- const groupReExports = categorized.filter((c) => c.group === group);
590
- const sorted = [...groupReExports].sort((a, b) => compare(a.sortKey, b.sortKey));
591
- for (let i = 0; i < groupReExports.length; i++) if (groupReExports[i] !== sorted[i]) errors.push({
592
- node: groupReExports[i].declaration,
593
- messageId: "sortedReExports"
594
- });
595
- }
596
- return errors;
597
- }
598
- //#endregion
599
- //#region src/rules/sortedReExports/checkGroupOrdering.ts
2997
+ const errors = [];
2998
+ for (const group of reExportGroupOrder) {
2999
+ const groupReExports = categorized.filter((c) => c.group === group);
3000
+ const sorted = [...groupReExports].sort(
3001
+ (a, b) => compare(a.sortKey, b.sortKey)
3002
+ );
3003
+ for (let i = 0; i < groupReExports.length; i++) {
3004
+ if (groupReExports[i] !== sorted[i]) {
3005
+ errors.push({
3006
+ messageId: "sortedReExports",
3007
+ node: groupReExports[i].declaration
3008
+ });
3009
+ }
3010
+ }
3011
+ }
3012
+ return errors;
3013
+ }
600
3014
  function checkGroupOrdering(categorized) {
601
- const errors = [];
602
- let currentGroupIndex = -1;
603
- for (const { declaration, group } of categorized) {
604
- const groupIndex = reExportGroupOrder.indexOf(group);
605
- if (groupIndex < currentGroupIndex) errors.push({
606
- node: declaration,
607
- messageId: "wrongGroup"
608
- });
609
- else currentGroupIndex = groupIndex;
610
- }
611
- return errors;
612
- }
613
- //#endregion
614
- //#region src/rules/sortedReExports/getSpecifierName.ts
3015
+ const errors = [];
3016
+ let currentGroupIndex = -1;
3017
+ for (const { declaration, group } of categorized) {
3018
+ const groupIndex = reExportGroupOrder.indexOf(group);
3019
+ if (groupIndex < currentGroupIndex) {
3020
+ errors.push({
3021
+ messageId: "wrongGroup",
3022
+ node: declaration
3023
+ });
3024
+ } else
3025
+ currentGroupIndex = groupIndex;
3026
+ }
3027
+ return errors;
3028
+ }
615
3029
  function getSpecifierName(specifier) {
616
- return specifier.local.type === "Identifier" ? specifier.local.name : String(specifier.local.value);
3030
+ return specifier.local.type === "Identifier" ? specifier.local.name : String(specifier.local.value);
617
3031
  }
618
- //#endregion
619
- //#region src/rules/sortedReExports/areSpecifiersSorted.ts
620
3032
  function areSpecifiersSorted(specifiers) {
621
- const names = specifiers.map((s) => getSpecifierName(s));
622
- const sorted = [...names].sort((a, b) => compare(a, b));
623
- return names.every((name, i) => name === sorted[i]);
3033
+ const names = specifiers.map((s) => getSpecifierName(s));
3034
+ const sorted = [...names].sort((a, b) => compare(a, b));
3035
+ return names.every((name, i) => name === sorted[i]);
624
3036
  }
625
- //#endregion
626
- //#region src/rules/sortedReExports/getNamedSpecifiers.ts
627
- function getNamedSpecifiers(declaration) {
628
- return declaration.specifiers.filter((s) => s.type === "ExportSpecifier" && s.local.type === "Identifier");
3037
+ function getReExportNamedSpecifiers(declaration) {
3038
+ return declaration.specifiers.filter(
3039
+ (s) => s.type === "ExportSpecifier" && s.local.type === "Identifier"
3040
+ );
629
3041
  }
630
- //#endregion
631
- //#region src/rules/sortedReExports/isNamedReExport.ts
632
3042
  function isNamedReExport(x) {
633
- return x.group !== "re-export-all" && x.group !== "re-export-namespace";
3043
+ return x.group !== "re-export-all" && x.group !== "re-export-namespace";
634
3044
  }
635
- //#endregion
636
- //#region src/rules/sortedReExports/checkSpecifiersSorting.ts
637
3045
  function checkSpecifiersSorting(categorized) {
638
- const errors = [];
639
- const namedReExports = categorized.filter(isNamedReExport);
640
- for (const { declaration } of namedReExports) {
641
- const specifiers = getNamedSpecifiers(declaration);
642
- const isSorted = areSpecifiersSorted(specifiers);
643
- if (specifiers.length > 1 && !isSorted) errors.push({
644
- node: declaration,
645
- messageId: "sortedNames"
646
- });
647
- }
648
- return errors;
649
- }
650
- //#endregion
651
- //#region src/rules/sortedReExports/sortSpecifiersText.ts
3046
+ const errors = [];
3047
+ const namedReExports = categorized.filter(isNamedReExport);
3048
+ for (const { declaration } of namedReExports) {
3049
+ const specifiers = getReExportNamedSpecifiers(declaration);
3050
+ const isSorted = areSpecifiersSorted(specifiers);
3051
+ if (specifiers.length > 1 && !isSorted) {
3052
+ errors.push({
3053
+ messageId: "sortedNames",
3054
+ node: declaration
3055
+ });
3056
+ }
3057
+ }
3058
+ return errors;
3059
+ }
652
3060
  function sortSpecifiersText(specifiers, sourceCode) {
653
- return [...specifiers].sort((a, b) => {
654
- return compare(getSpecifierName(a), getSpecifierName(b));
655
- }).map((s) => sourceCode.getText(s)).join(", ");
656
- }
657
- //#endregion
658
- //#region src/rules/sortedReExports/createFix/formatNamedReExport.ts
659
- function formatNamedReExport(declaration, sourceCode) {
660
- const specifiers = getNamedSpecifiers(declaration);
661
- if (specifiers.length > 1 && !areSpecifiersSorted(specifiers)) {
662
- const sortedSpecifiers = sortSpecifiersText(specifiers, sourceCode);
663
- const source = declaration.source.value;
664
- return `${declaration.exportKind === "type" ? "export type " : "export "}{${sortedSpecifiers}} from '${source}'`;
665
- }
666
- return sourceCode.getText(declaration);
667
- }
668
- //#endregion
669
- //#region src/rules/sortedReExports/createFix/buildSortedCode.ts
670
- function buildSortedCode(grouped, sourceCode) {
671
- const sortedCode = [];
672
- for (const group of reExportGroupOrder) for (const item of grouped[group]) if (isNamedReExport(item)) sortedCode.push(formatNamedReExport(item.declaration, sourceCode));
673
- else sortedCode.push(sourceCode.getText(item.declaration));
674
- return sortedCode;
675
- }
676
- //#endregion
677
- //#region src/rules/sortedReExports/createFix/groupReExportsByType.ts
3061
+ const sorted = [...specifiers].sort((a, b) => {
3062
+ const nameA = getSpecifierName(a);
3063
+ const nameB = getSpecifierName(b);
3064
+ return compare(nameA, nameB);
3065
+ });
3066
+ return sorted.map((s) => sourceCode.getText(s)).join(", ");
3067
+ }
3068
+ function formatNamedReExportSpecifiers(declaration, sourceCode) {
3069
+ const specifiers = getReExportNamedSpecifiers(declaration);
3070
+ if (specifiers.length > 1 && !areSpecifiersSorted(specifiers)) {
3071
+ const sortedSpecifiers = sortSpecifiersText(specifiers, sourceCode);
3072
+ const source = declaration.source.value;
3073
+ const prefix = declaration.exportKind === "type" ? "export type " : "export ";
3074
+ return `${prefix}{${sortedSpecifiers}} from '${source}'`;
3075
+ }
3076
+ return sourceCode.getText(declaration);
3077
+ }
3078
+ function buildSortedReExportCode(grouped, sourceCode) {
3079
+ const sortedCode = [];
3080
+ for (const group of reExportGroupOrder) {
3081
+ for (const item of grouped[group]) {
3082
+ if (isNamedReExport(item)) {
3083
+ sortedCode.push(
3084
+ formatNamedReExportSpecifiers(
3085
+ item.declaration,
3086
+ sourceCode
3087
+ )
3088
+ );
3089
+ } else
3090
+ sortedCode.push(sourceCode.getText(item.declaration));
3091
+ }
3092
+ }
3093
+ return sortedCode;
3094
+ }
678
3095
  function groupReExportsByType(categorized) {
679
- const grouped = {
680
- "re-export-all": [],
681
- "re-export-namespace": [],
682
- "re-export-named": [],
683
- "re-export-type": []
684
- };
685
- for (const item of categorized) grouped[item.group].push(item);
686
- return grouped;
687
- }
688
- //#endregion
689
- //#region src/rules/sortedReExports/createFix/sortExportGroups.ts
3096
+ const grouped = {
3097
+ "re-export-all": [],
3098
+ "re-export-named": [],
3099
+ "re-export-namespace": [],
3100
+ "type-all": [],
3101
+ "type-named": [],
3102
+ "type-namespace": []
3103
+ };
3104
+ for (const item of categorized)
3105
+ grouped[item.group].push(item);
3106
+ return grouped;
3107
+ }
690
3108
  function sortExportGroups(grouped) {
691
- grouped["re-export-all"].sort((a, b) => compare(a.sortKey, b.sortKey));
692
- grouped["re-export-namespace"].sort((a, b) => compare(a.sortKey, b.sortKey));
693
- grouped["re-export-named"].sort((a, b) => compare(a.sortKey, b.sortKey));
694
- grouped["re-export-type"].sort((a, b) => compare(a.sortKey, b.sortKey));
3109
+ grouped["re-export-all"].sort((a, b) => compare(a.sortKey, b.sortKey));
3110
+ grouped["re-export-namespace"].sort((a, b) => compare(a.sortKey, b.sortKey));
3111
+ grouped["re-export-named"].sort((a, b) => compare(a.sortKey, b.sortKey));
3112
+ grouped["type-all"].sort((a, b) => compare(a.sortKey, b.sortKey));
3113
+ grouped["type-namespace"].sort((a, b) => compare(a.sortKey, b.sortKey));
3114
+ grouped["type-named"].sort((a, b) => compare(a.sortKey, b.sortKey));
695
3115
  }
696
- //#endregion
697
- //#region src/rules/sortedReExports/createFix/index.ts
698
3116
  function createFixForGroup(fixer, reExportDeclarations, sourceCode) {
699
- if (reExportDeclarations.length === 0) return null;
700
- const grouped = groupReExportsByType(categorizeReExports(reExportDeclarations));
701
- sortExportGroups(grouped);
702
- const sortedCode = buildSortedCode(grouped, sourceCode).join("\n");
703
- const firstReExport = reExportDeclarations[0];
704
- const lastReExport = reExportDeclarations[reExportDeclarations.length - 1];
705
- return fixer.replaceTextRange([firstReExport.range[0], lastReExport.range[1]], sortedCode);
706
- }
707
- function createFix(fixer, reExportGroups, sourceCode) {
708
- const fixes = [];
709
- for (const group of reExportGroups) {
710
- const fix = createFixForGroup(fixer, group, sourceCode);
711
- if (fix) fixes.push(fix);
712
- }
713
- return fixes;
714
- }
715
- //#endregion
716
- //#region src/rules/sortedReExports/getReExportGroups.ts
3117
+ if (reExportDeclarations.length === 0)
3118
+ return null;
3119
+ const categorized = categorizeReExports(reExportDeclarations);
3120
+ const grouped = groupReExportsByType(categorized);
3121
+ sortExportGroups(grouped);
3122
+ const sortedCode = buildSortedReExportCode(grouped, sourceCode).join("\n");
3123
+ const firstReExport = reExportDeclarations[0];
3124
+ const lastReExport = reExportDeclarations[reExportDeclarations.length - 1];
3125
+ return fixer.replaceTextRange(
3126
+ [firstReExport.range[0], lastReExport.range[1]],
3127
+ sortedCode
3128
+ );
3129
+ }
3130
+ function createReExportFix(fixer, reExportGroups, sourceCode) {
3131
+ const fixes = [];
3132
+ for (const group of reExportGroups) {
3133
+ const fix = createFixForGroup(fixer, group, sourceCode);
3134
+ if (fix)
3135
+ fixes.push(fix);
3136
+ }
3137
+ return fixes;
3138
+ }
717
3139
  function isReExportDeclaration(statement) {
718
- return statement.type === "ExportNamedDeclaration" && statement.source !== null || statement.type === "ExportAllDeclaration";
3140
+ return statement.type === "ExportNamedDeclaration" && statement.source !== null || statement.type === "ExportAllDeclaration";
719
3141
  }
720
3142
  function getReExportGroups(programBody) {
721
- const groups = [];
722
- let currentGroup = [];
723
- for (const statement of programBody) {
724
- if (isReExportDeclaration(statement)) {
725
- currentGroup.push(statement);
726
- continue;
727
- }
728
- if (currentGroup.length > 0) {
729
- groups.push(currentGroup);
730
- currentGroup = [];
731
- }
732
- }
733
- if (currentGroup.length > 0) groups.push(currentGroup);
734
- return groups;
735
- }
736
- //#endregion
737
- //#region src/rules/sortedReExports/index.ts
3143
+ const groups = [];
3144
+ let currentGroup = [];
3145
+ for (const statement of programBody) {
3146
+ if (isReExportDeclaration(statement)) {
3147
+ currentGroup.push(statement);
3148
+ continue;
3149
+ }
3150
+ if (currentGroup.length > 0) {
3151
+ groups.push(currentGroup);
3152
+ currentGroup = [];
3153
+ }
3154
+ }
3155
+ if (currentGroup.length > 0)
3156
+ groups.push(currentGroup);
3157
+ return groups;
3158
+ }
738
3159
  const sortedReExports = {
739
- meta: {
740
- docs: { description: "Enforce sorted exports alphabetically" },
741
- fixable: "code",
742
- messages: {
743
- sortedReExports: "Exports should be sorted alphabetically",
744
- sortedNames: "Named exports should be sorted alphabetically",
745
- wrongGroup: "Export is in wrong group"
746
- },
747
- schema: [],
748
- type: "suggestion"
749
- },
750
- create(context) {
751
- return { Program(node) {
752
- const body = node.body;
753
- const reExportGroups = getReExportGroups(body);
754
- if (reExportGroups.length === 0) return;
755
- const allErrors = [];
756
- for (const group of reExportGroups) {
757
- const categorized = categorizeReExports(group);
758
- const errors = [
759
- ...checkGroupOrdering(categorized),
760
- ...checkAlphabeticalSorting(categorized),
761
- ...checkSpecifiersSorting(categorized)
762
- ];
763
- allErrors.push(...errors);
764
- }
765
- for (const error of allErrors) context.report({
766
- node: error.node,
767
- messageId: error.messageId,
768
- fix(fixer) {
769
- const sourceCode = context.sourceCode;
770
- return createFix(fixer, reExportGroups, sourceCode);
771
- }
772
- });
773
- } };
774
- }
775
- };
776
- //#endregion
777
- //#region src/index.ts
778
- const CONFIG = [
779
- { ignores: [
780
- "src/graphql/sdk.ts",
781
- "**/node_modules/**",
782
- "**/dist/**"
783
- ] },
784
- { settings: { react: { version: "19" } } },
785
- eslint.configs.recommended,
786
- react.configs.flat.recommended,
787
- stylistic.configs.recommended,
788
- ...typescript.configs.recommended,
789
- ...typescript.configs.stylistic,
790
- {
791
- plugins: { "react-hooks": reactHooks },
792
- rules: reactHooks.configs.recommended.rules
793
- },
794
- {
795
- plugins: { "@borela-tech": { rules: {
796
- "imports-and-re-exports-at-top": importsAndReExportsAtTop,
797
- "individual-imports": individualImports,
798
- "individual-re-exports": individualReExports,
799
- "multiline-union-types": multilineUnionTypes,
800
- "single-line-imports": singleLineImports,
801
- "single-line-re-exports": singleLineReExports,
802
- "sorted-imports": sortedImports,
803
- "sorted-re-exports": sortedReExports
804
- } } },
805
- rules: {
806
- "@borela-tech/imports-and-re-exports-at-top": "error",
807
- "@borela-tech/individual-imports": "error",
808
- "@borela-tech/individual-re-exports": "error",
809
- "@borela-tech/multiline-union-types": "error",
810
- "@borela-tech/single-line-imports": "error",
811
- "@borela-tech/single-line-re-exports": "error",
812
- "@borela-tech/sorted-imports": "error",
813
- "@borela-tech/sorted-re-exports": "error"
814
- }
815
- },
816
- { rules: {
817
- "capitalized-comments": [
818
- "error",
819
- "always",
820
- { ignoreConsecutiveComments: true }
821
- ],
822
- "react/react-in-jsx-scope": "off",
823
- "@stylistic/arrow-parens": ["error", "as-needed"],
824
- "@stylistic/array-bracket-newline": ["error", "consistent"],
825
- "@stylistic/array-bracket-spacing": ["error", "never"],
826
- "@stylistic/array-element-newline": ["error", "consistent"],
827
- "@stylistic/block-spacing": "off",
828
- "@stylistic/brace-style": [
829
- "error",
830
- "1tbs",
831
- { allowSingleLine: true }
832
- ],
833
- "@stylistic/indent": [
834
- "error",
835
- 2,
836
- { ignoredNodes: ["TSMappedType > *"] }
837
- ],
838
- "@stylistic/jsx-tag-spacing": ["error", {
839
- afterOpening: "never",
840
- beforeClosing: "never",
841
- beforeSelfClosing: "never",
842
- closingSlash: "never"
843
- }],
844
- "@stylistic/jsx-wrap-multilines": "off",
845
- "@stylistic/lines-between-class-members": "off",
846
- "@stylistic/object-curly-newline": ["error", { consistent: true }],
847
- "@stylistic/object-curly-spacing": ["error", "never"],
848
- "@stylistic/operator-linebreak": [
849
- "error",
850
- "before",
851
- { overrides: { "=": "after" } }
852
- ],
853
- "@stylistic/quotes": [
854
- "error",
855
- "single",
856
- { avoidEscape: true }
857
- ],
858
- "@stylistic/quote-props": ["error", "as-needed"],
859
- "@stylistic/semi": [
860
- "error",
861
- "never",
862
- { beforeStatementContinuationChars: "always" }
863
- ],
864
- "@typescript-eslint/no-empty-function": "off",
865
- "@typescript-eslint/consistent-indexed-object-style": "off",
866
- "@typescript-eslint/consistent-type-imports": ["error", { fixStyle: "separate-type-imports" }]
867
- } }
3160
+ create(context) {
3161
+ return {
3162
+ Program(node2) {
3163
+ const programBody = node2.body;
3164
+ const reExportGroups = getReExportGroups(programBody);
3165
+ if (reExportGroups.length === 0)
3166
+ return;
3167
+ const allReExportErrors = [];
3168
+ for (const group of reExportGroups) {
3169
+ const categorizedReExports = categorizeReExports(group);
3170
+ const groupErrors = [
3171
+ ...checkGroupOrdering(categorizedReExports),
3172
+ ...checkAlphabeticalSorting(categorizedReExports),
3173
+ ...checkSpecifiersSorting(categorizedReExports)
3174
+ ];
3175
+ allReExportErrors.push(...groupErrors);
3176
+ }
3177
+ for (const error of allReExportErrors) {
3178
+ context.report({
3179
+ fix(fixer) {
3180
+ const sourceCode = context.sourceCode;
3181
+ return createReExportFix(fixer, reExportGroups, sourceCode);
3182
+ },
3183
+ messageId: error.messageId,
3184
+ node: error.node
3185
+ });
3186
+ }
3187
+ }
3188
+ };
3189
+ },
3190
+ meta: {
3191
+ docs: {
3192
+ description: "Enforce sorted exports alphabetically."
3193
+ },
3194
+ fixable: "code",
3195
+ messages: {
3196
+ sortedNames: "Named exports should be sorted alphabetically",
3197
+ sortedReExports: "Exports should be sorted alphabetically",
3198
+ wrongGroup: "Export is in wrong group"
3199
+ },
3200
+ schema: [],
3201
+ type: "suggestion"
3202
+ }
3203
+ };
3204
+ const customRules = {
3205
+ plugins: {
3206
+ "@borela-tech": {
3207
+ rules: {
3208
+ "array-items-line-break": arrayItemsLineBreak,
3209
+ "brace-style-control-statements": braceStyleControlStatements,
3210
+ "brace-style-object-literal": braceStyleObjectLiteral,
3211
+ "compact-array-items": compactArrayItems,
3212
+ "export-filename-match": exportFilenameMatch,
3213
+ "function-call-argument-line-break": functionCallArgumentLineBreak,
3214
+ "function-cognitive-complexity": functionCognitiveComplexity,
3215
+ "function-parameter-line-break": functionParameterLineBreak,
3216
+ "imports-and-re-exports-at-top": importsAndReExportsAtTop,
3217
+ "individual-imports": individualImports,
3218
+ "individual-re-exports": individualReExports,
3219
+ "interface-property-line-break": interfacePropertyLineBreak,
3220
+ "max-declarations-per-file": maxDeclarationsPerFile,
3221
+ "multiline-union-type-aliases": multilineUnionTypeAliases,
3222
+ "no-inline-object-types": noInlineObjectTypes,
3223
+ "no-unnecessary-braces": noUnnecessaryBraces,
3224
+ "object-property-line-break": objectPropertyLineBreak,
3225
+ "one-export-per-file": oneExportPerFile,
3226
+ "prefer-inline-export": preferInlineExport,
3227
+ "single-line-arrow-function-parameters": singleLineArrowFunctionParameters,
3228
+ "single-line-function-parameters": singleLineFunctionParameters,
3229
+ "single-line-imports": singleLineImports,
3230
+ "single-line-re-exports": singleLineReExports,
3231
+ "sorted-imports": sortedImports,
3232
+ "sorted-re-exports": sortedReExports
3233
+ }
3234
+ }
3235
+ },
3236
+ rules: {
3237
+ "@borela-tech/array-items-line-break": [
3238
+ "error",
3239
+ { maxLength: 80 }
3240
+ ],
3241
+ "@borela-tech/brace-style-control-statements": "error",
3242
+ "@borela-tech/brace-style-object-literal": "error",
3243
+ "@borela-tech/compact-array-items": "error",
3244
+ "@borela-tech/export-filename-match": "error",
3245
+ "@borela-tech/function-call-argument-line-break": [
3246
+ "error",
3247
+ { maxLength: 80 }
3248
+ ],
3249
+ "@borela-tech/function-cognitive-complexity": [
3250
+ "error",
3251
+ { maxCognitiveComplexity: 15 }
3252
+ ],
3253
+ "@borela-tech/function-parameter-line-break": [
3254
+ "error",
3255
+ { maxLength: 80 }
3256
+ ],
3257
+ "@borela-tech/imports-and-re-exports-at-top": "error",
3258
+ "@borela-tech/individual-imports": "error",
3259
+ "@borela-tech/individual-re-exports": "error",
3260
+ "@borela-tech/interface-property-line-break": [
3261
+ "error",
3262
+ { maxLength: 80 }
3263
+ ],
3264
+ "@borela-tech/max-declarations-per-file": "error",
3265
+ "@borela-tech/multiline-union-type-aliases": "error",
3266
+ "@borela-tech/no-inline-object-types": "error",
3267
+ "@borela-tech/no-unnecessary-braces": "error",
3268
+ "@borela-tech/object-property-line-break": "error",
3269
+ "@borela-tech/one-export-per-file": "error",
3270
+ "@borela-tech/prefer-inline-export": "error",
3271
+ "@borela-tech/single-line-arrow-function-parameters": [
3272
+ "error",
3273
+ { maxLength: 80 }
3274
+ ],
3275
+ "@borela-tech/single-line-function-parameters": [
3276
+ "error",
3277
+ { maxLength: 80 }
3278
+ ],
3279
+ "@borela-tech/single-line-imports": "error",
3280
+ "@borela-tech/single-line-re-exports": "error",
3281
+ "@borela-tech/sorted-imports": "error",
3282
+ "@borela-tech/sorted-re-exports": "error"
3283
+ }
3284
+ };
3285
+ const generalRules = {
3286
+ rules: {
3287
+ "capitalized-comments": [
3288
+ "error",
3289
+ "always",
3290
+ { ignoreConsecutiveComments: true }
3291
+ ],
3292
+ complexity: ["error", 10],
3293
+ "no-restricted-exports": ["error", {
3294
+ restrictDefaultExports: {
3295
+ direct: true
3296
+ }
3297
+ }],
3298
+ "react/react-in-jsx-scope": "off"
3299
+ }
3300
+ };
3301
+ const ignores = {
3302
+ ignores: [
3303
+ "src/graphql/sdk.ts",
3304
+ "**/node_modules/**",
3305
+ "**/dist/**"
3306
+ ]
3307
+ };
3308
+ const languageOptions = {
3309
+ languageOptions: {
3310
+ parserOptions: {
3311
+ projectService: true
3312
+ }
3313
+ },
3314
+ settings: {
3315
+ react: {
3316
+ version: "19"
3317
+ }
3318
+ }
3319
+ };
3320
+ const perfectionistRules = {
3321
+ plugins: { perfectionist },
3322
+ rules: {
3323
+ "perfectionist/sort-array-includes": ["error", {
3324
+ order: "asc",
3325
+ type: "natural"
3326
+ }],
3327
+ "perfectionist/sort-decorators": ["error", {
3328
+ order: "asc",
3329
+ type: "natural"
3330
+ }],
3331
+ "perfectionist/sort-enums": ["error", {
3332
+ order: "asc",
3333
+ type: "natural"
3334
+ }],
3335
+ "perfectionist/sort-heritage-clauses": ["error", {
3336
+ order: "asc",
3337
+ type: "natural"
3338
+ }],
3339
+ "perfectionist/sort-interfaces": ["error", {
3340
+ order: "asc",
3341
+ type: "natural"
3342
+ }],
3343
+ "perfectionist/sort-intersection-types": ["error", {
3344
+ order: "asc",
3345
+ type: "natural"
3346
+ }],
3347
+ "perfectionist/sort-jsx-props": ["error", {
3348
+ order: "asc",
3349
+ type: "natural"
3350
+ }],
3351
+ "perfectionist/sort-maps": ["error", {
3352
+ order: "asc",
3353
+ type: "natural"
3354
+ }],
3355
+ "perfectionist/sort-object-types": ["error", {
3356
+ order: "asc",
3357
+ type: "natural"
3358
+ }],
3359
+ "perfectionist/sort-objects": ["error", {
3360
+ order: "asc",
3361
+ type: "natural"
3362
+ }],
3363
+ "perfectionist/sort-sets": ["error", {
3364
+ order: "asc",
3365
+ type: "natural"
3366
+ }],
3367
+ "perfectionist/sort-switch-case": ["error", {
3368
+ order: "asc",
3369
+ type: "natural"
3370
+ }],
3371
+ "perfectionist/sort-union-types": ["error", {
3372
+ order: "asc",
3373
+ type: "natural"
3374
+ }]
3375
+ }
3376
+ };
3377
+ const reactHooks = {
3378
+ plugins: {
3379
+ "react-hooks": rule
3380
+ },
3381
+ rules: rule.configs.recommended.rules
3382
+ };
3383
+ const stylisticRules = {
3384
+ rules: {
3385
+ "@stylistic/array-bracket-spacing": [
3386
+ "error",
3387
+ "never"
3388
+ ],
3389
+ "@stylistic/arrow-parens": [
3390
+ "error",
3391
+ "as-needed"
3392
+ ],
3393
+ "@stylistic/block-spacing": "off",
3394
+ "@stylistic/brace-style": [
3395
+ "error",
3396
+ "1tbs",
3397
+ { allowSingleLine: true }
3398
+ ],
3399
+ "@stylistic/indent": [
3400
+ "error",
3401
+ 2,
3402
+ { ignoredNodes: ["TSMappedType > *"] }
3403
+ ],
3404
+ "@stylistic/jsx-tag-spacing": ["error", {
3405
+ afterOpening: "never",
3406
+ beforeClosing: "never",
3407
+ beforeSelfClosing: "never",
3408
+ closingSlash: "never"
3409
+ }],
3410
+ "@stylistic/jsx-wrap-multilines": "off",
3411
+ "@stylistic/lines-between-class-members": "off",
3412
+ "@stylistic/object-curly-newline": "off",
3413
+ "@stylistic/object-curly-spacing": [
3414
+ "error",
3415
+ "never"
3416
+ ],
3417
+ "@stylistic/operator-linebreak": [
3418
+ "error",
3419
+ "before",
3420
+ { overrides: { "=": "after" } }
3421
+ ],
3422
+ "@stylistic/quote-props": [
3423
+ "error",
3424
+ "as-needed"
3425
+ ],
3426
+ "@stylistic/quotes": [
3427
+ "error",
3428
+ "single",
3429
+ { avoidEscape: true }
3430
+ ],
3431
+ "@stylistic/semi": [
3432
+ "error",
3433
+ "never",
3434
+ { beforeStatementContinuationChars: "always" }
3435
+ ]
3436
+ }
3437
+ };
3438
+ const typescriptRules = {
3439
+ rules: {
3440
+ "@typescript-eslint/consistent-indexed-object-style": "off",
3441
+ "@typescript-eslint/consistent-type-imports": [
3442
+ "error",
3443
+ { fixStyle: "separate-type-imports" }
3444
+ ],
3445
+ "@typescript-eslint/explicit-function-return-type": "error",
3446
+ "@typescript-eslint/naming-convention": ["error", {
3447
+ format: ["camelCase"],
3448
+ leadingUnderscore: "allow",
3449
+ selector: "default",
3450
+ trailingUnderscore: "allow"
3451
+ }, {
3452
+ format: ["camelCase", "PascalCase"],
3453
+ selector: "import"
3454
+ }, {
3455
+ format: ["camelCase", "UPPER_CASE"],
3456
+ leadingUnderscore: "allow",
3457
+ selector: "variable",
3458
+ trailingUnderscore: "allow"
3459
+ }, {
3460
+ format: ["PascalCase"],
3461
+ selector: "typeLike"
3462
+ }, {
3463
+ format: null,
3464
+ selector: "property"
3465
+ }, {
3466
+ format: null,
3467
+ selector: "objectLiteralProperty"
3468
+ }, {
3469
+ format: null,
3470
+ selector: "objectLiteralMethod"
3471
+ }],
3472
+ "@typescript-eslint/no-empty-function": "off",
3473
+ "@typescript-eslint/no-unused-vars": ["error", {
3474
+ argsIgnorePattern: "^_",
3475
+ caughtErrorsIgnorePattern: "^_",
3476
+ varsIgnorePattern: "^_"
3477
+ }]
3478
+ }
3479
+ };
3480
+ function getDefaultExportFromCjs(x) {
3481
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
3482
+ }
3483
+ const builtin = { "AggregateError": false, "Array": false, "ArrayBuffer": false, "Atomics": false, "BigInt": false, "BigInt64Array": false, "BigUint64Array": false, "Boolean": false, "constructor": false, "DataView": false, "Date": false, "decodeURI": false, "decodeURIComponent": false, "encodeURI": false, "encodeURIComponent": false, "Error": false, "escape": false, "eval": false, "EvalError": false, "FinalizationRegistry": false, "Float32Array": false, "Float64Array": false, "Function": false, "globalThis": false, "hasOwnProperty": false, "Infinity": false, "Int16Array": false, "Int32Array": false, "Int8Array": false, "isFinite": false, "isNaN": false, "isPrototypeOf": false, "JSON": false, "Map": false, "Math": false, "NaN": false, "Number": false, "Object": false, "parseFloat": false, "parseInt": false, "Promise": false, "propertyIsEnumerable": false, "Proxy": false, "RangeError": false, "ReferenceError": false, "Reflect": false, "RegExp": false, "Set": false, "SharedArrayBuffer": false, "String": false, "Symbol": false, "SyntaxError": false, "toLocaleString": false, "toString": false, "TypeError": false, "Uint16Array": false, "Uint32Array": false, "Uint8Array": false, "Uint8ClampedArray": false, "undefined": false, "unescape": false, "URIError": false, "valueOf": false, "WeakMap": false, "WeakRef": false, "WeakSet": false };
3484
+ const es5 = { "Array": false, "Boolean": false, "constructor": false, "Date": false, "decodeURI": false, "decodeURIComponent": false, "encodeURI": false, "encodeURIComponent": false, "Error": false, "escape": false, "eval": false, "EvalError": false, "Function": false, "hasOwnProperty": false, "Infinity": false, "isFinite": false, "isNaN": false, "isPrototypeOf": false, "JSON": false, "Math": false, "NaN": false, "Number": false, "Object": false, "parseFloat": false, "parseInt": false, "propertyIsEnumerable": false, "RangeError": false, "ReferenceError": false, "RegExp": false, "String": false, "SyntaxError": false, "toLocaleString": false, "toString": false, "TypeError": false, "undefined": false, "unescape": false, "URIError": false, "valueOf": false };
3485
+ const es2015 = { "Array": false, "ArrayBuffer": false, "Boolean": false, "constructor": false, "DataView": false, "Date": false, "decodeURI": false, "decodeURIComponent": false, "encodeURI": false, "encodeURIComponent": false, "Error": false, "escape": false, "eval": false, "EvalError": false, "Float32Array": false, "Float64Array": false, "Function": false, "hasOwnProperty": false, "Infinity": false, "Int16Array": false, "Int32Array": false, "Int8Array": false, "isFinite": false, "isNaN": false, "isPrototypeOf": false, "JSON": false, "Map": false, "Math": false, "NaN": false, "Number": false, "Object": false, "parseFloat": false, "parseInt": false, "Promise": false, "propertyIsEnumerable": false, "Proxy": false, "RangeError": false, "ReferenceError": false, "Reflect": false, "RegExp": false, "Set": false, "String": false, "Symbol": false, "SyntaxError": false, "toLocaleString": false, "toString": false, "TypeError": false, "Uint16Array": false, "Uint32Array": false, "Uint8Array": false, "Uint8ClampedArray": false, "undefined": false, "unescape": false, "URIError": false, "valueOf": false, "WeakMap": false, "WeakSet": false };
3486
+ const es2017 = { "Array": false, "ArrayBuffer": false, "Atomics": false, "Boolean": false, "constructor": false, "DataView": false, "Date": false, "decodeURI": false, "decodeURIComponent": false, "encodeURI": false, "encodeURIComponent": false, "Error": false, "escape": false, "eval": false, "EvalError": false, "Float32Array": false, "Float64Array": false, "Function": false, "hasOwnProperty": false, "Infinity": false, "Int16Array": false, "Int32Array": false, "Int8Array": false, "isFinite": false, "isNaN": false, "isPrototypeOf": false, "JSON": false, "Map": false, "Math": false, "NaN": false, "Number": false, "Object": false, "parseFloat": false, "parseInt": false, "Promise": false, "propertyIsEnumerable": false, "Proxy": false, "RangeError": false, "ReferenceError": false, "Reflect": false, "RegExp": false, "Set": false, "SharedArrayBuffer": false, "String": false, "Symbol": false, "SyntaxError": false, "toLocaleString": false, "toString": false, "TypeError": false, "Uint16Array": false, "Uint32Array": false, "Uint8Array": false, "Uint8ClampedArray": false, "undefined": false, "unescape": false, "URIError": false, "valueOf": false, "WeakMap": false, "WeakSet": false };
3487
+ const es2020 = { "Array": false, "ArrayBuffer": false, "Atomics": false, "BigInt": false, "BigInt64Array": false, "BigUint64Array": false, "Boolean": false, "constructor": false, "DataView": false, "Date": false, "decodeURI": false, "decodeURIComponent": false, "encodeURI": false, "encodeURIComponent": false, "Error": false, "escape": false, "eval": false, "EvalError": false, "Float32Array": false, "Float64Array": false, "Function": false, "globalThis": false, "hasOwnProperty": false, "Infinity": false, "Int16Array": false, "Int32Array": false, "Int8Array": false, "isFinite": false, "isNaN": false, "isPrototypeOf": false, "JSON": false, "Map": false, "Math": false, "NaN": false, "Number": false, "Object": false, "parseFloat": false, "parseInt": false, "Promise": false, "propertyIsEnumerable": false, "Proxy": false, "RangeError": false, "ReferenceError": false, "Reflect": false, "RegExp": false, "Set": false, "SharedArrayBuffer": false, "String": false, "Symbol": false, "SyntaxError": false, "toLocaleString": false, "toString": false, "TypeError": false, "Uint16Array": false, "Uint32Array": false, "Uint8Array": false, "Uint8ClampedArray": false, "undefined": false, "unescape": false, "URIError": false, "valueOf": false, "WeakMap": false, "WeakSet": false };
3488
+ const es2021 = { "AggregateError": false, "Array": false, "ArrayBuffer": false, "Atomics": false, "BigInt": false, "BigInt64Array": false, "BigUint64Array": false, "Boolean": false, "constructor": false, "DataView": false, "Date": false, "decodeURI": false, "decodeURIComponent": false, "encodeURI": false, "encodeURIComponent": false, "Error": false, "escape": false, "eval": false, "EvalError": false, "FinalizationRegistry": false, "Float32Array": false, "Float64Array": false, "Function": false, "globalThis": false, "hasOwnProperty": false, "Infinity": false, "Int16Array": false, "Int32Array": false, "Int8Array": false, "isFinite": false, "isNaN": false, "isPrototypeOf": false, "JSON": false, "Map": false, "Math": false, "NaN": false, "Number": false, "Object": false, "parseFloat": false, "parseInt": false, "Promise": false, "propertyIsEnumerable": false, "Proxy": false, "RangeError": false, "ReferenceError": false, "Reflect": false, "RegExp": false, "Set": false, "SharedArrayBuffer": false, "String": false, "Symbol": false, "SyntaxError": false, "toLocaleString": false, "toString": false, "TypeError": false, "Uint16Array": false, "Uint32Array": false, "Uint8Array": false, "Uint8ClampedArray": false, "undefined": false, "unescape": false, "URIError": false, "valueOf": false, "WeakMap": false, "WeakRef": false, "WeakSet": false };
3489
+ const browser = /* @__PURE__ */ JSON.parse('{"AbortController":false,"AbortSignal":false,"addEventListener":false,"alert":false,"AnalyserNode":false,"Animation":false,"AnimationEffectReadOnly":false,"AnimationEffectTiming":false,"AnimationEffectTimingReadOnly":false,"AnimationEvent":false,"AnimationPlaybackEvent":false,"AnimationTimeline":false,"applicationCache":false,"ApplicationCache":false,"ApplicationCacheErrorEvent":false,"atob":false,"Attr":false,"Audio":false,"AudioBuffer":false,"AudioBufferSourceNode":false,"AudioContext":false,"AudioDestinationNode":false,"AudioListener":false,"AudioNode":false,"AudioParam":false,"AudioProcessingEvent":false,"AudioScheduledSourceNode":false,"AudioWorkletGlobalScope":false,"AudioWorkletNode":false,"AudioWorkletProcessor":false,"BarProp":false,"BaseAudioContext":false,"BatteryManager":false,"BeforeUnloadEvent":false,"BiquadFilterNode":false,"Blob":false,"BlobEvent":false,"blur":false,"BroadcastChannel":false,"btoa":false,"BudgetService":false,"ByteLengthQueuingStrategy":false,"Cache":false,"caches":false,"CacheStorage":false,"cancelAnimationFrame":false,"cancelIdleCallback":false,"CanvasCaptureMediaStreamTrack":false,"CanvasGradient":false,"CanvasPattern":false,"CanvasRenderingContext2D":false,"ChannelMergerNode":false,"ChannelSplitterNode":false,"CharacterData":false,"clearInterval":false,"clearTimeout":false,"clientInformation":false,"ClipboardEvent":false,"ClipboardItem":false,"close":false,"closed":false,"CloseEvent":false,"Comment":false,"CompositionEvent":false,"CompressionStream":false,"confirm":false,"console":false,"ConstantSourceNode":false,"ConvolverNode":false,"CountQueuingStrategy":false,"createImageBitmap":false,"Credential":false,"CredentialsContainer":false,"crypto":false,"Crypto":false,"CryptoKey":false,"CSS":false,"CSSConditionRule":false,"CSSFontFaceRule":false,"CSSGroupingRule":false,"CSSImportRule":false,"CSSKeyframeRule":false,"CSSKeyframesRule":false,"CSSMatrixComponent":false,"CSSMediaRule":false,"CSSNamespaceRule":false,"CSSPageRule":false,"CSSPerspective":false,"CSSRotate":false,"CSSRule":false,"CSSRuleList":false,"CSSScale":false,"CSSSkew":false,"CSSSkewX":false,"CSSSkewY":false,"CSSStyleDeclaration":false,"CSSStyleRule":false,"CSSStyleSheet":false,"CSSSupportsRule":false,"CSSTransformValue":false,"CSSTranslate":false,"CustomElementRegistry":false,"customElements":false,"CustomEvent":false,"DataTransfer":false,"DataTransferItem":false,"DataTransferItemList":false,"DecompressionStream":false,"defaultstatus":false,"defaultStatus":false,"DelayNode":false,"DeviceMotionEvent":false,"DeviceOrientationEvent":false,"devicePixelRatio":false,"dispatchEvent":false,"document":false,"Document":false,"DocumentFragment":false,"DocumentType":false,"DOMError":false,"DOMException":false,"DOMImplementation":false,"DOMMatrix":false,"DOMMatrixReadOnly":false,"DOMParser":false,"DOMPoint":false,"DOMPointReadOnly":false,"DOMQuad":false,"DOMRect":false,"DOMRectList":false,"DOMRectReadOnly":false,"DOMStringList":false,"DOMStringMap":false,"DOMTokenList":false,"DragEvent":false,"DynamicsCompressorNode":false,"Element":false,"ErrorEvent":false,"event":false,"Event":false,"EventSource":false,"EventTarget":false,"external":false,"fetch":false,"File":false,"FileList":false,"FileReader":false,"find":false,"focus":false,"FocusEvent":false,"FontFace":false,"FontFaceSetLoadEvent":false,"FormData":false,"FormDataEvent":false,"frameElement":false,"frames":false,"GainNode":false,"Gamepad":false,"GamepadButton":false,"GamepadEvent":false,"getComputedStyle":false,"getSelection":false,"HashChangeEvent":false,"Headers":false,"history":false,"History":false,"HTMLAllCollection":false,"HTMLAnchorElement":false,"HTMLAreaElement":false,"HTMLAudioElement":false,"HTMLBaseElement":false,"HTMLBodyElement":false,"HTMLBRElement":false,"HTMLButtonElement":false,"HTMLCanvasElement":false,"HTMLCollection":false,"HTMLContentElement":false,"HTMLDataElement":false,"HTMLDataListElement":false,"HTMLDetailsElement":false,"HTMLDialogElement":false,"HTMLDirectoryElement":false,"HTMLDivElement":false,"HTMLDListElement":false,"HTMLDocument":false,"HTMLElement":false,"HTMLEmbedElement":false,"HTMLFieldSetElement":false,"HTMLFontElement":false,"HTMLFormControlsCollection":false,"HTMLFormElement":false,"HTMLFrameElement":false,"HTMLFrameSetElement":false,"HTMLHeadElement":false,"HTMLHeadingElement":false,"HTMLHRElement":false,"HTMLHtmlElement":false,"HTMLIFrameElement":false,"HTMLImageElement":false,"HTMLInputElement":false,"HTMLLabelElement":false,"HTMLLegendElement":false,"HTMLLIElement":false,"HTMLLinkElement":false,"HTMLMapElement":false,"HTMLMarqueeElement":false,"HTMLMediaElement":false,"HTMLMenuElement":false,"HTMLMetaElement":false,"HTMLMeterElement":false,"HTMLModElement":false,"HTMLObjectElement":false,"HTMLOListElement":false,"HTMLOptGroupElement":false,"HTMLOptionElement":false,"HTMLOptionsCollection":false,"HTMLOutputElement":false,"HTMLParagraphElement":false,"HTMLParamElement":false,"HTMLPictureElement":false,"HTMLPreElement":false,"HTMLProgressElement":false,"HTMLQuoteElement":false,"HTMLScriptElement":false,"HTMLSelectElement":false,"HTMLShadowElement":false,"HTMLSlotElement":false,"HTMLSourceElement":false,"HTMLSpanElement":false,"HTMLStyleElement":false,"HTMLTableCaptionElement":false,"HTMLTableCellElement":false,"HTMLTableColElement":false,"HTMLTableElement":false,"HTMLTableRowElement":false,"HTMLTableSectionElement":false,"HTMLTemplateElement":false,"HTMLTextAreaElement":false,"HTMLTimeElement":false,"HTMLTitleElement":false,"HTMLTrackElement":false,"HTMLUListElement":false,"HTMLUnknownElement":false,"HTMLVideoElement":false,"IDBCursor":false,"IDBCursorWithValue":false,"IDBDatabase":false,"IDBFactory":false,"IDBIndex":false,"IDBKeyRange":false,"IDBObjectStore":false,"IDBOpenDBRequest":false,"IDBRequest":false,"IDBTransaction":false,"IDBVersionChangeEvent":false,"IdleDeadline":false,"IIRFilterNode":false,"Image":false,"ImageBitmap":false,"ImageBitmapRenderingContext":false,"ImageCapture":false,"ImageData":false,"indexedDB":false,"innerHeight":false,"innerWidth":false,"InputEvent":false,"IntersectionObserver":false,"IntersectionObserverEntry":false,"Intl":false,"isSecureContext":false,"KeyboardEvent":false,"KeyframeEffect":false,"KeyframeEffectReadOnly":false,"length":false,"localStorage":false,"location":true,"Location":false,"locationbar":false,"matchMedia":false,"MediaDeviceInfo":false,"MediaDevices":false,"MediaElementAudioSourceNode":false,"MediaEncryptedEvent":false,"MediaError":false,"MediaKeyMessageEvent":false,"MediaKeySession":false,"MediaKeyStatusMap":false,"MediaKeySystemAccess":false,"MediaList":false,"MediaMetadata":false,"MediaQueryList":false,"MediaQueryListEvent":false,"MediaRecorder":false,"MediaSettingsRange":false,"MediaSource":false,"MediaStream":false,"MediaStreamAudioDestinationNode":false,"MediaStreamAudioSourceNode":false,"MediaStreamConstraints":false,"MediaStreamEvent":false,"MediaStreamTrack":false,"MediaStreamTrackEvent":false,"menubar":false,"MessageChannel":false,"MessageEvent":false,"MessagePort":false,"MIDIAccess":false,"MIDIConnectionEvent":false,"MIDIInput":false,"MIDIInputMap":false,"MIDIMessageEvent":false,"MIDIOutput":false,"MIDIOutputMap":false,"MIDIPort":false,"MimeType":false,"MimeTypeArray":false,"MouseEvent":false,"moveBy":false,"moveTo":false,"MutationEvent":false,"MutationObserver":false,"MutationRecord":false,"name":false,"NamedNodeMap":false,"NavigationPreloadManager":false,"navigator":false,"Navigator":false,"NavigatorUAData":false,"NetworkInformation":false,"Node":false,"NodeFilter":false,"NodeIterator":false,"NodeList":false,"Notification":false,"OfflineAudioCompletionEvent":false,"OfflineAudioContext":false,"offscreenBuffering":false,"OffscreenCanvas":true,"OffscreenCanvasRenderingContext2D":false,"onabort":true,"onafterprint":true,"onanimationend":true,"onanimationiteration":true,"onanimationstart":true,"onappinstalled":true,"onauxclick":true,"onbeforeinstallprompt":true,"onbeforeprint":true,"onbeforeunload":true,"onblur":true,"oncancel":true,"oncanplay":true,"oncanplaythrough":true,"onchange":true,"onclick":true,"onclose":true,"oncontextmenu":true,"oncuechange":true,"ondblclick":true,"ondevicemotion":true,"ondeviceorientation":true,"ondeviceorientationabsolute":true,"ondrag":true,"ondragend":true,"ondragenter":true,"ondragleave":true,"ondragover":true,"ondragstart":true,"ondrop":true,"ondurationchange":true,"onemptied":true,"onended":true,"onerror":true,"onfocus":true,"ongotpointercapture":true,"onhashchange":true,"oninput":true,"oninvalid":true,"onkeydown":true,"onkeypress":true,"onkeyup":true,"onlanguagechange":true,"onload":true,"onloadeddata":true,"onloadedmetadata":true,"onloadstart":true,"onlostpointercapture":true,"onmessage":true,"onmessageerror":true,"onmousedown":true,"onmouseenter":true,"onmouseleave":true,"onmousemove":true,"onmouseout":true,"onmouseover":true,"onmouseup":true,"onmousewheel":true,"onoffline":true,"ononline":true,"onpagehide":true,"onpageshow":true,"onpause":true,"onplay":true,"onplaying":true,"onpointercancel":true,"onpointerdown":true,"onpointerenter":true,"onpointerleave":true,"onpointermove":true,"onpointerout":true,"onpointerover":true,"onpointerup":true,"onpopstate":true,"onprogress":true,"onratechange":true,"onrejectionhandled":true,"onreset":true,"onresize":true,"onscroll":true,"onsearch":true,"onseeked":true,"onseeking":true,"onselect":true,"onstalled":true,"onstorage":true,"onsubmit":true,"onsuspend":true,"ontimeupdate":true,"ontoggle":true,"ontransitionend":true,"onunhandledrejection":true,"onunload":true,"onvolumechange":true,"onwaiting":true,"onwheel":true,"open":false,"openDatabase":false,"opener":false,"Option":false,"origin":false,"OscillatorNode":false,"outerHeight":false,"outerWidth":false,"OverconstrainedError":false,"PageTransitionEvent":false,"pageXOffset":false,"pageYOffset":false,"PannerNode":false,"parent":false,"Path2D":false,"PaymentAddress":false,"PaymentRequest":false,"PaymentRequestUpdateEvent":false,"PaymentResponse":false,"performance":false,"Performance":false,"PerformanceEntry":false,"PerformanceLongTaskTiming":false,"PerformanceMark":false,"PerformanceMeasure":false,"PerformanceNavigation":false,"PerformanceNavigationTiming":false,"PerformanceObserver":false,"PerformanceObserverEntryList":false,"PerformancePaintTiming":false,"PerformanceResourceTiming":false,"PerformanceTiming":false,"PeriodicWave":false,"Permissions":false,"PermissionStatus":false,"personalbar":false,"PhotoCapabilities":false,"Plugin":false,"PluginArray":false,"PointerEvent":false,"PopStateEvent":false,"postMessage":false,"Presentation":false,"PresentationAvailability":false,"PresentationConnection":false,"PresentationConnectionAvailableEvent":false,"PresentationConnectionCloseEvent":false,"PresentationConnectionList":false,"PresentationReceiver":false,"PresentationRequest":false,"print":false,"ProcessingInstruction":false,"ProgressEvent":false,"PromiseRejectionEvent":false,"prompt":false,"PushManager":false,"PushSubscription":false,"PushSubscriptionOptions":false,"queueMicrotask":false,"RadioNodeList":false,"Range":false,"ReadableByteStreamController":false,"ReadableStream":false,"ReadableStreamBYOBReader":false,"ReadableStreamBYOBRequest":false,"ReadableStreamDefaultController":false,"ReadableStreamDefaultReader":false,"registerProcessor":false,"RemotePlayback":false,"removeEventListener":false,"reportError":false,"Request":false,"requestAnimationFrame":false,"requestIdleCallback":false,"resizeBy":false,"ResizeObserver":false,"ResizeObserverEntry":false,"resizeTo":false,"Response":false,"RTCCertificate":false,"RTCDataChannel":false,"RTCDataChannelEvent":false,"RTCDtlsTransport":false,"RTCIceCandidate":false,"RTCIceGatherer":false,"RTCIceTransport":false,"RTCPeerConnection":false,"RTCPeerConnectionIceEvent":false,"RTCRtpContributingSource":false,"RTCRtpReceiver":false,"RTCRtpSender":false,"RTCSctpTransport":false,"RTCSessionDescription":false,"RTCStatsReport":false,"RTCTrackEvent":false,"screen":false,"Screen":false,"screenLeft":false,"ScreenOrientation":false,"screenTop":false,"screenX":false,"screenY":false,"ScriptProcessorNode":false,"scroll":false,"scrollbars":false,"scrollBy":false,"scrollTo":false,"scrollX":false,"scrollY":false,"SecurityPolicyViolationEvent":false,"Selection":false,"self":false,"ServiceWorker":false,"ServiceWorkerContainer":false,"ServiceWorkerRegistration":false,"sessionStorage":false,"setInterval":false,"setTimeout":false,"ShadowRoot":false,"SharedWorker":false,"SourceBuffer":false,"SourceBufferList":false,"speechSynthesis":false,"SpeechSynthesisEvent":false,"SpeechSynthesisUtterance":false,"StaticRange":false,"status":false,"statusbar":false,"StereoPannerNode":false,"stop":false,"Storage":false,"StorageEvent":false,"StorageManager":false,"structuredClone":false,"styleMedia":false,"StyleSheet":false,"StyleSheetList":false,"SubmitEvent":false,"SubtleCrypto":false,"SVGAElement":false,"SVGAngle":false,"SVGAnimatedAngle":false,"SVGAnimatedBoolean":false,"SVGAnimatedEnumeration":false,"SVGAnimatedInteger":false,"SVGAnimatedLength":false,"SVGAnimatedLengthList":false,"SVGAnimatedNumber":false,"SVGAnimatedNumberList":false,"SVGAnimatedPreserveAspectRatio":false,"SVGAnimatedRect":false,"SVGAnimatedString":false,"SVGAnimatedTransformList":false,"SVGAnimateElement":false,"SVGAnimateMotionElement":false,"SVGAnimateTransformElement":false,"SVGAnimationElement":false,"SVGCircleElement":false,"SVGClipPathElement":false,"SVGComponentTransferFunctionElement":false,"SVGDefsElement":false,"SVGDescElement":false,"SVGDiscardElement":false,"SVGElement":false,"SVGEllipseElement":false,"SVGFEBlendElement":false,"SVGFEColorMatrixElement":false,"SVGFEComponentTransferElement":false,"SVGFECompositeElement":false,"SVGFEConvolveMatrixElement":false,"SVGFEDiffuseLightingElement":false,"SVGFEDisplacementMapElement":false,"SVGFEDistantLightElement":false,"SVGFEDropShadowElement":false,"SVGFEFloodElement":false,"SVGFEFuncAElement":false,"SVGFEFuncBElement":false,"SVGFEFuncGElement":false,"SVGFEFuncRElement":false,"SVGFEGaussianBlurElement":false,"SVGFEImageElement":false,"SVGFEMergeElement":false,"SVGFEMergeNodeElement":false,"SVGFEMorphologyElement":false,"SVGFEOffsetElement":false,"SVGFEPointLightElement":false,"SVGFESpecularLightingElement":false,"SVGFESpotLightElement":false,"SVGFETileElement":false,"SVGFETurbulenceElement":false,"SVGFilterElement":false,"SVGForeignObjectElement":false,"SVGGElement":false,"SVGGeometryElement":false,"SVGGradientElement":false,"SVGGraphicsElement":false,"SVGImageElement":false,"SVGLength":false,"SVGLengthList":false,"SVGLinearGradientElement":false,"SVGLineElement":false,"SVGMarkerElement":false,"SVGMaskElement":false,"SVGMatrix":false,"SVGMetadataElement":false,"SVGMPathElement":false,"SVGNumber":false,"SVGNumberList":false,"SVGPathElement":false,"SVGPatternElement":false,"SVGPoint":false,"SVGPointList":false,"SVGPolygonElement":false,"SVGPolylineElement":false,"SVGPreserveAspectRatio":false,"SVGRadialGradientElement":false,"SVGRect":false,"SVGRectElement":false,"SVGScriptElement":false,"SVGSetElement":false,"SVGStopElement":false,"SVGStringList":false,"SVGStyleElement":false,"SVGSVGElement":false,"SVGSwitchElement":false,"SVGSymbolElement":false,"SVGTextContentElement":false,"SVGTextElement":false,"SVGTextPathElement":false,"SVGTextPositioningElement":false,"SVGTitleElement":false,"SVGTransform":false,"SVGTransformList":false,"SVGTSpanElement":false,"SVGUnitTypes":false,"SVGUseElement":false,"SVGViewElement":false,"TaskAttributionTiming":false,"Text":false,"TextDecoder":false,"TextDecoderStream":false,"TextEncoder":false,"TextEncoderStream":false,"TextEvent":false,"TextMetrics":false,"TextTrack":false,"TextTrackCue":false,"TextTrackCueList":false,"TextTrackList":false,"TimeRanges":false,"ToggleEvent":false,"toolbar":false,"top":false,"Touch":false,"TouchEvent":false,"TouchList":false,"TrackEvent":false,"TransformStream":false,"TransformStreamDefaultController":false,"TransitionEvent":false,"TreeWalker":false,"UIEvent":false,"URL":false,"URLSearchParams":false,"ValidityState":false,"visualViewport":false,"VisualViewport":false,"VTTCue":false,"WaveShaperNode":false,"WebAssembly":false,"WebGL2RenderingContext":false,"WebGLActiveInfo":false,"WebGLBuffer":false,"WebGLContextEvent":false,"WebGLFramebuffer":false,"WebGLProgram":false,"WebGLQuery":false,"WebGLRenderbuffer":false,"WebGLRenderingContext":false,"WebGLSampler":false,"WebGLShader":false,"WebGLShaderPrecisionFormat":false,"WebGLSync":false,"WebGLTexture":false,"WebGLTransformFeedback":false,"WebGLUniformLocation":false,"WebGLVertexArrayObject":false,"WebSocket":false,"WheelEvent":false,"window":false,"Window":false,"Worker":false,"WritableStream":false,"WritableStreamDefaultController":false,"WritableStreamDefaultWriter":false,"XMLDocument":false,"XMLHttpRequest":false,"XMLHttpRequestEventTarget":false,"XMLHttpRequestUpload":false,"XMLSerializer":false,"XPathEvaluator":false,"XPathExpression":false,"XPathResult":false,"XRAnchor":false,"XRBoundedReferenceSpace":false,"XRCPUDepthInformation":false,"XRDepthInformation":false,"XRFrame":false,"XRInputSource":false,"XRInputSourceArray":false,"XRInputSourceEvent":false,"XRInputSourcesChangeEvent":false,"XRPose":false,"XRReferenceSpace":false,"XRReferenceSpaceEvent":false,"XRRenderState":false,"XRRigidTransform":false,"XRSession":false,"XRSessionEvent":false,"XRSpace":false,"XRSystem":false,"XRView":false,"XRViewerPose":false,"XRViewport":false,"XRWebGLBinding":false,"XRWebGLDepthInformation":false,"XRWebGLLayer":false,"XSLTProcessor":false}');
3490
+ const worker = { "addEventListener": false, "applicationCache": false, "atob": false, "Blob": false, "BroadcastChannel": false, "btoa": false, "ByteLengthQueuingStrategy": false, "Cache": false, "caches": false, "clearInterval": false, "clearTimeout": false, "close": true, "CompressionStream": false, "console": false, "CountQueuingStrategy": false, "crypto": false, "Crypto": false, "CryptoKey": false, "CustomEvent": false, "DecompressionStream": false, "ErrorEvent": false, "Event": false, "fetch": false, "File": false, "FileReaderSync": false, "FormData": false, "Headers": false, "IDBCursor": false, "IDBCursorWithValue": false, "IDBDatabase": false, "IDBFactory": false, "IDBIndex": false, "IDBKeyRange": false, "IDBObjectStore": false, "IDBOpenDBRequest": false, "IDBRequest": false, "IDBTransaction": false, "IDBVersionChangeEvent": false, "ImageData": false, "importScripts": true, "indexedDB": false, "location": false, "MessageChannel": false, "MessageEvent": false, "MessagePort": false, "name": false, "navigator": false, "Notification": false, "onclose": true, "onconnect": true, "onerror": true, "onlanguagechange": true, "onmessage": true, "onoffline": true, "ononline": true, "onrejectionhandled": true, "onunhandledrejection": true, "performance": false, "Performance": false, "PerformanceEntry": false, "PerformanceMark": false, "PerformanceMeasure": false, "PerformanceNavigation": false, "PerformanceObserver": false, "PerformanceObserverEntryList": false, "PerformanceResourceTiming": false, "PerformanceTiming": false, "postMessage": true, "Promise": false, "queueMicrotask": false, "ReadableByteStreamController": false, "ReadableStream": false, "ReadableStreamBYOBReader": false, "ReadableStreamBYOBRequest": false, "ReadableStreamDefaultController": false, "ReadableStreamDefaultReader": false, "removeEventListener": false, "reportError": false, "Request": false, "Response": false, "self": true, "ServiceWorkerRegistration": false, "setInterval": false, "setTimeout": false, "SubtleCrypto": false, "TextDecoder": false, "TextDecoderStream": false, "TextEncoder": false, "TextEncoderStream": false, "TransformStream": false, "TransformStreamDefaultController": false, "URL": false, "URLSearchParams": false, "WebAssembly": false, "WebSocket": false, "Worker": false, "WorkerGlobalScope": false, "WritableStream": false, "WritableStreamDefaultController": false, "WritableStreamDefaultWriter": false, "XMLHttpRequest": false };
3491
+ const node = { "__dirname": false, "__filename": false, "AbortController": false, "AbortSignal": false, "atob": false, "Blob": false, "BroadcastChannel": false, "btoa": false, "Buffer": false, "ByteLengthQueuingStrategy": false, "clearImmediate": false, "clearInterval": false, "clearTimeout": false, "CompressionStream": false, "console": false, "CountQueuingStrategy": false, "crypto": false, "Crypto": false, "CryptoKey": false, "CustomEvent": false, "DecompressionStream": false, "DOMException": false, "Event": false, "EventTarget": false, "exports": true, "fetch": false, "File": false, "FormData": false, "global": false, "Headers": false, "Intl": false, "MessageChannel": false, "MessageEvent": false, "MessagePort": false, "module": false, "performance": false, "PerformanceEntry": false, "PerformanceMark": false, "PerformanceMeasure": false, "PerformanceObserver": false, "PerformanceObserverEntryList": false, "PerformanceResourceTiming": false, "process": false, "queueMicrotask": false, "ReadableByteStreamController": false, "ReadableStream": false, "ReadableStreamBYOBReader": false, "ReadableStreamBYOBRequest": false, "ReadableStreamDefaultController": false, "ReadableStreamDefaultReader": false, "Request": false, "require": false, "Response": false, "setImmediate": false, "setInterval": false, "setTimeout": false, "structuredClone": false, "SubtleCrypto": false, "TextDecoder": false, "TextDecoderStream": false, "TextEncoder": false, "TextEncoderStream": false, "TransformStream": false, "TransformStreamDefaultController": false, "URL": false, "URLSearchParams": false, "WebAssembly": false, "WritableStream": false, "WritableStreamDefaultController": false, "WritableStreamDefaultWriter": false };
3492
+ const nodeBuiltin = { "AbortController": false, "AbortSignal": false, "atob": false, "Blob": false, "BroadcastChannel": false, "btoa": false, "Buffer": false, "ByteLengthQueuingStrategy": false, "clearImmediate": false, "clearInterval": false, "clearTimeout": false, "CompressionStream": false, "console": false, "CountQueuingStrategy": false, "crypto": false, "Crypto": false, "CryptoKey": false, "CustomEvent": false, "DecompressionStream": false, "DOMException": false, "Event": false, "EventTarget": false, "fetch": false, "File": false, "FormData": false, "global": false, "Headers": false, "Intl": false, "MessageChannel": false, "MessageEvent": false, "MessagePort": false, "performance": false, "PerformanceEntry": false, "PerformanceMark": false, "PerformanceMeasure": false, "PerformanceObserver": false, "PerformanceObserverEntryList": false, "PerformanceResourceTiming": false, "process": false, "queueMicrotask": false, "ReadableByteStreamController": false, "ReadableStream": false, "ReadableStreamBYOBReader": false, "ReadableStreamBYOBRequest": false, "ReadableStreamDefaultController": false, "ReadableStreamDefaultReader": false, "Request": false, "Response": false, "setImmediate": false, "setInterval": false, "setTimeout": false, "structuredClone": false, "SubtleCrypto": false, "TextDecoder": false, "TextDecoderStream": false, "TextEncoder": false, "TextEncoderStream": false, "TransformStream": false, "TransformStreamDefaultController": false, "URL": false, "URLSearchParams": false, "WebAssembly": false, "WritableStream": false, "WritableStreamDefaultController": false, "WritableStreamDefaultWriter": false };
3493
+ const commonjs = { "exports": true, "global": false, "module": false, "require": false };
3494
+ const amd = { "define": false, "require": false };
3495
+ const mocha = { "after": false, "afterEach": false, "before": false, "beforeEach": false, "context": false, "describe": false, "it": false, "mocha": false, "run": false, "setup": false, "specify": false, "suite": false, "suiteSetup": false, "suiteTeardown": false, "teardown": false, "test": false, "xcontext": false, "xdescribe": false, "xit": false, "xspecify": false };
3496
+ const jasmine = { "afterAll": false, "afterEach": false, "beforeAll": false, "beforeEach": false, "describe": false, "expect": false, "expectAsync": false, "fail": false, "fdescribe": false, "fit": false, "it": false, "jasmine": false, "pending": false, "runs": false, "spyOn": false, "spyOnAllFunctions": false, "spyOnProperty": false, "waits": false, "waitsFor": false, "xdescribe": false, "xit": false };
3497
+ const jest = { "afterAll": false, "afterEach": false, "beforeAll": false, "beforeEach": false, "describe": false, "expect": false, "fdescribe": false, "fit": false, "it": false, "jest": false, "pit": false, "require": false, "test": false, "xdescribe": false, "xit": false, "xtest": false };
3498
+ const qunit = { "asyncTest": false, "deepEqual": false, "equal": false, "expect": false, "module": false, "notDeepEqual": false, "notEqual": false, "notOk": false, "notPropEqual": false, "notStrictEqual": false, "ok": false, "propEqual": false, "QUnit": false, "raises": false, "start": false, "stop": false, "strictEqual": false, "test": false, "throws": false };
3499
+ const phantomjs = { "console": true, "exports": true, "phantom": true, "require": true, "WebPage": true };
3500
+ const couch = { "emit": false, "exports": false, "getRow": false, "log": false, "module": false, "provides": false, "require": false, "respond": false, "send": false, "start": false, "sum": false };
3501
+ const rhino = { "defineClass": false, "deserialize": false, "gc": false, "help": false, "importClass": false, "importPackage": false, "java": false, "load": false, "loadClass": false, "Packages": false, "print": false, "quit": false, "readFile": false, "readUrl": false, "runCommand": false, "seal": false, "serialize": false, "spawn": false, "sync": false, "toint32": false, "version": false };
3502
+ const nashorn = { "__DIR__": false, "__FILE__": false, "__LINE__": false, "com": false, "edu": false, "exit": false, "java": false, "Java": false, "javafx": false, "JavaImporter": false, "javax": false, "JSAdapter": false, "load": false, "loadWithNewGlobal": false, "org": false, "Packages": false, "print": false, "quit": false };
3503
+ const wsh = { "ActiveXObject": false, "CollectGarbage": false, "Debug": false, "Enumerator": false, "GetObject": false, "RuntimeObject": false, "ScriptEngine": false, "ScriptEngineBuildVersion": false, "ScriptEngineMajorVersion": false, "ScriptEngineMinorVersion": false, "VBArray": false, "WScript": false, "WSH": false };
3504
+ const jquery = { "$": false, "jQuery": false };
3505
+ const yui = { "YAHOO": false, "YAHOO_config": false, "YUI": false, "YUI_config": false };
3506
+ const shelljs = { "cat": false, "cd": false, "chmod": false, "config": false, "cp": false, "dirs": false, "echo": false, "env": false, "error": false, "exec": false, "exit": false, "find": false, "grep": false, "ln": false, "ls": false, "mkdir": false, "mv": false, "popd": false, "pushd": false, "pwd": false, "rm": false, "sed": false, "set": false, "target": false, "tempdir": false, "test": false, "touch": false, "which": false };
3507
+ const prototypejs = { "$": false, "$$": false, "$A": false, "$break": false, "$continue": false, "$F": false, "$H": false, "$R": false, "$w": false, "Abstract": false, "Ajax": false, "Autocompleter": false, "Builder": false, "Class": false, "Control": false, "Draggable": false, "Draggables": false, "Droppables": false, "Effect": false, "Element": false, "Enumerable": false, "Event": false, "Field": false, "Form": false, "Hash": false, "Insertion": false, "ObjectRange": false, "PeriodicalExecuter": false, "Position": false, "Prototype": false, "Scriptaculous": false, "Selector": false, "Sortable": false, "SortableObserver": false, "Sound": false, "Template": false, "Toggle": false, "Try": false };
3508
+ const meteor = { "$": false, "Accounts": false, "AccountsClient": false, "AccountsCommon": false, "AccountsServer": false, "App": false, "Assets": false, "Blaze": false, "check": false, "Cordova": false, "DDP": false, "DDPRateLimiter": false, "DDPServer": false, "Deps": false, "EJSON": false, "Email": false, "HTTP": false, "Log": false, "Match": false, "Meteor": false, "Mongo": false, "MongoInternals": false, "Npm": false, "Package": false, "Plugin": false, "process": false, "Random": false, "ReactiveDict": false, "ReactiveVar": false, "Router": false, "ServiceConfiguration": false, "Session": false, "share": false, "Spacebars": false, "Template": false, "Tinytest": false, "Tracker": false, "UI": false, "Utils": false, "WebApp": false, "WebAppInternals": false };
3509
+ const mongo = { "_isWindows": false, "_rand": false, "BulkWriteResult": false, "cat": false, "cd": false, "connect": false, "db": false, "getHostName": false, "getMemInfo": false, "hostname": false, "ISODate": false, "listFiles": false, "load": false, "ls": false, "md5sumFile": false, "mkdir": false, "Mongo": false, "NumberInt": false, "NumberLong": false, "ObjectId": false, "PlanCache": false, "print": false, "printjson": false, "pwd": false, "quit": false, "removeFile": false, "rs": false, "sh": false, "UUID": false, "version": false, "WriteResult": false };
3510
+ const applescript = { "$": false, "Application": false, "Automation": false, "console": false, "delay": false, "Library": false, "ObjC": false, "ObjectSpecifier": false, "Path": false, "Progress": false, "Ref": false };
3511
+ const serviceworker = { "addEventListener": false, "applicationCache": false, "atob": false, "Blob": false, "BroadcastChannel": false, "btoa": false, "ByteLengthQueuingStrategy": false, "Cache": false, "caches": false, "CacheStorage": false, "clearInterval": false, "clearTimeout": false, "Client": false, "clients": false, "Clients": false, "close": true, "CompressionStream": false, "console": false, "CountQueuingStrategy": false, "crypto": false, "Crypto": false, "CryptoKey": false, "CustomEvent": false, "DecompressionStream": false, "ErrorEvent": false, "Event": false, "ExtendableEvent": false, "ExtendableMessageEvent": false, "fetch": false, "FetchEvent": false, "File": false, "FileReaderSync": false, "FormData": false, "Headers": false, "IDBCursor": false, "IDBCursorWithValue": false, "IDBDatabase": false, "IDBFactory": false, "IDBIndex": false, "IDBKeyRange": false, "IDBObjectStore": false, "IDBOpenDBRequest": false, "IDBRequest": false, "IDBTransaction": false, "IDBVersionChangeEvent": false, "ImageData": false, "importScripts": false, "indexedDB": false, "location": false, "MessageChannel": false, "MessageEvent": false, "MessagePort": false, "name": false, "navigator": false, "Notification": false, "onclose": true, "onconnect": true, "onerror": true, "onfetch": true, "oninstall": true, "onlanguagechange": true, "onmessage": true, "onmessageerror": true, "onnotificationclick": true, "onnotificationclose": true, "onoffline": true, "ononline": true, "onpush": true, "onpushsubscriptionchange": true, "onrejectionhandled": true, "onsync": true, "onunhandledrejection": true, "performance": false, "Performance": false, "PerformanceEntry": false, "PerformanceMark": false, "PerformanceMeasure": false, "PerformanceNavigation": false, "PerformanceObserver": false, "PerformanceObserverEntryList": false, "PerformanceResourceTiming": false, "PerformanceTiming": false, "postMessage": true, "Promise": false, "queueMicrotask": false, "ReadableByteStreamController": false, "ReadableStream": false, "ReadableStreamBYOBReader": false, "ReadableStreamBYOBRequest": false, "ReadableStreamDefaultController": false, "ReadableStreamDefaultReader": false, "registration": false, "removeEventListener": false, "Request": false, "Response": false, "self": false, "ServiceWorker": false, "ServiceWorkerContainer": false, "ServiceWorkerGlobalScope": false, "ServiceWorkerMessageEvent": false, "ServiceWorkerRegistration": false, "setInterval": false, "setTimeout": false, "skipWaiting": false, "SubtleCrypto": false, "TextDecoder": false, "TextDecoderStream": false, "TextEncoder": false, "TextEncoderStream": false, "TransformStream": false, "TransformStreamDefaultController": false, "URL": false, "URLSearchParams": false, "WebAssembly": false, "WebSocket": false, "WindowClient": false, "Worker": false, "WorkerGlobalScope": false, "WritableStream": false, "WritableStreamDefaultController": false, "WritableStreamDefaultWriter": false, "XMLHttpRequest": false };
3512
+ const atomtest = { "advanceClock": false, "atom": false, "fakeClearInterval": false, "fakeClearTimeout": false, "fakeSetInterval": false, "fakeSetTimeout": false, "resetTimeouts": false, "waitsForPromise": false };
3513
+ const embertest = { "andThen": false, "click": false, "currentPath": false, "currentRouteName": false, "currentURL": false, "fillIn": false, "find": false, "findAll": false, "findWithAssert": false, "keyEvent": false, "pauseTest": false, "resumeTest": false, "triggerEvent": false, "visit": false, "wait": false };
3514
+ const protractor = { "$": false, "$$": false, "browser": false, "by": false, "By": false, "DartObject": false, "element": false, "protractor": false };
3515
+ const webextensions = { "browser": false, "chrome": false, "opr": false };
3516
+ const greasemonkey = { "cloneInto": false, "createObjectIn": false, "exportFunction": false, "GM": false, "GM_addElement": false, "GM_addStyle": false, "GM_addValueChangeListener": false, "GM_deleteValue": false, "GM_download": false, "GM_getResourceText": false, "GM_getResourceURL": false, "GM_getTab": false, "GM_getTabs": false, "GM_getValue": false, "GM_info": false, "GM_listValues": false, "GM_log": false, "GM_notification": false, "GM_openInTab": false, "GM_registerMenuCommand": false, "GM_removeValueChangeListener": false, "GM_saveTab": false, "GM_setClipboard": false, "GM_setValue": false, "GM_unregisterMenuCommand": false, "GM_xmlhttpRequest": false, "unsafeWindow": false };
3517
+ const devtools = { "$": false, "$_": false, "$$": false, "$0": false, "$1": false, "$2": false, "$3": false, "$4": false, "$x": false, "chrome": false, "clear": false, "copy": false, "debug": false, "dir": false, "dirxml": false, "getEventListeners": false, "inspect": false, "keys": false, "monitor": false, "monitorEvents": false, "profile": false, "profileEnd": false, "queryObjects": false, "table": false, "undebug": false, "unmonitor": false, "unmonitorEvents": false, "values": false };
3518
+ const require$$0 = {
3519
+ builtin,
3520
+ es5,
3521
+ es2015,
3522
+ es2017,
3523
+ es2020,
3524
+ es2021,
3525
+ browser,
3526
+ worker,
3527
+ node,
3528
+ nodeBuiltin,
3529
+ commonjs,
3530
+ amd,
3531
+ mocha,
3532
+ jasmine,
3533
+ jest,
3534
+ qunit,
3535
+ phantomjs,
3536
+ couch,
3537
+ rhino,
3538
+ nashorn,
3539
+ wsh,
3540
+ jquery,
3541
+ yui,
3542
+ shelljs,
3543
+ prototypejs,
3544
+ meteor,
3545
+ mongo,
3546
+ applescript,
3547
+ serviceworker,
3548
+ atomtest,
3549
+ embertest,
3550
+ protractor,
3551
+ "shared-node-browser": { "AbortController": false, "AbortSignal": false, "atob": false, "Blob": false, "BroadcastChannel": false, "btoa": false, "ByteLengthQueuingStrategy": false, "clearInterval": false, "clearTimeout": false, "CompressionStream": false, "console": false, "CountQueuingStrategy": false, "crypto": false, "Crypto": false, "CryptoKey": false, "CustomEvent": false, "DecompressionStream": false, "DOMException": false, "Event": false, "EventTarget": false, "fetch": false, "File": false, "FormData": false, "Headers": false, "Intl": false, "MessageChannel": false, "MessageEvent": false, "MessagePort": false, "performance": false, "PerformanceEntry": false, "PerformanceMark": false, "PerformanceMeasure": false, "PerformanceObserver": false, "PerformanceObserverEntryList": false, "PerformanceResourceTiming": false, "queueMicrotask": false, "ReadableByteStreamController": false, "ReadableStream": false, "ReadableStreamBYOBReader": false, "ReadableStreamBYOBRequest": false, "ReadableStreamDefaultController": false, "ReadableStreamDefaultReader": false, "Request": false, "Response": false, "setInterval": false, "setTimeout": false, "structuredClone": false, "SubtleCrypto": false, "TextDecoder": false, "TextDecoderStream": false, "TextEncoder": false, "TextEncoderStream": false, "TransformStream": false, "TransformStreamDefaultController": false, "URL": false, "URLSearchParams": false, "WebAssembly": false, "WritableStream": false, "WritableStreamDefaultController": false, "WritableStreamDefaultWriter": false },
3552
+ webextensions,
3553
+ greasemonkey,
3554
+ devtools
3555
+ };
3556
+ var globals$1;
3557
+ var hasRequiredGlobals;
3558
+ function requireGlobals() {
3559
+ if (hasRequiredGlobals) return globals$1;
3560
+ hasRequiredGlobals = 1;
3561
+ globals$1 = require$$0;
3562
+ return globals$1;
3563
+ }
3564
+ var globalsExports = /* @__PURE__ */ requireGlobals();
3565
+ const globals = /* @__PURE__ */ getDefaultExportFromCjs(globalsExports);
3566
+ const unicornRules = {
3567
+ languageOptions: {
3568
+ globals: {
3569
+ ...globals.builtin
3570
+ }
3571
+ },
3572
+ plugins: {
3573
+ unicorn: eslintPluginUnicorn
3574
+ },
3575
+ rules: {
3576
+ "unicorn/better-regex": "error",
3577
+ "unicorn/catch-error-name": "error",
3578
+ "unicorn/consistent-date-clone": "error",
3579
+ "unicorn/consistent-destructuring": "error",
3580
+ "unicorn/escape-case": "error",
3581
+ "unicorn/no-array-for-each": "error",
3582
+ "unicorn/no-array-reduce": "error",
3583
+ "unicorn/no-await-in-promise-methods": "error",
3584
+ "unicorn/no-invalid-remove-event-listener": "error",
3585
+ "unicorn/no-new-array": "error",
3586
+ "unicorn/no-new-buffer": "error",
3587
+ "unicorn/no-object-as-default-parameter": "error",
3588
+ "unicorn/no-single-promise-in-promise-methods": "error",
3589
+ "unicorn/no-unnecessary-await": "error",
3590
+ "unicorn/no-unreadable-iife": "error",
3591
+ "unicorn/no-useless-collection-argument": "error",
3592
+ "unicorn/no-useless-error-capture-stack-trace": "error",
3593
+ "unicorn/no-useless-fallback-in-spread": "error",
3594
+ "unicorn/no-useless-promise-resolve-reject": "error",
3595
+ "unicorn/no-useless-spread": "error",
3596
+ "unicorn/no-useless-switch-case": "error",
3597
+ "unicorn/no-useless-undefined": "error",
3598
+ "unicorn/number-literal-case": "error",
3599
+ "unicorn/numeric-separators-style": "error",
3600
+ "unicorn/prefer-array-find": "error",
3601
+ "unicorn/prefer-array-flat": "error",
3602
+ "unicorn/prefer-array-flat-map": "error",
3603
+ "unicorn/prefer-array-index-of": "error",
3604
+ "unicorn/prefer-array-some": "error",
3605
+ "unicorn/prefer-bigint-literals": "error",
3606
+ "unicorn/prefer-blob-reading-methods": "error",
3607
+ "unicorn/prefer-date-now": "error",
3608
+ "unicorn/prefer-import-meta-properties": "error",
3609
+ "unicorn/prefer-includes": "error",
3610
+ "unicorn/prefer-logical-operator-over-ternary": "error",
3611
+ "unicorn/prefer-number-properties": "error",
3612
+ "unicorn/prefer-object-from-entries": "error",
3613
+ "unicorn/prefer-optional-catch-binding": "error",
3614
+ "unicorn/prefer-prototype-methods": "error",
3615
+ "unicorn/prefer-response-static-json": "error",
3616
+ "unicorn/prefer-set-has": "error",
3617
+ "unicorn/prefer-set-size": "error",
3618
+ "unicorn/prefer-string-raw": "error",
3619
+ "unicorn/prefer-string-replace-all": "error",
3620
+ "unicorn/prefer-string-starts-ends-with": "error",
3621
+ "unicorn/prefer-string-trim-start-end": "error",
3622
+ "unicorn/prefer-structured-clone": "error",
3623
+ "unicorn/prefer-switch": "error",
3624
+ "unicorn/require-module-attributes": "error",
3625
+ "unicorn/require-module-specifiers": "error",
3626
+ "unicorn/template-indent": "error"
3627
+ }
3628
+ };
3629
+ const config = [
3630
+ ignores,
3631
+ languageOptions,
3632
+ //////////////////////////////////////////////////////////////////////////////
3633
+ eslint.configs.recommended,
3634
+ react.configs.flat.recommended,
3635
+ stylistic.configs.recommended,
3636
+ ...typescript.configs.recommended,
3637
+ ...typescript.configs.stylistic,
3638
+ //////////////////////////////////////////////////////////////////////////////
3639
+ customRules,
3640
+ generalRules,
3641
+ perfectionistRules,
3642
+ reactHooks,
3643
+ stylisticRules,
3644
+ typescriptRules,
3645
+ unicornRules
868
3646
  ];
869
- //#endregion
870
- export { CONFIG };
871
-
872
- //# sourceMappingURL=index.mjs.map
3647
+ export {
3648
+ config
3649
+ };
3650
+ //# sourceMappingURL=index.mjs.map