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

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 (4) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/base.js +0 -265
  3. package/package.json +3 -3
  4. package/ts.js +17 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @modern-js-app/eslint-config
2
2
 
3
+ ## 1.2.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 10f47286: fix: typescript eslint rule due to @typescript-eslint/eslint-plugin's breaking change
8
+ - 0ef81796: feat: simplify react eslint rules
9
+
3
10
  ## 1.2.4
4
11
 
5
12
  ### Patch Changes
package/base.js CHANGED
@@ -1013,12 +1013,6 @@ module.exports = {
1013
1013
  'react/button-has-type': 'error',
1014
1014
  // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/default-props-match-prop-types.md
1015
1015
  'react/default-props-match-prop-types': 'error',
1016
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/destructuring-assignment.md
1017
- 'react/destructuring-assignment': [
1018
- 'error',
1019
- 'always',
1020
- { ignoreClassFields: true },
1021
- ],
1022
1016
 
1023
1017
  /*
1024
1018
  * https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/display-name.md
@@ -1042,59 +1036,6 @@ module.exports = {
1042
1036
  * - 嗯ok,这个规则现在的性价比是不太高了…
1043
1037
  */
1044
1038
  'react/display-name': 'off',
1045
- // 'react/display-name': [
1046
- // 'error',
1047
- // {
1048
- // ignoreTranspilerName: false,
1049
- // },
1050
- // ],
1051
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/forbid-component-props.md
1052
- 'react/forbid-component-props': 'off',
1053
-
1054
- /*
1055
- * @CUSTOM
1056
- * "react/forbid-component-props": [
1057
- * "error",
1058
- * {
1059
- * "forbid": [
1060
- * "className",
1061
- * "style"
1062
- * ]
1063
- * }
1064
- * ],
1065
- * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-dom-props.md
1066
- */
1067
- 'react/forbid-dom-props': 'off',
1068
-
1069
- /*
1070
- * @CUSTOM
1071
- * "react/forbid-dom-props": [
1072
- * "error",
1073
- * {
1074
- * "forbid": []
1075
- * }
1076
- * ],
1077
- * https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/forbid-elements.md
1078
- */
1079
- 'react/forbid-elements': 'off',
1080
-
1081
- /*
1082
- * @CUSTOM
1083
- * "react/forbid-elements": [
1084
- * "error",
1085
- * {
1086
- * "forbid": [
1087
- * {
1088
- * "element": "button",
1089
- * "message": "use <Button> instead"
1090
- * }
1091
- * ]
1092
- * }
1093
- * ],
1094
- * https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/forbid-prop-types.md
1095
- */
1096
- 'react/forbid-prop-types': 'off',
1097
-
1098
1039
  /*
1099
1040
  * @CUSTOM
1100
1041
  * "react/forbid-prop-types": [
@@ -1118,52 +1059,22 @@ module.exports = {
1118
1059
  'react/no-access-state-in-setstate': 'error',
1119
1060
  // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-array-index-key.md
1120
1061
  'react/no-array-index-key': 'warn',
1121
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-children-prop.md
1122
- 'react/no-children-prop': 'error',
1123
-
1124
1062
  /*
1125
1063
  * https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-danger.md
1126
1064
  * @TIPS
1127
1065
  * explicitly declare `eslint-disable` when truly necessary
1128
1066
  */
1129
1067
  'react/no-danger': 'error',
1130
-
1131
- /*
1132
- * https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-danger-with-children.md
1133
- * @TIPS
1134
- * explicitly declare `eslint-disable` when truly necessary
1135
- */
1136
- 'react/no-danger-with-children': 'error',
1137
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-deprecated.md
1138
- 'react/no-deprecated': 'error',
1139
1068
  // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-did-mount-set-state.md
1140
1069
  'react/no-did-mount-set-state': 'error',
1141
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-did-update-set-state.md
1142
- 'react/no-did-update-set-state': 'off',
1143
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-direct-mutation-state.md
1144
- 'react/no-direct-mutation-state': 'error',
1145
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-find-dom-node.md
1146
- 'react/no-find-dom-node': 'error',
1147
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-is-mounted.md
1148
- 'react/no-is-mounted': 'error',
1149
1070
  // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-multi-comp.md
1150
1071
  'react/no-multi-comp': ['error', { ignoreStateless: true }],
1151
1072
  // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-redundant-should-component-update.md
1152
1073
  'react/no-redundant-should-component-update': 'error',
1153
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-render-return-value.md
1154
- 'react/no-render-return-value': 'error',
1155
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-set-state.md
1156
- 'react/no-set-state': 'off',
1157
1074
  // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-typos.md
1158
1075
  'react/no-typos': 'error',
1159
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-string-refs.md
1160
- 'react/no-string-refs': 'error',
1161
1076
  // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-this-in-sfc.md
1162
1077
  'react/no-this-in-sfc': 'error',
1163
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-unescaped-entities.md
1164
- 'react/no-unescaped-entities': 'error',
1165
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-unknown-property.md
1166
- 'react/no-unknown-property': 'error',
1167
1078
  // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unsafe.md
1168
1079
  'react/no-unsafe': ['error', { checkAliases: true }],
1169
1080
  // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/no-unused-prop-types.md
@@ -1194,14 +1105,6 @@ module.exports = {
1194
1105
  { forbidDefaultForRequired: true },
1195
1106
  ],
1196
1107
 
1197
- /*
1198
- * https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/require-optimization.md
1199
- * https://github.com/facebook/react/pull/7195#issuecomment-236361372
1200
- * https://hackernoon.com/react-purecomponent-considered-harmful-8155b5c1d4bc
1201
- */
1202
- 'react/require-optimization': 'off',
1203
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/require-render-return.md
1204
- 'react/require-render-return': 'error',
1205
1108
  // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/self-closing-comp.md
1206
1109
  'react/self-closing-comp': [
1207
1110
  'error',
@@ -1210,102 +1113,15 @@ module.exports = {
1210
1113
  html: false,
1211
1114
  },
1212
1115
  ],
1213
- // https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/sort-comp.md
1214
- 'react/sort-comp': [
1215
- 'error',
1216
- {
1217
- order: [
1218
- 'type-annotations',
1219
- 'class-properties-and-methods',
1220
- 'instance-variables',
1221
- 'state',
1222
- 'getInitialState',
1223
- 'getChildContext',
1224
- 'getDefaultProps',
1225
- 'constructor',
1226
- 'lifecycle',
1227
- '/^is.+$/',
1228
- '/^_is.+$/',
1229
- '/^has.+$/',
1230
- '/^_has.+$/',
1231
- '/^should.+$/',
1232
- '/^_should.+$/',
1233
- '/^get.+$/',
1234
- '/^_get.+$/',
1235
- 'getters',
1236
- '/^set.+$/',
1237
- '/^_set.+$/',
1238
- 'setters',
1239
- '/^on.+$/',
1240
- '/^_on.+$/',
1241
- '/^handle.+$/',
1242
- '/^_handle.+$/',
1243
- 'instance-methods',
1244
- 'everything-else',
1245
- 'rendering',
1246
- ],
1247
- groups: {
1248
- 'class-properties-and-methods': [
1249
- 'displayName',
1250
- 'propTypes',
1251
- 'contextTypes',
1252
- 'childContextTypes',
1253
- 'mixins',
1254
- 'statics',
1255
- 'defaultProps',
1256
- 'getDerivedStateFromProps',
1257
- 'static-methods',
1258
- ],
1259
- lifecycle: [
1260
- 'UNSAFE_componentWillMount',
1261
- 'componentWillMount',
1262
- 'componentDidMount',
1263
- 'UNSAFE_componentWillReceiveProps',
1264
- 'componentWillReceiveProps',
1265
- 'shouldComponentUpdate',
1266
- 'getSnapshotBeforeUpdate',
1267
- 'UNSAFE_componentWillUpdate',
1268
- 'componentWillUpdate',
1269
- 'componentDidUpdate',
1270
- 'componentWillUnmount',
1271
- ],
1272
- rendering: ['/^render.+$/', 'render'],
1273
- },
1274
- },
1275
- ],
1276
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md
1277
- 'react/sort-prop-types': 'off',
1278
1116
  // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/style-prop-object.md
1279
1117
  'react/style-prop-object': 'error',
1280
1118
  // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/void-dom-elements-no-children.md
1281
1119
  'react/void-dom-elements-no-children': 'error',
1282
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
1283
- 'react/jsx-boolean-value': ['error', 'always'],
1284
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-child-element-spacing.md
1285
- 'react/jsx-child-element-spacing': 'error',
1286
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md
1287
- 'react/jsx-closing-bracket-location': [
1288
- 'error',
1289
- {
1290
- // "selfClosing": "props-aligned",
1291
- selfClosing: 'after-props',
1292
- // "nonEmpty": "props-aligned"
1293
- nonEmpty: 'after-props',
1294
- },
1295
- ],
1296
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-tag-location.md
1297
- 'react/jsx-closing-tag-location': 'error',
1298
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md
1299
- 'react/jsx-curly-spacing': ['error', { when: 'never' }],
1300
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-equals-spacing.md
1301
- 'react/jsx-equals-spacing': ['error', 'never'],
1302
1120
  // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
1303
1121
  'react/jsx-filename-extension': [
1304
1122
  'error',
1305
1123
  { extensions: ['.jsx', '.tsx', '.mjsx', '.cjsx'] },
1306
1124
  ],
1307
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-first-prop-new-line.md
1308
- 'react/jsx-first-prop-new-line': ['error', 'multiline'],
1309
1125
  // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md
1310
1126
  'react/jsx-handler-names': [
1311
1127
  'error',
@@ -1315,22 +1131,6 @@ module.exports = {
1315
1131
  eventHandlerPropPrefix: 'on',
1316
1132
  },
1317
1133
  ],
1318
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent.md
1319
- 'react/jsx-indent': ['error', 2],
1320
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent-props.md
1321
- 'react/jsx-indent-props': ['error', 2],
1322
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-key.md
1323
- 'react/jsx-key': 'error',
1324
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-max-depth.md
1325
- 'react/jsx-max-depth': 'off',
1326
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md
1327
- 'react/jsx-max-props-per-line': [
1328
- 'error',
1329
- {
1330
- maximum: 1,
1331
- when: 'always',
1332
- },
1333
- ],
1334
1134
  // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
1335
1135
  'react/jsx-no-bind': [
1336
1136
  'error',
@@ -1339,85 +1139,20 @@ module.exports = {
1339
1139
  allowArrowFunctions: true,
1340
1140
  },
1341
1141
  ],
1342
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md
1343
- 'react/jsx-no-comment-textnodes': 'error',
1344
1142
  // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md
1345
1143
  'react/jsx-no-duplicate-props': ['error', { ignoreCase: true }],
1346
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md
1347
- 'react/jsx-no-literals': 'off',
1348
1144
  // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md
1349
1145
  'react/jsx-no-target-blank': 'off',
1350
1146
  // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md
1351
1147
  'react/jsx-no-undef': ['error', { allowGlobals: true }],
1352
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-one-expression-per-line.md
1353
- 'react/jsx-one-expression-per-line': ['error', { allow: 'single-child' }],
1354
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md
1355
- 'react/jsx-curly-brace-presence': 'off',
1356
-
1357
- /*
1358
- * "react/jsx-curly-brace-presence": [
1359
- * "error",
1360
- * "never"
1361
- * ],
1362
- * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-fragments.md
1363
- * @TODO bug
1364
- */
1365
- 'react/jsx-fragments': 'off', // ['error', 'syntax'],
1366
1148
  // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md
1367
1149
  'react/jsx-pascal-case': 'error',
1368
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-multi-spaces.md
1369
- 'react/jsx-props-no-multi-spaces': 'error',
1370
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-default-props.md
1371
- 'react/jsx-sort-default-props': 'off',
1372
-
1373
- /*
1374
- * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md
1375
- * @TODO bug: conflict with prettier
1376
- */
1377
- 'react/jsx-sort-props': 'off',
1378
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md
1379
- 'react/jsx-tag-spacing': [
1380
- 'error',
1381
- {
1382
- closingSlash: 'never',
1383
- beforeSelfClosing: 'always',
1384
- afterOpening: 'never',
1385
- beforeClosing: 'never',
1386
- },
1387
- ],
1388
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md
1389
- // react 17
1390
- 'react/jsx-uses-react': 'error',
1391
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md
1392
- 'react/jsx-uses-vars': 'error',
1393
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-wrap-multilines.md
1394
- 'react/jsx-wrap-multilines': [
1395
- 'error',
1396
- {
1397
- declaration: true,
1398
- assignment: true,
1399
- return: true,
1400
- arrow: true,
1401
- condition: 'parens-new-line',
1402
- logical: 'parens-new-line',
1403
- prop: 'parens-new-line',
1404
- },
1405
- ],
1406
1150
  // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unused-state.md
1407
1151
  'react/no-unused-state': 'error',
1408
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spreading.md
1409
- 'react/jsx-props-no-spreading': 'off',
1410
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-read-only-props.md
1411
- 'react/prefer-read-only-props': 'off',
1412
1152
  // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md
1413
1153
  'react/state-in-constructor': ['error', 'never'],
1414
1154
  // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md
1415
1155
  'react/static-property-placement': 'error',
1416
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-newline.md
1417
- 'react/jsx-curly-newline': [
1418
- 'error',
1419
- { multiline: 'require', singleline: 'forbid' },
1420
- ],
1421
1156
  // https://reactjs.org/docs/hooks-rules.html
1422
1157
  'react-hooks/rules-of-hooks': 'error',
1423
1158
  // https://github.com/facebook/react/issues/16006
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modern-js-app/eslint-config",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
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",
@@ -15,8 +15,8 @@
15
15
  "peerDependencies": {
16
16
  "@babel/eslint-parser": "^7.15.0",
17
17
  "@babel/eslint-plugin": "^7.13.10",
18
- "@typescript-eslint/eslint-plugin": "^5.12.1",
19
- "@typescript-eslint/parser": "^5.12.1",
18
+ "@typescript-eslint/eslint-plugin": "^5.17.0",
19
+ "@typescript-eslint/parser": "^5.17.0",
20
20
  "eslint": "^7.32.0",
21
21
  "eslint-config-prettier": "^8.3.0",
22
22
  "eslint-import-resolver-webpack": "^0.13.1",
package/ts.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* eslint-disable max-lines */
1
2
  const { jsExtensions } = require('./utils');
2
3
 
3
4
  module.exports = {
@@ -165,7 +166,21 @@ module.exports = {
165
166
  leadingUnderscore: 'allowSingleOrDouble',
166
167
  trailingUnderscore: 'allowSingleOrDouble',
167
168
  },
168
-
169
+ // https://typescript-eslint.io/rules/naming-convention/#ignore-properties-that-require-quotes
170
+ {
171
+ selector: [
172
+ 'classProperty',
173
+ 'objectLiteralProperty',
174
+ 'typeProperty',
175
+ 'classMethod',
176
+ 'objectLiteralMethod',
177
+ 'typeMethod',
178
+ 'accessor',
179
+ 'enumMember',
180
+ ],
181
+ format: null,
182
+ modifiers: ['requiresQuotes'],
183
+ },
169
184
  {
170
185
  selector: 'variable',
171
186
  format: ['camelCase', 'PascalCase', 'UPPER_CASE', 'snake_case'],
@@ -403,3 +418,4 @@ module.exports = {
403
418
  },
404
419
  ],
405
420
  };
421
+ /* eslint-enable max-lines */