katon-labs-eslint-config 0.0.5-alpha.1 → 0.0.5-alpha.3

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
@@ -28,8 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
30
  // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
33
  GLOB_ALL_SRC: () => GLOB_ALL_SRC,
34
34
  GLOB_ASTRO: () => GLOB_ASTRO,
35
35
  GLOB_ASTRO_TS: () => GLOB_ASTRO_TS,
@@ -61,7 +61,7 @@ __export(src_exports, {
61
61
  GLOB_XML: () => GLOB_XML,
62
62
  GLOB_YAML: () => GLOB_YAML,
63
63
  StylisticConfigDefaults: () => StylisticConfigDefaults,
64
- default: () => src_default,
64
+ default: () => index_default,
65
65
  ignores: () => ignores,
66
66
  imports: () => imports,
67
67
  katonlabs: () => katonlabs,
@@ -72,7 +72,7 @@ __export(src_exports, {
72
72
  unicorn: () => unicorn,
73
73
  vue: () => vue
74
74
  });
75
- module.exports = __toCommonJS(src_exports);
75
+ module.exports = __toCommonJS(index_exports);
76
76
 
77
77
  // src/factory.ts
78
78
  var import_eslint_flat_config_utils = require("eslint-flat-config-utils");
@@ -163,6 +163,13 @@ var GLOB_EXCLUDE = [
163
163
  ];
164
164
 
165
165
  // src/configs/typescript.ts
166
+ var getRulesFromConfigs = (config) => {
167
+ const array = Array.isArray(config) ? config : [config];
168
+ const object = array.reduce((acc, item) => {
169
+ return { ...acc, ...item.rules };
170
+ }, {});
171
+ return object;
172
+ };
166
173
  function typescript(options) {
167
174
  const files = [GLOB_TS, GLOB_TSX, GLOB_VUE];
168
175
  const fileTypeAware = options?.fileTypeAware ?? [GLOB_TS, GLOB_TSX, GLOB_VUE];
@@ -226,12 +233,67 @@ function typescript(options) {
226
233
  files,
227
234
  name: "katon-labs/typescript/rules",
228
235
  rules: {
236
+ ...getRulesFromConfigs(import_eslint_plugin.default.configs["flat/recommended"]),
237
+ // Type-aware rules
238
+ ...tsconfigPath ? getRulesFromConfigs(import_eslint_plugin.default.configs["flat/recommended-type-checked-only"]) : {},
239
+ ...getRulesFromConfigs(import_eslint_plugin.default.configs["flat/strict"]),
229
240
  ...import_eslint_plugin.default.configs["eslint-recommended"].overrides[0].rules,
230
241
  ...import_eslint_plugin.default.configs.strict.rules,
242
+ // Include typescript eslint rules in *.vue files
243
+ // https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslint-recommended.ts
244
+ "constructor-super": "off",
245
+ // ts(2335) & ts(2377)
246
+ "getter-return": "off",
247
+ // ts(2378)
248
+ "no-const-assign": "off",
249
+ // ts(2588)
250
+ "no-dupe-args": "off",
251
+ // ts(2300)
231
252
  "no-dupe-class-members": "off",
253
+ // ts(2393) & ts(2300)
254
+ "no-dupe-keys": "off",
255
+ // ts(1117)
256
+ "no-func-assign": "off",
257
+ // ts(2539)
258
+ "no-import-assign": "off",
259
+ // ts(2539) & ts(2540)
260
+ "no-new-symbol": "off",
261
+ // ts(7009)
262
+ "no-obj-calls": "off",
263
+ // ts(2349)
232
264
  "no-redeclare": "off",
233
- "no-use-before-define": "off",
234
- "no-useless-constructor": "off",
265
+ // ts(2451)
266
+ "no-setter-return": "off",
267
+ // ts(2408)
268
+ "no-this-before-super": "off",
269
+ // ts(2376)
270
+ "no-undef": "off",
271
+ // ts(2304)
272
+ "no-unreachable": "off",
273
+ // ts(7027)
274
+ "no-unsafe-negation": "off",
275
+ // ts(2365) & ts(2360) & ts(2358)
276
+ "no-var": "error",
277
+ // ts transpiles let/const to var, so no need for vars any more
278
+ "prefer-const": "error",
279
+ // ts provides better types with const
280
+ "prefer-rest-params": "error",
281
+ // ts provides better types with rest args over arguments
282
+ "prefer-spread": "error",
283
+ // ts transpiles spread to apply, so no need for manual apply
284
+ "valid-typeof": "off",
285
+ // ts(2367)
286
+ "no-unused-vars": "off",
287
+ // ts takes care of this
288
+ "@typescript-eslint/no-non-null-assertion": "off",
289
+ "@typescript-eslint/no-unused-vars": ["error", {
290
+ args: "after-used",
291
+ argsIgnorePattern: "^_",
292
+ ignoreRestSiblings: true,
293
+ vars: "all",
294
+ varsIgnorePattern: "^_"
295
+ }],
296
+ "@typescript-eslint/no-import-type-side-effects": "error",
235
297
  "@typescript-eslint/ban-ts-comment": ["error", { "ts-expect-error": "allow-with-description" }],
236
298
  "@typescript-eslint/consistent-type-definitions": ["error", "interface"],
237
299
  "@typescript-eslint/consistent-type-imports": ["error", { disallowTypeAnnotations: true, prefer: "type-imports" }],
@@ -241,14 +303,7 @@ function typescript(options) {
241
303
  "@typescript-eslint/no-explicit-any": "off",
242
304
  "@typescript-eslint/no-duplicate-type-constituents": "error"
243
305
  }
244
- },
245
- ...isTypeAware ? [{
246
- files: fileTypeAware,
247
- name: "katon-labs/typescript/typeaware-rules",
248
- rules: {
249
- ...typeAwareRules
250
- }
251
- }] : []
306
+ }
252
307
  ];
253
308
  }
254
309
 
@@ -268,6 +323,15 @@ function vue() {
268
323
  // This allows Vue plugin to work with auto imports
269
324
  // https://github.com/vuejs/eslint-plugin-vue/pull/2422
270
325
  languageOptions: {
326
+ parserOptions: {
327
+ ecmaVersion: "latest",
328
+ extraFileExtensions: [".vue"],
329
+ parser: import_parser2.default,
330
+ sourceType: "module",
331
+ ecmaFeatures: {
332
+ jsx: true
333
+ }
334
+ },
271
335
  globals: {
272
336
  computed: "readonly",
273
337
  defineEmits: "readonly",
@@ -304,9 +368,9 @@ function vue() {
304
368
  rules: {
305
369
  ...import_eslint_plugin_vue.default.configs.base.rules,
306
370
  ...import_eslint_plugin_vue.default.configs.essential.rules,
307
- ...import_eslint_plugin_vue.default.configs["vue3-recommended"].rules,
308
- ...import_eslint_plugin_vue.default.configs["vue3-strongly-recommended"].rules,
309
- ...import_eslint_plugin_vue.default.configs["vue3-essential"].rules,
371
+ ...import_eslint_plugin_vue.default.configs["flat/essential"].map((c) => c.rules).reduce((acc, c) => ({ ...acc, ...c }), {}),
372
+ ...import_eslint_plugin_vue.default.configs["flat/strongly-recommended"].map((c) => c.rules).reduce((acc, c) => ({ ...acc, ...c }), {}),
373
+ ...import_eslint_plugin_vue.default.configs["flat/recommended"].map((c) => c.rules).reduce((acc, c) => ({ ...acc, ...c }), {}),
310
374
  "vue/block-order": ["error", {
311
375
  order: ["script", "template", "style"]
312
376
  }],
@@ -550,7 +614,7 @@ function ignores() {
550
614
  function katonlabs(options = {}, ...userConfigs) {
551
615
  const { ts } = options;
552
616
  const configs = [];
553
- configs.push(typescript(ts));
617
+ configs.push(typescript(ts ? ts : void 0));
554
618
  configs.push(vue());
555
619
  configs.push(imports());
556
620
  configs.push(unicorn());
@@ -567,7 +631,7 @@ function katonlabs(options = {}, ...userConfigs) {
567
631
  }
568
632
 
569
633
  // src/index.ts
570
- var src_default = katonlabs;
634
+ var index_default = katonlabs;
571
635
  // Annotate the CommonJS export names for ESM import in node:
572
636
  0 && (module.exports = {
573
637
  GLOB_ALL_SRC,