@icebreakers/eslint-config 1.6.26 → 1.6.27
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 +151 -0
- package/dist/index.js +147 -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") {
|
|
@@ -414,6 +424,19 @@ var BASE_RULES = {
|
|
|
414
424
|
"unused-imports/no-unused-vars": "off",
|
|
415
425
|
"unicorn/prefer-number-properties": "warn"
|
|
416
426
|
};
|
|
427
|
+
var require2 = (0, import_node_module.createRequire)(importMetaUrl);
|
|
428
|
+
var ANTFU_PACKAGE_DIR = import_node_path.default.dirname(
|
|
429
|
+
require2.resolve("@antfu/eslint-config/package.json")
|
|
430
|
+
);
|
|
431
|
+
var GENERAL_EDITORCONFIG_SECTIONS = /* @__PURE__ */ new Set([
|
|
432
|
+
"*",
|
|
433
|
+
"**",
|
|
434
|
+
"**/*",
|
|
435
|
+
"*.*",
|
|
436
|
+
"**.*",
|
|
437
|
+
"**/*.*"
|
|
438
|
+
]);
|
|
439
|
+
var NEWLINE_PATTERN = /\r?\n/u;
|
|
417
440
|
function mergeOptionWithDefaults(input, defaults, options = {}) {
|
|
418
441
|
const { postProcess, useDefaultWhenUndefined = false } = options;
|
|
419
442
|
const shouldUseDefaults = input === true || useDefaultWhenUndefined && input === void 0;
|
|
@@ -449,6 +472,133 @@ function applyVueVersionSpecificRules(option) {
|
|
|
449
472
|
"vue/no-v-for-template-key": "off"
|
|
450
473
|
});
|
|
451
474
|
}
|
|
475
|
+
function isPackageAvailable(name, paths) {
|
|
476
|
+
try {
|
|
477
|
+
require2.resolve(name, paths ? { paths } : void 0);
|
|
478
|
+
return true;
|
|
479
|
+
} catch {
|
|
480
|
+
return false;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
function getDefaultFormatterOptions(cwd = import_node_process.default.cwd()) {
|
|
484
|
+
const hasXmlPlugin = isPackageAvailable("@prettier/plugin-xml", [ANTFU_PACKAGE_DIR]);
|
|
485
|
+
return {
|
|
486
|
+
astro: isPackageAvailable("prettier-plugin-astro", [ANTFU_PACKAGE_DIR]),
|
|
487
|
+
css: true,
|
|
488
|
+
graphql: true,
|
|
489
|
+
html: true,
|
|
490
|
+
markdown: true,
|
|
491
|
+
slidev: isPackageAvailable("@slidev/cli", [cwd]),
|
|
492
|
+
svg: hasXmlPlugin,
|
|
493
|
+
xml: hasXmlPlugin
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
function normalizeEditorConfigEndOfLine(value) {
|
|
497
|
+
switch (value.trim().toLowerCase()) {
|
|
498
|
+
case "cr":
|
|
499
|
+
case "crlf":
|
|
500
|
+
case "lf":
|
|
501
|
+
return value.trim().toLowerCase();
|
|
502
|
+
default:
|
|
503
|
+
return void 0;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
function isGeneralEditorConfigSection(section) {
|
|
507
|
+
return GENERAL_EDITORCONFIG_SECTIONS.has(section.trim());
|
|
508
|
+
}
|
|
509
|
+
function parseEditorConfig(filePath) {
|
|
510
|
+
const lines = import_node_fs.default.readFileSync(filePath, "utf8").split(NEWLINE_PATTERN);
|
|
511
|
+
let currentSection;
|
|
512
|
+
let endOfLine;
|
|
513
|
+
let isRoot = false;
|
|
514
|
+
for (const rawLine of lines) {
|
|
515
|
+
const line = rawLine.trim();
|
|
516
|
+
if (!line || line.startsWith("#") || line.startsWith(";")) {
|
|
517
|
+
continue;
|
|
518
|
+
}
|
|
519
|
+
if (line.startsWith("[") && line.endsWith("]")) {
|
|
520
|
+
currentSection = line.slice(1, -1).trim();
|
|
521
|
+
continue;
|
|
522
|
+
}
|
|
523
|
+
const separatorIndex = line.indexOf("=");
|
|
524
|
+
if (separatorIndex === -1) {
|
|
525
|
+
continue;
|
|
526
|
+
}
|
|
527
|
+
const key = line.slice(0, separatorIndex).trim().toLowerCase();
|
|
528
|
+
const value = line.slice(separatorIndex + 1).trim();
|
|
529
|
+
if (!currentSection && key === "root") {
|
|
530
|
+
isRoot = value.toLowerCase() === "true";
|
|
531
|
+
continue;
|
|
532
|
+
}
|
|
533
|
+
if (key !== "end_of_line") {
|
|
534
|
+
continue;
|
|
535
|
+
}
|
|
536
|
+
const normalized = normalizeEditorConfigEndOfLine(value);
|
|
537
|
+
if (!normalized) {
|
|
538
|
+
continue;
|
|
539
|
+
}
|
|
540
|
+
if (!currentSection || isGeneralEditorConfigSection(currentSection)) {
|
|
541
|
+
endOfLine = normalized;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
return endOfLine ? {
|
|
545
|
+
endOfLine,
|
|
546
|
+
isRoot
|
|
547
|
+
} : {
|
|
548
|
+
isRoot
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
function inferPrettierEndOfLineFromEditorConfig(cwd = import_node_process.default.cwd()) {
|
|
552
|
+
const configs = [];
|
|
553
|
+
let currentDir = import_node_path.default.resolve(cwd);
|
|
554
|
+
while (true) {
|
|
555
|
+
const editorConfigPath = import_node_path.default.join(currentDir, ".editorconfig");
|
|
556
|
+
if (import_node_fs.default.existsSync(editorConfigPath)) {
|
|
557
|
+
configs.push(editorConfigPath);
|
|
558
|
+
if (parseEditorConfig(editorConfigPath).isRoot) {
|
|
559
|
+
break;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
const parentDir = import_node_path.default.dirname(currentDir);
|
|
563
|
+
if (parentDir === currentDir) {
|
|
564
|
+
break;
|
|
565
|
+
}
|
|
566
|
+
currentDir = parentDir;
|
|
567
|
+
}
|
|
568
|
+
let endOfLine;
|
|
569
|
+
for (const filePath of configs.reverse()) {
|
|
570
|
+
const parsed = parseEditorConfig(filePath);
|
|
571
|
+
if (parsed.endOfLine) {
|
|
572
|
+
endOfLine = parsed.endOfLine;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
return endOfLine;
|
|
576
|
+
}
|
|
577
|
+
function resolveFormattersOption(input, cwd = import_node_process.default.cwd()) {
|
|
578
|
+
if (input === false) {
|
|
579
|
+
return false;
|
|
580
|
+
}
|
|
581
|
+
const defaults = getDefaultFormatterOptions(cwd);
|
|
582
|
+
const inferredEndOfLine = inferPrettierEndOfLineFromEditorConfig(cwd);
|
|
583
|
+
const defaultsWithPrettier = inferredEndOfLine ? defu(
|
|
584
|
+
{
|
|
585
|
+
prettierOptions: {
|
|
586
|
+
endOfLine: inferredEndOfLine
|
|
587
|
+
}
|
|
588
|
+
},
|
|
589
|
+
defaults
|
|
590
|
+
) : defaults;
|
|
591
|
+
if (input === void 0) {
|
|
592
|
+
return inferredEndOfLine ? defaultsWithPrettier : true;
|
|
593
|
+
}
|
|
594
|
+
if (input === true) {
|
|
595
|
+
return defaultsWithPrettier;
|
|
596
|
+
}
|
|
597
|
+
if (isObject(input)) {
|
|
598
|
+
return defu(input, defaultsWithPrettier);
|
|
599
|
+
}
|
|
600
|
+
return defaultsWithPrettier;
|
|
601
|
+
}
|
|
452
602
|
function resolveUserOptions(options) {
|
|
453
603
|
const resolved = defu(
|
|
454
604
|
{},
|
|
@@ -479,6 +629,7 @@ function resolveUserOptions(options) {
|
|
|
479
629
|
} else {
|
|
480
630
|
resolved.typescript = resolvedTypescript;
|
|
481
631
|
}
|
|
632
|
+
resolved.formatters = resolveFormattersOption(options?.formatters);
|
|
482
633
|
return resolved;
|
|
483
634
|
}
|
|
484
635
|
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") {
|
|
@@ -390,6 +396,19 @@ var BASE_RULES = {
|
|
|
390
396
|
"unused-imports/no-unused-vars": "off",
|
|
391
397
|
"unicorn/prefer-number-properties": "warn"
|
|
392
398
|
};
|
|
399
|
+
var require2 = createRequire(import.meta.url);
|
|
400
|
+
var ANTFU_PACKAGE_DIR = path.dirname(
|
|
401
|
+
require2.resolve("@antfu/eslint-config/package.json")
|
|
402
|
+
);
|
|
403
|
+
var GENERAL_EDITORCONFIG_SECTIONS = /* @__PURE__ */ new Set([
|
|
404
|
+
"*",
|
|
405
|
+
"**",
|
|
406
|
+
"**/*",
|
|
407
|
+
"*.*",
|
|
408
|
+
"**.*",
|
|
409
|
+
"**/*.*"
|
|
410
|
+
]);
|
|
411
|
+
var NEWLINE_PATTERN = /\r?\n/u;
|
|
393
412
|
function mergeOptionWithDefaults(input, defaults, options = {}) {
|
|
394
413
|
const { postProcess, useDefaultWhenUndefined = false } = options;
|
|
395
414
|
const shouldUseDefaults = input === true || useDefaultWhenUndefined && input === void 0;
|
|
@@ -425,6 +444,133 @@ function applyVueVersionSpecificRules(option) {
|
|
|
425
444
|
"vue/no-v-for-template-key": "off"
|
|
426
445
|
});
|
|
427
446
|
}
|
|
447
|
+
function isPackageAvailable(name, paths) {
|
|
448
|
+
try {
|
|
449
|
+
require2.resolve(name, paths ? { paths } : void 0);
|
|
450
|
+
return true;
|
|
451
|
+
} catch {
|
|
452
|
+
return false;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
function getDefaultFormatterOptions(cwd = process.cwd()) {
|
|
456
|
+
const hasXmlPlugin = isPackageAvailable("@prettier/plugin-xml", [ANTFU_PACKAGE_DIR]);
|
|
457
|
+
return {
|
|
458
|
+
astro: isPackageAvailable("prettier-plugin-astro", [ANTFU_PACKAGE_DIR]),
|
|
459
|
+
css: true,
|
|
460
|
+
graphql: true,
|
|
461
|
+
html: true,
|
|
462
|
+
markdown: true,
|
|
463
|
+
slidev: isPackageAvailable("@slidev/cli", [cwd]),
|
|
464
|
+
svg: hasXmlPlugin,
|
|
465
|
+
xml: hasXmlPlugin
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
function normalizeEditorConfigEndOfLine(value) {
|
|
469
|
+
switch (value.trim().toLowerCase()) {
|
|
470
|
+
case "cr":
|
|
471
|
+
case "crlf":
|
|
472
|
+
case "lf":
|
|
473
|
+
return value.trim().toLowerCase();
|
|
474
|
+
default:
|
|
475
|
+
return void 0;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
function isGeneralEditorConfigSection(section) {
|
|
479
|
+
return GENERAL_EDITORCONFIG_SECTIONS.has(section.trim());
|
|
480
|
+
}
|
|
481
|
+
function parseEditorConfig(filePath) {
|
|
482
|
+
const lines = fs.readFileSync(filePath, "utf8").split(NEWLINE_PATTERN);
|
|
483
|
+
let currentSection;
|
|
484
|
+
let endOfLine;
|
|
485
|
+
let isRoot = false;
|
|
486
|
+
for (const rawLine of lines) {
|
|
487
|
+
const line = rawLine.trim();
|
|
488
|
+
if (!line || line.startsWith("#") || line.startsWith(";")) {
|
|
489
|
+
continue;
|
|
490
|
+
}
|
|
491
|
+
if (line.startsWith("[") && line.endsWith("]")) {
|
|
492
|
+
currentSection = line.slice(1, -1).trim();
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
const separatorIndex = line.indexOf("=");
|
|
496
|
+
if (separatorIndex === -1) {
|
|
497
|
+
continue;
|
|
498
|
+
}
|
|
499
|
+
const key = line.slice(0, separatorIndex).trim().toLowerCase();
|
|
500
|
+
const value = line.slice(separatorIndex + 1).trim();
|
|
501
|
+
if (!currentSection && key === "root") {
|
|
502
|
+
isRoot = value.toLowerCase() === "true";
|
|
503
|
+
continue;
|
|
504
|
+
}
|
|
505
|
+
if (key !== "end_of_line") {
|
|
506
|
+
continue;
|
|
507
|
+
}
|
|
508
|
+
const normalized = normalizeEditorConfigEndOfLine(value);
|
|
509
|
+
if (!normalized) {
|
|
510
|
+
continue;
|
|
511
|
+
}
|
|
512
|
+
if (!currentSection || isGeneralEditorConfigSection(currentSection)) {
|
|
513
|
+
endOfLine = normalized;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
return endOfLine ? {
|
|
517
|
+
endOfLine,
|
|
518
|
+
isRoot
|
|
519
|
+
} : {
|
|
520
|
+
isRoot
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
function inferPrettierEndOfLineFromEditorConfig(cwd = process.cwd()) {
|
|
524
|
+
const configs = [];
|
|
525
|
+
let currentDir = path.resolve(cwd);
|
|
526
|
+
while (true) {
|
|
527
|
+
const editorConfigPath = path.join(currentDir, ".editorconfig");
|
|
528
|
+
if (fs.existsSync(editorConfigPath)) {
|
|
529
|
+
configs.push(editorConfigPath);
|
|
530
|
+
if (parseEditorConfig(editorConfigPath).isRoot) {
|
|
531
|
+
break;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
const parentDir = path.dirname(currentDir);
|
|
535
|
+
if (parentDir === currentDir) {
|
|
536
|
+
break;
|
|
537
|
+
}
|
|
538
|
+
currentDir = parentDir;
|
|
539
|
+
}
|
|
540
|
+
let endOfLine;
|
|
541
|
+
for (const filePath of configs.reverse()) {
|
|
542
|
+
const parsed = parseEditorConfig(filePath);
|
|
543
|
+
if (parsed.endOfLine) {
|
|
544
|
+
endOfLine = parsed.endOfLine;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
return endOfLine;
|
|
548
|
+
}
|
|
549
|
+
function resolveFormattersOption(input, cwd = process.cwd()) {
|
|
550
|
+
if (input === false) {
|
|
551
|
+
return false;
|
|
552
|
+
}
|
|
553
|
+
const defaults = getDefaultFormatterOptions(cwd);
|
|
554
|
+
const inferredEndOfLine = inferPrettierEndOfLineFromEditorConfig(cwd);
|
|
555
|
+
const defaultsWithPrettier = inferredEndOfLine ? defu(
|
|
556
|
+
{
|
|
557
|
+
prettierOptions: {
|
|
558
|
+
endOfLine: inferredEndOfLine
|
|
559
|
+
}
|
|
560
|
+
},
|
|
561
|
+
defaults
|
|
562
|
+
) : defaults;
|
|
563
|
+
if (input === void 0) {
|
|
564
|
+
return inferredEndOfLine ? defaultsWithPrettier : true;
|
|
565
|
+
}
|
|
566
|
+
if (input === true) {
|
|
567
|
+
return defaultsWithPrettier;
|
|
568
|
+
}
|
|
569
|
+
if (isObject(input)) {
|
|
570
|
+
return defu(input, defaultsWithPrettier);
|
|
571
|
+
}
|
|
572
|
+
return defaultsWithPrettier;
|
|
573
|
+
}
|
|
428
574
|
function resolveUserOptions(options) {
|
|
429
575
|
const resolved = defu(
|
|
430
576
|
{},
|
|
@@ -455,6 +601,7 @@ function resolveUserOptions(options) {
|
|
|
455
601
|
} else {
|
|
456
602
|
resolved.typescript = resolvedTypescript;
|
|
457
603
|
}
|
|
604
|
+
resolved.formatters = resolveFormattersOption(options?.formatters);
|
|
458
605
|
return resolved;
|
|
459
606
|
}
|
|
460
607
|
function createBaseRuleSet(isLegacy) {
|
package/package.json
CHANGED