eslint-plugin-rxjs-x 0.6.2 → 0.7.1

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.d.mts CHANGED
@@ -146,7 +146,7 @@ declare const rxjsX: {
146
146
  'no-subscribe-handlers': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
147
147
  'no-subscribe-in-pipe': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
148
148
  'no-tap': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
149
- 'no-topromise': TSESLint.RuleModule<"forbidden" | "suggestLastValueFrom" | "suggestFirstValueFrom", [], RxjsXRuleDocs, TSESLint.RuleListener>;
149
+ 'no-topromise': TSESLint.RuleModule<"forbidden" | "suggestLastValueFromWithDefault" | "suggestLastValueFrom" | "suggestFirstValueFrom", [], RxjsXRuleDocs, TSESLint.RuleListener>;
150
150
  'no-unbound-methods': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
151
151
  'no-unsafe-catch': TSESLint.RuleModule<"forbidden", readonly {
152
152
  observable?: string;
package/dist/index.d.ts CHANGED
@@ -146,7 +146,7 @@ declare const rxjsX: {
146
146
  'no-subscribe-handlers': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
147
147
  'no-subscribe-in-pipe': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
148
148
  'no-tap': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
149
- 'no-topromise': TSESLint.RuleModule<"forbidden" | "suggestLastValueFrom" | "suggestFirstValueFrom", [], RxjsXRuleDocs, TSESLint.RuleListener>;
149
+ 'no-topromise': TSESLint.RuleModule<"forbidden" | "suggestLastValueFromWithDefault" | "suggestLastValueFrom" | "suggestFirstValueFrom", [], RxjsXRuleDocs, TSESLint.RuleListener>;
150
150
  'no-unbound-methods': TSESLint.RuleModule<"forbidden", [], RxjsXRuleDocs, TSESLint.RuleListener>;
151
151
  'no-unsafe-catch': TSESLint.RuleModule<"forbidden", readonly {
152
152
  observable?: string;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// package.json
2
2
  var name = "eslint-plugin-rxjs-x";
3
- var version = "0.6.2";
3
+ var version = "0.7.1";
4
4
 
5
5
  // src/configs/recommended.ts
6
6
  var createRecommendedConfig = (plugin2) => ({
@@ -94,8 +94,9 @@ function createRegExpForWords(config) {
94
94
  function escapeRegExp(text) {
95
95
  return text.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
96
96
  }
97
+ var REPO_URL = "https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x";
97
98
  var ruleCreator = _utils.ESLintUtils.RuleCreator(
98
- (name2) => `https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/docs/rules/${name2}.md`
99
+ (name2) => `${REPO_URL}/blob/v${version}/docs/rules/${name2}.md`
99
100
  );
100
101
 
101
102
  // src/rules/ban-observables.ts
@@ -2908,6 +2909,7 @@ var noTopromiseRule = ruleCreator({
2908
2909
  hasSuggestions: true,
2909
2910
  messages: {
2910
2911
  forbidden: "The toPromise method is forbidden.",
2912
+ suggestLastValueFromWithDefault: "Use lastValueFrom(..., { defaultValue: undefined }) instead.",
2911
2913
  suggestLastValueFrom: "Use lastValueFrom instead.",
2912
2914
  suggestFirstValueFrom: "Use firstValueFrom instead."
2913
2915
  },
@@ -2925,7 +2927,7 @@ var noTopromiseRule = ruleCreator({
2925
2927
  const [, quote] = match;
2926
2928
  return quote;
2927
2929
  }
2928
- function createFix(conversion, callExpression, observableNode, importDeclarations) {
2930
+ function createFix(conversion, callExpression, observableNode, importDeclarations, { withDefault } = {}) {
2929
2931
  return function* fix(fixer) {
2930
2932
  var _a, _b, _c;
2931
2933
  let namespace = "";
@@ -2956,7 +2958,7 @@ import { ${functionName} } from ${quote}rxjs${quote};`
2956
2958
  }
2957
2959
  yield fixer.replaceText(
2958
2960
  callExpression,
2959
- `${namespace}${functionName}(${context.sourceCode.getText(observableNode)})`
2961
+ `${namespace}${functionName}(${context.sourceCode.getText(observableNode)}${withDefault ? ", { defaultValue: undefined }" : ""})`
2960
2962
  );
2961
2963
  };
2962
2964
  }
@@ -2975,6 +2977,10 @@ import { ${functionName} } from ${quote}rxjs${quote};`
2975
2977
  messageId: "forbidden",
2976
2978
  node: memberExpression.property,
2977
2979
  suggest: [
2980
+ {
2981
+ messageId: "suggestLastValueFromWithDefault",
2982
+ fix: createFix("lastValueFrom", node, memberExpression.object, importDeclarations, { withDefault: true })
2983
+ },
2978
2984
  {
2979
2985
  messageId: "suggestLastValueFrom",
2980
2986
  fix: createFix("lastValueFrom", node, memberExpression.object, importDeclarations)
@@ -4041,9 +4047,9 @@ var rxjsX = {
4041
4047
  strict: createStrictConfig(plugin)
4042
4048
  }
4043
4049
  };
4044
- var src_default = rxjsX;
4050
+ var index_default = rxjsX;
4045
4051
 
4046
4052
 
4047
- exports.default = src_default;
4053
+ exports.default = index_default;
4048
4054
 
4049
4055
  module.exports = exports.default;
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  // package.json
2
2
  var name = "eslint-plugin-rxjs-x";
3
- var version = "0.6.2";
3
+ var version = "0.7.1";
4
4
 
5
5
  // src/configs/recommended.ts
6
6
  var createRecommendedConfig = (plugin2) => ({
@@ -94,8 +94,9 @@ function createRegExpForWords(config) {
94
94
  function escapeRegExp(text) {
95
95
  return text.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
96
96
  }
97
+ var REPO_URL = "https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x";
97
98
  var ruleCreator = ESLintUtils.RuleCreator(
98
- (name2) => `https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/docs/rules/${name2}.md`
99
+ (name2) => `${REPO_URL}/blob/v${version}/docs/rules/${name2}.md`
99
100
  );
100
101
 
101
102
  // src/rules/ban-observables.ts
@@ -2908,6 +2909,7 @@ var noTopromiseRule = ruleCreator({
2908
2909
  hasSuggestions: true,
2909
2910
  messages: {
2910
2911
  forbidden: "The toPromise method is forbidden.",
2912
+ suggestLastValueFromWithDefault: "Use lastValueFrom(..., { defaultValue: undefined }) instead.",
2911
2913
  suggestLastValueFrom: "Use lastValueFrom instead.",
2912
2914
  suggestFirstValueFrom: "Use firstValueFrom instead."
2913
2915
  },
@@ -2925,7 +2927,7 @@ var noTopromiseRule = ruleCreator({
2925
2927
  const [, quote] = match;
2926
2928
  return quote;
2927
2929
  }
2928
- function createFix(conversion, callExpression, observableNode, importDeclarations) {
2930
+ function createFix(conversion, callExpression, observableNode, importDeclarations, { withDefault } = {}) {
2929
2931
  return function* fix(fixer) {
2930
2932
  var _a, _b, _c;
2931
2933
  let namespace = "";
@@ -2956,7 +2958,7 @@ import { ${functionName} } from ${quote}rxjs${quote};`
2956
2958
  }
2957
2959
  yield fixer.replaceText(
2958
2960
  callExpression,
2959
- `${namespace}${functionName}(${context.sourceCode.getText(observableNode)})`
2961
+ `${namespace}${functionName}(${context.sourceCode.getText(observableNode)}${withDefault ? ", { defaultValue: undefined }" : ""})`
2960
2962
  );
2961
2963
  };
2962
2964
  }
@@ -2975,6 +2977,10 @@ import { ${functionName} } from ${quote}rxjs${quote};`
2975
2977
  messageId: "forbidden",
2976
2978
  node: memberExpression.property,
2977
2979
  suggest: [
2980
+ {
2981
+ messageId: "suggestLastValueFromWithDefault",
2982
+ fix: createFix("lastValueFrom", node, memberExpression.object, importDeclarations, { withDefault: true })
2983
+ },
2978
2984
  {
2979
2985
  messageId: "suggestLastValueFrom",
2980
2986
  fix: createFix("lastValueFrom", node, memberExpression.object, importDeclarations)
@@ -4041,7 +4047,7 @@ var rxjsX = {
4041
4047
  strict: createStrictConfig(plugin)
4042
4048
  }
4043
4049
  };
4044
- var src_default = rxjsX;
4050
+ var index_default = rxjsX;
4045
4051
  export {
4046
- src_default as default
4052
+ index_default as default
4047
4053
  };
@@ -10,9 +10,10 @@
10
10
 
11
11
  This rule effects failures if the `toPromise` method is used.
12
12
 
13
- This rule provides two editor suggestions which replace `toPromise` with either:
13
+ This rule provides three editor suggestions which replace `toPromise` with either:
14
14
 
15
- - `lastValueFrom(...)`, which behaves closest to the behavior of `toPromise`,
15
+ - `lastValueFrom(..., { defaultValue: undefined })`, which imitates the behavior of `toPromise`,
16
+ - or `lastValueFrom(...)`, which throws `EmptyError` instead of defaulting to `undefined`,
16
17
  - or `firstValueFrom(...)`.
17
18
 
18
19
  ## When Not To Use It
@@ -26,6 +27,10 @@ Type checked lint rules are more powerful than traditional lint rules, but also
26
27
 
27
28
  - [Conversion to Promises](https://rxjs.dev/deprecations/to-promise)
28
29
 
30
+ ## Related To
31
+
32
+ - [`no-ignored-default-value`](./no-ignored-default-value.md)
33
+
29
34
  ## Resources
30
35
 
31
36
  - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-topromise.ts)
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "eslint-plugin-rxjs-x",
3
3
  "type": "commonjs",
4
- "version": "0.6.2",
5
- "packageManager": "yarn@4.6.0+sha512.5383cc12567a95f1d668fbe762dfe0075c595b4bfff433be478dbbe24e05251a8e8c3eb992a986667c1d53b6c3a9c85b8398c35a960587fbd9fa3a0915406728",
4
+ "version": "0.7.1",
5
+ "packageManager": "yarn@4.7.0+sha512.5a0afa1d4c1d844b3447ee3319633797bcd6385d9a44be07993ae52ff4facabccafb4af5dcd1c2f9a94ac113e5e9ff56f6130431905884414229e284e37bb7c9",
6
6
  "description": "ESLint v9+ plugin for RxJS",
7
7
  "author": "Jason Weinzierl <weinzierljason@gmail.com>",
8
8
  "license": "MIT",
@@ -55,11 +55,11 @@
55
55
  "typecheck": "tsc --noEmit"
56
56
  },
57
57
  "dependencies": {
58
- "@typescript-eslint/scope-manager": "^8.1.0",
59
- "@typescript-eslint/utils": "^8.1.0",
58
+ "@typescript-eslint/scope-manager": "^8.19.1",
59
+ "@typescript-eslint/utils": "^8.19.1",
60
60
  "common-tags": "^1.8.0",
61
61
  "decamelize": "^5.0.1",
62
- "ts-api-utils": "^1.3.0",
62
+ "ts-api-utils": "^2.0.0",
63
63
  "tslib": "^2.1.0"
64
64
  },
65
65
  "peerDependencies": {
@@ -73,28 +73,28 @@
73
73
  }
74
74
  },
75
75
  "devDependencies": {
76
- "@eslint/js": "^9.17.0",
77
- "@stylistic/eslint-plugin": "^2.12.1",
76
+ "@eslint/js": "^9.22.0",
77
+ "@stylistic/eslint-plugin": "^4.2.0",
78
78
  "@types/common-tags": "^1.8.4",
79
79
  "@types/node": "~18.18.0",
80
- "@typescript-eslint/rule-tester": "^8.19.1",
81
- "@typescript/vfs": "^1.6.0",
82
- "@vitest/coverage-v8": "^2.1.8",
83
- "@vitest/eslint-plugin": "^1.1.24",
84
- "bumpp": "^9.9.3",
85
- "eslint": "^9.17.0",
86
- "eslint-config-flat-gitignore": "^0.3.0",
87
- "eslint-doc-generator": "^2.0.2",
88
- "eslint-import-resolver-typescript": "^3.7.0",
80
+ "@typescript-eslint/rule-tester": "^8.26.1",
81
+ "@typescript/vfs": "^1.6.1",
82
+ "@vitest/coverage-v8": "^3.0.8",
83
+ "@vitest/eslint-plugin": "^1.1.37",
84
+ "bumpp": "^10.1.0",
85
+ "eslint": "^9.22.0",
86
+ "eslint-config-flat-gitignore": "^2.1.0",
87
+ "eslint-doc-generator": "^2.1.1",
88
+ "eslint-import-resolver-typescript": "^3.8.5",
89
89
  "eslint-plugin-eslint-plugin": "^6.4.0",
90
90
  "eslint-plugin-import-x": "^4.6.1",
91
- "eslint-plugin-n": "^17.15.1",
92
- "markdownlint-cli2": "^0.17.1",
93
- "rxjs": "^7.8.1",
94
- "tsup": "^8.3.5",
95
- "typescript": "~5.7.2",
96
- "typescript-eslint": "^8.19.1",
97
- "vitest": "^2.1.8"
91
+ "eslint-plugin-n": "^17.16.2",
92
+ "markdownlint-cli2": "^0.17.2",
93
+ "rxjs": "^7.8.2",
94
+ "tsup": "^8.4.0",
95
+ "typescript": "~5.7.3",
96
+ "typescript-eslint": "^8.26.1",
97
+ "vitest": "^3.0.8"
98
98
  },
99
99
  "engines": {
100
100
  "node": "^18.18.0 || ^20.9.0 || >= 21.1.0"