@unshared/eslint-config 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ function typescript(options) {
30
30
  parserOptions: {
31
31
  ecmaVersion: "latest",
32
32
  sourceType: "module",
33
- project: toArray(options.tsConfigPaths ?? "./tsconfig.json"),
33
+ project: toArray(options.tsConfigPath ?? "./tsconfig.json"),
34
34
  tsconfigRootDir: cwd()
35
35
  }
36
36
  },
@@ -103,7 +103,7 @@ function typescript(options) {
103
103
  "@stylistic/no-multiple-empty-lines": ["error", {
104
104
  max: 1,
105
105
  maxBOF: 0,
106
- maxEOF: 1
106
+ maxEOF: 0
107
107
  }],
108
108
  /**
109
109
  * Enforce a trailing comma after the last element or property in a multiline
@@ -174,6 +174,7 @@ function typescript(options) {
174
174
  "function-call-spacing": "off",
175
175
  "generator-star-spacing": "off",
176
176
  "template-curly-spacing": "off",
177
+ "object-property-newline ": "off",
177
178
  "newline-per-chained-call": "off",
178
179
  "computed-property-spacing": "off",
179
180
  "lines-between-class-members": "off",
@@ -195,6 +196,7 @@ function typescript(options) {
195
196
  "@stylistic/array-bracket-newline": ["error", "consistent"],
196
197
  "@stylistic/function-call-spacing": ["error", "never"],
197
198
  "@stylistic/template-curly-spacing": ["error", "never"],
199
+ "@stylistic/object-property-newline": ["error", { allowAllPropertiesOnSameLine: !0 }],
198
200
  "@stylistic/generator-star-spacing": ["error", { before: !0, after: !0 }],
199
201
  "@stylistic/computed-property-spacing": ["error", "never"],
200
202
  "@stylistic/multiline-ternary": ["error", "always-multiline"],
@@ -370,10 +372,10 @@ function typescript(options) {
370
372
  }
371
373
  ];
372
374
  }
373
- const VUE_RECOMMENDED_RULES = vuePlugin.configs?.["flat/recommended"].rules, VUE_BASE_RULES = vuePlugin.configs?.base.rules;
374
375
  function vue(options) {
375
376
  const TYPESCRIPT_CONFIG = typescript(options).at(1);
376
377
  return [
378
+ ...vuePlugin.configs?.["flat/base"],
377
379
  {
378
380
  plugins: {
379
381
  vue: vuePlugin,
@@ -412,11 +414,21 @@ function vue(options) {
412
414
  "**/*.vue"
413
415
  ],
414
416
  rules: {
415
- ...VUE_BASE_RULES,
416
- ...VUE_RECOMMENDED_RULES,
417
417
  ...TYPESCRIPT_CONFIG.rules,
418
- "@typescript-eslint/no-unsafe-assignment": "off",
418
+ // @ts-expect-error: ignore
419
+ ...vuePlugin.configs["flat/recommended"].rules,
420
+ // @ts-expect-error: ignore
421
+ ...vuePlugin.configs["flat/strongly-recommended"].rules,
422
+ // @ts-expect-error: ignore
423
+ ...vuePlugin.configs["flat/essential"].rules,
424
+ /**
425
+ * Disable some TypeScript rules that may conflict with the Vue SFC parser.
426
+ */
419
427
  "@typescript-eslint/no-unsafe-call": "off",
428
+ "@typescript-eslint/no-unsafe-return": "off",
429
+ "@typescript-eslint/no-misused-promises": "off",
430
+ "@typescript-eslint/no-unsafe-assignment": "off",
431
+ "@typescript-eslint/no-unsafe-member-access": "off",
420
432
  /**
421
433
  * Enforces consistent usage of type imports. This rule will enforce the use
422
434
  * of `type` imports to make it easier for the Vue SFC compiler to analyze
@@ -425,11 +437,11 @@ function vue(options) {
425
437
  * @see https://typescript-eslint.io/rules/consistent-type-imports
426
438
  * @see https://vuejs.github.io/vetur/guide/FAQ.html#why-does-vetur-show-cannot-find-module-xxx
427
439
  */
428
- "@typescript-eslint/consistent-type-imports": ["error", {
429
- disallowTypeAnnotations: !1,
430
- fixStyle: "inline-type-imports",
431
- prefer: "type-imports"
432
- }],
440
+ // '@typescript-eslint/consistent-type-imports': ['error', {
441
+ // disallowTypeAnnotations: false,
442
+ // fixStyle: 'inline-type-imports',
443
+ // prefer: 'type-imports',
444
+ // }],
433
445
  /**
434
446
  * Enforce the order of the top-level properties in the component. This rule
435
447
  * helps to maintain consistency and readability by enforcing a predictable
@@ -451,7 +463,9 @@ function vue(options) {
451
463
  * consistency and maintainability.
452
464
  *
453
465
  * @see https://eslint.vuejs.org/rules/vue/prefer-define-options.html
466
+ * @see https://eslint.vuejs.org/rules/vue/component-api-style.html
454
467
  */
468
+ "vue/prefer-define-options": "error",
455
469
  "vue/component-api-style": ["error", ["script-setup"]],
456
470
  /**
457
471
  * Enforce the component name casing to be PascalCase. This rules helps identify
@@ -471,6 +485,10 @@ function vue(options) {
471
485
  * @see https://eslint.vuejs.org/rules/html-comment-content-newline.html
472
486
  */
473
487
  "vue/html-comment-content-spacing": ["error", "always"],
488
+ "vue/html-comment-content-newline": ["error", {
489
+ multiline: "always",
490
+ singleline: "never"
491
+ }],
474
492
  /**
475
493
  * Enforce consistent spacing between HTML / Component tags. This makes it
476
494
  * easier to read and understand the structure of the component.
@@ -478,11 +496,17 @@ function vue(options) {
478
496
  * @see https://eslint.vuejs.org/rules/padding-line-between-blocks.html
479
497
  * @see https://eslint.vuejs.org/rules/padding-line-between-tags.html
480
498
  */
481
- "vue/html-comment-indent": ["error", 2],
499
+ "vue/padding-line-between-blocks": ["error", "always"],
482
500
  "vue/padding-line-between-tags": ["error", [
483
501
  { blankLine: "consistent", next: "*", prev: "*" },
484
502
  { blankLine: "always", next: "*", prev: "comment" }
485
503
  ]],
504
+ "vue/html-comment-indent": ["error", 2],
505
+ "vue/multiline-html-element-content-newline": ["error", {
506
+ allowEmptyLines: !0,
507
+ ignores: [],
508
+ ignoreWhenEmpty: !0
509
+ }],
486
510
  /**
487
511
  * Enforce consistent spacing and newlines in the template. This rule helps
488
512
  * to maintain consistency and readability by enforcing a predictable
@@ -512,11 +536,7 @@ function vue(options) {
512
536
  * @see https://eslint.vuejs.org/rules/multi-word-component-names.html
513
537
  */
514
538
  "vue/multi-word-component-names": "off",
515
- "vue/multiline-html-element-content-newline": ["error", {
516
- allowEmptyLines: !0,
517
- ignores: [],
518
- ignoreWhenEmpty: !0
519
- }],
539
+ "vue/no-reserved-component-names": "off",
520
540
  /**
521
541
  * Reports the destructuring or member expression of props passed to setup
522
542
  * causing the value to lose reactivity. This rule helps to avoid common
@@ -549,6 +569,7 @@ function vue(options) {
549
569
  * @see https://eslint.vuejs.org/rules/v-on-handler-style.html
550
570
  */
551
571
  "vue/v-on-style": ["error", "shorthand"],
572
+ "vue/return-in-computed-property": "off",
552
573
  "vue/no-sparse-arrays": "error",
553
574
  "vue/no-unused-emit-declarations": "error",
554
575
  "vue/no-use-v-else-with-v-for": "error",
@@ -566,8 +587,6 @@ function vue(options) {
566
587
  }
567
588
  ],
568
589
  "vue/operator-linebreak": ["error", "before"],
569
- "vue/padding-line-between-blocks": ["error", "always"],
570
- "vue/prefer-define-options": "error",
571
590
  "vue/prefer-import-from-vue": "off",
572
591
  "vue/prefer-separate-static-class": "error",
573
592
  "vue/prefer-template": "error",
@@ -607,10 +626,6 @@ function vue(options) {
607
626
  },
608
627
  singleline: "never"
609
628
  }],
610
- "vue/html-comment-content-newline": ["error", {
611
- multiline: "always",
612
- singleline: "never"
613
- }],
614
629
  "vue/no-constant-condition": "warn",
615
630
  "vue/no-empty-pattern": "error",
616
631
  "vue/no-extra-parens": ["error", "functions"],
@@ -628,12 +643,14 @@ function vue(options) {
628
643
  "vue/space-infix-ops": "error",
629
644
  "vue/space-unary-ops": ["error", { nonwords: !1, words: !0 }],
630
645
  "vue/template-curly-spacing": "error",
631
- "vue/v-on-handler-style": ["error", "inline"]
646
+ "vue/v-on-handler-style": ["error", "inline"],
647
+ /** User-defined rules */
648
+ ...options.rules
632
649
  }
633
650
  }
634
651
  ];
635
652
  }
636
- function vitest() {
653
+ function vitest(options) {
637
654
  return [
638
655
  {
639
656
  plugins: {
@@ -717,13 +734,15 @@ function vitest() {
717
734
  mustMatch: {
718
735
  test: ["^should"]
719
736
  }
720
- }]
737
+ }],
738
+ /** User-defined rules */
739
+ ...options.rules
721
740
  }
722
741
  }
723
742
  ];
724
743
  }
725
744
  const UNICORN_RECOMMENDED_RULES = unicornPlugin.configs.recommended.rules;
726
- function unicorn() {
745
+ function unicorn(options) {
727
746
  return [
728
747
  {
729
748
  plugins: {
@@ -827,11 +846,13 @@ function unicorn() {
827
846
  }
828
847
  }],
829
848
  "unicorn/throw-new-error": "error"
830
- }
849
+ },
850
+ /** User-defined rules */
851
+ ...options.rules
831
852
  }
832
853
  ];
833
854
  }
834
- function sonarjs() {
855
+ function sonarjs(options) {
835
856
  return new FlatCompat().config({
836
857
  extends: [
837
858
  "plugin:sonarjs/recommended"
@@ -868,11 +889,13 @@ function sonarjs() {
868
889
  "sonarjs/no-one-iteration-loop": "off",
869
890
  "sonarjs/no-redundant-jump": "off",
870
891
  "sonarjs/no-unused-collection": "off",
871
- "sonarjs/no-use-of-empty-return-value": "off"
892
+ "sonarjs/no-use-of-empty-return-value": "off",
893
+ /** User-defined rules */
894
+ ...options.rules
872
895
  }
873
896
  });
874
897
  }
875
- function node() {
898
+ function node(options) {
876
899
  return [
877
900
  {
878
901
  plugins: {
@@ -922,7 +945,9 @@ function node() {
922
945
  *
923
946
  * @see https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-node-protocol.md
924
947
  */
925
- "n/prefer-node-protocol": "error"
948
+ "n/prefer-node-protocol": "error",
949
+ /** User-defined rules */
950
+ ...options.rules
926
951
  },
927
952
  settings: {
928
953
  node: {
@@ -1134,7 +1159,7 @@ function jsonPackage() {
1134
1159
  }
1135
1160
  ];
1136
1161
  }
1137
- function configJson() {
1162
+ function configJson(options) {
1138
1163
  return [
1139
1164
  ...jsonc.configs["flat/recommended-with-json"],
1140
1165
  {
@@ -1148,12 +1173,14 @@ function configJson() {
1148
1173
  *
1149
1174
  * @see https://ota-meshi.github.io/eslint-plugin-jsonc/rules/auto.html
1150
1175
  */
1151
- "jsonc/auto": "error"
1176
+ "jsonc/auto": "error",
1177
+ /** User-defined rules */
1178
+ ...options.rules
1152
1179
  }
1153
1180
  }
1154
1181
  ];
1155
1182
  }
1156
- function jsdoc() {
1183
+ function jsdoc(options) {
1157
1184
  return [
1158
1185
  pluginJsdoc.configs["flat/recommended-typescript-flavor-error"],
1159
1186
  {
@@ -1215,12 +1242,14 @@ function jsdoc() {
1215
1242
  *
1216
1243
  * @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/tag-lines.md
1217
1244
  */
1218
- "jsdoc/tag-lines": ["error", "any", { startLines: 1 }]
1245
+ "jsdoc/tag-lines": ["error", "any", { startLines: 1 }],
1246
+ /** User-defined rules */
1247
+ ...options.rules
1219
1248
  }
1220
1249
  }
1221
1250
  ];
1222
1251
  }
1223
- function eslintComments() {
1252
+ function eslintComments(options) {
1224
1253
  return [
1225
1254
  {
1226
1255
  plugins: {
@@ -1263,12 +1292,14 @@ function eslintComments() {
1263
1292
  *
1264
1293
  * @see https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-unused-disable
1265
1294
  */
1266
- "eslint-comments/no-unused-disable": "error"
1295
+ "eslint-comments/no-unused-disable": "error",
1296
+ /** User-defined rules */
1297
+ ...options.rules
1267
1298
  }
1268
1299
  }
1269
1300
  ];
1270
1301
  }
1271
- function antfu() {
1302
+ function antfu(options) {
1272
1303
  return [
1273
1304
  {
1274
1305
  plugins: {
@@ -1300,27 +1331,27 @@ function antfu() {
1300
1331
  *
1301
1332
  * @see https://github.com/antfu/eslint-plugin-antfu/blob/main/src/rules/consistent-list-newline.md
1302
1333
  */
1303
- "object-curly-newline": "off"
1334
+ "object-curly-newline": "off",
1335
+ /** User-defined rules */
1336
+ ...options.rules
1304
1337
  }
1305
1338
  }
1306
1339
  ];
1307
1340
  }
1308
1341
  function all(options = {}) {
1309
1342
  return [
1310
- ...antfu(),
1311
- ...eslintComments(),
1312
- ...jsdoc(),
1313
- ...configJson(),
1343
+ ...antfu(options),
1344
+ ...eslintComments(options),
1345
+ ...jsdoc(options),
1346
+ ...configJson(options),
1314
1347
  ...jsonPackage(),
1315
1348
  ...jsonTsconfig(),
1316
- ...node(),
1317
- ...sonarjs(),
1349
+ ...node(options),
1350
+ ...sonarjs(options),
1318
1351
  ...typescript(options),
1319
- ...unicorn(),
1320
- ...vitest(),
1352
+ ...unicorn(options),
1353
+ ...vitest(options),
1321
1354
  ...vue(options),
1322
- // ...promise(),
1323
- // ...markdown(),
1324
1355
  {
1325
1356
  ignores: [
1326
1357
  "**/dist",