eslint-plugin-absolute 0.11.1 → 0.11.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 (2) hide show
  1. package/dist/index.js +76 -1
  2. package/package.json +3 -2
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { AST_NODE_TYPES } from "@typescript-eslint/utils";
4
4
 
5
5
  // src/createRule.ts
6
6
  import { ESLintUtils } from "@typescript-eslint/utils";
7
- var createRule = ESLintUtils.RuleCreator((name) => `https://absolutejs.com/documentation/eslint/${name}`);
7
+ var createRule = ESLintUtils.RuleCreator((name) => `https://absolutejs.com/documentation/eslint-${name}`);
8
8
 
9
9
  // src/rules/angular-one-feature-per-file.ts
10
10
  var FEATURE_DECORATOR_NAMES = new Set([
@@ -2871,6 +2871,80 @@ var noMultiStyleObjects = createRule({
2871
2871
  name: "no-multi-style-objects"
2872
2872
  });
2873
2873
 
2874
+ // src/rules/no-useless-catch.ts
2875
+ var unwrapExpression = (expression) => {
2876
+ switch (expression.type) {
2877
+ case "ChainExpression":
2878
+ return unwrapExpression(expression.expression);
2879
+ case "TSAsExpression":
2880
+ case "TSNonNullExpression":
2881
+ case "TSSatisfiesExpression":
2882
+ case "TSTypeAssertion":
2883
+ return unwrapExpression(expression.expression);
2884
+ default:
2885
+ return expression;
2886
+ }
2887
+ };
2888
+ var hasSideEffect = (expression) => {
2889
+ const unwrapped = unwrapExpression(expression);
2890
+ switch (unwrapped.type) {
2891
+ case "AssignmentExpression":
2892
+ case "AwaitExpression":
2893
+ case "CallExpression":
2894
+ case "ImportExpression":
2895
+ case "NewExpression":
2896
+ case "UpdateExpression":
2897
+ case "YieldExpression":
2898
+ return true;
2899
+ case "UnaryExpression":
2900
+ return unwrapped.operator === "delete";
2901
+ case "ConditionalExpression":
2902
+ return hasSideEffect(unwrapped.consequent) || hasSideEffect(unwrapped.alternate);
2903
+ case "LogicalExpression":
2904
+ return hasSideEffect(unwrapped.left) || hasSideEffect(unwrapped.right);
2905
+ case "SequenceExpression":
2906
+ return unwrapped.expressions.some(hasSideEffect);
2907
+ default:
2908
+ return false;
2909
+ }
2910
+ };
2911
+ var statementDoesWork = (statement) => {
2912
+ if (statement.type === "EmptyStatement") {
2913
+ return false;
2914
+ }
2915
+ if (statement.type === "ExpressionStatement") {
2916
+ return hasSideEffect(statement.expression);
2917
+ }
2918
+ return true;
2919
+ };
2920
+ var noUselessCatch = createRule({
2921
+ create(context) {
2922
+ return {
2923
+ CatchClause(node) {
2924
+ if (node.body.body.some(statementDoesWork)) {
2925
+ return;
2926
+ }
2927
+ context.report({
2928
+ messageId: "uselessCatch",
2929
+ node: node.body
2930
+ });
2931
+ }
2932
+ };
2933
+ },
2934
+ defaultOptions: [],
2935
+ meta: {
2936
+ docs: {
2937
+ description: "Disallow catch blocks that contain only comments or no-op statements. A catch block should handle, propagate, or record the error."
2938
+ },
2939
+ messages: {
2940
+ uselessCatch: "This catch block does not do any work. Handle, log, return, or rethrow the error instead of leaving a comment or no-op."
2941
+ },
2942
+ schema: [],
2943
+ type: "problem"
2944
+ },
2945
+ name: "no-useless-catch"
2946
+ });
2947
+
2874
2948
  // src/rules/no-useless-function.ts
2875
2949
  var noUselessFunction = createRule({
2876
2950
  create(context) {
@@ -4103,6 +4177,7 @@ var src_default = {
4103
4177
  "no-trivial-alias": noTrivialAlias,
4104
4178
  "no-unnecessary-div": noUnnecessaryDiv,
4105
4179
  "no-unnecessary-key": noUnnecessaryKey,
4180
+ "no-useless-catch": noUselessCatch,
4106
4181
  "no-useless-function": noUselessFunction,
4107
4182
  "prefer-inline-exports": preferInlineExports,
4108
4183
  "seperate-style-files": seperateStyleFiles,
package/package.json CHANGED
@@ -32,13 +32,14 @@
32
32
  },
33
33
  "scripts": {
34
34
  "build": "rm -rf dist && bun build src/index.ts --outdir dist --splitting --target=bun --external eslint --external @typescript-eslint/utils --external typescript",
35
+ "config": "absolute config",
35
36
  "format": "absolutejs prettier --write",
36
- "lint": "bun run build && bun run absolutejs eslint",
37
37
  "knip": "knip",
38
+ "lint": "bun run build && bun run absolutejs eslint",
38
39
  "release": "bun run format && bun run build && bun publish",
39
40
  "test": "bun test tests/",
40
41
  "typecheck": "bun run tsc --noEmit"
41
42
  },
42
43
  "type": "module",
43
- "version": "0.11.1"
44
+ "version": "0.11.3"
44
45
  }