@moso/eslint-config 1.0.2 → 1.0.3

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +841 -278
  2. package/dist/index.js +157 -54
  3. package/package.json +15 -14
package/dist/index.js CHANGED
@@ -339,6 +339,7 @@ var javascript = async (options = {}) => {
339
339
  "no-nonoctal-decimal-escape": "error",
340
340
  "no-obj-calls": "error",
341
341
  "no-octal": "error",
342
+ "no-param-reassign": "error",
342
343
  "no-prototype-builtins": "error",
343
344
  "no-redeclare": ["error", { builtinGlobals: true }],
344
345
  "no-regex-spaces": "error",
@@ -736,22 +737,82 @@ var react = async (options = {}) => {
736
737
  },
737
738
  name: "moso/react/rules",
738
739
  rules: {
740
+ // Recommended rules from @eslint-react/react-x
741
+ // @see https://eslint-react.xyz/docs/rules/overview#core-rules
742
+ "@eslint-react/jsx-no-duplicate-props": "error",
743
+ "@eslint-react/jsx-no-undef": "error",
744
+ "@eslint-react/no-access-state-in-setstate": "error",
745
+ "@eslint-react/no-array-index-key": "warn",
746
+ "@eslint-react/no-children-count": "warn",
747
+ "@eslint-react/no-children-for-each": "warn",
748
+ "@eslint-react/no-children-map": "warn",
749
+ "@eslint-react/no-children-only": "warn",
750
+ "@eslint-react/no-children-to-array": "warn",
751
+ "@eslint-react/no-clone-element": "warn",
752
+ "@eslint-react/no-comment-textnodes": "warn",
753
+ "@eslint-react/no-component-will-mount": "error",
754
+ "@eslint-react/no-component-will-receive-props": "error",
755
+ "@eslint-react/no-component-will-update": "error",
756
+ "@eslint-react/no-context-provider": "warn",
757
+ "@eslint-react/no-create-ref": "error",
758
+ "@eslint-react/no-default-props": "error",
759
+ "@eslint-react/no-direct-mutation-state": "error",
760
+ "@eslint-react/no-duplicate-jsx-props": "warn",
761
+ "@eslint-react/no-duplicate-key": "warn",
762
+ "@eslint-react/no-forward-ref": "warn",
763
+ "@eslint-react/no-implicit-key": "warn",
764
+ "@eslint-react/no-missing-key": "error",
765
+ "@eslint-react/no-nested-component-definitions": "error",
766
+ "@eslint-react/no-prop-types": "error",
767
+ "@eslint-react/no-redundant-should-component-update": "error",
768
+ "@eslint-react/no-set-state-in-component-did-mount": "warn",
769
+ "@eslint-react/no-set-state-in-component-did-update": "warn",
770
+ "@eslint-react/no-set-state-in-component-will-update": "warn",
771
+ "@eslint-react/no-string-refs": "error",
772
+ "@eslint-react/no-unsafe-component-will-mount": "warn",
773
+ "@eslint-react/no-unsafe-component-will-receive-props": "warn",
774
+ "@eslint-react/no-unsafe-component-will-update": "warn",
775
+ "@eslint-react/no-unstable-context-value": "warn",
776
+ "@eslint-react/no-unstable-default-props": "warn",
777
+ "@eslint-react/no-unused-class-component-members": "warn",
778
+ "@eslint-react/no-unused-state": "warn",
779
+ "@eslint-react/no-use-context": "warn",
780
+ "@eslint-react/no-useless-forward-ref": "warn",
781
+ "@eslint-react/use-jsx-vars": "warn",
739
782
  // Recommended rules from @eslint-react/dom
783
+ // @see https://eslint-react.xyz/docs/rules/overview#dom-rules
740
784
  "@eslint-react/dom/no-dangerously-set-innerhtml": "warn",
741
785
  "@eslint-react/dom/no-dangerously-set-innerhtml-with-children": "error",
742
786
  "@eslint-react/dom/no-find-dom-node": "error",
787
+ "@eslint-react/dom/no-flush-sync": "error",
788
+ "@eslint-react/dom/no-hydrate": "error",
743
789
  "@eslint-react/dom/no-missing-button-type": "warn",
744
790
  "@eslint-react/dom/no-missing-iframe-sandbox": "warn",
745
791
  "@eslint-react/dom/no-namespace": "error",
792
+ "@eslint-react/dom/no-render": "error",
746
793
  "@eslint-react/dom/no-render-return-value": "error",
747
794
  "@eslint-react/dom/no-script-url": "warn",
748
795
  "@eslint-react/dom/no-unsafe-iframe-sandbox": "warn",
749
796
  "@eslint-react/dom/no-unsafe-target-blank": "warn",
750
- "@eslint-react/dom/no-void-elements-with-children": "warn",
797
+ "@eslint-react/dom/no-use-form-state": "error",
798
+ "@eslint-react/dom/no-void-elements-with-children": "error",
751
799
  // Recommended rules for eslint-plugin-react-hooks
800
+ // @see https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks/src/rules
752
801
  "react-hooks/exhaustive-deps": "warn",
753
802
  "react-hooks/rules-of-hooks": "error",
754
- // react-refresh
803
+ // Recommended rules for eslint-plugin-react-hooks-extra
804
+ // @see https://eslint-react.xyz/docs/rules/overview#hooks-extra-rules
805
+ "@eslint-react/hooks-extra/no-direct-set-state-in-use-effect": "warn",
806
+ "@eslint-react/hooks-extra/no-useless-custom-hooks": "warn",
807
+ "@eslint-react/hooks-extra/prefer-use-state-lazy-initialization": "warn",
808
+ // Recommended rules from @eslint-react/web-api
809
+ // @see https://eslint-react.xyz/docs/rules/overview#web-api-rules
810
+ "@eslint-react/web-api/no-leaked-event-listener": "warn",
811
+ "@eslint-react/web-api/no-leaked-interval": "warn",
812
+ "@eslint-react/web-api/no-leaked-resize-observer": "warn",
813
+ "@eslint-react/web-api/no-leaked-timeout": "warn",
814
+ // Preconfigured rules from eslint-plugin-react-refresh
815
+ // @see https://github.com/ArnaudBarre/eslint-plugin-react-refresh/tree/main/src
755
816
  "react-refresh/only-export-components": [
756
817
  "warn",
757
818
  {
@@ -782,55 +843,11 @@ var react = async (options = {}) => {
782
843
  ]
783
844
  }
784
845
  ],
785
- // Recommended rules from @eslint-react/web-api
786
- // @see https://github.com/Rel1cx/eslint-react/blob/main/packages/plugins/eslint-plugin/src/configs/web-api.ts
787
- "@eslint-react/web-api/no-leaked-event-listener": "warn",
788
- "@eslint-react/web-api/no-leaked-interval": "warn",
789
- "@eslint-react/web-api/no-leaked-resize-observer": "warn",
790
- "@eslint-react/web-api/no-leaked-timeout": "warn",
791
- // Recommended rules from @eslint-react
792
- // @see https://github.com/Rel1cx/eslint-react/blob/main/packages/plugins/eslint-plugin/src/configs/core.ts
793
- "@eslint-react/ensure-forward-ref-using-ref": "warn",
794
- "@eslint-react/no-access-state-in-setstate": "error",
795
- "@eslint-react/no-array-index-key": "warn",
796
- "@eslint-react/no-children-count": "warn",
797
- "@eslint-react/no-children-for-each": "warn",
798
- "@eslint-react/no-children-map": "warn",
799
- "@eslint-react/no-children-only": "warn",
800
- "@eslint-react/no-children-to-array": "warn",
801
- "@eslint-react/no-clone-element": "warn",
802
- "@eslint-react/no-comment-textnodes": "warn",
803
- "@eslint-react/no-component-will-mount": "error",
804
- "@eslint-react/no-component-will-receive-props": "error",
805
- "@eslint-react/no-component-will-update": "error",
806
- "@eslint-react/no-context-provider": "warn",
807
- "@eslint-react/no-create-ref": "error",
808
- "@eslint-react/no-default-props": "error",
809
- "@eslint-react/no-direct-mutation-state": "error",
810
- "@eslint-react/no-duplicate-key": "error",
811
- "@eslint-react/no-forward-ref": "warn",
812
- "@eslint-react/no-implicit-key": "warn",
813
- "@eslint-react/no-missing-key": "error",
814
- "@eslint-react/no-nested-components": "error",
815
- "@eslint-react/no-prop-types": "error",
816
- "@eslint-react/no-redundant-should-component-update": "error",
817
- "@eslint-react/no-set-state-in-component-did-mount": "warn",
818
- "@eslint-react/no-set-state-in-component-did-update": "warn",
819
- "@eslint-react/no-set-state-in-component-will-update": "warn",
820
- "@eslint-react/no-string-refs": "error",
821
- "@eslint-react/no-unsafe-component-will-mount": "warn",
822
- "@eslint-react/no-unsafe-component-will-receive-props": "warn",
823
- "@eslint-react/no-unsafe-component-will-update": "warn",
824
- "@eslint-react/no-unstable-context-value": "warn",
825
- "@eslint-react/no-unstable-default-props": "warn",
826
- "@eslint-react/no-unused-class-component-members": "warn",
827
- "@eslint-react/no-unused-state": "warn",
828
- "@eslint-react/use-jsx-vars": "warn",
829
- "@eslint-react/hooks-extra/no-direct-set-state-in-use-effect": "warn",
830
- "@eslint-react/hooks-extra/no-useless-custom-hooks": "warn",
831
- "@eslint-react/hooks-extra/prefer-use-state-lazy-initialization": "warn",
846
+ // @moso's rules
832
847
  "@eslint-react/naming-convention/context-name": "warn",
833
848
  "@eslint-react/naming-convention/use-state": "warn",
849
+ "@eslint-react/ensure-forward-ref-using-ref": "warn",
850
+ "@eslint-react/no-nested-components": "error",
834
851
  "@eslint-react/prefer-destructuring-assignment": "warn",
835
852
  "@eslint-react/prefer-shorthand-boolean": "warn",
836
853
  "@eslint-react/prefer-shorthand-fragment": "warn",
@@ -877,6 +894,7 @@ var sortPackageJson = () => {
877
894
  "packageManager",
878
895
  "description",
879
896
  "author",
897
+ "contributors",
880
898
  "license",
881
899
  "funding",
882
900
  "homepage",
@@ -990,6 +1008,7 @@ var sortTsconfig = () => {
990
1008
  "useDefineForClassFields",
991
1009
  "emitDecoratorMetadata",
992
1010
  "experimentalDecorators",
1011
+ "libReplacement",
993
1012
  "baseUrl",
994
1013
  "rootDir",
995
1014
  "rootDirs",
@@ -1058,6 +1077,7 @@ var sortTsconfig = () => {
1058
1077
  "isolatedModules",
1059
1078
  "preserveSymlinks",
1060
1079
  "verbatimModuleSyntax",
1080
+ "erasableSyntaxOnly",
1061
1081
  "skipDefaultLibCheck",
1062
1082
  "skipLibCheck"
1063
1083
  ],
@@ -1251,6 +1271,7 @@ import process2 from "node:process";
1251
1271
  var typescript = async (options = {}) => {
1252
1272
  const {
1253
1273
  componentExts = [],
1274
+ lessOpinionated = false,
1254
1275
  overrides = {},
1255
1276
  overridesTypeAware = {},
1256
1277
  parserOptions = {}
@@ -1288,19 +1309,82 @@ var typescript = async (options = {}) => {
1288
1309
  "@typescript-eslint/no-unsafe-assignment": "error",
1289
1310
  "@typescript-eslint/no-unsafe-call": "error",
1290
1311
  "@typescript-eslint/no-unsafe-member-access": "error",
1291
- "@typescript-eslint/no-unsafe-return": "error",
1292
1312
  "@typescript-eslint/only-throw-error": "error",
1293
1313
  "@typescript-eslint/parameter-properties": "off",
1294
1314
  "@typescript-eslint/restrict-plus-operands": "error",
1295
1315
  "@typescript-eslint/restrict-template-expressions": "error",
1296
- "@typescript-eslint/unbound-method": "error"
1316
+ "@typescript-eslint/unbound-method": "error",
1317
+ ...lessOpinionated ? {} : {
1318
+ // Opinionated TypeScript
1319
+ "@typescript-eslint/no-unsafe-return": "error",
1320
+ "@typescript-eslint/switch-exhaustiveness-check": [
1321
+ "error",
1322
+ {
1323
+ considerDefaultExhaustiveForUnions: true
1324
+ }
1325
+ ],
1326
+ // Opinionated Functional
1327
+ // @see https://github.com/eslint-functional/eslint-plugin-functional
1328
+ "functional/no-mixed-types": "error",
1329
+ "functional/prefer-property-signatures": "error",
1330
+ "functional/readonly-type": "error",
1331
+ "functional/type-declaration-immutability": [
1332
+ "error",
1333
+ {
1334
+ rules: [
1335
+ {
1336
+ identifiers: "I?Immutable.+",
1337
+ immutability: "Immutable",
1338
+ comparator: "AtLeast"
1339
+ },
1340
+ {
1341
+ identifiers: "I?ReadonlyDeep.+",
1342
+ immutability: "ReadonlyDeep",
1343
+ comparator: "AtLeast"
1344
+ },
1345
+ {
1346
+ identifiers: "I?Readonly.+",
1347
+ immutability: "ReadonlyShallow",
1348
+ comparator: "AtLeast",
1349
+ fixer: [
1350
+ {
1351
+ pattern: "^(Array|Map|Set)<(.+)>$",
1352
+ replace: "Readonly$1<$2>"
1353
+ },
1354
+ {
1355
+ pattern: "^(.+)$",
1356
+ replace: "Readonly<$1>"
1357
+ }
1358
+ ]
1359
+ },
1360
+ {
1361
+ identifiers: "I?Mutable.+",
1362
+ immutability: "Mutable",
1363
+ comparator: "AtMost",
1364
+ fixer: [
1365
+ {
1366
+ pattern: "^Readonly(Array|Map|Set)<(.+)>$",
1367
+ replace: "$1<$2>"
1368
+ },
1369
+ {
1370
+ pattern: "^Readonly<(.+)>$",
1371
+ replace: "$1"
1372
+ }
1373
+ ]
1374
+ }
1375
+ ]
1376
+ }
1377
+ ]
1378
+ }
1297
1379
  };
1298
1380
  const [
1299
1381
  antfuPlugin,
1382
+ functionalPlugin,
1300
1383
  typeScriptParser,
1301
1384
  typeScriptPlugin
1302
1385
  ] = await Promise.all([
1303
1386
  interopDefault(import("eslint-plugin-antfu")),
1387
+ interopDefault(import("eslint-plugin-functional")),
1304
1388
  interopDefault(import("@typescript-eslint/parser")),
1305
1389
  interopDefault(import("@typescript-eslint/eslint-plugin"))
1306
1390
  ]);
@@ -1315,7 +1399,7 @@ var typescript = async (options = {}) => {
1315
1399
  sourceType: "module",
1316
1400
  ...typeAware ? {
1317
1401
  projectService: {
1318
- allowDefaultProject: ["./*.js"],
1402
+ allowDefaultProject: ["./*.js", "./*.ts"],
1319
1403
  defaultProject: tsconfigPath
1320
1404
  },
1321
1405
  tsconfigRootDir: process2.cwd()
@@ -1331,6 +1415,7 @@ var typescript = async (options = {}) => {
1331
1415
  name: "moso/typescript/setup",
1332
1416
  plugins: {
1333
1417
  "antfu": antfuPlugin,
1418
+ "functional": functionalPlugin,
1334
1419
  "@typescript-eslint": typeScriptPlugin
1335
1420
  }
1336
1421
  },
@@ -1347,9 +1432,12 @@ var typescript = async (options = {}) => {
1347
1432
  ...typeScriptPlugin.configs["eslint-recommended"].overrides[0].rules,
1348
1433
  ...typeScriptPlugin.configs.strict.rules,
1349
1434
  // JS off
1435
+ "no-dupe-class-members": "off",
1436
+ "no-redeclare": "off",
1350
1437
  "no-loss-of-precision": "off",
1351
1438
  "no-unused-vars": "off",
1352
1439
  "no-use-before-define": "off",
1440
+ "no-useless-constructor": "off",
1353
1441
  // Stylistic
1354
1442
  "@stylistic/type-annotation-spacing": "error",
1355
1443
  // Typescript
@@ -1359,7 +1447,6 @@ var typescript = async (options = {}) => {
1359
1447
  "ts-ignore": "allow-with-description"
1360
1448
  }
1361
1449
  ],
1362
- "@typescript-eslint/consistent-type-definitions": ["error", "interface"],
1363
1450
  "@typescript-eslint/consistent-type-imports": [
1364
1451
  "error",
1365
1452
  {
@@ -1369,12 +1456,21 @@ var typescript = async (options = {}) => {
1369
1456
  ],
1370
1457
  "@typescript-eslint/method-signature-style": ["error", "property"],
1371
1458
  "@typescript-eslint/no-dynamic-delete": "off",
1459
+ "@typescript-eslint/no-empty-object-type": ["error", { allowInterfaces: "always" }],
1372
1460
  "@typescript-eslint/no-explicit-any": "off",
1373
1461
  "@typescript-eslint/no-extraneous-class": "off",
1374
1462
  "@typescript-eslint/no-import-type-side-effects": "error",
1375
1463
  "@typescript-eslint/no-invalid-void-type": "off",
1376
1464
  "@typescript-eslint/no-non-null-assertion": "off",
1377
1465
  "@typescript-eslint/no-require-imports": "error",
1466
+ "@typescript-eslint/no-unused-expressions": [
1467
+ "error",
1468
+ {
1469
+ allowShortCircuit: true,
1470
+ allowTaggedTemplates: true,
1471
+ allowTernary: true
1472
+ }
1473
+ ],
1378
1474
  "@typescript-eslint/no-unused-vars": [
1379
1475
  "error",
1380
1476
  {
@@ -1447,6 +1543,7 @@ var unicorn = async (options = {}) => {
1447
1543
  "unicorn/consistent-empty-array-spread": "error",
1448
1544
  "unicorn/error-message": "error",
1449
1545
  "unicorn/escape-case": "error",
1546
+ "unicorn/no-instanceof-builtins": "error",
1450
1547
  "unicorn/no-new-array": "error",
1451
1548
  "unicorn/no-new-buffer": "error",
1452
1549
  "unicorn/number-literal-case": "error",
@@ -1551,7 +1648,13 @@ var vue = async (options = {}) => {
1551
1648
  "vue/dot-notation": ["error", { allowKeywords: true }],
1552
1649
  "vue/eqeqeq": ["error", "smart"],
1553
1650
  "vue/html-indent": ["error", indent],
1554
- "vue/html-quotes": ["error", "double"],
1651
+ "vue/html-quotes": [
1652
+ "error",
1653
+ "double",
1654
+ {
1655
+ avoidEscape: true
1656
+ }
1657
+ ],
1555
1658
  "vue/html-self-closing": "off",
1556
1659
  "vue/max-attributes-per-line": ["warn", { singleline: 5 }],
1557
1660
  "vue/multi-word-component-names": "off",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@moso/eslint-config",
3
3
  "type": "module",
4
- "version": "1.0.2",
4
+ "version": "1.0.3",
5
5
  "packageManager": "bun@1.2.5",
6
6
  "description": "moso's shared ESLint config",
7
7
  "author": {
@@ -52,24 +52,25 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
55
- "@eslint-react/eslint-plugin": "^1.34.1",
55
+ "@eslint-react/eslint-plugin": "^1.38.0",
56
56
  "@stylistic/eslint-plugin": "^4.2.0",
57
- "@typescript-eslint/eslint-plugin": "^8.26.1",
58
- "@typescript-eslint/parser": "^8.26.1",
59
- "@vitest/eslint-plugin": "^1.1.37",
57
+ "@typescript-eslint/eslint-plugin": "^8.28.0",
58
+ "@typescript-eslint/parser": "^8.28.0",
59
+ "@vitest/eslint-plugin": "^1.1.38",
60
60
  "eslint-config-flat-gitignore": "^2.1.0",
61
61
  "eslint-flat-config-utils": "^2.0.1",
62
62
  "eslint-merge-processors": "^2.0.0",
63
63
  "eslint-plugin-antfu": "^3.1.1",
64
- "eslint-plugin-import-x": "^4.8.0",
65
- "eslint-plugin-jsdoc": "^50.6.6",
64
+ "eslint-plugin-functional": "^9.0.1",
65
+ "eslint-plugin-import-x": "^4.9.1",
66
+ "eslint-plugin-jsdoc": "^50.6.9",
66
67
  "eslint-plugin-jsonc": "^2.19.1",
67
68
  "eslint-plugin-n": "^17.16.2",
68
69
  "eslint-plugin-no-only-tests": "^3.3.0",
69
70
  "eslint-plugin-perfectionist": "^4.10.1",
70
71
  "eslint-plugin-react-hooks": "^5.2.0",
71
72
  "eslint-plugin-react-refresh": "^0.4.19",
72
- "eslint-plugin-unicorn": "^57.0.0",
73
+ "eslint-plugin-unicorn": "^58.0.0",
73
74
  "eslint-plugin-unused-imports": "^4.1.4",
74
75
  "eslint-plugin-vue": "^10.0.0",
75
76
  "eslint-plugin-yml": "^1.17.0",
@@ -86,23 +87,23 @@
86
87
  "@eslint-types/unicorn": "^52.0.0",
87
88
  "@eslint/config-inspector": "^1.0.2",
88
89
  "@types/eslint": "^9.6.1",
89
- "@types/node": "^22.13.10",
90
+ "@types/node": "^22.13.13",
90
91
  "bumpp": "^10.1.0",
91
- "eslint": "^9.22.0",
92
+ "eslint": "^9.23.0",
92
93
  "eslint-typegen": "^2.1.0",
93
94
  "jiti": "^2.4.2",
94
95
  "lint-staged": "^15.5.0",
95
- "simple-git-hooks": "^2.11.1",
96
+ "simple-git-hooks": "^2.12.1",
96
97
  "tsup": "^8.4.0",
97
98
  "tsx": "^4.19.3",
98
99
  "typescript": "^5.8.2",
99
- "vitest": "^3.0.8",
100
+ "vitest": "^3.0.9",
100
101
  "vue": "^3.5.13"
101
102
  },
102
103
  "resolutions": {
103
104
  "@eslint-community/eslint-utils": "^4.4.1",
104
- "@typescript-eslint/utils": "^8.26.1",
105
- "eslint": "^9.22.0",
105
+ "@typescript-eslint/utils": "^8.28.0",
106
+ "eslint": "^9.23.0",
106
107
  "tsx": "^4.19.3"
107
108
  },
108
109
  "simple-git-hooks": {