@w5s/eslint-config 3.12.0 → 3.14.0

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.js CHANGED
@@ -60,7 +60,7 @@ const StylisticConfig = {
60
60
  };
61
61
  //#endregion
62
62
  //#region src/config/e18e.ts
63
- const defaultFiles$11 = [sourceGlob$1];
63
+ const defaultFiles$10 = [sourceGlob$1];
64
64
  /**
65
65
  * @see https://e18e.dev
66
66
  * @param options
@@ -73,7 +73,7 @@ async function e18e(options = {}) {
73
73
  name: "w5s/e18e/setup",
74
74
  plugins: { e18e: e18ePlugin }
75
75
  }, {
76
- files: withDefaultFiles(files, defaultFiles$11),
76
+ files: withDefaultFiles(files, defaultFiles$10),
77
77
  name: "w5s/e18e/rules",
78
78
  rules: {
79
79
  ...modernization ? e18ePlugin.configs.modernization.rules : {},
@@ -102,7 +102,6 @@ const bestPractices = () => ({
102
102
  "default-case": ["error", { commentPattern: "^no default$" }],
103
103
  "default-case-last": "error",
104
104
  "default-param-last": "error",
105
- "dot-location": ["error", "property"],
106
105
  "dot-notation": ["error", { allowKeywords: true }],
107
106
  "eqeqeq": [
108
107
  "error",
@@ -155,7 +154,6 @@ const bestPractices = () => ({
155
154
  ignore: [],
156
155
  ignoreArrayIndexes: true
157
156
  }],
158
- "no-multi-spaces": ["error", { ignoreEOLComments: false }],
159
157
  "no-multi-str": "error",
160
158
  "no-native-reassign": "off",
161
159
  "no-new": "error",
@@ -300,17 +298,6 @@ const errors = () => ({
300
298
  "no-empty-character-class": "error",
301
299
  "no-ex-assign": "error",
302
300
  "no-extra-boolean-cast": "error",
303
- "no-extra-parens": [
304
- "off",
305
- "all",
306
- {
307
- conditionalAssign: true,
308
- enforceForArrowConditionals: false,
309
- ignoreJSX: "all",
310
- nestedBinaryExpressions: false,
311
- returnAssign: false
312
- }
313
- ],
314
301
  "no-extra-semi": "error",
315
302
  "no-func-assign": "error",
316
303
  "no-import-assign": "error",
@@ -344,21 +331,7 @@ const errors = () => ({
344
331
  //#endregion
345
332
  //#region src/rules/esRules/es6.ts
346
333
  const es6 = () => ({
347
- "arrow-body-style": [
348
- "error",
349
- "as-needed",
350
- { requireReturnForObjectLiteral: false }
351
- ],
352
- "arrow-parens": ["error", "always"],
353
- "arrow-spacing": ["error", {
354
- after: true,
355
- before: true
356
- }],
357
334
  "constructor-super": "error",
358
- "generator-star-spacing": ["error", {
359
- after: true,
360
- before: false
361
- }],
362
335
  "no-class-assign": "error",
363
336
  "no-confusing-arrow": ["error", { allowParens: true }],
364
337
  "no-const-assign": "error",
@@ -379,57 +352,17 @@ const es6 = () => ({
379
352
  ignoreImport: false
380
353
  }],
381
354
  "no-var": "error",
382
- "object-shorthand": [
383
- "error",
384
- "always",
385
- {
386
- avoidQuotes: true,
387
- ignoreConstructors: false
388
- }
389
- ],
390
- "prefer-arrow-callback": ["error", {
391
- allowNamedFunctions: false,
392
- allowUnboundThis: true
393
- }],
394
355
  "prefer-const": ["error", {
395
356
  destructuring: "any",
396
357
  ignoreReadBeforeAssign: true
397
358
  }],
398
- "prefer-destructuring": [
399
- "error",
400
- {
401
- AssignmentExpression: {
402
- array: true,
403
- object: false
404
- },
405
- VariableDeclarator: {
406
- array: false,
407
- object: true
408
- }
409
- },
410
- { enforceForRenamedProperties: false }
411
- ],
412
359
  "prefer-numeric-literals": "error",
413
360
  "prefer-reflect": "off",
414
361
  "prefer-rest-params": "error",
415
362
  "prefer-spread": "error",
416
363
  "prefer-template": "error",
417
364
  "require-yield": "error",
418
- "rest-spread-spacing": ["error", "never"],
419
- "sort-imports": ["off", {
420
- ignoreCase: false,
421
- ignoreDeclarationSort: false,
422
- ignoreMemberSort: false,
423
- memberSyntaxSortOrder: [
424
- "none",
425
- "all",
426
- "multiple",
427
- "single"
428
- ]
429
- }],
430
- "symbol-description": "error",
431
- "template-curly-spacing": "error",
432
- "yield-star-spacing": ["error", "after"]
365
+ "symbol-description": "error"
433
366
  });
434
367
  //#endregion
435
368
  //#region src/rules/esRules/overrides.ts
@@ -442,8 +375,7 @@ const overrides = () => ({
442
375
  "no-underscore-dangle": "off",
443
376
  "no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
444
377
  "no-use-before-define": ["error", "nofunc"],
445
- "no-void": ["error", { allowAsStatement: true }],
446
- "unicode-bom": ["error", "never"]
378
+ "no-void": ["error", { allowAsStatement: true }]
447
379
  });
448
380
  //#endregion
449
381
  //#region src/rules/esRules/strict.ts
@@ -494,7 +426,7 @@ const esRules = () => ({
494
426
  });
495
427
  //#endregion
496
428
  //#region src/config/es.ts
497
- const defaultFiles$10 = [esSourceGlob];
429
+ const defaultFiles$9 = [esSourceGlob];
498
430
  async function es(options) {
499
431
  const { recommended = true, rules = {} } = options;
500
432
  return [{
@@ -521,7 +453,7 @@ async function es(options) {
521
453
  linterOptions: { reportUnusedDisableDirectives: true },
522
454
  name: "w5s/es/setup"
523
455
  }, {
524
- files: defaultFiles$10,
456
+ files: defaultFiles$9,
525
457
  name: "w5s/es/rules",
526
458
  rules: {
527
459
  ...recommended ? es["recommended"] : {},
@@ -548,8 +480,10 @@ async function imports(options = {}) {
548
480
  const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
549
481
  const [importPlugin] = await Promise.all([interopDefault(import("eslint-plugin-import"))]);
550
482
  return [{
483
+ name: "w5s/import/setup",
484
+ plugins: { import: importPlugin }
485
+ }, {
551
486
  name: "w5s/import/rules",
552
- plugins: { import: importPlugin },
553
487
  rules: {
554
488
  ...recommended ? imports["recommended"] : {},
555
489
  ...stylisticEnabled ? imports["stylistic"] : {},
@@ -572,42 +506,70 @@ imports["recommended"] = {
572
506
  imports["stylistic"] = { "import/newline-after-import": ["error", { count: 1 }] };
573
507
  //#endregion
574
508
  //#region src/config/jsdoc.ts
575
- const defaultFiles$9 = [sourceGlob$1];
509
+ const defaultJsFiles = [esSourceGlob];
510
+ const defaultTsFiles = [tsSourceGlob];
576
511
  async function jsdoc(options = {}) {
577
512
  const [jsdocPlugin] = await Promise.all([interopDefault(import("eslint-plugin-jsdoc"))]);
578
513
  const { files, recommended = true, rules = {}, stylistic = true } = options;
579
514
  const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
580
- return [{
581
- name: "w5s/jsdoc/setup",
582
- plugins: { jsdoc: jsdocPlugin }
583
- }, {
584
- files: withDefaultFiles(files, defaultFiles$9),
585
- name: "w5s/jsdoc/rules",
586
- rules: {
587
- ...recommended ? jsdocPlugin.configs["flat/recommended-typescript-flavor"].rules : {},
588
- ...recommended ? {
589
- "jsdoc/no-undefined-types": "off",
590
- "jsdoc/require-hyphen-before-param-description": ["warn", "always"],
591
- "jsdoc/require-jsdoc": "off",
592
- "jsdoc/require-param-description": "off",
593
- "jsdoc/require-param-type": "off",
594
- "jsdoc/require-returns": "off",
595
- "jsdoc/valid-types": "off"
596
- } : {},
597
- ...stylisticEnabled ? {
598
- ...jsdocPlugin.configs["flat/stylistic-typescript"].rules,
599
- "jsdoc/check-alignment": "warn",
600
- "jsdoc/multiline-blocks": "warn",
601
- "jsdoc/tag-lines": [
602
- "warn",
603
- "any",
604
- { startLines: 1 }
605
- ]
606
- } : {},
607
- ...rules
515
+ const recommendedRules = recommended ? jsdocPlugin.configs["flat/recommended-typescript-flavor"].rules : {};
516
+ const stylisticRules = stylisticEnabled ? {
517
+ ...jsdocPlugin.configs["flat/stylistic-typescript"].rules,
518
+ "jsdoc/check-alignment": "warn",
519
+ "jsdoc/multiline-blocks": "warn",
520
+ "jsdoc/tag-lines": [
521
+ "warn",
522
+ "any",
523
+ { startLines: 1 }
524
+ ]
525
+ } : {};
526
+ return [
527
+ {
528
+ name: "w5s/jsdoc/setup",
529
+ plugins: { jsdoc: jsdocPlugin }
608
530
  },
609
- settings: { jsdoc: { mode: "typescript" } }
610
- }];
531
+ {
532
+ files: withDefaultFiles(files, defaultJsFiles),
533
+ name: "w5s/jsdoc/rules-js",
534
+ rules: {
535
+ ...recommendedRules,
536
+ ...recommended ? {
537
+ "jsdoc/no-undefined-types": "off",
538
+ "jsdoc/require-hyphen-before-param-description": ["warn", "always"],
539
+ "jsdoc/require-jsdoc": "off",
540
+ "jsdoc/require-param-description": "off",
541
+ "jsdoc/require-param-type": "off",
542
+ "jsdoc/require-returns": "off",
543
+ "jsdoc/require-returns-type": "off",
544
+ "jsdoc/valid-types": "off"
545
+ } : {},
546
+ ...stylisticRules,
547
+ ...rules
548
+ },
549
+ settings: { jsdoc: { mode: "typescript" } }
550
+ },
551
+ {
552
+ files: withDefaultFiles(files, defaultTsFiles),
553
+ name: "w5s/jsdoc/rules-ts",
554
+ rules: {
555
+ ...recommendedRules,
556
+ ...recommended ? {
557
+ "jsdoc/no-types": "warn",
558
+ "jsdoc/no-undefined-types": "off",
559
+ "jsdoc/require-hyphen-before-param-description": ["warn", "always"],
560
+ "jsdoc/require-jsdoc": "off",
561
+ "jsdoc/require-param-description": "off",
562
+ "jsdoc/require-param-type": "off",
563
+ "jsdoc/require-returns": "off",
564
+ "jsdoc/require-returns-type": "off",
565
+ "jsdoc/valid-types": "off"
566
+ } : {},
567
+ ...stylisticRules,
568
+ ...rules
569
+ },
570
+ settings: { jsdoc: { mode: "typescript" } }
571
+ }
572
+ ];
611
573
  }
612
574
  //#endregion
613
575
  //#region src/config/jsonc.ts
@@ -1048,7 +1010,6 @@ async function test(options = {}) {
1048
1010
  const tsRules = () => {
1049
1011
  const baseRules = esRules();
1050
1012
  return ESLintConfig.renameRules({
1051
- "@typescript-eslint/adjacent-overload-signatures": "error",
1052
1013
  "@typescript-eslint/ban-ts-comment": ["warn", {
1053
1014
  "minimumDescriptionLength": 3,
1054
1015
  "ts-check": false,
@@ -1056,37 +1017,14 @@ const tsRules = () => {
1056
1017
  "ts-ignore": "allow-with-description",
1057
1018
  "ts-nocheck": true
1058
1019
  }],
1059
- "@typescript-eslint/consistent-type-assertions": ["error", {
1060
- assertionStyle: "as",
1061
- objectLiteralTypeAssertions: "never"
1062
- }],
1063
1020
  "@typescript-eslint/default-param-last": baseRules["default-param-last"],
1064
1021
  "@typescript-eslint/explicit-function-return-type": "off",
1065
1022
  "@typescript-eslint/explicit-module-boundary-types": "off",
1066
- "@typescript-eslint/naming-convention": [
1067
- "error",
1068
- {
1069
- format: [
1070
- "PascalCase",
1071
- "camelCase",
1072
- "UPPER_CASE"
1073
- ],
1074
- leadingUnderscore: "allow",
1075
- selector: "variable",
1076
- trailingUnderscore: "allow"
1077
- },
1078
- {
1079
- format: ["PascalCase"],
1080
- selector: "typeLike"
1081
- }
1082
- ],
1083
1023
  "@typescript-eslint/no-dupe-class-members": baseRules["no-dupe-class-members"],
1084
1024
  "@typescript-eslint/no-empty-function": baseRules["no-empty-function"],
1085
1025
  "@typescript-eslint/no-empty-interface": ["error", { allowSingleExtends: true }],
1086
1026
  "@typescript-eslint/no-empty-object-type": "off",
1087
1027
  "@typescript-eslint/no-explicit-any": "off",
1088
- "@typescript-eslint/no-extra-parens": baseRules["no-extra-parens"],
1089
- "@typescript-eslint/no-inferrable-types": "error",
1090
1028
  "@typescript-eslint/no-loop-func": baseRules["no-loop-func"],
1091
1029
  "@typescript-eslint/no-loss-of-precision": baseRules["no-loss-of-precision"],
1092
1030
  "@typescript-eslint/no-magic-numbers": baseRules["no-magic-numbers"],
@@ -1101,7 +1039,6 @@ const tsRules = () => {
1101
1039
  "@typescript-eslint/no-unused-vars": baseRules["no-unused-vars"],
1102
1040
  "@typescript-eslint/no-use-before-define": baseRules["no-use-before-define"],
1103
1041
  "@typescript-eslint/no-useless-constructor": baseRules["no-useless-constructor"],
1104
- "@typescript-eslint/no-var-requires": "error",
1105
1042
  "@typescript-eslint/no-wrapper-object-types": "error",
1106
1043
  "@typescript-eslint/prefer-namespace-keyword": "error",
1107
1044
  "@typescript-eslint/require-await": baseRules["require-await"],
@@ -1118,6 +1055,7 @@ async function ts(options = {}) {
1118
1055
  const tsTypeCheckedRules = tsPlugin.configs["recommended-type-checked-only"].rules;
1119
1056
  const { files, rules = {}, stylistic = true, typeChecked = false } = options;
1120
1057
  const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
1058
+ const tsCustomRules = tsRules();
1121
1059
  return [
1122
1060
  {
1123
1061
  name: "w5s/ts/setup",
@@ -1133,8 +1071,33 @@ async function ts(options = {}) {
1133
1071
  rules: {
1134
1072
  ...ESLintConfig.renameRules(tsRecommendedRules, { "@typescript-eslint": "ts" }),
1135
1073
  ...ESLintConfig.renameRules(tsStrictRules, { "@typescript-eslint": "ts" }),
1136
- ...tsRules(),
1137
- ...stylisticEnabled ? {} : {},
1074
+ ...tsCustomRules,
1075
+ ...stylisticEnabled ? {
1076
+ ...ESLintConfig.renameRules(tsPlugin.configs["stylistic"]?.rules, { "@typescript-eslint": "ts" }),
1077
+ "ts/array-type": ["error", { default: "generic" }],
1078
+ "ts/consistent-type-assertions": ["error", {
1079
+ assertionStyle: "as",
1080
+ objectLiteralTypeAssertions: "allow"
1081
+ }],
1082
+ "ts/naming-convention": [
1083
+ "error",
1084
+ {
1085
+ format: [
1086
+ "PascalCase",
1087
+ "camelCase",
1088
+ "UPPER_CASE"
1089
+ ],
1090
+ leadingUnderscore: "allow",
1091
+ selector: "variable",
1092
+ trailingUnderscore: "allow"
1093
+ },
1094
+ {
1095
+ format: ["PascalCase"],
1096
+ selector: "typeLike"
1097
+ }
1098
+ ],
1099
+ "ts/no-empty-function": tsCustomRules["ts/no-empty-function"]
1100
+ } : {},
1138
1101
  ...rules
1139
1102
  }
1140
1103
  },
@@ -1150,7 +1113,7 @@ async function ts(options = {}) {
1150
1113
  const defaultFiles$1 = [sourceGlob$1];
1151
1114
  async function unicorn(options = {}) {
1152
1115
  const [unicornPlugin] = await Promise.all([interopDefault(import("eslint-plugin-unicorn"))]);
1153
- const { files = defaultFiles$1, recommended = true, rules = {}, stylistic = true } = options;
1116
+ const { files, recommended = true, rules = {}, stylistic = true } = options;
1154
1117
  const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
1155
1118
  return [
1156
1119
  {
@@ -1158,7 +1121,7 @@ async function unicorn(options = {}) {
1158
1121
  plugins: { unicorn: unicornPlugin }
1159
1122
  },
1160
1123
  {
1161
- files,
1124
+ files: withDefaultFiles(files, defaultFiles$1),
1162
1125
  name: "w5s/unicorn/rules",
1163
1126
  rules: {
1164
1127
  ...recommended && unicornPlugin.configs["unopinionated"].rules,
@@ -1239,19 +1202,19 @@ async function defineConfig(options = {}) {
1239
1202
  stylistic: stylisticOptions,
1240
1203
  ..._options
1241
1204
  });
1242
- const toOption = (optionsOrBoolean) => withDefaultStylistic(typeof optionsOrBoolean === "boolean" ? { enabled: optionsOrBoolean } : {
1243
- enabled: true,
1205
+ const toOption = (optionsOrBoolean, defaultEnabled = true) => withDefaultStylistic(typeof optionsOrBoolean === "boolean" ? { enabled: optionsOrBoolean } : optionsOrBoolean === void 0 ? { enabled: defaultEnabled } : {
1206
+ enabled: defaultEnabled,
1244
1207
  ...optionsOrBoolean
1245
1208
  });
1246
1209
  const includeEnabled = (factory, input) => input.enabled ? [factory(input)] : [];
1247
- return ESLintConfig.concat(...includeEnabled(e18e, toOption(plugins.e18e)), ...includeEnabled(es, toOption(plugins.es)), ...includeEnabled(ts, toOption(plugins.ts)), ...includeEnabled(ignores, toOption(options)), ...includeEnabled(jsonc, toOption(plugins.jsonc)), ...includeEnabled(jsdoc, toOption(plugins.jsdoc)), ...includeEnabled(react, toOption(plugins.react)), ...includeEnabled(stylistic, toOption(plugins.stylistic)), ...includeEnabled(imports, toOption(plugins.import)), ...includeEnabled(markdown, toOption(plugins.markdown)), ...includeEnabled(next, toOption(plugins.next)), ...includeEnabled(node, toOption(plugins.node)), ...includeEnabled(perfectionist, toOption(plugins.perfectionist)), ...includeEnabled(unicorn, toOption(plugins.unicorn)), ...includeEnabled(yml, toOption(plugins.yml)), ...includeEnabled(test, toOption(plugins.test)), ...rules ? [{ rules }] : []);
1210
+ return ESLintConfig.concat(...includeEnabled(e18e, toOption(plugins.e18e)), ...includeEnabled(es, toOption(plugins.es)), ...includeEnabled(ts, toOption(plugins.ts)), ...includeEnabled(ignores, toOption(options)), ...includeEnabled(jsonc, toOption(plugins.jsonc)), ...includeEnabled(jsdoc, toOption(plugins.jsdoc)), ...includeEnabled(react, toOption(plugins.react)), ...includeEnabled(stylistic, toOption(plugins.stylistic)), ...includeEnabled(imports, toOption(plugins.import)), ...includeEnabled(markdown, toOption(plugins.markdown)), ...includeEnabled(next, toOption(plugins.next, false)), ...includeEnabled(node, toOption(plugins.node)), ...includeEnabled(perfectionist, toOption(plugins.perfectionist)), ...includeEnabled(unicorn, toOption(plugins.unicorn)), ...includeEnabled(yml, toOption(plugins.yml)), ...includeEnabled(test, toOption(plugins.test)), ...rules ? [{ rules }] : []);
1248
1211
  }
1249
1212
  //#endregion
1250
1213
  //#region src/meta.ts
1251
1214
  const meta = Object.freeze({
1252
1215
  buildNumber: 1,
1253
1216
  name: "@w5s/eslint-config",
1254
- version: "3.12.0"
1217
+ version: "3.14.0"
1255
1218
  });
1256
1219
  //#endregion
1257
1220
  export { StylisticConfig, defineConfig as default, defineConfig, e18e, es, ignores, imports, jsdoc, jsonc, markdown, meta, next, node, perfectionist, react, stylistic, test, ts, unicorn, yml };