@unshared/eslint-config 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.cjs CHANGED
@@ -14,7 +14,7 @@ function typescript(options) {
14
14
  parserOptions: {
15
15
  ecmaVersion: "latest",
16
16
  sourceType: "module",
17
- project: toArray.toArray(options.tsConfigPaths ?? "./tsconfig.json"),
17
+ project: toArray.toArray(options.tsConfigPath ?? "./tsconfig.json"),
18
18
  tsconfigRootDir: node_process.cwd()
19
19
  }
20
20
  },
@@ -87,7 +87,7 @@ function typescript(options) {
87
87
  "@stylistic/no-multiple-empty-lines": ["error", {
88
88
  max: 1,
89
89
  maxBOF: 0,
90
- maxEOF: 1
90
+ maxEOF: 0
91
91
  }],
92
92
  /**
93
93
  * Enforce a trailing comma after the last element or property in a multiline
@@ -158,6 +158,7 @@ function typescript(options) {
158
158
  "function-call-spacing": "off",
159
159
  "generator-star-spacing": "off",
160
160
  "template-curly-spacing": "off",
161
+ "object-property-newline ": "off",
161
162
  "newline-per-chained-call": "off",
162
163
  "computed-property-spacing": "off",
163
164
  "lines-between-class-members": "off",
@@ -179,6 +180,7 @@ function typescript(options) {
179
180
  "@stylistic/array-bracket-newline": ["error", "consistent"],
180
181
  "@stylistic/function-call-spacing": ["error", "never"],
181
182
  "@stylistic/template-curly-spacing": ["error", "never"],
183
+ "@stylistic/object-property-newline": ["error", { allowAllPropertiesOnSameLine: !0 }],
182
184
  "@stylistic/generator-star-spacing": ["error", { before: !0, after: !0 }],
183
185
  "@stylistic/computed-property-spacing": ["error", "never"],
184
186
  "@stylistic/multiline-ternary": ["error", "always-multiline"],
@@ -254,6 +256,10 @@ function typescript(options) {
254
256
  disallowTypeAnnotations: !1,
255
257
  prefer: "no-type-imports"
256
258
  }],
259
+ "perfectionist/sort-exports": ["error", {
260
+ type: "alphabetical",
261
+ "ignore-case": !1
262
+ }],
257
263
  "perfectionist/sort-named-imports": ["error", { type: "natural" }],
258
264
  "perfectionist/sort-imports": ["error", {
259
265
  "newlines-between": "never",
@@ -354,10 +360,10 @@ function typescript(options) {
354
360
  }
355
361
  ];
356
362
  }
357
- const VUE_RECOMMENDED_RULES = vuePlugin.configs?.["flat/recommended"].rules, VUE_BASE_RULES = vuePlugin.configs?.base.rules;
358
363
  function vue(options) {
359
364
  const TYPESCRIPT_CONFIG = typescript(options).at(1);
360
365
  return [
366
+ ...vuePlugin.configs?.["flat/base"],
361
367
  {
362
368
  plugins: {
363
369
  vue: vuePlugin,
@@ -396,11 +402,21 @@ function vue(options) {
396
402
  "**/*.vue"
397
403
  ],
398
404
  rules: {
399
- ...VUE_BASE_RULES,
400
- ...VUE_RECOMMENDED_RULES,
401
405
  ...TYPESCRIPT_CONFIG.rules,
402
- "@typescript-eslint/no-unsafe-assignment": "off",
406
+ // @ts-expect-error: ignore
407
+ ...vuePlugin.configs["flat/recommended"].rules,
408
+ // @ts-expect-error: ignore
409
+ ...vuePlugin.configs["flat/strongly-recommended"].rules,
410
+ // @ts-expect-error: ignore
411
+ ...vuePlugin.configs["flat/essential"].rules,
412
+ /**
413
+ * Disable some TypeScript rules that may conflict with the Vue SFC parser.
414
+ */
403
415
  "@typescript-eslint/no-unsafe-call": "off",
416
+ "@typescript-eslint/no-unsafe-return": "off",
417
+ "@typescript-eslint/no-misused-promises": "off",
418
+ "@typescript-eslint/no-unsafe-assignment": "off",
419
+ "@typescript-eslint/no-unsafe-member-access": "off",
404
420
  /**
405
421
  * Enforces consistent usage of type imports. This rule will enforce the use
406
422
  * of `type` imports to make it easier for the Vue SFC compiler to analyze
@@ -409,11 +425,11 @@ function vue(options) {
409
425
  * @see https://typescript-eslint.io/rules/consistent-type-imports
410
426
  * @see https://vuejs.github.io/vetur/guide/FAQ.html#why-does-vetur-show-cannot-find-module-xxx
411
427
  */
412
- "@typescript-eslint/consistent-type-imports": ["error", {
413
- disallowTypeAnnotations: !1,
414
- fixStyle: "inline-type-imports",
415
- prefer: "type-imports"
416
- }],
428
+ // '@typescript-eslint/consistent-type-imports': ['error', {
429
+ // disallowTypeAnnotations: false,
430
+ // fixStyle: 'inline-type-imports',
431
+ // prefer: 'type-imports',
432
+ // }],
417
433
  /**
418
434
  * Enforce the order of the top-level properties in the component. This rule
419
435
  * helps to maintain consistency and readability by enforcing a predictable
@@ -435,7 +451,9 @@ function vue(options) {
435
451
  * consistency and maintainability.
436
452
  *
437
453
  * @see https://eslint.vuejs.org/rules/vue/prefer-define-options.html
454
+ * @see https://eslint.vuejs.org/rules/vue/component-api-style.html
438
455
  */
456
+ "vue/prefer-define-options": "error",
439
457
  "vue/component-api-style": ["error", ["script-setup"]],
440
458
  /**
441
459
  * Enforce the component name casing to be PascalCase. This rules helps identify
@@ -455,6 +473,10 @@ function vue(options) {
455
473
  * @see https://eslint.vuejs.org/rules/html-comment-content-newline.html
456
474
  */
457
475
  "vue/html-comment-content-spacing": ["error", "always"],
476
+ "vue/html-comment-content-newline": ["error", {
477
+ multiline: "always",
478
+ singleline: "never"
479
+ }],
458
480
  /**
459
481
  * Enforce consistent spacing between HTML / Component tags. This makes it
460
482
  * easier to read and understand the structure of the component.
@@ -462,11 +484,17 @@ function vue(options) {
462
484
  * @see https://eslint.vuejs.org/rules/padding-line-between-blocks.html
463
485
  * @see https://eslint.vuejs.org/rules/padding-line-between-tags.html
464
486
  */
465
- "vue/html-comment-indent": ["error", 2],
487
+ "vue/padding-line-between-blocks": ["error", "always"],
466
488
  "vue/padding-line-between-tags": ["error", [
467
489
  { blankLine: "consistent", next: "*", prev: "*" },
468
490
  { blankLine: "always", next: "*", prev: "comment" }
469
491
  ]],
492
+ "vue/html-comment-indent": ["error", 2],
493
+ "vue/multiline-html-element-content-newline": ["error", {
494
+ allowEmptyLines: !0,
495
+ ignores: [],
496
+ ignoreWhenEmpty: !0
497
+ }],
470
498
  /**
471
499
  * Enforce consistent spacing and newlines in the template. This rule helps
472
500
  * to maintain consistency and readability by enforcing a predictable
@@ -496,11 +524,7 @@ function vue(options) {
496
524
  * @see https://eslint.vuejs.org/rules/multi-word-component-names.html
497
525
  */
498
526
  "vue/multi-word-component-names": "off",
499
- "vue/multiline-html-element-content-newline": ["error", {
500
- allowEmptyLines: !0,
501
- ignores: [],
502
- ignoreWhenEmpty: !0
503
- }],
527
+ "vue/no-reserved-component-names": "off",
504
528
  /**
505
529
  * Reports the destructuring or member expression of props passed to setup
506
530
  * causing the value to lose reactivity. This rule helps to avoid common
@@ -533,6 +557,7 @@ function vue(options) {
533
557
  * @see https://eslint.vuejs.org/rules/v-on-handler-style.html
534
558
  */
535
559
  "vue/v-on-style": ["error", "shorthand"],
560
+ "vue/return-in-computed-property": "off",
536
561
  "vue/no-sparse-arrays": "error",
537
562
  "vue/no-unused-emit-declarations": "error",
538
563
  "vue/no-use-v-else-with-v-for": "error",
@@ -550,8 +575,6 @@ function vue(options) {
550
575
  }
551
576
  ],
552
577
  "vue/operator-linebreak": ["error", "before"],
553
- "vue/padding-line-between-blocks": ["error", "always"],
554
- "vue/prefer-define-options": "error",
555
578
  "vue/prefer-import-from-vue": "off",
556
579
  "vue/prefer-separate-static-class": "error",
557
580
  "vue/prefer-template": "error",
@@ -591,10 +614,6 @@ function vue(options) {
591
614
  },
592
615
  singleline: "never"
593
616
  }],
594
- "vue/html-comment-content-newline": ["error", {
595
- multiline: "always",
596
- singleline: "never"
597
- }],
598
617
  "vue/no-constant-condition": "warn",
599
618
  "vue/no-empty-pattern": "error",
600
619
  "vue/no-extra-parens": ["error", "functions"],
@@ -612,12 +631,14 @@ function vue(options) {
612
631
  "vue/space-infix-ops": "error",
613
632
  "vue/space-unary-ops": ["error", { nonwords: !1, words: !0 }],
614
633
  "vue/template-curly-spacing": "error",
615
- "vue/v-on-handler-style": ["error", "inline"]
634
+ "vue/v-on-handler-style": ["error", "inline"],
635
+ /** User-defined rules */
636
+ ...options.rules
616
637
  }
617
638
  }
618
639
  ];
619
640
  }
620
- function vitest() {
641
+ function vitest(options) {
621
642
  return [
622
643
  {
623
644
  plugins: {
@@ -701,13 +722,15 @@ function vitest() {
701
722
  mustMatch: {
702
723
  test: ["^should"]
703
724
  }
704
- }]
725
+ }],
726
+ /** User-defined rules */
727
+ ...options.rules
705
728
  }
706
729
  }
707
730
  ];
708
731
  }
709
732
  const UNICORN_RECOMMENDED_RULES = unicornPlugin.configs.recommended.rules;
710
- function unicorn() {
733
+ function unicorn(options) {
711
734
  return [
712
735
  {
713
736
  plugins: {
@@ -811,11 +834,13 @@ function unicorn() {
811
834
  }
812
835
  }],
813
836
  "unicorn/throw-new-error": "error"
814
- }
837
+ },
838
+ /** User-defined rules */
839
+ ...options.rules
815
840
  }
816
841
  ];
817
842
  }
818
- function sonarjs() {
843
+ function sonarjs(options) {
819
844
  return new eslintrc.FlatCompat().config({
820
845
  extends: [
821
846
  "plugin:sonarjs/recommended"
@@ -852,11 +877,13 @@ function sonarjs() {
852
877
  "sonarjs/no-one-iteration-loop": "off",
853
878
  "sonarjs/no-redundant-jump": "off",
854
879
  "sonarjs/no-unused-collection": "off",
855
- "sonarjs/no-use-of-empty-return-value": "off"
880
+ "sonarjs/no-use-of-empty-return-value": "off",
881
+ /** User-defined rules */
882
+ ...options.rules
856
883
  }
857
884
  });
858
885
  }
859
- function node() {
886
+ function node(options) {
860
887
  return [
861
888
  {
862
889
  plugins: {
@@ -906,7 +933,9 @@ function node() {
906
933
  *
907
934
  * @see https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-node-protocol.md
908
935
  */
909
- "n/prefer-node-protocol": "error"
936
+ "n/prefer-node-protocol": "error",
937
+ /** User-defined rules */
938
+ ...options.rules
910
939
  },
911
940
  settings: {
912
941
  node: {
@@ -1118,7 +1147,7 @@ function jsonPackage() {
1118
1147
  }
1119
1148
  ];
1120
1149
  }
1121
- function configJson() {
1150
+ function configJson(options) {
1122
1151
  return [
1123
1152
  ...jsonc.configs["flat/recommended-with-json"],
1124
1153
  {
@@ -1132,12 +1161,14 @@ function configJson() {
1132
1161
  *
1133
1162
  * @see https://ota-meshi.github.io/eslint-plugin-jsonc/rules/auto.html
1134
1163
  */
1135
- "jsonc/auto": "error"
1164
+ "jsonc/auto": "error",
1165
+ /** User-defined rules */
1166
+ ...options.rules
1136
1167
  }
1137
1168
  }
1138
1169
  ];
1139
1170
  }
1140
- function jsdoc() {
1171
+ function jsdoc(options) {
1141
1172
  return [
1142
1173
  pluginJsdoc.configs["flat/recommended-typescript-flavor-error"],
1143
1174
  {
@@ -1199,12 +1230,14 @@ function jsdoc() {
1199
1230
  *
1200
1231
  * @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/tag-lines.md
1201
1232
  */
1202
- "jsdoc/tag-lines": ["error", "any", { startLines: 1 }]
1233
+ "jsdoc/tag-lines": ["error", "any", { startLines: 1 }],
1234
+ /** User-defined rules */
1235
+ ...options.rules
1203
1236
  }
1204
1237
  }
1205
1238
  ];
1206
1239
  }
1207
- function eslintComments() {
1240
+ function eslintComments(options) {
1208
1241
  return [
1209
1242
  {
1210
1243
  plugins: {
@@ -1247,12 +1280,14 @@ function eslintComments() {
1247
1280
  *
1248
1281
  * @see https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-unused-disable
1249
1282
  */
1250
- "eslint-comments/no-unused-disable": "error"
1283
+ "eslint-comments/no-unused-disable": "error",
1284
+ /** User-defined rules */
1285
+ ...options.rules
1251
1286
  }
1252
1287
  }
1253
1288
  ];
1254
1289
  }
1255
- function antfu() {
1290
+ function antfu(options) {
1256
1291
  return [
1257
1292
  {
1258
1293
  plugins: {
@@ -1284,27 +1319,27 @@ function antfu() {
1284
1319
  *
1285
1320
  * @see https://github.com/antfu/eslint-plugin-antfu/blob/main/src/rules/consistent-list-newline.md
1286
1321
  */
1287
- "object-curly-newline": "off"
1322
+ "object-curly-newline": "off",
1323
+ /** User-defined rules */
1324
+ ...options.rules
1288
1325
  }
1289
1326
  }
1290
1327
  ];
1291
1328
  }
1292
1329
  function all(options = {}) {
1293
1330
  return [
1294
- ...antfu(),
1295
- ...eslintComments(),
1296
- ...jsdoc(),
1297
- ...configJson(),
1331
+ ...antfu(options),
1332
+ ...eslintComments(options),
1333
+ ...jsdoc(options),
1334
+ ...configJson(options),
1298
1335
  ...jsonPackage(),
1299
1336
  ...jsonTsconfig(),
1300
- ...node(),
1301
- ...sonarjs(),
1337
+ ...node(options),
1338
+ ...sonarjs(options),
1302
1339
  ...typescript(options),
1303
- ...unicorn(),
1304
- ...vitest(),
1340
+ ...unicorn(options),
1341
+ ...vitest(options),
1305
1342
  ...vue(options),
1306
- // ...promise(),
1307
- // ...markdown(),
1308
1343
  {
1309
1344
  ignores: [
1310
1345
  "**/dist",