@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 +85 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +85 -50
- package/dist/index.js.map +1 -1
- package/package.json +3 -8
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.
|
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:
|
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"],
|
@@ -270,6 +272,10 @@ function typescript(options) {
|
|
270
272
|
disallowTypeAnnotations: !1,
|
271
273
|
prefer: "no-type-imports"
|
272
274
|
}],
|
275
|
+
"perfectionist/sort-exports": ["error", {
|
276
|
+
type: "alphabetical",
|
277
|
+
"ignore-case": !1
|
278
|
+
}],
|
273
279
|
"perfectionist/sort-named-imports": ["error", { type: "natural" }],
|
274
280
|
"perfectionist/sort-imports": ["error", {
|
275
281
|
"newlines-between": "never",
|
@@ -370,10 +376,10 @@ function typescript(options) {
|
|
370
376
|
}
|
371
377
|
];
|
372
378
|
}
|
373
|
-
const VUE_RECOMMENDED_RULES = vuePlugin.configs?.["flat/recommended"].rules, VUE_BASE_RULES = vuePlugin.configs?.base.rules;
|
374
379
|
function vue(options) {
|
375
380
|
const TYPESCRIPT_CONFIG = typescript(options).at(1);
|
376
381
|
return [
|
382
|
+
...vuePlugin.configs?.["flat/base"],
|
377
383
|
{
|
378
384
|
plugins: {
|
379
385
|
vue: vuePlugin,
|
@@ -412,11 +418,21 @@ function vue(options) {
|
|
412
418
|
"**/*.vue"
|
413
419
|
],
|
414
420
|
rules: {
|
415
|
-
...VUE_BASE_RULES,
|
416
|
-
...VUE_RECOMMENDED_RULES,
|
417
421
|
...TYPESCRIPT_CONFIG.rules,
|
418
|
-
|
422
|
+
// @ts-expect-error: ignore
|
423
|
+
...vuePlugin.configs["flat/recommended"].rules,
|
424
|
+
// @ts-expect-error: ignore
|
425
|
+
...vuePlugin.configs["flat/strongly-recommended"].rules,
|
426
|
+
// @ts-expect-error: ignore
|
427
|
+
...vuePlugin.configs["flat/essential"].rules,
|
428
|
+
/**
|
429
|
+
* Disable some TypeScript rules that may conflict with the Vue SFC parser.
|
430
|
+
*/
|
419
431
|
"@typescript-eslint/no-unsafe-call": "off",
|
432
|
+
"@typescript-eslint/no-unsafe-return": "off",
|
433
|
+
"@typescript-eslint/no-misused-promises": "off",
|
434
|
+
"@typescript-eslint/no-unsafe-assignment": "off",
|
435
|
+
"@typescript-eslint/no-unsafe-member-access": "off",
|
420
436
|
/**
|
421
437
|
* Enforces consistent usage of type imports. This rule will enforce the use
|
422
438
|
* of `type` imports to make it easier for the Vue SFC compiler to analyze
|
@@ -425,11 +441,11 @@ function vue(options) {
|
|
425
441
|
* @see https://typescript-eslint.io/rules/consistent-type-imports
|
426
442
|
* @see https://vuejs.github.io/vetur/guide/FAQ.html#why-does-vetur-show-cannot-find-module-xxx
|
427
443
|
*/
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
}],
|
444
|
+
// '@typescript-eslint/consistent-type-imports': ['error', {
|
445
|
+
// disallowTypeAnnotations: false,
|
446
|
+
// fixStyle: 'inline-type-imports',
|
447
|
+
// prefer: 'type-imports',
|
448
|
+
// }],
|
433
449
|
/**
|
434
450
|
* Enforce the order of the top-level properties in the component. This rule
|
435
451
|
* helps to maintain consistency and readability by enforcing a predictable
|
@@ -451,7 +467,9 @@ function vue(options) {
|
|
451
467
|
* consistency and maintainability.
|
452
468
|
*
|
453
469
|
* @see https://eslint.vuejs.org/rules/vue/prefer-define-options.html
|
470
|
+
* @see https://eslint.vuejs.org/rules/vue/component-api-style.html
|
454
471
|
*/
|
472
|
+
"vue/prefer-define-options": "error",
|
455
473
|
"vue/component-api-style": ["error", ["script-setup"]],
|
456
474
|
/**
|
457
475
|
* Enforce the component name casing to be PascalCase. This rules helps identify
|
@@ -471,6 +489,10 @@ function vue(options) {
|
|
471
489
|
* @see https://eslint.vuejs.org/rules/html-comment-content-newline.html
|
472
490
|
*/
|
473
491
|
"vue/html-comment-content-spacing": ["error", "always"],
|
492
|
+
"vue/html-comment-content-newline": ["error", {
|
493
|
+
multiline: "always",
|
494
|
+
singleline: "never"
|
495
|
+
}],
|
474
496
|
/**
|
475
497
|
* Enforce consistent spacing between HTML / Component tags. This makes it
|
476
498
|
* easier to read and understand the structure of the component.
|
@@ -478,11 +500,17 @@ function vue(options) {
|
|
478
500
|
* @see https://eslint.vuejs.org/rules/padding-line-between-blocks.html
|
479
501
|
* @see https://eslint.vuejs.org/rules/padding-line-between-tags.html
|
480
502
|
*/
|
481
|
-
"vue/
|
503
|
+
"vue/padding-line-between-blocks": ["error", "always"],
|
482
504
|
"vue/padding-line-between-tags": ["error", [
|
483
505
|
{ blankLine: "consistent", next: "*", prev: "*" },
|
484
506
|
{ blankLine: "always", next: "*", prev: "comment" }
|
485
507
|
]],
|
508
|
+
"vue/html-comment-indent": ["error", 2],
|
509
|
+
"vue/multiline-html-element-content-newline": ["error", {
|
510
|
+
allowEmptyLines: !0,
|
511
|
+
ignores: [],
|
512
|
+
ignoreWhenEmpty: !0
|
513
|
+
}],
|
486
514
|
/**
|
487
515
|
* Enforce consistent spacing and newlines in the template. This rule helps
|
488
516
|
* to maintain consistency and readability by enforcing a predictable
|
@@ -512,11 +540,7 @@ function vue(options) {
|
|
512
540
|
* @see https://eslint.vuejs.org/rules/multi-word-component-names.html
|
513
541
|
*/
|
514
542
|
"vue/multi-word-component-names": "off",
|
515
|
-
"vue/
|
516
|
-
allowEmptyLines: !0,
|
517
|
-
ignores: [],
|
518
|
-
ignoreWhenEmpty: !0
|
519
|
-
}],
|
543
|
+
"vue/no-reserved-component-names": "off",
|
520
544
|
/**
|
521
545
|
* Reports the destructuring or member expression of props passed to setup
|
522
546
|
* causing the value to lose reactivity. This rule helps to avoid common
|
@@ -549,6 +573,7 @@ function vue(options) {
|
|
549
573
|
* @see https://eslint.vuejs.org/rules/v-on-handler-style.html
|
550
574
|
*/
|
551
575
|
"vue/v-on-style": ["error", "shorthand"],
|
576
|
+
"vue/return-in-computed-property": "off",
|
552
577
|
"vue/no-sparse-arrays": "error",
|
553
578
|
"vue/no-unused-emit-declarations": "error",
|
554
579
|
"vue/no-use-v-else-with-v-for": "error",
|
@@ -566,8 +591,6 @@ function vue(options) {
|
|
566
591
|
}
|
567
592
|
],
|
568
593
|
"vue/operator-linebreak": ["error", "before"],
|
569
|
-
"vue/padding-line-between-blocks": ["error", "always"],
|
570
|
-
"vue/prefer-define-options": "error",
|
571
594
|
"vue/prefer-import-from-vue": "off",
|
572
595
|
"vue/prefer-separate-static-class": "error",
|
573
596
|
"vue/prefer-template": "error",
|
@@ -607,10 +630,6 @@ function vue(options) {
|
|
607
630
|
},
|
608
631
|
singleline: "never"
|
609
632
|
}],
|
610
|
-
"vue/html-comment-content-newline": ["error", {
|
611
|
-
multiline: "always",
|
612
|
-
singleline: "never"
|
613
|
-
}],
|
614
633
|
"vue/no-constant-condition": "warn",
|
615
634
|
"vue/no-empty-pattern": "error",
|
616
635
|
"vue/no-extra-parens": ["error", "functions"],
|
@@ -628,12 +647,14 @@ function vue(options) {
|
|
628
647
|
"vue/space-infix-ops": "error",
|
629
648
|
"vue/space-unary-ops": ["error", { nonwords: !1, words: !0 }],
|
630
649
|
"vue/template-curly-spacing": "error",
|
631
|
-
"vue/v-on-handler-style": ["error", "inline"]
|
650
|
+
"vue/v-on-handler-style": ["error", "inline"],
|
651
|
+
/** User-defined rules */
|
652
|
+
...options.rules
|
632
653
|
}
|
633
654
|
}
|
634
655
|
];
|
635
656
|
}
|
636
|
-
function vitest() {
|
657
|
+
function vitest(options) {
|
637
658
|
return [
|
638
659
|
{
|
639
660
|
plugins: {
|
@@ -717,13 +738,15 @@ function vitest() {
|
|
717
738
|
mustMatch: {
|
718
739
|
test: ["^should"]
|
719
740
|
}
|
720
|
-
}]
|
741
|
+
}],
|
742
|
+
/** User-defined rules */
|
743
|
+
...options.rules
|
721
744
|
}
|
722
745
|
}
|
723
746
|
];
|
724
747
|
}
|
725
748
|
const UNICORN_RECOMMENDED_RULES = unicornPlugin.configs.recommended.rules;
|
726
|
-
function unicorn() {
|
749
|
+
function unicorn(options) {
|
727
750
|
return [
|
728
751
|
{
|
729
752
|
plugins: {
|
@@ -827,11 +850,13 @@ function unicorn() {
|
|
827
850
|
}
|
828
851
|
}],
|
829
852
|
"unicorn/throw-new-error": "error"
|
830
|
-
}
|
853
|
+
},
|
854
|
+
/** User-defined rules */
|
855
|
+
...options.rules
|
831
856
|
}
|
832
857
|
];
|
833
858
|
}
|
834
|
-
function sonarjs() {
|
859
|
+
function sonarjs(options) {
|
835
860
|
return new FlatCompat().config({
|
836
861
|
extends: [
|
837
862
|
"plugin:sonarjs/recommended"
|
@@ -868,11 +893,13 @@ function sonarjs() {
|
|
868
893
|
"sonarjs/no-one-iteration-loop": "off",
|
869
894
|
"sonarjs/no-redundant-jump": "off",
|
870
895
|
"sonarjs/no-unused-collection": "off",
|
871
|
-
"sonarjs/no-use-of-empty-return-value": "off"
|
896
|
+
"sonarjs/no-use-of-empty-return-value": "off",
|
897
|
+
/** User-defined rules */
|
898
|
+
...options.rules
|
872
899
|
}
|
873
900
|
});
|
874
901
|
}
|
875
|
-
function node() {
|
902
|
+
function node(options) {
|
876
903
|
return [
|
877
904
|
{
|
878
905
|
plugins: {
|
@@ -922,7 +949,9 @@ function node() {
|
|
922
949
|
*
|
923
950
|
* @see https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-node-protocol.md
|
924
951
|
*/
|
925
|
-
"n/prefer-node-protocol": "error"
|
952
|
+
"n/prefer-node-protocol": "error",
|
953
|
+
/** User-defined rules */
|
954
|
+
...options.rules
|
926
955
|
},
|
927
956
|
settings: {
|
928
957
|
node: {
|
@@ -1134,7 +1163,7 @@ function jsonPackage() {
|
|
1134
1163
|
}
|
1135
1164
|
];
|
1136
1165
|
}
|
1137
|
-
function configJson() {
|
1166
|
+
function configJson(options) {
|
1138
1167
|
return [
|
1139
1168
|
...jsonc.configs["flat/recommended-with-json"],
|
1140
1169
|
{
|
@@ -1148,12 +1177,14 @@ function configJson() {
|
|
1148
1177
|
*
|
1149
1178
|
* @see https://ota-meshi.github.io/eslint-plugin-jsonc/rules/auto.html
|
1150
1179
|
*/
|
1151
|
-
"jsonc/auto": "error"
|
1180
|
+
"jsonc/auto": "error",
|
1181
|
+
/** User-defined rules */
|
1182
|
+
...options.rules
|
1152
1183
|
}
|
1153
1184
|
}
|
1154
1185
|
];
|
1155
1186
|
}
|
1156
|
-
function jsdoc() {
|
1187
|
+
function jsdoc(options) {
|
1157
1188
|
return [
|
1158
1189
|
pluginJsdoc.configs["flat/recommended-typescript-flavor-error"],
|
1159
1190
|
{
|
@@ -1215,12 +1246,14 @@ function jsdoc() {
|
|
1215
1246
|
*
|
1216
1247
|
* @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/tag-lines.md
|
1217
1248
|
*/
|
1218
|
-
"jsdoc/tag-lines": ["error", "any", { startLines: 1 }]
|
1249
|
+
"jsdoc/tag-lines": ["error", "any", { startLines: 1 }],
|
1250
|
+
/** User-defined rules */
|
1251
|
+
...options.rules
|
1219
1252
|
}
|
1220
1253
|
}
|
1221
1254
|
];
|
1222
1255
|
}
|
1223
|
-
function eslintComments() {
|
1256
|
+
function eslintComments(options) {
|
1224
1257
|
return [
|
1225
1258
|
{
|
1226
1259
|
plugins: {
|
@@ -1263,12 +1296,14 @@ function eslintComments() {
|
|
1263
1296
|
*
|
1264
1297
|
* @see https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-unused-disable
|
1265
1298
|
*/
|
1266
|
-
"eslint-comments/no-unused-disable": "error"
|
1299
|
+
"eslint-comments/no-unused-disable": "error",
|
1300
|
+
/** User-defined rules */
|
1301
|
+
...options.rules
|
1267
1302
|
}
|
1268
1303
|
}
|
1269
1304
|
];
|
1270
1305
|
}
|
1271
|
-
function antfu() {
|
1306
|
+
function antfu(options) {
|
1272
1307
|
return [
|
1273
1308
|
{
|
1274
1309
|
plugins: {
|
@@ -1300,27 +1335,27 @@ function antfu() {
|
|
1300
1335
|
*
|
1301
1336
|
* @see https://github.com/antfu/eslint-plugin-antfu/blob/main/src/rules/consistent-list-newline.md
|
1302
1337
|
*/
|
1303
|
-
"object-curly-newline": "off"
|
1338
|
+
"object-curly-newline": "off",
|
1339
|
+
/** User-defined rules */
|
1340
|
+
...options.rules
|
1304
1341
|
}
|
1305
1342
|
}
|
1306
1343
|
];
|
1307
1344
|
}
|
1308
1345
|
function all(options = {}) {
|
1309
1346
|
return [
|
1310
|
-
...antfu(),
|
1311
|
-
...eslintComments(),
|
1312
|
-
...jsdoc(),
|
1313
|
-
...configJson(),
|
1347
|
+
...antfu(options),
|
1348
|
+
...eslintComments(options),
|
1349
|
+
...jsdoc(options),
|
1350
|
+
...configJson(options),
|
1314
1351
|
...jsonPackage(),
|
1315
1352
|
...jsonTsconfig(),
|
1316
|
-
...node(),
|
1317
|
-
...sonarjs(),
|
1353
|
+
...node(options),
|
1354
|
+
...sonarjs(options),
|
1318
1355
|
...typescript(options),
|
1319
|
-
...unicorn(),
|
1320
|
-
...vitest(),
|
1356
|
+
...unicorn(options),
|
1357
|
+
...vitest(options),
|
1321
1358
|
...vue(options),
|
1322
|
-
// ...promise(),
|
1323
|
-
// ...markdown(),
|
1324
1359
|
{
|
1325
1360
|
ignores: [
|
1326
1361
|
"**/dist",
|