@lincy/eslint-config 4.6.2 → 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.js CHANGED
@@ -1,6 +1,4 @@
1
1
  // src/factory.ts
2
- import process3 from "node:process";
3
- import fs from "node:fs";
4
2
  import { isPackageExists as isPackageExists3 } from "local-pkg";
5
3
  import { FlatConfigComposer } from "eslint-flat-config-utils";
6
4
 
@@ -93,6 +91,7 @@ var GLOB_EXCLUDE = [
93
91
  "**/.output",
94
92
  "**/.vite-inspect",
95
93
  "**/.yarn",
94
+ "**/vite.config.*.timestamp-*",
96
95
  "**/CHANGELOG*.md",
97
96
  "**/*.min.*",
98
97
  "**/LICENSE*",
@@ -111,7 +110,8 @@ async function ignores(options = {}) {
111
110
  ignores: [
112
111
  ...GLOB_EXCLUDE,
113
112
  ...ignores2
114
- ]
113
+ ],
114
+ name: "eslint:ignores"
115
115
  }
116
116
  ];
117
117
  }
@@ -186,6 +186,9 @@ async function javascript(options = {}) {
186
186
  linterOptions: {
187
187
  reportUnusedDisableDirectives: true
188
188
  },
189
+ name: "eslint:javascript:setup"
190
+ },
191
+ {
189
192
  name: "eslint:javascript:rules",
190
193
  plugins: {
191
194
  "antfu": default2,
@@ -443,6 +446,9 @@ async function ensurePackages(packages) {
443
446
  await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
444
447
  }
445
448
  }
449
+ function isInEditorEnv() {
450
+ return !!((process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM) && !process.env.CI);
451
+ }
446
452
 
447
453
  // src/configs/jsdoc.ts
448
454
  async function jsdoc(options = {}) {
@@ -552,6 +558,23 @@ async function jsonc(options = {}) {
552
558
  ];
553
559
  }
554
560
 
561
+ // src/configs/jsx.ts
562
+ async function jsx() {
563
+ return [
564
+ {
565
+ files: [GLOB_JSX, GLOB_TSX],
566
+ languageOptions: {
567
+ parserOptions: {
568
+ ecmaFeatures: {
569
+ jsx: true
570
+ }
571
+ }
572
+ },
573
+ name: "eslint:jsx:setup"
574
+ }
575
+ ];
576
+ }
577
+
555
578
  // src/configs/markdown.ts
556
579
  import * as parserPlain from "eslint-parser-plain";
557
580
  import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
@@ -616,6 +639,7 @@ async function markdown(options = {}) {
616
639
  "ts/no-namespace": "off",
617
640
  "ts/no-redeclare": "off",
618
641
  "ts/no-require-imports": "off",
642
+ "ts/no-unused-expressions": "off",
619
643
  "ts/no-unused-vars": "off",
620
644
  "ts/no-use-before-define": "off",
621
645
  "ts/no-var-requires": "off",
@@ -676,7 +700,7 @@ async function stylistic(options = {}) {
676
700
  } = options;
677
701
  const {
678
702
  indent,
679
- jsx,
703
+ jsx: jsx2,
680
704
  lessOpinionated,
681
705
  quotes,
682
706
  semi
@@ -685,7 +709,7 @@ async function stylistic(options = {}) {
685
709
  const config = pluginStylistic.configs.customize({
686
710
  flat: true,
687
711
  indent,
688
- jsx,
712
+ jsx: jsx2,
689
713
  pluginName: "style",
690
714
  quotes,
691
715
  semi
@@ -912,13 +936,12 @@ var ReactRefreshAllowConstantExportPackages = [
912
936
  async function react(options = {}) {
913
937
  const {
914
938
  files = [GLOB_JSX, GLOB_TSX],
915
- jsx = true,
939
+ jsx: jsx2 = true,
916
940
  overrides = {},
917
- typescript: typescript2 = true,
918
941
  version = "detect"
919
942
  } = options;
920
943
  const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
921
- const isTypeAware = !!tsconfigPath || !typescript2;
944
+ const isTypeAware = !!tsconfigPath;
922
945
  await ensurePackages([
923
946
  "@eslint-react/eslint-plugin",
924
947
  "eslint-plugin-react-hooks",
@@ -959,7 +982,7 @@ async function react(options = {}) {
959
982
  parser: parserTs,
960
983
  parserOptions: {
961
984
  ecmaFeatures: {
962
- jsx
985
+ jsx: jsx2
963
986
  },
964
987
  ...isTypeAware ? { project: tsconfigPath } : {}
965
988
  }
@@ -1089,6 +1112,7 @@ async function sortPackageJson() {
1089
1112
  "private",
1090
1113
  "packageManager",
1091
1114
  "description",
1115
+ "contributors",
1092
1116
  "author",
1093
1117
  "license",
1094
1118
  "funding",
@@ -1331,6 +1355,7 @@ async function test(options = {}) {
1331
1355
  "test/no-only-tests": isInEditor ? "off" : "error",
1332
1356
  "test/prefer-hooks-in-order": "error",
1333
1357
  "test/prefer-lowercase-title": "error",
1358
+ "ts/explicit-function-return-type": "off",
1334
1359
  ...overrides
1335
1360
  }
1336
1361
  }
@@ -1343,19 +1368,19 @@ async function typescript(options = {}) {
1343
1368
  const {
1344
1369
  componentExts = [],
1345
1370
  overrides = {},
1346
- parserOptions = {}
1371
+ parserOptions = {},
1372
+ type = "app"
1347
1373
  } = options;
1348
1374
  const files = options.files ?? [
1349
1375
  GLOB_SRC,
1350
1376
  ...componentExts.map((ext) => `**/*.${ext}`)
1351
1377
  ];
1352
1378
  const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
1353
- const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
1379
+ const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
1354
1380
  const isTypeAware = !!tsconfigPath;
1355
1381
  const typeAwareRules = {
1356
1382
  "dot-notation": "off",
1357
1383
  "no-implied-eval": "off",
1358
- "no-throw-literal": "off",
1359
1384
  "ts/await-thenable": "error",
1360
1385
  "ts/dot-notation": ["error", { allowKeywords: true }],
1361
1386
  "ts/no-floating-promises": "error",
@@ -1368,8 +1393,12 @@ async function typescript(options = {}) {
1368
1393
  "ts/no-unsafe-call": "error",
1369
1394
  "ts/no-unsafe-member-access": "error",
1370
1395
  "ts/no-unsafe-return": "error",
1396
+ "ts/promise-function-async": "error",
1371
1397
  "ts/restrict-plus-operands": "error",
1372
1398
  "ts/restrict-template-expressions": "error",
1399
+ "ts/return-await": ["error", "in-try-catch"],
1400
+ "ts/strict-boolean-expressions": ["error", { allowNullableBoolean: true, allowNullableObject: true }],
1401
+ "ts/switch-exhaustiveness-check": "error",
1373
1402
  "ts/unbound-method": "error"
1374
1403
  };
1375
1404
  const [
@@ -1389,7 +1418,10 @@ async function typescript(options = {}) {
1389
1418
  extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1390
1419
  sourceType: "module",
1391
1420
  ...typeAware ? {
1392
- project: tsconfigPath,
1421
+ projectService: {
1422
+ allowDefaultProject: ["./*.js"],
1423
+ defaultProject: tsconfigPath
1424
+ },
1393
1425
  tsconfigRootDir: process2.cwd()
1394
1426
  } : {},
1395
1427
  ...parserOptions
@@ -1432,12 +1464,15 @@ async function typescript(options = {}) {
1432
1464
  "no-use-before-define": "off",
1433
1465
  "no-useless-constructor": "off",
1434
1466
  "ts/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
1435
- "ts/ban-types": ["error", { types: { Function: false } }],
1436
1467
  "ts/consistent-type-definitions": ["error", "interface"],
1437
- "ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, prefer: "type-imports" }],
1468
+ "ts/consistent-type-imports": ["error", {
1469
+ disallowTypeAnnotations: false,
1470
+ prefer: "type-imports"
1471
+ }],
1438
1472
  "ts/method-signature-style": ["error", "property"],
1439
1473
  "ts/no-dupe-class-members": "error",
1440
1474
  "ts/no-dynamic-delete": "off",
1475
+ "ts/no-empty-object-type": ["error", { allowInterfaces: "always" }],
1441
1476
  "ts/no-explicit-any": "off",
1442
1477
  "ts/no-extraneous-class": "off",
1443
1478
  "ts/no-import-type-side-effects": "error",
@@ -1449,9 +1484,16 @@ async function typescript(options = {}) {
1449
1484
  "ts/no-unused-vars": "off",
1450
1485
  "ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
1451
1486
  "ts/no-useless-constructor": "off",
1452
- "ts/prefer-ts-expect-error": "error",
1487
+ "ts/no-wrapper-object-types": "error",
1453
1488
  "ts/triple-slash-reference": "off",
1454
1489
  "ts/unified-signatures": "off",
1490
+ ...type === "lib" ? {
1491
+ "ts/explicit-function-return-type": ["error", {
1492
+ allowExpressions: true,
1493
+ allowHigherOrderFunctions: true,
1494
+ allowIIFEs: true
1495
+ }]
1496
+ } : {},
1455
1497
  ...overrides
1456
1498
  }
1457
1499
  },
@@ -1459,12 +1501,12 @@ async function typescript(options = {}) {
1459
1501
  files: filesTypeAware,
1460
1502
  name: "eslint:typescript:rules-type-aware",
1461
1503
  rules: {
1462
- ...tsconfigPath ? typeAwareRules : {},
1504
+ ...typeAwareRules,
1463
1505
  ...overrides
1464
1506
  }
1465
1507
  }] : [],
1466
1508
  {
1467
- files: ["**/*.d.ts"],
1509
+ files: ["**/*.d.?([cm])ts"],
1468
1510
  name: "eslint:typescript:disables:dts",
1469
1511
  rules: {
1470
1512
  "eslint-comments/no-unlimited-disable": "off",
@@ -1897,7 +1939,8 @@ function lincy(options = {}, ...userConfigs) {
1897
1939
  autoRenamePlugins = true,
1898
1940
  componentExts = [],
1899
1941
  gitignore: enableGitignore = true,
1900
- isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE || process3.env.VIM) && !process3.env.CI),
1942
+ isInEditor = isInEditorEnv(),
1943
+ jsx: enableJsx = true,
1901
1944
  overrides = {},
1902
1945
  react: enableReact = ReactPackages.some((i) => isPackageExists3(i)),
1903
1946
  regexp: enableRegexp = true,
@@ -1906,9 +1949,10 @@ function lincy(options = {}, ...userConfigs) {
1906
1949
  vue: enableVue = VuePackages.some((i) => isPackageExists3(i))
1907
1950
  } = options;
1908
1951
  const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
1952
+ const tsconfigPath = typeof enableTypeScript !== "boolean" && "tsconfigPath" in enableTypeScript ? enableTypeScript.tsconfigPath : void 0;
1909
1953
  if (stylisticOptions) {
1910
1954
  if (!("jsx" in stylisticOptions)) {
1911
- stylisticOptions.jsx = options.jsx ?? true;
1955
+ stylisticOptions.jsx = enableJsx;
1912
1956
  }
1913
1957
  }
1914
1958
  const configs2 = [];
@@ -1916,9 +1960,7 @@ function lincy(options = {}, ...userConfigs) {
1916
1960
  if (typeof enableGitignore !== "boolean") {
1917
1961
  configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
1918
1962
  } else {
1919
- if (fs.existsSync(".gitignore")) {
1920
- configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
1921
- }
1963
+ configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({ strict: false })]));
1922
1964
  }
1923
1965
  }
1924
1966
  configs2.push(
@@ -1948,9 +1990,14 @@ function lincy(options = {}, ...userConfigs) {
1948
1990
  configs2.push(typescript({
1949
1991
  ...typeof enableTypeScript !== "boolean" ? enableTypeScript : {},
1950
1992
  componentExts,
1951
- overrides: overrides.typescript
1993
+ overrides: overrides.typescript,
1994
+ tsconfigPath,
1995
+ type: options.type
1952
1996
  }));
1953
1997
  }
1998
+ if (enableJsx) {
1999
+ configs2.push(jsx());
2000
+ }
1954
2001
  if (stylisticOptions) {
1955
2002
  configs2.push(stylistic({
1956
2003
  overrides: overrides.stylistic,
@@ -1980,9 +2027,9 @@ function lincy(options = {}, ...userConfigs) {
1980
2027
  }
1981
2028
  if (enableReact) {
1982
2029
  configs2.push(react({
2030
+ tsconfigPath,
1983
2031
  ...typeof enableReact !== "boolean" ? enableReact : {},
1984
- overrides: overrides.react,
1985
- typescript: !!enableTypeScript
2032
+ overrides: overrides.react
1986
2033
  }));
1987
2034
  }
1988
2035
  if (enableUnoCSS) {
@@ -2087,9 +2134,11 @@ export {
2087
2134
  ignores,
2088
2135
  imports,
2089
2136
  interopDefault,
2137
+ isInEditorEnv,
2090
2138
  javascript,
2091
2139
  jsdoc,
2092
2140
  jsonc,
2141
+ jsx,
2093
2142
  lincy,
2094
2143
  markdown,
2095
2144
  node,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lincy/eslint-config",
3
3
  "type": "module",
4
- "version": "4.6.2",
4
+ "version": "4.7.0",
5
5
  "packageManager": "pnpm@9.1.0",
6
6
  "description": "LinCenYing's ESLint config",
7
7
  "author": "LinCenYing <lincenying@gmail.com> (https://github.com/lincenying/)",
@@ -64,71 +64,71 @@
64
64
  "dependencies": {
65
65
  "@antfu/eslint-define-config": "1.23.0-2",
66
66
  "@antfu/install-pkg": "^0.3.3",
67
- "@stylistic/eslint-plugin": "2.1.0",
68
- "@typescript-eslint/eslint-plugin": "^7.11.0",
69
- "@typescript-eslint/parser": "^7.11.0",
70
- "eslint-config-flat-gitignore": "^0.1.5",
71
- "eslint-flat-config-utils": "^0.2.5",
67
+ "@stylistic/eslint-plugin": "2.6.1",
68
+ "@typescript-eslint/eslint-plugin": "8.0.0",
69
+ "@typescript-eslint/parser": "8.0.0",
70
+ "eslint-config-flat-gitignore": "^0.1.8",
71
+ "eslint-flat-config-utils": "^0.3.0",
72
72
  "eslint-merge-processors": "^0.1.0",
73
73
  "eslint-parser-plain": "^0.1.0",
74
- "eslint-plugin-antfu": "^2.3.3",
74
+ "eslint-plugin-antfu": "^2.3.4",
75
75
  "eslint-plugin-eslint-comments": "^3.2.0",
76
- "eslint-plugin-import-x": "^0.5.1",
77
- "eslint-plugin-jsdoc": "^48.2.6",
76
+ "eslint-plugin-import-x": "^3.1.0",
77
+ "eslint-plugin-jsdoc": "^48.10.2",
78
78
  "eslint-plugin-jsonc": "^2.16.0",
79
- "eslint-plugin-markdown": "^5.0.0",
80
- "eslint-plugin-n": "^17.7.0",
79
+ "eslint-plugin-markdown": "^5.1.0",
80
+ "eslint-plugin-n": "^17.10.1",
81
81
  "eslint-plugin-no-only-tests": "^3.1.0",
82
- "eslint-plugin-perfectionist": "^2.10.0",
82
+ "eslint-plugin-perfectionist": "^3.0.0",
83
83
  "eslint-plugin-regexp": "^2.6.0",
84
- "eslint-plugin-toml": "^0.11.0",
85
- "eslint-plugin-unicorn": "^53.0.0",
86
- "eslint-plugin-unused-imports": "^4.0.0",
84
+ "eslint-plugin-toml": "^0.11.1",
85
+ "eslint-plugin-unicorn": "^55.0.0",
86
+ "eslint-plugin-unused-imports": "^4.0.1",
87
87
  "eslint-plugin-vitest": "^0.5.4",
88
- "eslint-plugin-vue": "^9.26.0",
88
+ "eslint-plugin-vue": "^9.27.0",
89
89
  "eslint-plugin-yml": "^1.14.0",
90
90
  "eslint-processor-vue-blocks": "^0.1.2",
91
- "globals": "^15.3.0",
91
+ "globals": "^15.9.0",
92
92
  "jsonc-eslint-parser": "^2.4.0",
93
93
  "local-pkg": "^0.5.0",
94
94
  "prompts": "^2.4.2",
95
- "toml-eslint-parser": "^0.9.3",
96
- "vue-eslint-parser": "^9.4.2",
95
+ "toml-eslint-parser": "^0.10.0",
96
+ "vue-eslint-parser": "^9.4.3",
97
97
  "yaml-eslint-parser": "^1.2.3"
98
98
  },
99
99
  "devDependencies": {
100
- "@antfu/ni": "^0.21.12",
101
- "@eslint-react/eslint-plugin": "^1.5.13",
100
+ "@antfu/ni": "^0.22.0",
101
+ "@eslint-react/eslint-plugin": "^1.8.0",
102
102
  "@eslint-types/jsdoc": "48.2.2",
103
103
  "@eslint-types/typescript-eslint": "^7.5.0",
104
104
  "@eslint-types/unicorn": "^52.0.0",
105
- "@eslint/config-inspector": "^0.4.8",
105
+ "@eslint/config-inspector": "^0.5.2",
106
106
  "@lincy/eslint-config": "workspace:*",
107
- "@stylistic/eslint-plugin-migrate": "^2.1.0",
108
- "@types/eslint": "^8.56.10",
109
- "@types/node": "^20.12.12",
107
+ "@stylistic/eslint-plugin-migrate": "^2.6.1",
108
+ "@types/eslint": "^9.6.0",
109
+ "@types/node": "^22.0.2",
110
110
  "@types/prompts": "^2.4.9",
111
- "@unocss/eslint-plugin": "^0.60.3",
112
- "bumpp": "^9.4.1",
113
- "eslint": "npm:eslint-ts-patch@9.2.0-6",
114
- "eslint-plugin-format": "^0.1.1",
111
+ "@unocss/eslint-plugin": "^0.61.9",
112
+ "bumpp": "^9.4.2",
113
+ "eslint": "9.8.0",
114
+ "eslint-plugin-format": "^0.1.2",
115
115
  "eslint-plugin-react-hooks": "^4.6.2",
116
- "eslint-plugin-react-refresh": "^0.4.7",
117
- "eslint-ts-patch": "9.2.0-6",
118
- "eslint-typegen": "^0.2.4",
116
+ "eslint-plugin-react-refresh": "^0.4.9",
117
+ "eslint-ts-patch": "9.8.0-1",
118
+ "eslint-typegen": "^0.3.0",
119
119
  "esno": "^4.7.0",
120
- "lint-staged": "^15.2.5",
121
- "prettier": "^3.2.5",
120
+ "lint-staged": "^15.2.7",
121
+ "prettier": "^3.3.3",
122
122
  "react": "^18.3.1",
123
- "rimraf": "^5.0.7",
123
+ "rimraf": "^6.0.1",
124
124
  "simple-git-hooks": "^2.11.1",
125
125
  "simple-open-url": "^3.0.1",
126
126
  "sucrase": "^3.35.0",
127
- "tsup": "^8.0.2",
128
- "typescript": "^5.4.5",
127
+ "tsup": "^8.2.3",
128
+ "typescript": "^5.5.4",
129
129
  "unbuild": "^2.0.0",
130
- "vitest": "^1.6.0",
131
- "vue": "^3.4.27"
130
+ "vitest": "^2.0.5",
131
+ "vue": "^3.4.35"
132
132
  },
133
133
  "pnpm": {
134
134
  "peerDependencyRules": {