@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.cjs +81 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +81 -50
- package/dist/index.js.map +1 -1
- package/package.json +3 -8
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.
|
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:
|
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"],
|
@@ -354,10 +356,10 @@ function typescript(options) {
|
|
354
356
|
}
|
355
357
|
];
|
356
358
|
}
|
357
|
-
const VUE_RECOMMENDED_RULES = vuePlugin.configs?.["flat/recommended"].rules, VUE_BASE_RULES = vuePlugin.configs?.base.rules;
|
358
359
|
function vue(options) {
|
359
360
|
const TYPESCRIPT_CONFIG = typescript(options).at(1);
|
360
361
|
return [
|
362
|
+
...vuePlugin.configs?.["flat/base"],
|
361
363
|
{
|
362
364
|
plugins: {
|
363
365
|
vue: vuePlugin,
|
@@ -396,11 +398,21 @@ function vue(options) {
|
|
396
398
|
"**/*.vue"
|
397
399
|
],
|
398
400
|
rules: {
|
399
|
-
...VUE_BASE_RULES,
|
400
|
-
...VUE_RECOMMENDED_RULES,
|
401
401
|
...TYPESCRIPT_CONFIG.rules,
|
402
|
-
|
402
|
+
// @ts-expect-error: ignore
|
403
|
+
...vuePlugin.configs["flat/recommended"].rules,
|
404
|
+
// @ts-expect-error: ignore
|
405
|
+
...vuePlugin.configs["flat/strongly-recommended"].rules,
|
406
|
+
// @ts-expect-error: ignore
|
407
|
+
...vuePlugin.configs["flat/essential"].rules,
|
408
|
+
/**
|
409
|
+
* Disable some TypeScript rules that may conflict with the Vue SFC parser.
|
410
|
+
*/
|
403
411
|
"@typescript-eslint/no-unsafe-call": "off",
|
412
|
+
"@typescript-eslint/no-unsafe-return": "off",
|
413
|
+
"@typescript-eslint/no-misused-promises": "off",
|
414
|
+
"@typescript-eslint/no-unsafe-assignment": "off",
|
415
|
+
"@typescript-eslint/no-unsafe-member-access": "off",
|
404
416
|
/**
|
405
417
|
* Enforces consistent usage of type imports. This rule will enforce the use
|
406
418
|
* of `type` imports to make it easier for the Vue SFC compiler to analyze
|
@@ -409,11 +421,11 @@ function vue(options) {
|
|
409
421
|
* @see https://typescript-eslint.io/rules/consistent-type-imports
|
410
422
|
* @see https://vuejs.github.io/vetur/guide/FAQ.html#why-does-vetur-show-cannot-find-module-xxx
|
411
423
|
*/
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
}],
|
424
|
+
// '@typescript-eslint/consistent-type-imports': ['error', {
|
425
|
+
// disallowTypeAnnotations: false,
|
426
|
+
// fixStyle: 'inline-type-imports',
|
427
|
+
// prefer: 'type-imports',
|
428
|
+
// }],
|
417
429
|
/**
|
418
430
|
* Enforce the order of the top-level properties in the component. This rule
|
419
431
|
* helps to maintain consistency and readability by enforcing a predictable
|
@@ -435,7 +447,9 @@ function vue(options) {
|
|
435
447
|
* consistency and maintainability.
|
436
448
|
*
|
437
449
|
* @see https://eslint.vuejs.org/rules/vue/prefer-define-options.html
|
450
|
+
* @see https://eslint.vuejs.org/rules/vue/component-api-style.html
|
438
451
|
*/
|
452
|
+
"vue/prefer-define-options": "error",
|
439
453
|
"vue/component-api-style": ["error", ["script-setup"]],
|
440
454
|
/**
|
441
455
|
* Enforce the component name casing to be PascalCase. This rules helps identify
|
@@ -455,6 +469,10 @@ function vue(options) {
|
|
455
469
|
* @see https://eslint.vuejs.org/rules/html-comment-content-newline.html
|
456
470
|
*/
|
457
471
|
"vue/html-comment-content-spacing": ["error", "always"],
|
472
|
+
"vue/html-comment-content-newline": ["error", {
|
473
|
+
multiline: "always",
|
474
|
+
singleline: "never"
|
475
|
+
}],
|
458
476
|
/**
|
459
477
|
* Enforce consistent spacing between HTML / Component tags. This makes it
|
460
478
|
* easier to read and understand the structure of the component.
|
@@ -462,11 +480,17 @@ function vue(options) {
|
|
462
480
|
* @see https://eslint.vuejs.org/rules/padding-line-between-blocks.html
|
463
481
|
* @see https://eslint.vuejs.org/rules/padding-line-between-tags.html
|
464
482
|
*/
|
465
|
-
"vue/
|
483
|
+
"vue/padding-line-between-blocks": ["error", "always"],
|
466
484
|
"vue/padding-line-between-tags": ["error", [
|
467
485
|
{ blankLine: "consistent", next: "*", prev: "*" },
|
468
486
|
{ blankLine: "always", next: "*", prev: "comment" }
|
469
487
|
]],
|
488
|
+
"vue/html-comment-indent": ["error", 2],
|
489
|
+
"vue/multiline-html-element-content-newline": ["error", {
|
490
|
+
allowEmptyLines: !0,
|
491
|
+
ignores: [],
|
492
|
+
ignoreWhenEmpty: !0
|
493
|
+
}],
|
470
494
|
/**
|
471
495
|
* Enforce consistent spacing and newlines in the template. This rule helps
|
472
496
|
* to maintain consistency and readability by enforcing a predictable
|
@@ -496,11 +520,7 @@ function vue(options) {
|
|
496
520
|
* @see https://eslint.vuejs.org/rules/multi-word-component-names.html
|
497
521
|
*/
|
498
522
|
"vue/multi-word-component-names": "off",
|
499
|
-
"vue/
|
500
|
-
allowEmptyLines: !0,
|
501
|
-
ignores: [],
|
502
|
-
ignoreWhenEmpty: !0
|
503
|
-
}],
|
523
|
+
"vue/no-reserved-component-names": "off",
|
504
524
|
/**
|
505
525
|
* Reports the destructuring or member expression of props passed to setup
|
506
526
|
* causing the value to lose reactivity. This rule helps to avoid common
|
@@ -533,6 +553,7 @@ function vue(options) {
|
|
533
553
|
* @see https://eslint.vuejs.org/rules/v-on-handler-style.html
|
534
554
|
*/
|
535
555
|
"vue/v-on-style": ["error", "shorthand"],
|
556
|
+
"vue/return-in-computed-property": "off",
|
536
557
|
"vue/no-sparse-arrays": "error",
|
537
558
|
"vue/no-unused-emit-declarations": "error",
|
538
559
|
"vue/no-use-v-else-with-v-for": "error",
|
@@ -550,8 +571,6 @@ function vue(options) {
|
|
550
571
|
}
|
551
572
|
],
|
552
573
|
"vue/operator-linebreak": ["error", "before"],
|
553
|
-
"vue/padding-line-between-blocks": ["error", "always"],
|
554
|
-
"vue/prefer-define-options": "error",
|
555
574
|
"vue/prefer-import-from-vue": "off",
|
556
575
|
"vue/prefer-separate-static-class": "error",
|
557
576
|
"vue/prefer-template": "error",
|
@@ -591,10 +610,6 @@ function vue(options) {
|
|
591
610
|
},
|
592
611
|
singleline: "never"
|
593
612
|
}],
|
594
|
-
"vue/html-comment-content-newline": ["error", {
|
595
|
-
multiline: "always",
|
596
|
-
singleline: "never"
|
597
|
-
}],
|
598
613
|
"vue/no-constant-condition": "warn",
|
599
614
|
"vue/no-empty-pattern": "error",
|
600
615
|
"vue/no-extra-parens": ["error", "functions"],
|
@@ -612,12 +627,14 @@ function vue(options) {
|
|
612
627
|
"vue/space-infix-ops": "error",
|
613
628
|
"vue/space-unary-ops": ["error", { nonwords: !1, words: !0 }],
|
614
629
|
"vue/template-curly-spacing": "error",
|
615
|
-
"vue/v-on-handler-style": ["error", "inline"]
|
630
|
+
"vue/v-on-handler-style": ["error", "inline"],
|
631
|
+
/** User-defined rules */
|
632
|
+
...options.rules
|
616
633
|
}
|
617
634
|
}
|
618
635
|
];
|
619
636
|
}
|
620
|
-
function vitest() {
|
637
|
+
function vitest(options) {
|
621
638
|
return [
|
622
639
|
{
|
623
640
|
plugins: {
|
@@ -701,13 +718,15 @@ function vitest() {
|
|
701
718
|
mustMatch: {
|
702
719
|
test: ["^should"]
|
703
720
|
}
|
704
|
-
}]
|
721
|
+
}],
|
722
|
+
/** User-defined rules */
|
723
|
+
...options.rules
|
705
724
|
}
|
706
725
|
}
|
707
726
|
];
|
708
727
|
}
|
709
728
|
const UNICORN_RECOMMENDED_RULES = unicornPlugin.configs.recommended.rules;
|
710
|
-
function unicorn() {
|
729
|
+
function unicorn(options) {
|
711
730
|
return [
|
712
731
|
{
|
713
732
|
plugins: {
|
@@ -811,11 +830,13 @@ function unicorn() {
|
|
811
830
|
}
|
812
831
|
}],
|
813
832
|
"unicorn/throw-new-error": "error"
|
814
|
-
}
|
833
|
+
},
|
834
|
+
/** User-defined rules */
|
835
|
+
...options.rules
|
815
836
|
}
|
816
837
|
];
|
817
838
|
}
|
818
|
-
function sonarjs() {
|
839
|
+
function sonarjs(options) {
|
819
840
|
return new eslintrc.FlatCompat().config({
|
820
841
|
extends: [
|
821
842
|
"plugin:sonarjs/recommended"
|
@@ -852,11 +873,13 @@ function sonarjs() {
|
|
852
873
|
"sonarjs/no-one-iteration-loop": "off",
|
853
874
|
"sonarjs/no-redundant-jump": "off",
|
854
875
|
"sonarjs/no-unused-collection": "off",
|
855
|
-
"sonarjs/no-use-of-empty-return-value": "off"
|
876
|
+
"sonarjs/no-use-of-empty-return-value": "off",
|
877
|
+
/** User-defined rules */
|
878
|
+
...options.rules
|
856
879
|
}
|
857
880
|
});
|
858
881
|
}
|
859
|
-
function node() {
|
882
|
+
function node(options) {
|
860
883
|
return [
|
861
884
|
{
|
862
885
|
plugins: {
|
@@ -906,7 +929,9 @@ function node() {
|
|
906
929
|
*
|
907
930
|
* @see https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-node-protocol.md
|
908
931
|
*/
|
909
|
-
"n/prefer-node-protocol": "error"
|
932
|
+
"n/prefer-node-protocol": "error",
|
933
|
+
/** User-defined rules */
|
934
|
+
...options.rules
|
910
935
|
},
|
911
936
|
settings: {
|
912
937
|
node: {
|
@@ -1118,7 +1143,7 @@ function jsonPackage() {
|
|
1118
1143
|
}
|
1119
1144
|
];
|
1120
1145
|
}
|
1121
|
-
function configJson() {
|
1146
|
+
function configJson(options) {
|
1122
1147
|
return [
|
1123
1148
|
...jsonc.configs["flat/recommended-with-json"],
|
1124
1149
|
{
|
@@ -1132,12 +1157,14 @@ function configJson() {
|
|
1132
1157
|
*
|
1133
1158
|
* @see https://ota-meshi.github.io/eslint-plugin-jsonc/rules/auto.html
|
1134
1159
|
*/
|
1135
|
-
"jsonc/auto": "error"
|
1160
|
+
"jsonc/auto": "error",
|
1161
|
+
/** User-defined rules */
|
1162
|
+
...options.rules
|
1136
1163
|
}
|
1137
1164
|
}
|
1138
1165
|
];
|
1139
1166
|
}
|
1140
|
-
function jsdoc() {
|
1167
|
+
function jsdoc(options) {
|
1141
1168
|
return [
|
1142
1169
|
pluginJsdoc.configs["flat/recommended-typescript-flavor-error"],
|
1143
1170
|
{
|
@@ -1199,12 +1226,14 @@ function jsdoc() {
|
|
1199
1226
|
*
|
1200
1227
|
* @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/tag-lines.md
|
1201
1228
|
*/
|
1202
|
-
"jsdoc/tag-lines": ["error", "any", { startLines: 1 }]
|
1229
|
+
"jsdoc/tag-lines": ["error", "any", { startLines: 1 }],
|
1230
|
+
/** User-defined rules */
|
1231
|
+
...options.rules
|
1203
1232
|
}
|
1204
1233
|
}
|
1205
1234
|
];
|
1206
1235
|
}
|
1207
|
-
function eslintComments() {
|
1236
|
+
function eslintComments(options) {
|
1208
1237
|
return [
|
1209
1238
|
{
|
1210
1239
|
plugins: {
|
@@ -1247,12 +1276,14 @@ function eslintComments() {
|
|
1247
1276
|
*
|
1248
1277
|
* @see https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-unused-disable
|
1249
1278
|
*/
|
1250
|
-
"eslint-comments/no-unused-disable": "error"
|
1279
|
+
"eslint-comments/no-unused-disable": "error",
|
1280
|
+
/** User-defined rules */
|
1281
|
+
...options.rules
|
1251
1282
|
}
|
1252
1283
|
}
|
1253
1284
|
];
|
1254
1285
|
}
|
1255
|
-
function antfu() {
|
1286
|
+
function antfu(options) {
|
1256
1287
|
return [
|
1257
1288
|
{
|
1258
1289
|
plugins: {
|
@@ -1284,27 +1315,27 @@ function antfu() {
|
|
1284
1315
|
*
|
1285
1316
|
* @see https://github.com/antfu/eslint-plugin-antfu/blob/main/src/rules/consistent-list-newline.md
|
1286
1317
|
*/
|
1287
|
-
"object-curly-newline": "off"
|
1318
|
+
"object-curly-newline": "off",
|
1319
|
+
/** User-defined rules */
|
1320
|
+
...options.rules
|
1288
1321
|
}
|
1289
1322
|
}
|
1290
1323
|
];
|
1291
1324
|
}
|
1292
1325
|
function all(options = {}) {
|
1293
1326
|
return [
|
1294
|
-
...antfu(),
|
1295
|
-
...eslintComments(),
|
1296
|
-
...jsdoc(),
|
1297
|
-
...configJson(),
|
1327
|
+
...antfu(options),
|
1328
|
+
...eslintComments(options),
|
1329
|
+
...jsdoc(options),
|
1330
|
+
...configJson(options),
|
1298
1331
|
...jsonPackage(),
|
1299
1332
|
...jsonTsconfig(),
|
1300
|
-
...node(),
|
1301
|
-
...sonarjs(),
|
1333
|
+
...node(options),
|
1334
|
+
...sonarjs(options),
|
1302
1335
|
...typescript(options),
|
1303
|
-
...unicorn(),
|
1304
|
-
...vitest(),
|
1336
|
+
...unicorn(options),
|
1337
|
+
...vitest(options),
|
1305
1338
|
...vue(options),
|
1306
|
-
// ...promise(),
|
1307
|
-
// ...markdown(),
|
1308
1339
|
{
|
1309
1340
|
ignores: [
|
1310
1341
|
"**/dist",
|