@exbotanical/eslint-config 1.0.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,19 @@
1
+ import {
2
+ init_esm_shims
3
+ } from "./chunk-6GNDNAEM.js";
4
+
5
+ // src/index.ts
6
+ init_esm_shims();
7
+
1
8
  // src/factory.ts
9
+ init_esm_shims();
2
10
  import { isPackageExists as isPackageExists3 } from "local-pkg";
3
11
 
12
+ // src/configs/index.ts
13
+ init_esm_shims();
14
+
4
15
  // src/configs/comments.ts
16
+ init_esm_shims();
5
17
  import plugin from "@eslint-community/eslint-plugin-eslint-comments";
6
18
  var NAMESPACE = "exbotanical/comments";
7
19
  async function comments() {
@@ -23,7 +35,12 @@ async function comments() {
23
35
  ];
24
36
  }
25
37
 
38
+ // src/configs/disables.ts
39
+ init_esm_shims();
40
+
26
41
  // src/filepaths.ts
42
+ init_esm_shims();
43
+ var GLOB_JS = "**/*.?([cm])js";
27
44
  var GLOB_JSX = "**/*.?([cm])jsx";
28
45
  var GLOB_TS = "**/*.?([cm])ts";
29
46
  var GLOB_TSX = "**/*.?([cm])tsx";
@@ -36,6 +53,7 @@ var GLOB_MARKDOWN = "**/*.md";
36
53
  var GLOB_VUE = "**/*.vue";
37
54
  var GLOB_YAML = "**/*.y?(a)ml";
38
55
  var GLOB_TOML = "**/*.toml";
56
+ var GLOB_GRAPHQL = "**/*.{g,graph}ql";
39
57
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
40
58
  var GLOB_TESTS = [
41
59
  `**/__tests__/**/*.${GLOB_SRC_EXT}`,
@@ -116,9 +134,119 @@ async function disables() {
116
134
  ];
117
135
  }
118
136
 
137
+ // src/configs/graphql.ts
138
+ init_esm_shims();
139
+
140
+ // src/utils.ts
141
+ init_esm_shims();
142
+ import { fileURLToPath } from "node:url";
143
+ import { isPackageExists } from "local-pkg";
144
+ var parserPlain = {
145
+ meta: {
146
+ name: "parser-plain"
147
+ },
148
+ parseForESLint: (code) => ({
149
+ ast: {
150
+ body: [],
151
+ comments: [],
152
+ loc: { end: code.length, start: 0 },
153
+ range: [0, code.length],
154
+ tokens: [],
155
+ type: "Program"
156
+ },
157
+ scopeManager: null,
158
+ services: { isPlain: true },
159
+ visitorKeys: {
160
+ Program: []
161
+ }
162
+ })
163
+ };
164
+ async function interopDefault(module) {
165
+ const resolved = await module;
166
+ return resolved.default || resolved;
167
+ }
168
+ function renameRules(rules, map) {
169
+ return Object.fromEntries(
170
+ Object.entries(rules).map(([key, value]) => {
171
+ for (const [from, to] of Object.entries(map)) {
172
+ if (key.startsWith(`${from}/`))
173
+ return [to + key.slice(from.length), value];
174
+ }
175
+ return [key, value];
176
+ })
177
+ );
178
+ }
179
+ function mergeProcessors(processors) {
180
+ const cache = /* @__PURE__ */ new Map();
181
+ return {
182
+ meta: {
183
+ name: `merged-processor:${processors.map((processor) => processor.meta?.name || "unknown").join("+")}`
184
+ },
185
+ supportsAutofix: true,
186
+ preprocess(text, filename) {
187
+ const counts = [];
188
+ cache.set(filename, counts);
189
+ return processors.flatMap((processor) => {
190
+ const result = processor.preprocess?.(text, filename) || [];
191
+ counts.push(result.length);
192
+ return result;
193
+ });
194
+ },
195
+ postprocess(messages, filename) {
196
+ const counts = cache.get(filename);
197
+ cache.delete(filename);
198
+ let index = 0;
199
+ return processors.flatMap((processor, index_) => {
200
+ const msgs = messages.slice(index, index + counts[index_]);
201
+ index += counts[index_];
202
+ return processor.postprocess?.(msgs, filename) || [];
203
+ });
204
+ }
205
+ };
206
+ }
207
+ var processorPassThrough = {
208
+ meta: {
209
+ name: "pass-through"
210
+ },
211
+ preprocess(text) {
212
+ return [text];
213
+ },
214
+ postprocess(messages) {
215
+ return messages[0];
216
+ }
217
+ };
218
+ var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
219
+
220
+ // src/configs/graphql.ts
221
+ async function graphql() {
222
+ const graphqlPlugin = await interopDefault(import("@graphql-eslint/eslint-plugin"));
223
+ const rules = {
224
+ ...graphqlPlugin.configs["flat/operations-recommended"].rules,
225
+ ...graphqlPlugin.configs["flat/schema-recommended"].rules
226
+ };
227
+ return [
228
+ {
229
+ files: [GLOB_JS, GLOB_JSX, GLOB_TS, GLOB_TSX],
230
+ processor: graphqlPlugin.processor
231
+ },
232
+ {
233
+ files: [GLOB_GRAPHQL],
234
+ languageOptions: {
235
+ parser: graphqlPlugin.parser
236
+ },
237
+ plugins: {
238
+ "@graphql-eslint": graphqlPlugin
239
+ },
240
+ // @ts-expect-error weird rule types in gql plugin
241
+ rules
242
+ }
243
+ ];
244
+ }
245
+
119
246
  // src/configs/ignores.ts
247
+ init_esm_shims();
120
248
  var NAMESPACE3 = "exbotanical/ignores";
121
- async function ignores({ files = [] } = {}) {
249
+ async function ignores(files = []) {
122
250
  return [
123
251
  {
124
252
  name: NAMESPACE3,
@@ -128,6 +256,7 @@ async function ignores({ files = [] } = {}) {
128
256
  }
129
257
 
130
258
  // src/configs/imports.ts
259
+ init_esm_shims();
131
260
  import plugin2 from "eslint-plugin-import";
132
261
  var NAMESPACE4 = "exbotanical/imports";
133
262
  async function imports() {
@@ -195,10 +324,12 @@ async function imports() {
195
324
  }
196
325
 
197
326
  // src/configs/javascript.ts
327
+ init_esm_shims();
198
328
  import pluginUnusedImports from "eslint-plugin-unused-imports";
199
329
  import globals from "globals";
200
330
 
201
331
  // src/common.ts
332
+ init_esm_shims();
202
333
  var VAR_IGNORE_PATTERN = "^_";
203
334
 
204
335
  // src/configs/javascript.ts
@@ -469,86 +600,8 @@ async function javascript({ overrides = {} } = {}) {
469
600
  ];
470
601
  }
471
602
 
472
- // src/utils.ts
473
- import { fileURLToPath } from "node:url";
474
- import { isPackageExists } from "local-pkg";
475
- var parserPlain = {
476
- meta: {
477
- name: "parser-plain"
478
- },
479
- parseForESLint: (code) => ({
480
- ast: {
481
- body: [],
482
- comments: [],
483
- loc: { end: code.length, start: 0 },
484
- range: [0, code.length],
485
- tokens: [],
486
- type: "Program"
487
- },
488
- scopeManager: null,
489
- services: { isPlain: true },
490
- visitorKeys: {
491
- Program: []
492
- }
493
- })
494
- };
495
- async function interopDefault(module) {
496
- const resolved = await module;
497
- return resolved.default || resolved;
498
- }
499
- function renameRules(rules, map) {
500
- return Object.fromEntries(
501
- Object.entries(rules).map(([key, value]) => {
502
- for (const [from, to] of Object.entries(map)) {
503
- if (key.startsWith(`${from}/`))
504
- return [to + key.slice(from.length), value];
505
- }
506
- return [key, value];
507
- })
508
- );
509
- }
510
- function mergeProcessors(processors) {
511
- const cache = /* @__PURE__ */ new Map();
512
- return {
513
- meta: {
514
- name: `merged-processor:${processors.map((processor) => processor.meta?.name || "unknown").join("+")}`
515
- },
516
- supportsAutofix: true,
517
- preprocess(text, filename) {
518
- const counts = [];
519
- cache.set(filename, counts);
520
- return processors.flatMap((processor) => {
521
- const result = processor.preprocess?.(text, filename) || [];
522
- counts.push(result.length);
523
- return result;
524
- });
525
- },
526
- postprocess(messages, filename) {
527
- const counts = cache.get(filename);
528
- cache.delete(filename);
529
- let index = 0;
530
- return processors.flatMap((processor, index_) => {
531
- const msgs = messages.slice(index, index + counts[index_]);
532
- index += counts[index_];
533
- return processor.postprocess?.(msgs, filename) || [];
534
- });
535
- }
536
- };
537
- }
538
- var processorPassThrough = {
539
- meta: {
540
- name: "pass-through"
541
- },
542
- preprocess(text) {
543
- return [text];
544
- },
545
- postprocess(messages) {
546
- return messages[0];
547
- }
548
- };
549
- var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
550
-
551
603
  // src/configs/jsdoc.ts
604
+ init_esm_shims();
552
605
  var NAMESPACE6 = "exbotanical/jsdoc";
553
606
  async function jsdoc() {
554
607
  return [
@@ -580,7 +633,11 @@ async function jsdoc() {
580
633
  ];
581
634
  }
582
635
 
636
+ // src/configs/jsonc.ts
637
+ init_esm_shims();
638
+
583
639
  // src/defaults.ts
640
+ init_esm_shims();
584
641
  var STYLE_DEFAULTS = {
585
642
  indent: 2,
586
643
  jsx: true,
@@ -664,6 +721,7 @@ async function jsonc({
664
721
  }
665
722
 
666
723
  // src/configs/jsx.ts
724
+ init_esm_shims();
667
725
  var NAMESPACE8 = "exbotanical/jsx";
668
726
  async function jsx() {
669
727
  return [
@@ -682,6 +740,7 @@ async function jsx() {
682
740
  }
683
741
 
684
742
  // src/configs/markdown.ts
743
+ init_esm_shims();
685
744
  var NAMESPACE9 = "exbotanical/markdown";
686
745
  async function markdown({
687
746
  files = [GLOB_MARKDOWN],
@@ -750,7 +809,11 @@ async function markdown({
750
809
  ];
751
810
  }
752
811
 
812
+ // src/configs/misc/index.ts
813
+ init_esm_shims();
814
+
753
815
  // src/configs/misc/perfectionist.ts
816
+ init_esm_shims();
754
817
  import pluginPerfectionist from "eslint-plugin-perfectionist";
755
818
  var NAMESPACE10 = "exbotanical/misc/perfectionist";
756
819
  async function perfectionist() {
@@ -798,6 +861,7 @@ async function perfectionist() {
798
861
  }
799
862
 
800
863
  // src/configs/misc/unicorn.ts
864
+ init_esm_shims();
801
865
  import pluginUnicorn from "eslint-plugin-unicorn";
802
866
  var NAMESPACE11 = "exbotanical/misc/unicorn";
803
867
  async function unicorn() {
@@ -812,13 +876,16 @@ async function unicorn() {
812
876
  "unicorn/prevent-abbreviations": "off",
813
877
  "unicorn/no-null": "off",
814
878
  "unicorn/prefer-top-level-await": "off",
815
- "unicorn/filename-case": "off"
879
+ "unicorn/filename-case": "off",
880
+ "unicorn/no-await-expression-member": "off",
881
+ "unicorn/throw-new-error": "off"
816
882
  }
817
883
  }
818
884
  ];
819
885
  }
820
886
 
821
887
  // src/configs/node.ts
888
+ init_esm_shims();
822
889
  import plugin3 from "eslint-plugin-n";
823
890
  var NAMESPACE12 = "exbotanical/node";
824
891
  async function node() {
@@ -842,6 +909,7 @@ async function node() {
842
909
  }
843
910
 
844
911
  // src/configs/package.json.ts
912
+ init_esm_shims();
845
913
  var NAMESPACE13 = "exbotanical/package.json";
846
914
  async function packageJson() {
847
915
  return [
@@ -941,7 +1009,11 @@ async function packageJson() {
941
1009
  ];
942
1010
  }
943
1011
 
1012
+ // src/configs/prettier.ts
1013
+ init_esm_shims();
1014
+
944
1015
  // src/vendor/plugins/eslint-config-prettier.ts
1016
+ init_esm_shims();
945
1017
  var specialRule = 0;
946
1018
  var eslint_config_prettier_default = {
947
1019
  rules: {
@@ -1237,6 +1309,7 @@ async function prettier() {
1237
1309
  }
1238
1310
 
1239
1311
  // src/configs/react.ts
1312
+ init_esm_shims();
1240
1313
  import { isPackageExists as isPackageExists2 } from "local-pkg";
1241
1314
  var REACT_REFRESH_ALLOW_CONSTANT_EXPORT_PACKAGES = ["vite"];
1242
1315
  var REACT_ROUTER_PACKAGES = [
@@ -1380,6 +1453,7 @@ async function react({
1380
1453
  }
1381
1454
 
1382
1455
  // src/configs/regexpr.ts
1456
+ init_esm_shims();
1383
1457
  import { configs } from "eslint-plugin-regexp";
1384
1458
  var NAMESPACE15 = "exbotanical/regexpr";
1385
1459
  async function regexpr({
@@ -1408,10 +1482,11 @@ async function regexpr({
1408
1482
  }
1409
1483
 
1410
1484
  // src/configs/test.ts
1485
+ init_esm_shims();
1411
1486
  var PLUGIN_RUNNER_MAP = {
1412
1487
  tap: [
1413
1488
  "eslint-plugin-tap",
1414
- {
1489
+ () => ({
1415
1490
  "tap/assertion-message": ["error", "always"],
1416
1491
  "tap/max-asserts": ["error", 8],
1417
1492
  "tap/no-identical-title": "error",
@@ -1427,19 +1502,25 @@ var PLUGIN_RUNNER_MAP = {
1427
1502
  "tap/use-t-well": "error",
1428
1503
  "tap/use-t": "error",
1429
1504
  "tap/use-tap": "error"
1430
- }
1505
+ })
1431
1506
  ],
1432
1507
  vitest: [
1433
1508
  "@vitest/eslint-plugin",
1434
- {
1435
- // ...vitest.configs.recommended.rules,
1436
- }
1509
+ async () => ({
1510
+ ...(await interopDefault(import("@vitest/eslint-plugin"))).configs.recommended.rules
1511
+ })
1437
1512
  ],
1438
- jest: ["eslint-plugin-jest", {}]
1513
+ jest: [
1514
+ "eslint-plugin-jest",
1515
+ async () => ({
1516
+ ...(await interopDefault(import("./lib-C4ZW2PPJ.js"))).configs["flat/recommended"].rules
1517
+ })
1518
+ ]
1439
1519
  };
1440
1520
  var NAMESPACE16 = "exbotanical/test";
1441
1521
  async function test({
1442
1522
  runner = "vitest",
1523
+ cypress = false,
1443
1524
  files = GLOB_TESTS,
1444
1525
  overrides = {}
1445
1526
  }) {
@@ -1449,6 +1530,15 @@ async function test({
1449
1530
  // @ts-expect-error no types
1450
1531
  interopDefault(import("eslint-plugin-no-only-tests"))
1451
1532
  ]);
1533
+ const extraConfigs = [];
1534
+ if (cypress) {
1535
+ const pluginCypress = await interopDefault(import("./flat-QQMMJZVN.js"));
1536
+ extraConfigs.push({
1537
+ name: `${NAMESPACE16}/cypress/rules`,
1538
+ ...pluginCypress.configs.recommended,
1539
+ ...typeof cypress === "boolean" ? {} : cypress
1540
+ });
1541
+ }
1452
1542
  return [
1453
1543
  {
1454
1544
  name: `${NAMESPACE16}/setup`,
@@ -1456,7 +1546,7 @@ async function test({
1456
1546
  test: {
1457
1547
  ...pluginRunner,
1458
1548
  rules: {
1459
- ...rules,
1549
+ ...await Promise.resolve(rules()),
1460
1550
  ...pluginNoOnlyTests.rules
1461
1551
  }
1462
1552
  }
@@ -1468,11 +1558,13 @@ async function test({
1468
1558
  rules: {
1469
1559
  ...overrides
1470
1560
  }
1471
- }
1561
+ },
1562
+ ...extraConfigs
1472
1563
  ];
1473
1564
  }
1474
1565
 
1475
1566
  // src/configs/toml.ts
1567
+ init_esm_shims();
1476
1568
  var NAMESPACE17 = "exbotanical/toml";
1477
1569
  async function toml({ files = [GLOB_TOML], overrides = {} } = {}, { indent } = STYLE_DEFAULTS) {
1478
1570
  const [plugin4, parser] = await Promise.all([
@@ -1520,6 +1612,7 @@ async function toml({ files = [GLOB_TOML], overrides = {} } = {}, { indent } = S
1520
1612
  }
1521
1613
 
1522
1614
  // src/configs/tsconfig.ts
1615
+ init_esm_shims();
1523
1616
  var NAMESPACE18 = "exbotanical/tsconfig";
1524
1617
  async function tsconfig() {
1525
1618
  return [
@@ -1649,6 +1742,7 @@ async function tsconfig() {
1649
1742
  }
1650
1743
 
1651
1744
  // src/configs/typescript.ts
1745
+ init_esm_shims();
1652
1746
  var NAMESPACE19 = "exbotanical/typescript";
1653
1747
  async function typescript(options = {}) {
1654
1748
  const {
@@ -1817,16 +1911,19 @@ async function typescript(options = {}) {
1817
1911
  }
1818
1912
 
1819
1913
  // src/configs/vue.ts
1914
+ init_esm_shims();
1820
1915
  var NAMESPACE20 = "exbotanical/vue";
1821
1916
  async function vue({
1822
1917
  files = [GLOB_VUE],
1823
1918
  overrides = {},
1824
1919
  typescript: typescript2 = true,
1825
- vueVersion = 3
1920
+ vueVersion = 3,
1921
+ graphql: graphql2 = false
1826
1922
  }, { indent } = STYLE_DEFAULTS) {
1827
- const [pluginVue, parserVue] = await Promise.all([
1923
+ const [pluginVue, parserVue, processorVueBlocks] = await Promise.all([
1828
1924
  interopDefault(import("eslint-plugin-vue")),
1829
- interopDefault(import("vue-eslint-parser"))
1925
+ interopDefault(import("vue-eslint-parser")),
1926
+ interopDefault(import("eslint-processor-vue-blocks"))
1830
1927
  ]);
1831
1928
  return [
1832
1929
  {
@@ -1867,7 +1964,16 @@ async function vue({
1867
1964
  sourceType: "module"
1868
1965
  }
1869
1966
  },
1870
- processor: pluginVue.processors[".vue"],
1967
+ processor: graphql2 === false ? pluginVue.processors[".vue"] : mergeProcessors([
1968
+ pluginVue.processors[".vue"],
1969
+ processorVueBlocks({
1970
+ blocks: {
1971
+ script: true,
1972
+ scriptSetup: true,
1973
+ customBlocks: true
1974
+ }
1975
+ })
1976
+ ]),
1871
1977
  rules: {
1872
1978
  ...pluginVue.configs.base.rules,
1873
1979
  ...vueVersion === 2 ? {
@@ -1894,12 +2000,7 @@ async function vue({
1894
2000
  "vue/define-macros-order": [
1895
2001
  "error",
1896
2002
  {
1897
- order: [
1898
- "defineOptions",
1899
- "defineProps",
1900
- "defineEmits",
1901
- "defineSlots"
1902
- ]
2003
+ order: ["defineOptions", "defineProps", "defineEmits", "defineSlots"]
1903
2004
  }
1904
2005
  ],
1905
2006
  "vue/dot-location": ["error", "property"],
@@ -1981,6 +2082,7 @@ async function vue({
1981
2082
  }
1982
2083
 
1983
2084
  // src/configs/yaml.ts
2085
+ init_esm_shims();
1984
2086
  var NAMESPACE21 = "exbotanical/yaml";
1985
2087
  async function yaml({ files = [GLOB_YAML], overrides = {} } = {}, { indent, quotes } = STYLE_DEFAULTS) {
1986
2088
  const [plugin4, parser] = await Promise.all([
@@ -2051,6 +2153,7 @@ async function exbotanical({
2051
2153
  style: optionsStyle = STYLE_DEFAULTS,
2052
2154
  react: optionsReact,
2053
2155
  vue: optionsVue,
2156
+ graphql: optionsGraphql,
2054
2157
  type
2055
2158
  }, ...userConfigs) {
2056
2159
  const configs2 = [
@@ -2078,6 +2181,9 @@ async function exbotanical({
2078
2181
  if (optionsMarkdown) {
2079
2182
  configs2.push(markdown({ ...factoryConfig(optionsMarkdown) }));
2080
2183
  }
2184
+ if (optionsGraphql) {
2185
+ configs2.push(graphql());
2186
+ }
2081
2187
  if (optionsReact) {
2082
2188
  configs2.push(react({ ...factoryConfig(optionsReact) }));
2083
2189
  }
@@ -2088,7 +2194,7 @@ async function exbotanical({
2088
2194
  configs2.push(typescript({ ...factoryConfig(optionsTypescript), type }));
2089
2195
  }
2090
2196
  if (optionsVue) {
2091
- configs2.push(vue({ ...factoryConfig(optionsVue) }));
2197
+ configs2.push(vue({ ...factoryConfig(optionsVue), graphql: !!optionsGraphql }));
2092
2198
  }
2093
2199
  if (optionsYaml) {
2094
2200
  configs2.push(yaml({ ...factoryConfig(optionsYaml), ...optionsStyle }));
@@ -2096,12 +2202,10 @@ async function exbotanical({
2096
2202
  if (formatter) {
2097
2203
  configs2.push(prettier());
2098
2204
  }
2099
- configs2.push(disables(), ignores({ ...optionsIgnore }));
2205
+ configs2.push(disables(), ignores(optionsIgnore));
2100
2206
  if (userConfigs.length > 0) {
2101
2207
  const resolved2 = await Promise.all(userConfigs);
2102
- configs2.push(
2103
- ...resolved2.map((r) => Promise.resolve(Array.isArray(r) ? r : [r]))
2104
- );
2208
+ configs2.push(...resolved2.map((r) => Promise.resolve(Array.isArray(r) ? r : [r])));
2105
2209
  }
2106
2210
  const resolved = await Promise.all(configs2);
2107
2211
  return resolved.flat();
@@ -2110,6 +2214,12 @@ function factoryConfig(options) {
2110
2214
  if (!options) return {};
2111
2215
  return typeof options === "boolean" ? {} : options;
2112
2216
  }
2217
+
2218
+ // src/options.ts
2219
+ init_esm_shims();
2220
+
2221
+ // src/types.ts
2222
+ init_esm_shims();
2113
2223
  export {
2114
2224
  exbotanical as default
2115
2225
  };