@modern-js-app/eslint-config 1.2.5 → 1.2.8

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/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # @modern-js-app/eslint-config
2
2
 
3
+ ## 1.2.8
4
+
5
+ ### Patch Changes
6
+
7
+ - 6cffe99d: chore:
8
+ remove react eslint rules for `modern-js` rule set.
9
+ add .eslintrc for each package to speed up linting
10
+ - Updated dependencies [6cffe99d]
11
+ - Updated dependencies [04ae5262]
12
+ - Updated dependencies [60f7d8bf]
13
+ - @modern-js/babel-preset-app@1.2.7
14
+
15
+ ## 1.2.7
16
+
17
+ ### Patch Changes
18
+
19
+ - d6522e85: feat: remove max-params and max-statements rule
20
+ - Updated dependencies [17d0cc46]
21
+ - @modern-js/babel-preset-app@1.2.6
22
+
23
+ ## 1.2.6
24
+
25
+ ### Patch Changes
26
+
27
+ - 8e737893: feat: disable promise/prefer-await-to-then
28
+ - 8e737893: feat: disable require-atomic-updates
29
+ - a2761eb7: fix: exclude modern.config.ts from with type rules
30
+ - 8e737893: feat: disable no-shadow
31
+ - 8e737893: feat: disable @typescript-eslint/no-base-to-string
32
+ - 8e737893: feat: disable filenames/match-exported
33
+ - Updated dependencies [9d4a005b]
34
+ - @modern-js/babel-preset-app@1.2.5
35
+
3
36
  ## 1.2.5
4
37
 
5
38
  ### Patch Changes
package/base.js CHANGED
@@ -1,5 +1,4 @@
1
- /* eslint-disable max-lines, no-magic-numbers */
2
-
1
+ /* eslint-disable max-lines */
3
2
  const { jsExtensions } = require('./utils');
4
3
 
5
4
  module.exports = {
@@ -9,7 +8,6 @@ module.exports = {
9
8
  ecmaVersion: 8,
10
9
  ecmaFeatures: {
11
10
  impliedStrict: true,
12
- jsx: true,
13
11
  },
14
12
  sourceType: 'module',
15
13
  babelOptions: {
@@ -36,10 +34,6 @@ module.exports = {
36
34
  plugins: [
37
35
  // https://www.npmjs.com/package/@babel/eslint-plugin
38
36
  '@babel',
39
- // https://www.npmjs.com/package/eslint-plugin-react
40
- 'react',
41
- // https://www.npmjs.com/package/eslint-plugin-react-hooks
42
- 'react-hooks',
43
37
  // https://www.npmjs.com/package/eslint-plugin-import
44
38
  'import',
45
39
  // https://www.npmjs.com/package/eslint-plugin-eslint-comments
@@ -59,7 +53,6 @@ module.exports = {
59
53
  extends: [
60
54
  // https://eslint.org/docs/user-guide/configuring#using-eslintrecommended
61
55
  'eslint:recommended',
62
- 'plugin:react/recommended',
63
56
  'plugin:import/errors',
64
57
  'plugin:import/warnings',
65
58
  'plugin:eslint-comments/recommended',
@@ -97,7 +90,7 @@ module.exports = {
97
90
 
98
91
  /*
99
92
  * https://eslint.org/docs/rules/no-debugger
100
- * @TIPS: for non-VSCode users, please use `debugger // eslint-disable-line`
93
+ * @TIPS: for non-VS Code users, please use `debugger // eslint-disable-line`
101
94
  * instead of `debugger` to avoid it to be removed by IDE's autoFixOnSave feature
102
95
  */
103
96
  'no-debugger': 'error',
@@ -155,10 +148,6 @@ module.exports = {
155
148
  'no-unsafe-finally': 'error',
156
149
  // https://eslint.org/docs/rules/no-unsafe-negation
157
150
  'no-unsafe-negation': 'error',
158
- // https://eslint.org/docs/rules/require-atomic-updates
159
- // @bug https://github.com/eslint/eslint/issues/11899
160
- 'require-atomic-updates': 'warn',
161
- // 'require-atomic-updates': 'error',
162
151
  // https://eslint.org/docs/rules/use-isnan
163
152
  'use-isnan': 'error',
164
153
  // https://eslint.org/docs/rules/valid-typeof
@@ -427,17 +416,6 @@ module.exports = {
427
416
  // @CUSTOM
428
417
  ],
429
418
 
430
- /*
431
- * https://eslint.org/docs/rules/no-shadow
432
- * "no-shadow": "off",
433
- */
434
- 'no-shadow': [
435
- 'error',
436
- {
437
- builtinGlobals: false,
438
- allow: [],
439
- },
440
- ],
441
419
  // https://eslint.org/docs/rules/no-shadow-restricted-names
442
420
  'no-shadow-restricted-names': 'error',
443
421
  // https://eslint.org/docs/rules/no-undef
@@ -634,28 +612,11 @@ module.exports = {
634
612
  skipComments: true,
635
613
  },
636
614
  ],
637
- // https://eslint.org/docs/rules/max-lines-per-function
638
- 'max-lines-per-function': 'off',
639
615
 
640
616
  /*
641
- * 'max-lines-per-function': [
642
- * 'error',
643
- * {
644
- * max: 50,
645
- * skipBlankLines: true,
646
- * skipComments: true,
647
- * IIFEs: true,
648
- * },
649
- * ],
650
617
  * https://eslint.org/docs/rules/max-nested-callbacks
651
618
  */
652
619
  'max-nested-callbacks': ['warn', 4],
653
- // https://eslint.org/docs/rules/max-params
654
- 'max-params': ['warn', 4],
655
- // https://eslint.org/docs/rules/max-statements
656
- 'max-statements': ['warn', 20],
657
- // https://eslint.org/docs/rules/max-statements-per-line
658
- 'max-statements-per-line': ['error', { max: 1 }],
659
620
  // https://eslint.org/docs/rules/multiline-comment-style
660
621
  // @TODO bug:
661
622
  // // class Foo {
@@ -998,166 +959,6 @@ module.exports = {
998
959
  },
999
960
  ],
1000
961
 
1001
- /*
1002
- * react
1003
- * https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/boolean-prop-naming.md
1004
- */
1005
- 'react/boolean-prop-naming': [
1006
- 'error',
1007
- {
1008
- propTypeNames: ['bool'],
1009
- rule: '^(is|has|should)[A-Z]([A-Za-z0-9]?)+',
1010
- },
1011
- ],
1012
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/button-has-type.md
1013
- 'react/button-has-type': 'error',
1014
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/default-props-match-prop-types.md
1015
- 'react/default-props-match-prop-types': 'error',
1016
-
1017
- /*
1018
- * https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/display-name.md
1019
- * @TODO
1020
- * @TIPS
1021
- * for stateless component: use named function for now
1022
- * const Dialog = ({ children }) => (
1023
- * <div className="dialog">{children}</div>
1024
- * )
1025
- * ->
1026
- * const Dialog = function Dialog({ children }) {
1027
- * return (
1028
- * <div className="dialog">{children}</div>
1029
- * )
1030
- * }
1031
- * issues:
1032
- * https://github.com/yannickcr/eslint-plugin-react/issues/1297
1033
- * https://github.com/yannickcr/eslint-plugin-react/issues/412
1034
- * feedback:
1035
- * - 把一个render 作为props传入组件还是比较常见的
1036
- * - 嗯ok,这个规则现在的性价比是不太高了…
1037
- */
1038
- 'react/display-name': 'off',
1039
- /*
1040
- * @CUSTOM
1041
- * "react/forbid-prop-types": [
1042
- * "error",
1043
- * {
1044
- * "forbid": [],
1045
- * "allowInPropTypes": []
1046
- * }
1047
- * ],
1048
- * https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/forbid-foreign-prop-types.md
1049
- */
1050
- 'react/forbid-foreign-prop-types': 'error',
1051
-
1052
- /*
1053
- * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-access-state-in-setstate.md
1054
- * @TIPS
1055
- * this.setState({value: this.state.value + 1});
1056
- * ->
1057
- * this.setState(prevState => ({value: prevState.value + 1}));
1058
- */
1059
- 'react/no-access-state-in-setstate': 'error',
1060
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-array-index-key.md
1061
- 'react/no-array-index-key': 'warn',
1062
- /*
1063
- * https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-danger.md
1064
- * @TIPS
1065
- * explicitly declare `eslint-disable` when truly necessary
1066
- */
1067
- 'react/no-danger': 'error',
1068
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-did-mount-set-state.md
1069
- 'react/no-did-mount-set-state': 'error',
1070
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-multi-comp.md
1071
- 'react/no-multi-comp': ['error', { ignoreStateless: true }],
1072
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-redundant-should-component-update.md
1073
- 'react/no-redundant-should-component-update': 'error',
1074
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-typos.md
1075
- 'react/no-typos': 'error',
1076
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-this-in-sfc.md
1077
- 'react/no-this-in-sfc': 'error',
1078
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unsafe.md
1079
- 'react/no-unsafe': ['error', { checkAliases: true }],
1080
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-unused-prop-types.md
1081
- 'react/no-unused-prop-types': 'error',
1082
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-will-update-set-state.md
1083
- 'react/no-will-update-set-state': 'error',
1084
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/prefer-es6-class.md
1085
- 'react/prefer-es6-class': 'error',
1086
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/prefer-stateless-function.md
1087
- 'react/prefer-stateless-function': [
1088
- 'error',
1089
- { ignorePureComponents: false },
1090
- ],
1091
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/prop-types.md
1092
- 'react/prop-types': [
1093
- 'error',
1094
- {
1095
- skipUndeclared: true,
1096
- ignore: ['children', 'className'],
1097
- },
1098
- ],
1099
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/react-in-jsx-scope.md
1100
- // react 17
1101
- 'react/react-in-jsx-scope': 'off',
1102
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/require-default-props.md
1103
- 'react/require-default-props': [
1104
- 'error',
1105
- { forbidDefaultForRequired: true },
1106
- ],
1107
-
1108
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/self-closing-comp.md
1109
- 'react/self-closing-comp': [
1110
- 'error',
1111
- {
1112
- component: true,
1113
- html: false,
1114
- },
1115
- ],
1116
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/style-prop-object.md
1117
- 'react/style-prop-object': 'error',
1118
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/void-dom-elements-no-children.md
1119
- 'react/void-dom-elements-no-children': 'error',
1120
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
1121
- 'react/jsx-filename-extension': [
1122
- 'error',
1123
- { extensions: ['.jsx', '.tsx', '.mjsx', '.cjsx'] },
1124
- ],
1125
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md
1126
- 'react/jsx-handler-names': [
1127
- 'error',
1128
- {
1129
- eventHandlerPrefix: '',
1130
- // eventHandlerPrefix: 'handle',
1131
- eventHandlerPropPrefix: 'on',
1132
- },
1133
- ],
1134
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
1135
- 'react/jsx-no-bind': [
1136
- 'error',
1137
- {
1138
- ignoreRefs: true,
1139
- allowArrowFunctions: true,
1140
- },
1141
- ],
1142
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md
1143
- 'react/jsx-no-duplicate-props': ['error', { ignoreCase: true }],
1144
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md
1145
- 'react/jsx-no-target-blank': 'off',
1146
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md
1147
- 'react/jsx-no-undef': ['error', { allowGlobals: true }],
1148
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md
1149
- 'react/jsx-pascal-case': 'error',
1150
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unused-state.md
1151
- 'react/no-unused-state': 'error',
1152
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md
1153
- 'react/state-in-constructor': ['error', 'never'],
1154
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md
1155
- 'react/static-property-placement': 'error',
1156
- // https://reactjs.org/docs/hooks-rules.html
1157
- 'react-hooks/rules-of-hooks': 'error',
1158
- // https://github.com/facebook/react/issues/16006
1159
- 'react-hooks/exhaustive-deps': 'off',
1160
-
1161
962
  /*
1162
963
  * import
1163
964
  * Static analysis
@@ -1363,8 +1164,6 @@ module.exports = {
1363
1164
  * use Camel Case for others
1364
1165
  */
1365
1166
  'filenames/match-regex': ['error', '^[\\[\\]_a-zA-Z0-9.-]+$'],
1366
- // https://www.npmjs.com/package/eslint-plugin-filenames#matching-exported-values-match-exported
1367
- 'filenames/match-exported': ['error', ['kebab', 'camel', 'pascal']],
1368
1167
  // https://www.npmjs.com/package/eslint-plugin-filenames#dont-allow-indexjs-files-no-index
1369
1168
  'filenames/no-index': 'off',
1370
1169
 
@@ -1394,12 +1193,6 @@ module.exports = {
1394
1193
  // https://github.com/xjamundx/eslint-plugin-promise/blob/master/docs/rules/valid-params.md
1395
1194
  'promise/valid-params': 'error',
1396
1195
 
1397
- /*
1398
- * https://github.com/xjamundx/eslint-plugin-promise/blob/master/docs/rules/prefer-await-to-then.md
1399
- * @CUSTOM
1400
- */
1401
- 'promise/prefer-await-to-then': 'error',
1402
-
1403
1196
  /*
1404
1197
  * https://github.com/xjamundx/eslint-plugin-promise/blob/master/docs/rules/prefer-await-to-callbacks.md
1405
1198
  * @CUSTOM
@@ -1476,71 +1269,11 @@ module.exports = {
1476
1269
  'node/prefer-promises/dns': 'off',
1477
1270
  // https://github.com/mysticatea/eslint-plugin-node/blob/v9.0.0/docs/rules/prefer-promises/fs.md
1478
1271
  'node/prefer-promises/fs': 'off',
1479
-
1480
- /*
1481
- * JSDoc
1482
- * @TIPS
1483
- * if your block comments are not JSDoc,
1484
- * change `/**` into `/*`
1485
- * https://github.com/gajus/eslint-plugin-jsdoc#check-alignment
1486
- */
1487
- // 'jsdoc/check-alignment': 'error',
1488
- // // https://github.com/gajus/eslint-plugin-jsdoc#check-examples
1489
- // 'jsdoc/check-examples': 'off',
1490
- // // https://github.com/gajus/eslint-plugin-jsdoc#check-indentation
1491
- // 'jsdoc/check-indentation': 'off',
1492
- // // https://github.com/gajus/eslint-plugin-jsdoc#check-param-names
1493
- // 'jsdoc/check-param-names': 'error',
1494
- // // https://github.com/gajus/eslint-plugin-jsdoc#check-syntax
1495
- // 'jsdoc/check-syntax': 'error',
1496
- // // https://github.com/gajus/eslint-plugin-jsdoc#check-tag-names
1497
- // 'jsdoc/check-tag-names': 'error',
1498
- // // https://github.com/gajus/eslint-plugin-jsdoc#check-types
1499
- // 'jsdoc/check-types': 'error',
1500
- // // https://github.com/gajus/eslint-plugin-jsdoc#implements-on-classes
1501
- // 'jsdoc/implements-on-classes': 'error',
1502
- // // https://github.com/gajus/eslint-plugin-jsdoc#match-description
1503
- // 'jsdoc/match-description': 'off',
1504
- // // https://github.com/gajus/eslint-plugin-jsdoc#newline-after-description
1505
- // 'jsdoc/newline-after-description': ['error', 'always'],
1506
- // // https://github.com/gajus/eslint-plugin-jsdoc#no-types
1507
- // 'jsdoc/no-types': 'off',
1508
- // // https://github.com/gajus/eslint-plugin-jsdoc#no-undefined-types
1509
- // 'jsdoc/no-undefined-types': 'error',
1510
- // // https://github.com/gajus/eslint-plugin-jsdoc#require-description-complete-sentence
1511
- // 'jsdoc/require-description-complete-sentence': 'off',
1512
- // // https://github.com/gajus/eslint-plugin-jsdoc#require-description
1513
- // 'jsdoc/require-description': 'error',
1514
- // // https://github.com/gajus/eslint-plugin-jsdoc#require-example
1515
- // 'jsdoc/require-example': 'off',
1516
- // // https://github.com/gajus/eslint-plugin-jsdoc#require-hyphen-before-param-description
1517
- // 'jsdoc/require-hyphen-before-param-description': ['error', 'always'],
1518
- // // https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-jsdoc
1519
- // 'jsdoc/require-jsdoc': 'off',
1520
- // // https://github.com/gajus/eslint-plugin-jsdoc#require-param-description
1521
- // 'jsdoc/require-param-description': 'error',
1522
- // // https://github.com/gajus/eslint-plugin-jsdoc#require-param-name
1523
- // 'jsdoc/require-param-name': 'error',
1524
- // // https://github.com/gajus/eslint-plugin-jsdoc#require-param-type
1525
- // 'jsdoc/require-param-type': 'off',
1526
- // // https://github.com/gajus/eslint-plugin-jsdoc#require-param
1527
- // 'jsdoc/require-param': 'off',
1528
- // // https://github.com/gajus/eslint-plugin-jsdoc#require-returns-check
1529
- // 'jsdoc/require-returns-check': 'error',
1530
- // // https://github.com/gajus/eslint-plugin-jsdoc#require-returns-description
1531
- // 'jsdoc/require-returns-description': 'error',
1532
- // // https://github.com/gajus/eslint-plugin-jsdoc#require-returns-type
1533
- // 'jsdoc/require-returns-type': 'off',
1534
- // // https://github.com/gajus/eslint-plugin-jsdoc#require-returns
1535
- // 'jsdoc/require-returns': 'off',
1536
- // // https://github.com/gajus/eslint-plugin-jsdoc#valid-types
1537
- // 'jsdoc/valid-types': 'off',
1538
1272
  },
1539
1273
  settings: {
1540
1274
  'import/resolver': 'webpack',
1541
1275
  'import/extensions': jsExtensions,
1542
1276
  'import/ignore': ['\\.coffee$'],
1543
- react: { version: '16.0' },
1544
1277
  },
1545
1278
  // https://eslint.org/docs/user-guide/configuring#configuration-based-on-glob-patterns
1546
1279
  // https://eslint.org/docs/user-guide/migrating-to-6.0.0#-overrides-in-an-extended-config-file-can-now-be-overridden-by-a-parent-config-file
@@ -1564,7 +1297,6 @@ module.exports = {
1564
1297
  files: ['**/pages/**/_*', '**/pages/**/index.*', '**/pages/**/\\[**'],
1565
1298
  rules: {
1566
1299
  'filenames/match-regex': 'off',
1567
- 'filenames/match-exported': 'off',
1568
1300
  },
1569
1301
  },
1570
1302
  {
@@ -1584,4 +1316,4 @@ module.exports = {
1584
1316
  },
1585
1317
  ],
1586
1318
  };
1587
- /* eslint-enable max-lines, no-magic-numbers */
1319
+ /* eslint-enable max-lines */
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  module.exports = {
2
2
  // https://eslint.org/docs/user-guide/configuring#extending-configuration-files
3
- extends: ['./base.js', './ts.withType.js', './prettier'],
3
+ extends: ['./base.js', './react', './ts', './ts.withType.js', './prettier'],
4
4
  };
package/jest.config.js CHANGED
@@ -2,7 +2,6 @@ const sharedConfig = require('@scripts/jest-config');
2
2
 
3
3
  /** @type {import('@jest/types').Config.InitialOptions} */
4
4
  module.exports = {
5
- // eslint-disable-next-line node/no-unsupported-features/es-syntax
6
5
  ...sharedConfig,
7
6
  rootDir: __dirname,
8
7
  };
package/lite.js CHANGED
@@ -1,4 +1,4 @@
1
1
  module.exports = {
2
2
  // https://eslint.org/docs/user-guide/configuring#extending-configuration-files
3
- extends: ['./base.js', './ts.js', './prettier'],
3
+ extends: ['./base.js', './react', './ts.js', './prettier'],
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modern-js-app/eslint-config",
3
- "version": "1.2.5",
3
+ "version": "1.2.8",
4
4
  "description": "The meta-framework suite designed from scratch for frontend-focused modern web development.",
5
5
  "homepage": "https://modernjs.dev",
6
6
  "bugs": "https://github.com/modern-js-dev/modern.js/issues",
@@ -32,9 +32,10 @@
32
32
  "prettier": "^2.5.1"
33
33
  },
34
34
  "dependencies": {
35
- "@modern-js/babel-preset-app": "^1.2.0"
35
+ "@modern-js/babel-preset-app": "^1.2.7"
36
36
  },
37
37
  "devDependencies": {
38
+ "@scripts/build": "0.0.0",
38
39
  "eslint": "^7.32.0",
39
40
  "eslint-find-rules": "^3.4.0",
40
41
  "eslint-index": "^1.5.0"
package/react.js ADDED
@@ -0,0 +1,123 @@
1
+ module.exports = {
2
+ // https://eslint.org/docs/user-guide/configuring#specifying-parser-options
3
+ parserOptions: {
4
+ ecmaFeatures: {
5
+ jsx: true,
6
+ },
7
+ },
8
+ // https://eslint.org/docs/user-guide/configuring#configuring-plugins
9
+ plugins: [
10
+ // https://www.npmjs.com/package/eslint-plugin-react
11
+ 'react',
12
+ // https://www.npmjs.com/package/eslint-plugin-react-hooks
13
+ 'react-hooks',
14
+ ],
15
+ // https://eslint.org/docs/user-guide/configuring#extending-configuration-files
16
+ extends: ['plugin:react/recommended', 'plugin:react/jsx-runtime'],
17
+
18
+ settings: {
19
+ react: { version: '16.0' },
20
+ },
21
+
22
+ rules: {
23
+ /*
24
+ * https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/display-name.md
25
+ * @TODO
26
+ * @TIPS
27
+ * for stateless component: use named function for now
28
+ * const Dialog = ({ children }) => (
29
+ * <div className="dialog">{children}</div>
30
+ * )
31
+ * ->
32
+ * const Dialog = function Dialog({ children }) {
33
+ * return (
34
+ * <div className="dialog">{children}</div>
35
+ * )
36
+ * }
37
+ * issues:
38
+ * https://github.com/yannickcr/eslint-plugin-react/issues/1297
39
+ * https://github.com/yannickcr/eslint-plugin-react/issues/412
40
+ * feedback:
41
+ * - 把一个render 作为props传入组件还是比较常见的
42
+ * - 嗯ok,这个规则现在的性价比是不太高了…
43
+ */
44
+ 'react/display-name': 'off',
45
+ /*
46
+ * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-access-state-in-setstate.md
47
+ * @TIPS
48
+ * this.setState({value: this.state.value + 1});
49
+ * ->
50
+ * this.setState(prevState => ({value: prevState.value + 1}));
51
+ */
52
+ 'react/no-access-state-in-setstate': 'error',
53
+ // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-array-index-key.md
54
+ 'react/no-array-index-key': 'warn',
55
+ /*
56
+ * https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-danger.md
57
+ * @TIPS
58
+ * explicitly declare `eslint-disable` when truly necessary
59
+ */
60
+ 'react/no-danger': 'error',
61
+ // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-did-mount-set-state.md
62
+ 'react/no-did-mount-set-state': 'error',
63
+ // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-redundant-should-component-update.md
64
+ 'react/no-redundant-should-component-update': 'error',
65
+ // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-typos.md
66
+ 'react/no-typos': 'error',
67
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-this-in-sfc.md
68
+ 'react/no-this-in-sfc': 'error',
69
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unsafe.md
70
+ 'react/no-unsafe': ['error', { checkAliases: true }],
71
+ // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-unused-prop-types.md
72
+ 'react/no-unused-prop-types': 'error',
73
+ // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-will-update-set-state.md
74
+ 'react/no-will-update-set-state': 'error',
75
+ // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/prefer-stateless-function.md
76
+ 'react/prefer-stateless-function': [
77
+ 'warn',
78
+ { ignorePureComponents: false },
79
+ ],
80
+ // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/prop-types.md
81
+ 'react/prop-types': [
82
+ 'error',
83
+ {
84
+ skipUndeclared: true,
85
+ ignore: ['children', 'className'],
86
+ },
87
+ ],
88
+ // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/require-default-props.md
89
+ 'react/require-default-props': [
90
+ 'error',
91
+ { forbidDefaultForRequired: true },
92
+ ],
93
+
94
+ // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/self-closing-comp.md
95
+ 'react/self-closing-comp': [
96
+ 'error',
97
+ {
98
+ component: true,
99
+ html: false,
100
+ },
101
+ ],
102
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/style-prop-object.md
103
+ 'react/style-prop-object': 'error',
104
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/void-dom-elements-no-children.md
105
+ 'react/void-dom-elements-no-children': 'error',
106
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md
107
+ 'react/jsx-no-target-blank': 'off',
108
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md
109
+ 'react/jsx-no-undef': ['error', { allowGlobals: true }],
110
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md
111
+ 'react/jsx-pascal-case': 'error',
112
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unused-state.md
113
+ 'react/no-unused-state': 'error',
114
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md
115
+ 'react/state-in-constructor': ['error', 'never'],
116
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md
117
+ 'react/static-property-placement': 'error',
118
+ // https://reactjs.org/docs/hooks-rules.html
119
+ 'react-hooks/rules-of-hooks': 'error',
120
+ // https://github.com/facebook/react/issues/16006
121
+ 'react-hooks/exhaustive-deps': 'off',
122
+ },
123
+ };
package/ts.js CHANGED
@@ -1,4 +1,3 @@
1
- /* eslint-disable max-lines */
2
1
  const { jsExtensions } = require('./utils');
3
2
 
4
3
  module.exports = {
@@ -391,15 +390,6 @@ module.exports = {
391
390
  // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-redeclare.md
392
391
  'no-redeclare': 'off',
393
392
  '@typescript-eslint/no-redeclare': ['error', { builtinGlobals: true }],
394
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-shadow.md
395
- 'no-shadow': 'off',
396
- '@typescript-eslint/no-shadow': [
397
- 'error',
398
- {
399
- builtinGlobals: false,
400
- allow: [],
401
- },
402
- ],
403
393
 
404
394
  // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/space-before-function-paren.md
405
395
  'space-before-function-paren': 'off',
@@ -418,4 +408,3 @@ module.exports = {
418
408
  },
419
409
  ],
420
410
  };
421
- /* eslint-enable max-lines */
package/ts.withType.js CHANGED
@@ -2,7 +2,8 @@ module.exports = {
2
2
  overrides: [
3
3
  {
4
4
  files: ['*.ts', '*.d.ts', '*.tsx'],
5
- extends: ['./ts'],
5
+ // modern.config.ts is usually not included in tsconfig.json
6
+ excludedFiles: ['modern.config.ts'],
6
7
  parserOptions: {
7
8
  ecmaFeatures: { jsx: true },
8
9
  // don't set tsconfigRootDir, using the path relative to the cwd
@@ -23,11 +24,6 @@ module.exports = {
23
24
  ],
24
25
  // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md
25
26
  '@typescript-eslint/no-unnecessary-type-assertion': 'error',
26
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/restrict-template-expressions.md
27
- '@typescript-eslint/restrict-template-expressions': [
28
- 'error',
29
- { allowNumber: true, allowAny: true },
30
- ],
31
27
  // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-base-to-string.md
32
28
  '@typescript-eslint/no-base-to-string': 'error',
33
29
  // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unnecessary-boolean-literal-compare.md