@luxass/eslint-config 4.8.3 → 4.10.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
@@ -105,6 +105,7 @@ var GLOB_YAML = "**/*.y?(a)ml";
105
105
  var GLOB_TOML = "**/*.toml";
106
106
  var GLOB_HTML = "**/*.htm?(l)";
107
107
  var GLOB_ASTRO = "**/*.astro";
108
+ var GLOB_ASTRO_TS = "**/*.astro/*.ts";
108
109
  var GLOB_GRAPHQL = "**/*.{g,graph}ql";
109
110
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
110
111
  var GLOB_TESTS = [
@@ -222,6 +223,7 @@ function sortPackageJson() {
222
223
  "type",
223
224
  "private",
224
225
  "author",
226
+ "contributors",
225
227
  "publisher",
226
228
  "packageManager",
227
229
  "license",
@@ -409,6 +411,7 @@ function sortTsconfig() {
409
411
  "allowSyntheticDefaultImports",
410
412
  "esModuleInterop",
411
413
  "forceConsistentCasingInFileNames",
414
+ "isolatedDeclarations",
412
415
  "isolatedModules",
413
416
  "preserveSymlinks",
414
417
  "verbatimModuleSyntax",
@@ -470,10 +473,13 @@ import globals from "globals";
470
473
  import pluginUnusedImports from "eslint-plugin-unused-imports";
471
474
  import pluginAntfu2 from "eslint-plugin-antfu";
472
475
  async function javascript(options = {}) {
473
- const { editor = false, overrides = {} } = options;
476
+ const {
477
+ editor = false,
478
+ overrides = {}
479
+ } = options;
474
480
  return [
475
481
  {
476
- name: "luxass/javascript",
482
+ name: "luxass/javascript/setup",
477
483
  languageOptions: {
478
484
  ecmaVersion: 2022,
479
485
  globals: {
@@ -495,7 +501,10 @@ async function javascript(options = {}) {
495
501
  },
496
502
  linterOptions: {
497
503
  reportUnusedDisableDirectives: true
498
- },
504
+ }
505
+ },
506
+ {
507
+ name: "luxass/javascript/rules",
499
508
  plugins: {
500
509
  "antfu": pluginAntfu2,
501
510
  "unused-imports": pluginUnusedImports
@@ -750,16 +759,37 @@ async function combine(...configs2) {
750
759
  const resolved = await Promise.all(configs2);
751
760
  return resolved.flat();
752
761
  }
753
- function renameRules(rules, from, to) {
762
+ function renameRules(rules, map) {
754
763
  return Object.fromEntries(
755
764
  Object.entries(rules).map(([key, value]) => {
756
- if (key.startsWith(from)) {
757
- return [to + key.slice(from.length), value];
765
+ for (const [from, to] of Object.entries(map)) {
766
+ if (key.startsWith(`${from}/`)) {
767
+ return [to + key.slice(from.length), value];
768
+ }
758
769
  }
759
770
  return [key, value];
760
771
  })
761
772
  );
762
773
  }
774
+ function renamePluginInConfigs(configs2, map) {
775
+ return configs2.map((i) => {
776
+ const clone = { ...i };
777
+ if (clone.rules) {
778
+ clone.rules = renameRules(clone.rules, map);
779
+ }
780
+ if (clone.plugins) {
781
+ clone.plugins = Object.fromEntries(
782
+ Object.entries(clone.plugins).map(([key, value]) => {
783
+ if (key in map) {
784
+ return [map[key], value];
785
+ }
786
+ return [key, value];
787
+ })
788
+ );
789
+ }
790
+ return clone;
791
+ });
792
+ }
763
793
  function toArray(value) {
764
794
  return Array.isArray(value) ? value : [value];
765
795
  }
@@ -802,7 +832,7 @@ async function jsdoc(options = {}) {
802
832
  } = options;
803
833
  return [
804
834
  {
805
- name: "luxass/jsdoc",
835
+ name: "luxass/jsdoc/rules",
806
836
  plugins: {
807
837
  jsdoc: await interop(import("eslint-plugin-jsdoc"))
808
838
  },
@@ -968,36 +998,24 @@ async function markdown(options = {}) {
968
998
  "import/newline-after-import": "off",
969
999
  "no-alert": "off",
970
1000
  "no-console": "off",
1001
+ "no-labels": "off",
1002
+ "no-lone-blocks": "off",
1003
+ "no-restricted-syntax": "off",
971
1004
  "no-undef": "off",
972
1005
  "no-unused-expressions": "off",
1006
+ "no-unused-labels": "off",
973
1007
  "no-unused-vars": "off",
974
1008
  "node/prefer-global/process": "off",
975
1009
  "style/comma-dangle": "off",
976
1010
  "style/eol-last": "off",
977
- // Type aware rules
978
- "ts/await-thenable": "off",
979
1011
  "ts/consistent-type-imports": "off",
980
- "ts/dot-notation": "off",
981
- "ts/no-floating-promises": "off",
982
- "ts/no-for-in-array": "off",
983
- "ts/no-implied-eval": "off",
984
- "ts/no-misused-promises": "off",
985
1012
  "ts/no-namespace": "off",
986
1013
  "ts/no-redeclare": "off",
987
1014
  "ts/no-require-imports": "off",
988
- "ts/no-throw-literal": "off",
989
- "ts/no-unnecessary-type-assertion": "off",
990
- "ts/no-unsafe-argument": "off",
991
- "ts/no-unsafe-assignment": "off",
992
- "ts/no-unsafe-call": "off",
993
- "ts/no-unsafe-member-access": "off",
994
- "ts/no-unsafe-return": "off",
1015
+ "ts/no-unused-expressions": "off",
995
1016
  "ts/no-unused-vars": "off",
996
1017
  "ts/no-use-before-define": "off",
997
1018
  "ts/no-var-requires": "off",
998
- "ts/restrict-plus-operands": "off",
999
- "ts/restrict-template-expressions": "off",
1000
- "ts/unbound-method": "off",
1001
1019
  "unicode-bom": "off",
1002
1020
  "unused-imports/no-unused-imports": "off",
1003
1021
  "unused-imports/no-unused-vars": "off",
@@ -1063,34 +1081,42 @@ async function typescript(options = {}) {
1063
1081
  const {
1064
1082
  exts = [],
1065
1083
  overrides = {},
1066
- parserOptions = {}
1084
+ parserOptions = {},
1085
+ type = "app"
1067
1086
  } = options ?? {};
1068
1087
  const files = options.files ?? [
1069
- GLOB_SRC,
1088
+ GLOB_TS,
1089
+ GLOB_TSX,
1070
1090
  ...exts.map((ext) => `**/*.${ext}`)
1071
1091
  ];
1072
- const filesTypeAware = options.typeAwareFileS ?? [GLOB_TS, GLOB_TSX];
1073
- const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
1092
+ const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
1093
+ const ignoresTypeAware = options.ignoresTypeAware ?? [
1094
+ `${GLOB_MARKDOWN}/**`,
1095
+ GLOB_ASTRO_TS
1096
+ ];
1097
+ const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
1074
1098
  const isTypeAware = !!tsconfigPath;
1075
1099
  const typeAwareRules = {
1076
1100
  "dot-notation": "off",
1077
1101
  "no-implied-eval": "off",
1078
- "no-throw-literal": "off",
1079
1102
  "ts/await-thenable": "error",
1080
1103
  "ts/dot-notation": ["error", { allowKeywords: true }],
1081
1104
  "ts/no-floating-promises": "error",
1082
1105
  "ts/no-for-in-array": "error",
1083
1106
  "ts/no-implied-eval": "error",
1084
1107
  "ts/no-misused-promises": "error",
1085
- "ts/no-throw-literal": "error",
1086
1108
  "ts/no-unnecessary-type-assertion": "error",
1087
1109
  "ts/no-unsafe-argument": "error",
1088
1110
  "ts/no-unsafe-assignment": "error",
1089
1111
  "ts/no-unsafe-call": "error",
1090
1112
  "ts/no-unsafe-member-access": "error",
1091
1113
  "ts/no-unsafe-return": "error",
1114
+ "ts/promise-function-async": "error",
1092
1115
  "ts/restrict-plus-operands": "error",
1093
1116
  "ts/restrict-template-expressions": "error",
1117
+ "ts/return-await": ["error", "in-try-catch"],
1118
+ "ts/strict-boolean-expressions": ["error", { allowNullableBoolean: true, allowNullableObject: true }],
1119
+ "ts/switch-exhaustiveness-check": "error",
1094
1120
  "ts/unbound-method": "error"
1095
1121
  };
1096
1122
  const [
@@ -1111,7 +1137,10 @@ async function typescript(options = {}) {
1111
1137
  extraFileExtensions: exts.map((ext) => `.${ext}`),
1112
1138
  sourceType: "module",
1113
1139
  ...typeAware ? {
1114
- project: tsconfigPath,
1140
+ projectService: {
1141
+ allowDefaultProject: ["./*.js"],
1142
+ defaultProject: tsconfigPath
1143
+ },
1115
1144
  tsconfigRootDir: process2.cwd()
1116
1145
  } : {},
1117
1146
  ...parserOptions
@@ -1129,7 +1158,7 @@ async function typescript(options = {}) {
1129
1158
  }
1130
1159
  },
1131
1160
  ...isTypeAware ? [
1132
- makeParser(true, filesTypeAware),
1161
+ makeParser(true, filesTypeAware, ignoresTypeAware),
1133
1162
  makeParser(false, files, filesTypeAware)
1134
1163
  ] : [makeParser(false, files)],
1135
1164
  {
@@ -1138,58 +1167,29 @@ async function typescript(options = {}) {
1138
1167
  rules: {
1139
1168
  ...renameRules(
1140
1169
  pluginTs.configs["eslint-recommended"].overrides[0].rules,
1141
- "@typescript-eslint/",
1142
- "ts/"
1170
+ {
1171
+ "@typescript-eslint": "ts"
1172
+ }
1143
1173
  ),
1144
1174
  ...renameRules(
1145
1175
  pluginTs.configs.strict.rules,
1146
- "@typescript-eslint/",
1147
- "ts/"
1176
+ {
1177
+ "@typescript-eslint": "ts"
1178
+ }
1148
1179
  ),
1149
1180
  "no-dupe-class-members": "off",
1150
1181
  "no-invalid-this": "off",
1151
- "no-loss-of-precision": "off",
1182
+ "no-loss-of-precision": "error",
1152
1183
  "no-redeclare": "off",
1153
1184
  "no-use-before-define": "off",
1154
1185
  "no-useless-constructor": "off",
1155
1186
  "ts/ban-ts-comment": [
1156
1187
  "error",
1157
- { "ts-ignore": "allow-with-description" }
1158
- ],
1159
- "ts/ban-types": ["error", {
1160
- extendDefaults: false,
1161
- types: {
1162
- BigInt: {
1163
- fixWith: "bigint",
1164
- message: "Use `bigint` instead."
1165
- },
1166
- Boolean: {
1167
- fixWith: "boolean",
1168
- message: "Use `boolean` instead."
1169
- },
1170
- Function: "Use a specific function type instead, like `() => void`.",
1171
- Number: {
1172
- fixWith: "number",
1173
- message: "Use `number` instead."
1174
- },
1175
- Object: {
1176
- fixWith: "Record<string, unknown>",
1177
- message: "The `Object` type is mostly the same as `unknown`. You probably want `Record<string, unknown>` instead. See https://github.com/typescript-eslint/typescript-eslint/pull/848"
1178
- },
1179
- String: {
1180
- fixWith: "string",
1181
- message: "Use `string` instead."
1182
- },
1183
- Symbol: {
1184
- fixWith: "symbol",
1185
- message: "Use `symbol` instead."
1186
- },
1187
- object: {
1188
- fixWith: "Record<string, unknown>",
1189
- message: "The `object` type is hard to use. Use `Record<string, unknown>` instead. See: https://github.com/typescript-eslint/typescript-eslint/pull/848"
1190
- }
1188
+ {
1189
+ "ts-ignore": "allow-with-description",
1190
+ "ts-expect-error": "allow-with-description"
1191
1191
  }
1192
- }],
1192
+ ],
1193
1193
  "ts/consistent-type-definitions": ["error", "interface"],
1194
1194
  "ts/consistent-type-imports": [
1195
1195
  "error",
@@ -1199,12 +1199,12 @@ async function typescript(options = {}) {
1199
1199
  // https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful
1200
1200
  "ts/no-dupe-class-members": "error",
1201
1201
  "ts/no-dynamic-delete": "off",
1202
+ "ts/no-empty-object-type": "error",
1202
1203
  "ts/no-explicit-any": "off",
1203
1204
  "ts/no-extraneous-class": "off",
1204
1205
  "ts/no-import-type-side-effects": "error",
1205
1206
  "ts/no-invalid-this": "error",
1206
1207
  "ts/no-invalid-void-type": "off",
1207
- "ts/no-loss-of-precision": "error",
1208
1208
  "ts/no-non-null-assertion": "off",
1209
1209
  "ts/no-redeclare": "error",
1210
1210
  "ts/no-require-imports": "error",
@@ -1214,23 +1214,28 @@ async function typescript(options = {}) {
1214
1214
  { classes: false, functions: false, variables: true }
1215
1215
  ],
1216
1216
  "ts/no-useless-constructor": "off",
1217
- "ts/prefer-ts-expect-error": "error",
1217
+ "ts/no-wrapper-object-types": "error",
1218
1218
  "ts/triple-slash-reference": "off",
1219
1219
  "ts/unified-signatures": "off",
1220
+ ...type === "lib" ? {
1221
+ "ts/explicit-function-return-type": ["error", {
1222
+ allowExpressions: true,
1223
+ allowHigherOrderFunctions: true,
1224
+ allowIIFEs: true
1225
+ }]
1226
+ } : {},
1220
1227
  ...overrides
1221
1228
  }
1222
1229
  },
1223
- {
1224
- name: "luxass/typescript/rules-type-aware",
1230
+ ...isTypeAware ? [{
1225
1231
  files: filesTypeAware,
1226
- rules: {
1227
- ...tsconfigPath ? typeAwareRules : {},
1228
- ...overrides
1229
- }
1230
- },
1232
+ ignores: ignoresTypeAware,
1233
+ name: "luxass/typescript/rules-type-aware",
1234
+ rules: typeAwareRules
1235
+ }] : [],
1231
1236
  {
1232
1237
  name: "luxass/typescript/disables/dts",
1233
- files: ["**/*.d.ts"],
1238
+ files: ["**/*.d.?([cm])ts"],
1234
1239
  rules: {
1235
1240
  "eslint-comments/no-unlimited-disable": "off",
1236
1241
  "import/no-duplicates": "off",
@@ -1239,21 +1244,14 @@ async function typescript(options = {}) {
1239
1244
  }
1240
1245
  },
1241
1246
  {
1242
- name: "luxass/typescript/disables/tests",
1243
1247
  files: ["**/*.{test,spec}.ts?(x)"],
1248
+ name: "luxass/typescript/disables/test",
1244
1249
  rules: {
1245
1250
  "no-unused-expressions": "off"
1246
1251
  }
1247
1252
  },
1248
1253
  {
1249
- name: "luxass/typescript/disables/playground",
1250
- files: [`**/playground.${GLOB_SRC_EXT}`],
1251
- rules: {
1252
- "no-console": "off"
1253
- }
1254
- },
1255
- {
1256
- name: "luxass/typescript/disables/javascript",
1254
+ name: "luxass/typescript/disables/cjs",
1257
1255
  files: ["**/*.js", "**/*.cjs"],
1258
1256
  rules: {
1259
1257
  "ts/no-require-imports": "off",
@@ -1556,6 +1554,7 @@ async function test(options = {}) {
1556
1554
  "test/no-focused-tests": editor ? "off" : "error",
1557
1555
  "test/prefer-hooks-in-order": "error",
1558
1556
  "test/prefer-lowercase-title": "error",
1557
+ "ts/explicit-function-return-type": "off",
1559
1558
  ...overrides
1560
1559
  }
1561
1560
  }
@@ -2210,7 +2209,8 @@ function luxass(options = {}, ...userConfigs) {
2210
2209
  typescript: enableTypeScript = isPackageExists4("typescript"),
2211
2210
  unocss: enableUnoCSS = false,
2212
2211
  tailwindcss: enableTailwindCSS = false,
2213
- vue: enableVue = VuePackages.some((i) => isPackageExists4(i))
2212
+ vue: enableVue = VuePackages.some((i) => isPackageExists4(i)),
2213
+ type: projectType = "app"
2214
2214
  } = options;
2215
2215
  const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
2216
2216
  if (stylisticOptions && !("jsx" in stylisticOptions)) {
@@ -2254,7 +2254,8 @@ function luxass(options = {}, ...userConfigs) {
2254
2254
  configs2.push(typescript({
2255
2255
  ...typescriptOptions,
2256
2256
  exts,
2257
- overrides: getOverrides(options, "typescript")
2257
+ overrides: getOverrides(options, "typescript"),
2258
+ type: projectType
2258
2259
  }));
2259
2260
  }
2260
2261
  if (stylisticOptions) {
@@ -2372,6 +2373,7 @@ function luxass(options = {}, ...userConfigs) {
2372
2373
  var src_default = luxass;
2373
2374
  export {
2374
2375
  GLOB_ASTRO,
2376
+ GLOB_ASTRO_TS,
2375
2377
  GLOB_CSS,
2376
2378
  GLOB_EXCLUDE,
2377
2379
  GLOB_GRAPHQL,
@@ -2419,6 +2421,7 @@ export {
2419
2421
  parserPlain,
2420
2422
  react,
2421
2423
  regexp,
2424
+ renamePluginInConfigs,
2422
2425
  renameRules,
2423
2426
  resolveSubOptions,
2424
2427
  sortPackageJson,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luxass/eslint-config",
3
- "version": "4.8.3",
3
+ "version": "4.10.0",
4
4
  "description": "ESLint config for @luxass",
5
5
  "type": "module",
6
6
  "author": {
@@ -8,7 +8,7 @@
8
8
  "email": "lucasnrgaard@gmail.com",
9
9
  "url": "https://luxass.dev"
10
10
  },
11
- "packageManager": "pnpm@9.5.0",
11
+ "packageManager": "pnpm@9.6.0",
12
12
  "license": "MIT",
13
13
  "repository": {
14
14
  "type": "git",
@@ -39,7 +39,7 @@
39
39
  "scripts": {
40
40
  "build": "pnpm typegen && tsup --format esm,cjs --clean --dts",
41
41
  "stub": "tsup --format esm",
42
- "dev": "pnpm eslint-config-inspector --config eslint.config.ts",
42
+ "dev": "pnpm eslint-config-inspector --config eslint.config.mjs",
43
43
  "build:inspector": "pnpm build && pnpm eslint-config-inspector build",
44
44
  "test": "vitest --run",
45
45
  "typegen": "pnpx tsx ./scripts/typegen.ts",
@@ -92,22 +92,22 @@
92
92
  "@antfu/install-pkg": "^0.3.3",
93
93
  "@clack/prompts": "^0.7.0",
94
94
  "@eslint-community/eslint-plugin-eslint-comments": "^4.3.0",
95
- "@stylistic/eslint-plugin": "^2.3.0",
96
- "@typescript-eslint/eslint-plugin": "^7.15.0",
97
- "@typescript-eslint/parser": "^7.15.0",
98
- "eslint-config-flat-gitignore": "^0.1.6",
99
- "eslint-flat-config-utils": "^0.2.5",
95
+ "@stylistic/eslint-plugin": "^2.6.0-beta.1",
96
+ "@typescript-eslint/eslint-plugin": "8.0.0-alpha.54",
97
+ "@typescript-eslint/parser": "8.0.0-alpha.54",
98
+ "eslint-config-flat-gitignore": "^0.1.8",
99
+ "eslint-flat-config-utils": "^0.3.0",
100
100
  "eslint-merge-processors": "^0.1.0",
101
101
  "eslint-plugin-antfu": "^2.3.4",
102
- "eslint-plugin-import-x": "^0.5.3",
103
- "eslint-plugin-jsdoc": "^48.5.2",
102
+ "eslint-plugin-import-x": "^3.1.0",
103
+ "eslint-plugin-jsdoc": "^48.8.3",
104
104
  "eslint-plugin-jsonc": "^2.16.0",
105
- "eslint-plugin-markdown": "^5.0.0",
106
- "eslint-plugin-n": "^17.9.0",
105
+ "eslint-plugin-markdown": "^5.1.0",
106
+ "eslint-plugin-n": "^17.10.1",
107
107
  "eslint-plugin-regexp": "^2.6.0",
108
108
  "eslint-plugin-toml": "^0.11.1",
109
- "eslint-plugin-unicorn": "^54.0.0",
110
- "eslint-plugin-unused-imports": "^4.0.0",
109
+ "eslint-plugin-unicorn": "^55.0.0",
110
+ "eslint-plugin-unused-imports": "^4.0.1",
111
111
  "eslint-plugin-vitest": "^0.5.4",
112
112
  "eslint-plugin-vue": "^9.27.0",
113
113
  "eslint-plugin-yml": "^1.14.0",
@@ -121,37 +121,29 @@
121
121
  "yaml-eslint-parser": "^1.2.3"
122
122
  },
123
123
  "devDependencies": {
124
- "@eslint-react/eslint-plugin": "^1.5.23",
125
- "@eslint/config-inspector": "^0.5.1",
126
- "@stylistic/eslint-plugin-migrate": "^2.3.0",
127
- "@types/eslint": "^8.56.10",
124
+ "@eslint-react/eslint-plugin": "^1.6.0",
125
+ "@eslint/config-inspector": "^0.5.2",
126
+ "@stylistic/eslint-plugin-migrate": "^2.4.0",
127
+ "@types/eslint": "^9.6.0",
128
128
  "@types/estree": "^1.0.5",
129
- "@types/node": "^20.14.9",
130
- "@typescript-eslint/rule-tester": "^7.15.0",
131
- "@unocss/eslint-plugin": "^0.61.3",
129
+ "@types/node": "^20.14.12",
130
+ "@typescript-eslint/rule-tester": "^7.17.0",
131
+ "@unocss/eslint-plugin": "^0.61.6",
132
132
  "astro-eslint-parser": "^1.0.2",
133
- "eslint": "^9.6.0",
134
- "eslint-plugin-astro": "^1.2.2",
133
+ "eslint": "^9.8.0",
134
+ "eslint-plugin-astro": "^1.2.3",
135
135
  "eslint-plugin-format": "^0.1.2",
136
136
  "eslint-plugin-react-hooks": "^4.6.2",
137
- "eslint-plugin-react-refresh": "^0.4.7",
137
+ "eslint-plugin-react-refresh": "^0.4.9",
138
138
  "eslint-plugin-tailwindcss": "^3.17.4",
139
- "eslint-typegen": "^0.2.4",
139
+ "eslint-typegen": "^0.3.0",
140
140
  "jiti": "^1.21.6",
141
- "lint-staged": "^15.2.7",
142
- "prettier-plugin-astro": "^0.14.0",
143
- "simple-git-hooks": "^2.11.1",
144
- "tailwindcss": "^3.4.4",
145
- "tsup": "^8.1.0",
146
- "typescript": "^5.5.3",
147
- "unocss": "^0.61.3",
148
- "vitest": "^1.6.0",
149
- "vue": "^3.4.31"
150
- },
151
- "simple-git-hooks": {
152
- "pre-commit": "pnpm lint-staged"
153
- },
154
- "lint-staged": {
155
- "*": "eslint --fix"
141
+ "prettier-plugin-astro": "^0.14.1",
142
+ "tailwindcss": "^3.4.7",
143
+ "tsup": "^8.2.3",
144
+ "typescript": "^5.5.4",
145
+ "unocss": "^0.61.6",
146
+ "vitest": "^2.0.4",
147
+ "vue": "^3.4.34"
156
148
  }
157
149
  }