@lincy/eslint-config 4.0.0 → 4.0.2
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.cjs +78 -16
- package/dist/index.js +78 -16
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1030,9 +1030,13 @@ async function stylistic(options = {}) {
|
|
|
1030
1030
|
"style/jsx-first-prop-new-line": "error",
|
|
1031
1031
|
"style/jsx-indent": ["error", indent, { checkAttributes: true, indentLogicalExpressions: true }],
|
|
1032
1032
|
"style/jsx-indent-props": ["error", indent],
|
|
1033
|
-
"style/jsx-max-props-per-line": ["error", { maximum: 1
|
|
1033
|
+
"style/jsx-max-props-per-line": ["error", { maximum: 1 }],
|
|
1034
|
+
// 在 JSX 中的单行上强制执行最多 props 数量
|
|
1035
|
+
"style/jsx-newline": "off",
|
|
1036
|
+
// 在 jsx 元素和表达式之后换行
|
|
1034
1037
|
"style/jsx-one-expression-per-line": ["error", { allow: "single-child" }],
|
|
1035
|
-
"style/jsx-quotes": "error",
|
|
1038
|
+
"style/jsx-quotes": ["error", "prefer-double"],
|
|
1039
|
+
// 强制在 JSX 属性中一致使用双引号或单引号
|
|
1036
1040
|
"style/jsx-tag-spacing": ["error", {
|
|
1037
1041
|
afterOpening: "never",
|
|
1038
1042
|
beforeClosing: "never",
|
|
@@ -1524,40 +1528,100 @@ async function react(options = {}) {
|
|
|
1524
1528
|
},
|
|
1525
1529
|
name: "eslint:react:rules",
|
|
1526
1530
|
rules: {
|
|
1527
|
-
|
|
1528
|
-
|
|
1531
|
+
"react-hooks/exhaustive-deps": "warn",
|
|
1532
|
+
"react-hooks/rules-of-hooks": "error",
|
|
1533
|
+
"react/boolean-prop-naming": 2,
|
|
1534
|
+
"react/button-has-type": 2,
|
|
1535
|
+
"react/default-props-match-prop-types": 2,
|
|
1536
|
+
"react/destructuring-assignment": 2,
|
|
1537
|
+
"react/display-name": 2,
|
|
1529
1538
|
"react/forbid-component-props": "off",
|
|
1530
1539
|
// 禁止组件上使用某些 props
|
|
1540
|
+
"react/forbid-dom-props": 2,
|
|
1541
|
+
"react/forbid-elements": 2,
|
|
1542
|
+
"react/forbid-foreign-prop-types": 2,
|
|
1543
|
+
"react/forbid-prop-types": 2,
|
|
1544
|
+
"react/function-component-definition": 2,
|
|
1531
1545
|
"react/hook-use-state": "off",
|
|
1532
1546
|
// useState 钩子值和 setter 变量的解构和对称命名
|
|
1547
|
+
"react/iframe-missing-sandbox": 2,
|
|
1548
|
+
"react/jsx-boolean-value": 2,
|
|
1533
1549
|
"react/jsx-filename-extension": "off",
|
|
1534
1550
|
// 禁止可能包含 JSX 文件扩展名
|
|
1551
|
+
"react/jsx-fragments": 2,
|
|
1552
|
+
"react/jsx-handler-names": 2,
|
|
1553
|
+
"react/jsx-key": 2,
|
|
1535
1554
|
"react/jsx-max-depth": "off",
|
|
1536
1555
|
// 强制 JSX 最大深度
|
|
1537
1556
|
"react/jsx-no-bind": "off",
|
|
1538
1557
|
// .bind()JSX 属性中禁止使用箭头函数
|
|
1558
|
+
"react/jsx-no-comment-textnodes": 2,
|
|
1559
|
+
"react/jsx-no-constructed-context-values": 2,
|
|
1560
|
+
"react/jsx-no-duplicate-props": 2,
|
|
1561
|
+
"react/jsx-no-leaked-render": 2,
|
|
1539
1562
|
"react/jsx-no-literals": "off",
|
|
1540
1563
|
// 禁止在 JSX 中使用字符串文字
|
|
1564
|
+
"react/jsx-no-script-url": 2,
|
|
1565
|
+
"react/jsx-no-target-blank": 2,
|
|
1566
|
+
"react/jsx-no-undef": 2,
|
|
1567
|
+
"react/jsx-no-useless-fragment": 2,
|
|
1568
|
+
"react/jsx-pascal-case": 2,
|
|
1541
1569
|
"react/jsx-props-no-spreading": "off",
|
|
1542
1570
|
// 强制任何 JSX 属性都不会传播
|
|
1571
|
+
"react/jsx-uses-react": 2,
|
|
1572
|
+
"react/jsx-uses-vars": 2,
|
|
1573
|
+
"react/no-access-state-in-setstate": 2,
|
|
1574
|
+
"react/no-adjacent-inline-elements": 2,
|
|
1575
|
+
"react/no-array-index-key": 2,
|
|
1576
|
+
"react/no-arrow-function-lifecycle": 2,
|
|
1577
|
+
"react/no-children-prop": 2,
|
|
1543
1578
|
"react/no-danger": "off",
|
|
1544
1579
|
// 禁止使用 dangerouslySetInnerHTML
|
|
1580
|
+
"react/no-danger-with-children": 2,
|
|
1581
|
+
"react/no-deprecated": 2,
|
|
1582
|
+
"react/no-did-mount-set-state": 2,
|
|
1583
|
+
"react/no-did-update-set-state": 2,
|
|
1584
|
+
"react/no-direct-mutation-state": 2,
|
|
1585
|
+
"react/no-find-dom-node": 2,
|
|
1586
|
+
"react/no-invalid-html-attribute": 2,
|
|
1587
|
+
"react/no-is-mounted": 2,
|
|
1588
|
+
"react/no-multi-comp": 2,
|
|
1589
|
+
"react/no-namespace": 2,
|
|
1590
|
+
"react/no-object-type-as-default-prop": 2,
|
|
1591
|
+
"react/no-redundant-should-component-update": 2,
|
|
1592
|
+
"react/no-render-return-value": 2,
|
|
1593
|
+
"react/no-set-state": 2,
|
|
1594
|
+
"react/no-string-refs": 2,
|
|
1595
|
+
"react/no-this-in-sfc": 2,
|
|
1596
|
+
"react/no-typos": 2,
|
|
1597
|
+
"react/no-unescaped-entities": 2,
|
|
1598
|
+
"react/no-unknown-property": 2,
|
|
1545
1599
|
"react/no-unsafe": "off",
|
|
1546
1600
|
// 禁止使用不安全的生命周期方法
|
|
1601
|
+
"react/no-unstable-nested-components": 2,
|
|
1602
|
+
"react/no-unused-class-component-methods": 2,
|
|
1603
|
+
"react/no-unused-prop-types": 2,
|
|
1604
|
+
"react/no-unused-state": 2,
|
|
1605
|
+
"react/no-will-update-set-state": 2,
|
|
1606
|
+
"react/prefer-es6-class": 2,
|
|
1607
|
+
"react/prefer-exact-props": 2,
|
|
1608
|
+
"react/prefer-read-only-props": 2,
|
|
1609
|
+
"react/prefer-stateless-function": 2,
|
|
1610
|
+
"react/prop-types": 2,
|
|
1547
1611
|
"react/react-in-jsx-scope": "off",
|
|
1548
1612
|
// 使用 JSX 时需要引入 React
|
|
1549
1613
|
"react/require-default-props": "off",
|
|
1550
1614
|
// 为每个非必需 prop 强制执行 defaultProps 定义
|
|
1551
|
-
"
|
|
1552
|
-
|
|
1553
|
-
"
|
|
1554
|
-
|
|
1555
|
-
"
|
|
1556
|
-
|
|
1557
|
-
"
|
|
1558
|
-
|
|
1559
|
-
"style
|
|
1560
|
-
|
|
1615
|
+
"react/require-optimization": 2,
|
|
1616
|
+
"react/require-render-return": 2,
|
|
1617
|
+
"react/self-closing-comp": 2,
|
|
1618
|
+
"react/sort-comp": 2,
|
|
1619
|
+
"react/sort-default-props": 2,
|
|
1620
|
+
"react/sort-prop-types": 2,
|
|
1621
|
+
"react/state-in-constructor": 2,
|
|
1622
|
+
"react/static-property-placement": 2,
|
|
1623
|
+
"react/style-prop-object": 2,
|
|
1624
|
+
"react/void-dom-elements-no-children": 2,
|
|
1561
1625
|
...overrides
|
|
1562
1626
|
},
|
|
1563
1627
|
settings: {
|
|
@@ -1604,8 +1668,6 @@ async function lincy(options = {}, ...userConfigs) {
|
|
|
1604
1668
|
if (stylisticOptions) {
|
|
1605
1669
|
if (!("jsx" in stylisticOptions))
|
|
1606
1670
|
stylisticOptions.jsx = options.jsx ?? true;
|
|
1607
|
-
if (enableReact)
|
|
1608
|
-
stylisticOptions.jsx = false;
|
|
1609
1671
|
}
|
|
1610
1672
|
const configs = [];
|
|
1611
1673
|
if (enableGitignore) {
|
package/dist/index.js
CHANGED
|
@@ -950,9 +950,13 @@ async function stylistic(options = {}) {
|
|
|
950
950
|
"style/jsx-first-prop-new-line": "error",
|
|
951
951
|
"style/jsx-indent": ["error", indent, { checkAttributes: true, indentLogicalExpressions: true }],
|
|
952
952
|
"style/jsx-indent-props": ["error", indent],
|
|
953
|
-
"style/jsx-max-props-per-line": ["error", { maximum: 1
|
|
953
|
+
"style/jsx-max-props-per-line": ["error", { maximum: 1 }],
|
|
954
|
+
// 在 JSX 中的单行上强制执行最多 props 数量
|
|
955
|
+
"style/jsx-newline": "off",
|
|
956
|
+
// 在 jsx 元素和表达式之后换行
|
|
954
957
|
"style/jsx-one-expression-per-line": ["error", { allow: "single-child" }],
|
|
955
|
-
"style/jsx-quotes": "error",
|
|
958
|
+
"style/jsx-quotes": ["error", "prefer-double"],
|
|
959
|
+
// 强制在 JSX 属性中一致使用双引号或单引号
|
|
956
960
|
"style/jsx-tag-spacing": ["error", {
|
|
957
961
|
afterOpening: "never",
|
|
958
962
|
beforeClosing: "never",
|
|
@@ -1444,40 +1448,100 @@ async function react(options = {}) {
|
|
|
1444
1448
|
},
|
|
1445
1449
|
name: "eslint:react:rules",
|
|
1446
1450
|
rules: {
|
|
1447
|
-
|
|
1448
|
-
|
|
1451
|
+
"react-hooks/exhaustive-deps": "warn",
|
|
1452
|
+
"react-hooks/rules-of-hooks": "error",
|
|
1453
|
+
"react/boolean-prop-naming": 2,
|
|
1454
|
+
"react/button-has-type": 2,
|
|
1455
|
+
"react/default-props-match-prop-types": 2,
|
|
1456
|
+
"react/destructuring-assignment": 2,
|
|
1457
|
+
"react/display-name": 2,
|
|
1449
1458
|
"react/forbid-component-props": "off",
|
|
1450
1459
|
// 禁止组件上使用某些 props
|
|
1460
|
+
"react/forbid-dom-props": 2,
|
|
1461
|
+
"react/forbid-elements": 2,
|
|
1462
|
+
"react/forbid-foreign-prop-types": 2,
|
|
1463
|
+
"react/forbid-prop-types": 2,
|
|
1464
|
+
"react/function-component-definition": 2,
|
|
1451
1465
|
"react/hook-use-state": "off",
|
|
1452
1466
|
// useState 钩子值和 setter 变量的解构和对称命名
|
|
1467
|
+
"react/iframe-missing-sandbox": 2,
|
|
1468
|
+
"react/jsx-boolean-value": 2,
|
|
1453
1469
|
"react/jsx-filename-extension": "off",
|
|
1454
1470
|
// 禁止可能包含 JSX 文件扩展名
|
|
1471
|
+
"react/jsx-fragments": 2,
|
|
1472
|
+
"react/jsx-handler-names": 2,
|
|
1473
|
+
"react/jsx-key": 2,
|
|
1455
1474
|
"react/jsx-max-depth": "off",
|
|
1456
1475
|
// 强制 JSX 最大深度
|
|
1457
1476
|
"react/jsx-no-bind": "off",
|
|
1458
1477
|
// .bind()JSX 属性中禁止使用箭头函数
|
|
1478
|
+
"react/jsx-no-comment-textnodes": 2,
|
|
1479
|
+
"react/jsx-no-constructed-context-values": 2,
|
|
1480
|
+
"react/jsx-no-duplicate-props": 2,
|
|
1481
|
+
"react/jsx-no-leaked-render": 2,
|
|
1459
1482
|
"react/jsx-no-literals": "off",
|
|
1460
1483
|
// 禁止在 JSX 中使用字符串文字
|
|
1484
|
+
"react/jsx-no-script-url": 2,
|
|
1485
|
+
"react/jsx-no-target-blank": 2,
|
|
1486
|
+
"react/jsx-no-undef": 2,
|
|
1487
|
+
"react/jsx-no-useless-fragment": 2,
|
|
1488
|
+
"react/jsx-pascal-case": 2,
|
|
1461
1489
|
"react/jsx-props-no-spreading": "off",
|
|
1462
1490
|
// 强制任何 JSX 属性都不会传播
|
|
1491
|
+
"react/jsx-uses-react": 2,
|
|
1492
|
+
"react/jsx-uses-vars": 2,
|
|
1493
|
+
"react/no-access-state-in-setstate": 2,
|
|
1494
|
+
"react/no-adjacent-inline-elements": 2,
|
|
1495
|
+
"react/no-array-index-key": 2,
|
|
1496
|
+
"react/no-arrow-function-lifecycle": 2,
|
|
1497
|
+
"react/no-children-prop": 2,
|
|
1463
1498
|
"react/no-danger": "off",
|
|
1464
1499
|
// 禁止使用 dangerouslySetInnerHTML
|
|
1500
|
+
"react/no-danger-with-children": 2,
|
|
1501
|
+
"react/no-deprecated": 2,
|
|
1502
|
+
"react/no-did-mount-set-state": 2,
|
|
1503
|
+
"react/no-did-update-set-state": 2,
|
|
1504
|
+
"react/no-direct-mutation-state": 2,
|
|
1505
|
+
"react/no-find-dom-node": 2,
|
|
1506
|
+
"react/no-invalid-html-attribute": 2,
|
|
1507
|
+
"react/no-is-mounted": 2,
|
|
1508
|
+
"react/no-multi-comp": 2,
|
|
1509
|
+
"react/no-namespace": 2,
|
|
1510
|
+
"react/no-object-type-as-default-prop": 2,
|
|
1511
|
+
"react/no-redundant-should-component-update": 2,
|
|
1512
|
+
"react/no-render-return-value": 2,
|
|
1513
|
+
"react/no-set-state": 2,
|
|
1514
|
+
"react/no-string-refs": 2,
|
|
1515
|
+
"react/no-this-in-sfc": 2,
|
|
1516
|
+
"react/no-typos": 2,
|
|
1517
|
+
"react/no-unescaped-entities": 2,
|
|
1518
|
+
"react/no-unknown-property": 2,
|
|
1465
1519
|
"react/no-unsafe": "off",
|
|
1466
1520
|
// 禁止使用不安全的生命周期方法
|
|
1521
|
+
"react/no-unstable-nested-components": 2,
|
|
1522
|
+
"react/no-unused-class-component-methods": 2,
|
|
1523
|
+
"react/no-unused-prop-types": 2,
|
|
1524
|
+
"react/no-unused-state": 2,
|
|
1525
|
+
"react/no-will-update-set-state": 2,
|
|
1526
|
+
"react/prefer-es6-class": 2,
|
|
1527
|
+
"react/prefer-exact-props": 2,
|
|
1528
|
+
"react/prefer-read-only-props": 2,
|
|
1529
|
+
"react/prefer-stateless-function": 2,
|
|
1530
|
+
"react/prop-types": 2,
|
|
1467
1531
|
"react/react-in-jsx-scope": "off",
|
|
1468
1532
|
// 使用 JSX 时需要引入 React
|
|
1469
1533
|
"react/require-default-props": "off",
|
|
1470
1534
|
// 为每个非必需 prop 强制执行 defaultProps 定义
|
|
1471
|
-
"
|
|
1472
|
-
|
|
1473
|
-
"
|
|
1474
|
-
|
|
1475
|
-
"
|
|
1476
|
-
|
|
1477
|
-
"
|
|
1478
|
-
|
|
1479
|
-
"style
|
|
1480
|
-
|
|
1535
|
+
"react/require-optimization": 2,
|
|
1536
|
+
"react/require-render-return": 2,
|
|
1537
|
+
"react/self-closing-comp": 2,
|
|
1538
|
+
"react/sort-comp": 2,
|
|
1539
|
+
"react/sort-default-props": 2,
|
|
1540
|
+
"react/sort-prop-types": 2,
|
|
1541
|
+
"react/state-in-constructor": 2,
|
|
1542
|
+
"react/static-property-placement": 2,
|
|
1543
|
+
"react/style-prop-object": 2,
|
|
1544
|
+
"react/void-dom-elements-no-children": 2,
|
|
1481
1545
|
...overrides
|
|
1482
1546
|
},
|
|
1483
1547
|
settings: {
|
|
@@ -1524,8 +1588,6 @@ async function lincy(options = {}, ...userConfigs) {
|
|
|
1524
1588
|
if (stylisticOptions) {
|
|
1525
1589
|
if (!("jsx" in stylisticOptions))
|
|
1526
1590
|
stylisticOptions.jsx = options.jsx ?? true;
|
|
1527
|
-
if (enableReact)
|
|
1528
|
-
stylisticOptions.jsx = false;
|
|
1529
1591
|
}
|
|
1530
1592
|
const configs = [];
|
|
1531
1593
|
if (enableGitignore) {
|
package/package.json
CHANGED