@icebreakers/eslint-config 1.6.26 → 1.6.28
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.cjs +154 -0
- package/dist/index.js +150 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -37,6 +37,10 @@ __export(index_exports, {
|
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(index_exports);
|
|
39
39
|
|
|
40
|
+
// ../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js
|
|
41
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
42
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
43
|
+
|
|
40
44
|
// src/antfu.ts
|
|
41
45
|
var antfu_exports = {};
|
|
42
46
|
__reExport(antfu_exports, require("@antfu/eslint-config"));
|
|
@@ -307,6 +311,12 @@ function resolveQueryPresets(isEnabled) {
|
|
|
307
311
|
];
|
|
308
312
|
}
|
|
309
313
|
|
|
314
|
+
// src/options.ts
|
|
315
|
+
var import_node_fs = __toESM(require("fs"), 1);
|
|
316
|
+
var import_node_module = require("module");
|
|
317
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
318
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
319
|
+
|
|
310
320
|
// ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
311
321
|
function isPlainObject(value) {
|
|
312
322
|
if (value === null || typeof value !== "object") {
|
|
@@ -402,6 +412,9 @@ var BASE_RULES = {
|
|
|
402
412
|
"dot-notation": "off",
|
|
403
413
|
// Keep dependency bans visible without blocking CI on upstream preset defaults.
|
|
404
414
|
"e18e/ban-dependencies": "warn",
|
|
415
|
+
// Disable until upstream fixes false positives on non-array iterables (Set, Map).
|
|
416
|
+
// See: [...new Set(arr)].sort() → new Set(arr).toSorted() is invalid.
|
|
417
|
+
"e18e/prefer-array-to-sorted": "off",
|
|
405
418
|
// Disable all pnpm rules by default
|
|
406
419
|
// @antfu/eslint-config auto-enables pnpm plugin when pnpm-workspace.yaml exists
|
|
407
420
|
// but we want it opt-in instead of auto-enabled
|
|
@@ -414,6 +427,19 @@ var BASE_RULES = {
|
|
|
414
427
|
"unused-imports/no-unused-vars": "off",
|
|
415
428
|
"unicorn/prefer-number-properties": "warn"
|
|
416
429
|
};
|
|
430
|
+
var require2 = (0, import_node_module.createRequire)(importMetaUrl);
|
|
431
|
+
var ANTFU_PACKAGE_DIR = import_node_path.default.dirname(
|
|
432
|
+
require2.resolve("@antfu/eslint-config/package.json")
|
|
433
|
+
);
|
|
434
|
+
var GENERAL_EDITORCONFIG_SECTIONS = /* @__PURE__ */ new Set([
|
|
435
|
+
"*",
|
|
436
|
+
"**",
|
|
437
|
+
"**/*",
|
|
438
|
+
"*.*",
|
|
439
|
+
"**.*",
|
|
440
|
+
"**/*.*"
|
|
441
|
+
]);
|
|
442
|
+
var NEWLINE_PATTERN = /\r?\n/u;
|
|
417
443
|
function mergeOptionWithDefaults(input, defaults, options = {}) {
|
|
418
444
|
const { postProcess, useDefaultWhenUndefined = false } = options;
|
|
419
445
|
const shouldUseDefaults = input === true || useDefaultWhenUndefined && input === void 0;
|
|
@@ -449,6 +475,133 @@ function applyVueVersionSpecificRules(option) {
|
|
|
449
475
|
"vue/no-v-for-template-key": "off"
|
|
450
476
|
});
|
|
451
477
|
}
|
|
478
|
+
function isPackageAvailable(name, paths) {
|
|
479
|
+
try {
|
|
480
|
+
require2.resolve(name, paths ? { paths } : void 0);
|
|
481
|
+
return true;
|
|
482
|
+
} catch {
|
|
483
|
+
return false;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
function getDefaultFormatterOptions(cwd = import_node_process.default.cwd()) {
|
|
487
|
+
const hasXmlPlugin = isPackageAvailable("@prettier/plugin-xml", [ANTFU_PACKAGE_DIR]);
|
|
488
|
+
return {
|
|
489
|
+
astro: isPackageAvailable("prettier-plugin-astro", [ANTFU_PACKAGE_DIR]),
|
|
490
|
+
css: true,
|
|
491
|
+
graphql: true,
|
|
492
|
+
html: true,
|
|
493
|
+
markdown: true,
|
|
494
|
+
slidev: isPackageAvailable("@slidev/cli", [cwd]),
|
|
495
|
+
svg: hasXmlPlugin,
|
|
496
|
+
xml: hasXmlPlugin
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
function normalizeEditorConfigEndOfLine(value) {
|
|
500
|
+
switch (value.trim().toLowerCase()) {
|
|
501
|
+
case "cr":
|
|
502
|
+
case "crlf":
|
|
503
|
+
case "lf":
|
|
504
|
+
return value.trim().toLowerCase();
|
|
505
|
+
default:
|
|
506
|
+
return void 0;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
function isGeneralEditorConfigSection(section) {
|
|
510
|
+
return GENERAL_EDITORCONFIG_SECTIONS.has(section.trim());
|
|
511
|
+
}
|
|
512
|
+
function parseEditorConfig(filePath) {
|
|
513
|
+
const lines = import_node_fs.default.readFileSync(filePath, "utf8").split(NEWLINE_PATTERN);
|
|
514
|
+
let currentSection;
|
|
515
|
+
let endOfLine;
|
|
516
|
+
let isRoot = false;
|
|
517
|
+
for (const rawLine of lines) {
|
|
518
|
+
const line = rawLine.trim();
|
|
519
|
+
if (!line || line.startsWith("#") || line.startsWith(";")) {
|
|
520
|
+
continue;
|
|
521
|
+
}
|
|
522
|
+
if (line.startsWith("[") && line.endsWith("]")) {
|
|
523
|
+
currentSection = line.slice(1, -1).trim();
|
|
524
|
+
continue;
|
|
525
|
+
}
|
|
526
|
+
const separatorIndex = line.indexOf("=");
|
|
527
|
+
if (separatorIndex === -1) {
|
|
528
|
+
continue;
|
|
529
|
+
}
|
|
530
|
+
const key = line.slice(0, separatorIndex).trim().toLowerCase();
|
|
531
|
+
const value = line.slice(separatorIndex + 1).trim();
|
|
532
|
+
if (!currentSection && key === "root") {
|
|
533
|
+
isRoot = value.toLowerCase() === "true";
|
|
534
|
+
continue;
|
|
535
|
+
}
|
|
536
|
+
if (key !== "end_of_line") {
|
|
537
|
+
continue;
|
|
538
|
+
}
|
|
539
|
+
const normalized = normalizeEditorConfigEndOfLine(value);
|
|
540
|
+
if (!normalized) {
|
|
541
|
+
continue;
|
|
542
|
+
}
|
|
543
|
+
if (!currentSection || isGeneralEditorConfigSection(currentSection)) {
|
|
544
|
+
endOfLine = normalized;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
return endOfLine ? {
|
|
548
|
+
endOfLine,
|
|
549
|
+
isRoot
|
|
550
|
+
} : {
|
|
551
|
+
isRoot
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
function inferPrettierEndOfLineFromEditorConfig(cwd = import_node_process.default.cwd()) {
|
|
555
|
+
const configs = [];
|
|
556
|
+
let currentDir = import_node_path.default.resolve(cwd);
|
|
557
|
+
while (true) {
|
|
558
|
+
const editorConfigPath = import_node_path.default.join(currentDir, ".editorconfig");
|
|
559
|
+
if (import_node_fs.default.existsSync(editorConfigPath)) {
|
|
560
|
+
configs.push(editorConfigPath);
|
|
561
|
+
if (parseEditorConfig(editorConfigPath).isRoot) {
|
|
562
|
+
break;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
const parentDir = import_node_path.default.dirname(currentDir);
|
|
566
|
+
if (parentDir === currentDir) {
|
|
567
|
+
break;
|
|
568
|
+
}
|
|
569
|
+
currentDir = parentDir;
|
|
570
|
+
}
|
|
571
|
+
let endOfLine;
|
|
572
|
+
for (const filePath of configs.reverse()) {
|
|
573
|
+
const parsed = parseEditorConfig(filePath);
|
|
574
|
+
if (parsed.endOfLine) {
|
|
575
|
+
endOfLine = parsed.endOfLine;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
return endOfLine;
|
|
579
|
+
}
|
|
580
|
+
function resolveFormattersOption(input, cwd = import_node_process.default.cwd()) {
|
|
581
|
+
if (input === false) {
|
|
582
|
+
return false;
|
|
583
|
+
}
|
|
584
|
+
const defaults = getDefaultFormatterOptions(cwd);
|
|
585
|
+
const inferredEndOfLine = inferPrettierEndOfLineFromEditorConfig(cwd);
|
|
586
|
+
const defaultsWithPrettier = inferredEndOfLine ? defu(
|
|
587
|
+
{
|
|
588
|
+
prettierOptions: {
|
|
589
|
+
endOfLine: inferredEndOfLine
|
|
590
|
+
}
|
|
591
|
+
},
|
|
592
|
+
defaults
|
|
593
|
+
) : defaults;
|
|
594
|
+
if (input === void 0) {
|
|
595
|
+
return inferredEndOfLine ? defaultsWithPrettier : true;
|
|
596
|
+
}
|
|
597
|
+
if (input === true) {
|
|
598
|
+
return defaultsWithPrettier;
|
|
599
|
+
}
|
|
600
|
+
if (isObject(input)) {
|
|
601
|
+
return defu(input, defaultsWithPrettier);
|
|
602
|
+
}
|
|
603
|
+
return defaultsWithPrettier;
|
|
604
|
+
}
|
|
452
605
|
function resolveUserOptions(options) {
|
|
453
606
|
const resolved = defu(
|
|
454
607
|
{},
|
|
@@ -479,6 +632,7 @@ function resolveUserOptions(options) {
|
|
|
479
632
|
} else {
|
|
480
633
|
resolved.typescript = resolvedTypescript;
|
|
481
634
|
}
|
|
635
|
+
resolved.formatters = resolveFormattersOption(options?.formatters);
|
|
482
636
|
return resolved;
|
|
483
637
|
}
|
|
484
638
|
function createBaseRuleSet(isLegacy) {
|
package/dist/index.js
CHANGED
|
@@ -283,6 +283,12 @@ function resolveQueryPresets(isEnabled) {
|
|
|
283
283
|
];
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
+
// src/options.ts
|
|
287
|
+
import fs from "fs";
|
|
288
|
+
import { createRequire } from "module";
|
|
289
|
+
import path from "path";
|
|
290
|
+
import process from "process";
|
|
291
|
+
|
|
286
292
|
// ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
287
293
|
function isPlainObject(value) {
|
|
288
294
|
if (value === null || typeof value !== "object") {
|
|
@@ -378,6 +384,9 @@ var BASE_RULES = {
|
|
|
378
384
|
"dot-notation": "off",
|
|
379
385
|
// Keep dependency bans visible without blocking CI on upstream preset defaults.
|
|
380
386
|
"e18e/ban-dependencies": "warn",
|
|
387
|
+
// Disable until upstream fixes false positives on non-array iterables (Set, Map).
|
|
388
|
+
// See: [...new Set(arr)].sort() → new Set(arr).toSorted() is invalid.
|
|
389
|
+
"e18e/prefer-array-to-sorted": "off",
|
|
381
390
|
// Disable all pnpm rules by default
|
|
382
391
|
// @antfu/eslint-config auto-enables pnpm plugin when pnpm-workspace.yaml exists
|
|
383
392
|
// but we want it opt-in instead of auto-enabled
|
|
@@ -390,6 +399,19 @@ var BASE_RULES = {
|
|
|
390
399
|
"unused-imports/no-unused-vars": "off",
|
|
391
400
|
"unicorn/prefer-number-properties": "warn"
|
|
392
401
|
};
|
|
402
|
+
var require2 = createRequire(import.meta.url);
|
|
403
|
+
var ANTFU_PACKAGE_DIR = path.dirname(
|
|
404
|
+
require2.resolve("@antfu/eslint-config/package.json")
|
|
405
|
+
);
|
|
406
|
+
var GENERAL_EDITORCONFIG_SECTIONS = /* @__PURE__ */ new Set([
|
|
407
|
+
"*",
|
|
408
|
+
"**",
|
|
409
|
+
"**/*",
|
|
410
|
+
"*.*",
|
|
411
|
+
"**.*",
|
|
412
|
+
"**/*.*"
|
|
413
|
+
]);
|
|
414
|
+
var NEWLINE_PATTERN = /\r?\n/u;
|
|
393
415
|
function mergeOptionWithDefaults(input, defaults, options = {}) {
|
|
394
416
|
const { postProcess, useDefaultWhenUndefined = false } = options;
|
|
395
417
|
const shouldUseDefaults = input === true || useDefaultWhenUndefined && input === void 0;
|
|
@@ -425,6 +447,133 @@ function applyVueVersionSpecificRules(option) {
|
|
|
425
447
|
"vue/no-v-for-template-key": "off"
|
|
426
448
|
});
|
|
427
449
|
}
|
|
450
|
+
function isPackageAvailable(name, paths) {
|
|
451
|
+
try {
|
|
452
|
+
require2.resolve(name, paths ? { paths } : void 0);
|
|
453
|
+
return true;
|
|
454
|
+
} catch {
|
|
455
|
+
return false;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
function getDefaultFormatterOptions(cwd = process.cwd()) {
|
|
459
|
+
const hasXmlPlugin = isPackageAvailable("@prettier/plugin-xml", [ANTFU_PACKAGE_DIR]);
|
|
460
|
+
return {
|
|
461
|
+
astro: isPackageAvailable("prettier-plugin-astro", [ANTFU_PACKAGE_DIR]),
|
|
462
|
+
css: true,
|
|
463
|
+
graphql: true,
|
|
464
|
+
html: true,
|
|
465
|
+
markdown: true,
|
|
466
|
+
slidev: isPackageAvailable("@slidev/cli", [cwd]),
|
|
467
|
+
svg: hasXmlPlugin,
|
|
468
|
+
xml: hasXmlPlugin
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
function normalizeEditorConfigEndOfLine(value) {
|
|
472
|
+
switch (value.trim().toLowerCase()) {
|
|
473
|
+
case "cr":
|
|
474
|
+
case "crlf":
|
|
475
|
+
case "lf":
|
|
476
|
+
return value.trim().toLowerCase();
|
|
477
|
+
default:
|
|
478
|
+
return void 0;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
function isGeneralEditorConfigSection(section) {
|
|
482
|
+
return GENERAL_EDITORCONFIG_SECTIONS.has(section.trim());
|
|
483
|
+
}
|
|
484
|
+
function parseEditorConfig(filePath) {
|
|
485
|
+
const lines = fs.readFileSync(filePath, "utf8").split(NEWLINE_PATTERN);
|
|
486
|
+
let currentSection;
|
|
487
|
+
let endOfLine;
|
|
488
|
+
let isRoot = false;
|
|
489
|
+
for (const rawLine of lines) {
|
|
490
|
+
const line = rawLine.trim();
|
|
491
|
+
if (!line || line.startsWith("#") || line.startsWith(";")) {
|
|
492
|
+
continue;
|
|
493
|
+
}
|
|
494
|
+
if (line.startsWith("[") && line.endsWith("]")) {
|
|
495
|
+
currentSection = line.slice(1, -1).trim();
|
|
496
|
+
continue;
|
|
497
|
+
}
|
|
498
|
+
const separatorIndex = line.indexOf("=");
|
|
499
|
+
if (separatorIndex === -1) {
|
|
500
|
+
continue;
|
|
501
|
+
}
|
|
502
|
+
const key = line.slice(0, separatorIndex).trim().toLowerCase();
|
|
503
|
+
const value = line.slice(separatorIndex + 1).trim();
|
|
504
|
+
if (!currentSection && key === "root") {
|
|
505
|
+
isRoot = value.toLowerCase() === "true";
|
|
506
|
+
continue;
|
|
507
|
+
}
|
|
508
|
+
if (key !== "end_of_line") {
|
|
509
|
+
continue;
|
|
510
|
+
}
|
|
511
|
+
const normalized = normalizeEditorConfigEndOfLine(value);
|
|
512
|
+
if (!normalized) {
|
|
513
|
+
continue;
|
|
514
|
+
}
|
|
515
|
+
if (!currentSection || isGeneralEditorConfigSection(currentSection)) {
|
|
516
|
+
endOfLine = normalized;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
return endOfLine ? {
|
|
520
|
+
endOfLine,
|
|
521
|
+
isRoot
|
|
522
|
+
} : {
|
|
523
|
+
isRoot
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
function inferPrettierEndOfLineFromEditorConfig(cwd = process.cwd()) {
|
|
527
|
+
const configs = [];
|
|
528
|
+
let currentDir = path.resolve(cwd);
|
|
529
|
+
while (true) {
|
|
530
|
+
const editorConfigPath = path.join(currentDir, ".editorconfig");
|
|
531
|
+
if (fs.existsSync(editorConfigPath)) {
|
|
532
|
+
configs.push(editorConfigPath);
|
|
533
|
+
if (parseEditorConfig(editorConfigPath).isRoot) {
|
|
534
|
+
break;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
const parentDir = path.dirname(currentDir);
|
|
538
|
+
if (parentDir === currentDir) {
|
|
539
|
+
break;
|
|
540
|
+
}
|
|
541
|
+
currentDir = parentDir;
|
|
542
|
+
}
|
|
543
|
+
let endOfLine;
|
|
544
|
+
for (const filePath of configs.reverse()) {
|
|
545
|
+
const parsed = parseEditorConfig(filePath);
|
|
546
|
+
if (parsed.endOfLine) {
|
|
547
|
+
endOfLine = parsed.endOfLine;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
return endOfLine;
|
|
551
|
+
}
|
|
552
|
+
function resolveFormattersOption(input, cwd = process.cwd()) {
|
|
553
|
+
if (input === false) {
|
|
554
|
+
return false;
|
|
555
|
+
}
|
|
556
|
+
const defaults = getDefaultFormatterOptions(cwd);
|
|
557
|
+
const inferredEndOfLine = inferPrettierEndOfLineFromEditorConfig(cwd);
|
|
558
|
+
const defaultsWithPrettier = inferredEndOfLine ? defu(
|
|
559
|
+
{
|
|
560
|
+
prettierOptions: {
|
|
561
|
+
endOfLine: inferredEndOfLine
|
|
562
|
+
}
|
|
563
|
+
},
|
|
564
|
+
defaults
|
|
565
|
+
) : defaults;
|
|
566
|
+
if (input === void 0) {
|
|
567
|
+
return inferredEndOfLine ? defaultsWithPrettier : true;
|
|
568
|
+
}
|
|
569
|
+
if (input === true) {
|
|
570
|
+
return defaultsWithPrettier;
|
|
571
|
+
}
|
|
572
|
+
if (isObject(input)) {
|
|
573
|
+
return defu(input, defaultsWithPrettier);
|
|
574
|
+
}
|
|
575
|
+
return defaultsWithPrettier;
|
|
576
|
+
}
|
|
428
577
|
function resolveUserOptions(options) {
|
|
429
578
|
const resolved = defu(
|
|
430
579
|
{},
|
|
@@ -455,6 +604,7 @@ function resolveUserOptions(options) {
|
|
|
455
604
|
} else {
|
|
456
605
|
resolved.typescript = resolvedTypescript;
|
|
457
606
|
}
|
|
607
|
+
resolved.formatters = resolveFormattersOption(options?.formatters);
|
|
458
608
|
return resolved;
|
|
459
609
|
}
|
|
460
610
|
function createBaseRuleSet(isLegacy) {
|
package/package.json
CHANGED