@dxos/eslint-plugin-rules 0.6.13 → 0.6.14-main.69511f5

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/index.js CHANGED
@@ -6,5 +6,6 @@ module.exports = {
6
6
  rules: {
7
7
  comment: require('./rules/comment'),
8
8
  header: require('./rules/header'),
9
+ 'no-empty-promise-catch': require('./rules/no-empty-promise-catch'),
9
10
  },
10
11
  };
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@dxos/eslint-plugin-rules",
3
- "version": "0.6.13",
3
+ "version": "0.6.14-main.69511f5",
4
4
  "homepage": "https://dxos.org",
5
5
  "bugs": "https://github.com/dxos/dxos/issues",
6
6
  "license": "MIT",
7
7
  "author": "info@dxos.org",
8
+ "sideEffects": true,
8
9
  "main": "index.js",
9
10
  "publishConfig": {
10
11
  "access": "public"
package/rules/comment.js CHANGED
@@ -152,7 +152,7 @@ module.exports = {
152
152
  return true;
153
153
  }
154
154
 
155
- // 6. Check TODO format.
155
+ // 6. Check "TODO" format.
156
156
  const containsTodo = TODO_PATTERN.test(comment.value);
157
157
  const startsWithTodo = TODO_START_PATTERN.test(comment.value);
158
158
  const isTodoFormatted = FORMATTED_TODO_PATTERN.test(comment.value);
@@ -0,0 +1,35 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ 'use strict';
6
+
7
+ const isCatchCallSite = (expression) =>
8
+ expression.type === 'CallExpression' &&
9
+ expression.callee.type === 'MemberExpression' &&
10
+ expression.callee.property.name === 'catch';
11
+
12
+ module.exports = {
13
+ meta: {
14
+ type: 'problem',
15
+ fixable: 'code',
16
+ docs: {
17
+ description: 'Enforces passing an error handler to promise .catch().',
18
+ },
19
+ },
20
+ create(context) {
21
+ return {
22
+ CallExpression(node) {
23
+ if (isCatchCallSite(node) && node.arguments.length === 0) {
24
+ context.report({
25
+ node,
26
+ message: 'Handler argument required. `undefined` handlers lead to unhandled rejections.',
27
+ fix: (fixer) => {
28
+ return fixer.insertTextAfter(context.sourceCode.getTokenAfter(node.callee), '() => {}');
29
+ },
30
+ });
31
+ }
32
+ },
33
+ };
34
+ },
35
+ };