@lincy/eslint-config 4.6.3 → 4.7.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.
package/dist/index.cjs CHANGED
@@ -66,9 +66,11 @@ __export(src_exports, {
66
66
  ignores: () => ignores,
67
67
  imports: () => imports,
68
68
  interopDefault: () => interopDefault,
69
+ isInEditorEnv: () => isInEditorEnv,
69
70
  javascript: () => javascript,
70
71
  jsdoc: () => jsdoc,
71
72
  jsonc: () => jsonc,
73
+ jsx: () => jsx,
72
74
  lincy: () => lincy,
73
75
  markdown: () => markdown,
74
76
  node: () => node,
@@ -92,8 +94,6 @@ __export(src_exports, {
92
94
  module.exports = __toCommonJS(src_exports);
93
95
 
94
96
  // src/factory.ts
95
- var import_node_process3 = __toESM(require("process"), 1);
96
- var import_node_fs = __toESM(require("fs"), 1);
97
97
  var import_local_pkg4 = require("local-pkg");
98
98
  var import_eslint_flat_config_utils = require("eslint-flat-config-utils");
99
99
 
@@ -186,6 +186,7 @@ var GLOB_EXCLUDE = [
186
186
  "**/.output",
187
187
  "**/.vite-inspect",
188
188
  "**/.yarn",
189
+ "**/vite.config.*.timestamp-*",
189
190
  "**/CHANGELOG*.md",
190
191
  "**/*.min.*",
191
192
  "**/LICENSE*",
@@ -204,7 +205,8 @@ async function ignores(options = {}) {
204
205
  ignores: [
205
206
  ...GLOB_EXCLUDE,
206
207
  ...ignores2
207
- ]
208
+ ],
209
+ name: "eslint:ignores"
208
210
  }
209
211
  ];
210
212
  }
@@ -279,6 +281,9 @@ async function javascript(options = {}) {
279
281
  linterOptions: {
280
282
  reportUnusedDisableDirectives: true
281
283
  },
284
+ name: "eslint:javascript:setup"
285
+ },
286
+ {
282
287
  name: "eslint:javascript:rules",
283
288
  plugins: {
284
289
  "antfu": import_eslint_plugin_antfu.default,
@@ -536,6 +541,9 @@ async function ensurePackages(packages) {
536
541
  await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
537
542
  }
538
543
  }
544
+ function isInEditorEnv() {
545
+ return !!((import_node_process.default.env.VSCODE_PID || import_node_process.default.env.VSCODE_CWD || import_node_process.default.env.JETBRAINS_IDE || import_node_process.default.env.VIM || import_node_process.default.env.NVIM) && !import_node_process.default.env.CI);
546
+ }
539
547
 
540
548
  // src/configs/jsdoc.ts
541
549
  async function jsdoc(options = {}) {
@@ -645,6 +653,23 @@ async function jsonc(options = {}) {
645
653
  ];
646
654
  }
647
655
 
656
+ // src/configs/jsx.ts
657
+ async function jsx() {
658
+ return [
659
+ {
660
+ files: [GLOB_JSX, GLOB_TSX],
661
+ languageOptions: {
662
+ parserOptions: {
663
+ ecmaFeatures: {
664
+ jsx: true
665
+ }
666
+ }
667
+ },
668
+ name: "eslint:jsx:setup"
669
+ }
670
+ ];
671
+ }
672
+
648
673
  // src/configs/markdown.ts
649
674
  var parserPlain = __toESM(require("eslint-parser-plain"), 1);
650
675
  var import_eslint_merge_processors = require("eslint-merge-processors");
@@ -709,6 +734,7 @@ async function markdown(options = {}) {
709
734
  "ts/no-namespace": "off",
710
735
  "ts/no-redeclare": "off",
711
736
  "ts/no-require-imports": "off",
737
+ "ts/no-unused-expressions": "off",
712
738
  "ts/no-unused-vars": "off",
713
739
  "ts/no-use-before-define": "off",
714
740
  "ts/no-var-requires": "off",
@@ -769,7 +795,7 @@ async function stylistic(options = {}) {
769
795
  } = options;
770
796
  const {
771
797
  indent,
772
- jsx,
798
+ jsx: jsx2,
773
799
  lessOpinionated,
774
800
  quotes,
775
801
  semi
@@ -778,7 +804,7 @@ async function stylistic(options = {}) {
778
804
  const config = pluginStylistic.configs.customize({
779
805
  flat: true,
780
806
  indent,
781
- jsx,
807
+ jsx: jsx2,
782
808
  pluginName: "style",
783
809
  quotes,
784
810
  semi
@@ -1005,7 +1031,7 @@ var ReactRefreshAllowConstantExportPackages = [
1005
1031
  async function react(options = {}) {
1006
1032
  const {
1007
1033
  files = [GLOB_JSX, GLOB_TSX],
1008
- jsx = true,
1034
+ jsx: jsx2 = true,
1009
1035
  overrides = {},
1010
1036
  version = "detect"
1011
1037
  } = options;
@@ -1051,7 +1077,7 @@ async function react(options = {}) {
1051
1077
  parser: parserTs,
1052
1078
  parserOptions: {
1053
1079
  ecmaFeatures: {
1054
- jsx
1080
+ jsx: jsx2
1055
1081
  },
1056
1082
  ...isTypeAware ? { project: tsconfigPath } : {}
1057
1083
  }
@@ -1181,6 +1207,7 @@ async function sortPackageJson() {
1181
1207
  "private",
1182
1208
  "packageManager",
1183
1209
  "description",
1210
+ "contributors",
1184
1211
  "author",
1185
1212
  "license",
1186
1213
  "funding",
@@ -1423,6 +1450,7 @@ async function test(options = {}) {
1423
1450
  "test/no-only-tests": isInEditor ? "off" : "error",
1424
1451
  "test/prefer-hooks-in-order": "error",
1425
1452
  "test/prefer-lowercase-title": "error",
1453
+ "ts/explicit-function-return-type": "off",
1426
1454
  ...overrides
1427
1455
  }
1428
1456
  }
@@ -1435,19 +1463,19 @@ async function typescript(options = {}) {
1435
1463
  const {
1436
1464
  componentExts = [],
1437
1465
  overrides = {},
1438
- parserOptions = {}
1466
+ parserOptions = {},
1467
+ type = "app"
1439
1468
  } = options;
1440
1469
  const files = options.files ?? [
1441
1470
  GLOB_SRC,
1442
1471
  ...componentExts.map((ext) => `**/*.${ext}`)
1443
1472
  ];
1444
1473
  const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
1445
- const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
1474
+ const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
1446
1475
  const isTypeAware = !!tsconfigPath;
1447
1476
  const typeAwareRules = {
1448
1477
  "dot-notation": "off",
1449
1478
  "no-implied-eval": "off",
1450
- "no-throw-literal": "off",
1451
1479
  "ts/await-thenable": "error",
1452
1480
  "ts/dot-notation": ["error", { allowKeywords: true }],
1453
1481
  "ts/no-floating-promises": "error",
@@ -1460,9 +1488,12 @@ async function typescript(options = {}) {
1460
1488
  "ts/no-unsafe-call": "error",
1461
1489
  "ts/no-unsafe-member-access": "error",
1462
1490
  "ts/no-unsafe-return": "error",
1491
+ "ts/promise-function-async": "error",
1463
1492
  "ts/restrict-plus-operands": "error",
1464
1493
  "ts/restrict-template-expressions": "error",
1465
- "ts/strict-boolean-expressions": "error",
1494
+ "ts/return-await": ["error", "in-try-catch"],
1495
+ "ts/strict-boolean-expressions": ["error", { allowNullableBoolean: true, allowNullableObject: true }],
1496
+ "ts/switch-exhaustiveness-check": "error",
1466
1497
  "ts/unbound-method": "error"
1467
1498
  };
1468
1499
  const [
@@ -1482,7 +1513,10 @@ async function typescript(options = {}) {
1482
1513
  extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1483
1514
  sourceType: "module",
1484
1515
  ...typeAware ? {
1485
- project: tsconfigPath,
1516
+ projectService: {
1517
+ allowDefaultProject: ["./*.js"],
1518
+ defaultProject: tsconfigPath
1519
+ },
1486
1520
  tsconfigRootDir: import_node_process2.default.cwd()
1487
1521
  } : {},
1488
1522
  ...parserOptions
@@ -1525,12 +1559,15 @@ async function typescript(options = {}) {
1525
1559
  "no-use-before-define": "off",
1526
1560
  "no-useless-constructor": "off",
1527
1561
  "ts/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
1528
- "ts/ban-types": ["error", { types: { Function: false } }],
1529
1562
  "ts/consistent-type-definitions": ["error", "interface"],
1530
- "ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, prefer: "type-imports" }],
1563
+ "ts/consistent-type-imports": ["error", {
1564
+ disallowTypeAnnotations: false,
1565
+ prefer: "type-imports"
1566
+ }],
1531
1567
  "ts/method-signature-style": ["error", "property"],
1532
1568
  "ts/no-dupe-class-members": "error",
1533
1569
  "ts/no-dynamic-delete": "off",
1570
+ "ts/no-empty-object-type": ["error", { allowInterfaces: "always" }],
1534
1571
  "ts/no-explicit-any": "off",
1535
1572
  "ts/no-extraneous-class": "off",
1536
1573
  "ts/no-import-type-side-effects": "error",
@@ -1542,9 +1579,16 @@ async function typescript(options = {}) {
1542
1579
  "ts/no-unused-vars": "off",
1543
1580
  "ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
1544
1581
  "ts/no-useless-constructor": "off",
1545
- "ts/prefer-ts-expect-error": "error",
1582
+ "ts/no-wrapper-object-types": "error",
1546
1583
  "ts/triple-slash-reference": "off",
1547
1584
  "ts/unified-signatures": "off",
1585
+ ...type === "lib" ? {
1586
+ "ts/explicit-function-return-type": ["error", {
1587
+ allowExpressions: true,
1588
+ allowHigherOrderFunctions: true,
1589
+ allowIIFEs: true
1590
+ }]
1591
+ } : {},
1548
1592
  ...overrides
1549
1593
  }
1550
1594
  },
@@ -1552,12 +1596,12 @@ async function typescript(options = {}) {
1552
1596
  files: filesTypeAware,
1553
1597
  name: "eslint:typescript:rules-type-aware",
1554
1598
  rules: {
1555
- ...tsconfigPath ? typeAwareRules : {},
1599
+ ...typeAwareRules,
1556
1600
  ...overrides
1557
1601
  }
1558
1602
  }] : [],
1559
1603
  {
1560
- files: ["**/*.d.ts"],
1604
+ files: ["**/*.d.?([cm])ts"],
1561
1605
  name: "eslint:typescript:disables:dts",
1562
1606
  rules: {
1563
1607
  "eslint-comments/no-unlimited-disable": "off",
@@ -1990,7 +2034,8 @@ function lincy(options = {}, ...userConfigs) {
1990
2034
  autoRenamePlugins = true,
1991
2035
  componentExts = [],
1992
2036
  gitignore: enableGitignore = true,
1993
- isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.JETBRAINS_IDE || import_node_process3.default.env.VIM) && !import_node_process3.default.env.CI),
2037
+ isInEditor = isInEditorEnv(),
2038
+ jsx: enableJsx = true,
1994
2039
  overrides = {},
1995
2040
  react: enableReact = ReactPackages.some((i) => (0, import_local_pkg4.isPackageExists)(i)),
1996
2041
  regexp: enableRegexp = true,
@@ -2002,7 +2047,7 @@ function lincy(options = {}, ...userConfigs) {
2002
2047
  const tsconfigPath = typeof enableTypeScript !== "boolean" && "tsconfigPath" in enableTypeScript ? enableTypeScript.tsconfigPath : void 0;
2003
2048
  if (stylisticOptions) {
2004
2049
  if (!("jsx" in stylisticOptions)) {
2005
- stylisticOptions.jsx = options.jsx ?? true;
2050
+ stylisticOptions.jsx = enableJsx;
2006
2051
  }
2007
2052
  }
2008
2053
  const configs2 = [];
@@ -2010,9 +2055,7 @@ function lincy(options = {}, ...userConfigs) {
2010
2055
  if (typeof enableGitignore !== "boolean") {
2011
2056
  configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
2012
2057
  } else {
2013
- if (import_node_fs.default.existsSync(".gitignore")) {
2014
- configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
2015
- }
2058
+ configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({ strict: false })]));
2016
2059
  }
2017
2060
  }
2018
2061
  configs2.push(
@@ -2043,9 +2086,13 @@ function lincy(options = {}, ...userConfigs) {
2043
2086
  ...typeof enableTypeScript !== "boolean" ? enableTypeScript : {},
2044
2087
  componentExts,
2045
2088
  overrides: overrides.typescript,
2046
- tsconfigPath
2089
+ tsconfigPath,
2090
+ type: options.type
2047
2091
  }));
2048
2092
  }
2093
+ if (enableJsx) {
2094
+ configs2.push(jsx());
2095
+ }
2049
2096
  if (stylisticOptions) {
2050
2097
  configs2.push(stylistic({
2051
2098
  overrides: overrides.stylistic,
@@ -2182,9 +2229,11 @@ var src_default = lincy;
2182
2229
  ignores,
2183
2230
  imports,
2184
2231
  interopDefault,
2232
+ isInEditorEnv,
2185
2233
  javascript,
2186
2234
  jsdoc,
2187
2235
  jsonc,
2236
+ jsx,
2188
2237
  lincy,
2189
2238
  markdown,
2190
2239
  node,