@fedify/lint 2.2.10 → 2.2.11

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/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/lint",
3
- "version": "2.2.10",
3
+ "version": "2.2.11",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./src/mod.ts"
package/dist/index.cjs CHANGED
@@ -29,7 +29,7 @@ let _typescript_eslint_parser = require("@typescript-eslint/parser");
29
29
  _typescript_eslint_parser = __toESM(_typescript_eslint_parser);
30
30
  //#region deno.json
31
31
  var name = "@fedify/lint";
32
- var version = "2.2.10";
32
+ var version = "2.2.11";
33
33
  //#endregion
34
34
  //#region src/lib/const.ts
35
35
  /**
@@ -273,7 +273,21 @@ const checkObjectExpression = (propertyChecker) => (obj) => obj.properties.some(
273
273
  * @returns A function that checks the ConditionalExpression
274
274
  */
275
275
  const checkConditionalExpression = (propertyChecker) => (node) => [node.consequent, node.alternate].every(checkBranchWith(propertyChecker));
276
- const checkBranchWith = (propertyChecker) => (branch) => (0, _fxts_core.pipe)(branch, cases(isNodeType("ConditionalExpression"), checkConditionalExpression(propertyChecker), (0, _fxts_core.pipeLazy)(extractObjectExpression, cases(_fxts_core.isObject, checkObjectExpression(propertyChecker), (0, _fxts_core.always)(false)))));
276
+ const unwrapTypeScriptExpression = (node) => {
277
+ switch (node.type) {
278
+ case "TSAsExpression":
279
+ case "TSSatisfiesExpression":
280
+ case "TSNonNullExpression":
281
+ case "TSTypeAssertion": return unwrapTypeScriptExpression(node.expression);
282
+ default: return node;
283
+ }
284
+ };
285
+ const isNullLiteral = (node) => node.type === "Literal" && node.value === null;
286
+ const checkBranchWith = (propertyChecker) => (branch) => {
287
+ const expression = unwrapTypeScriptExpression(branch);
288
+ if (isNullLiteral(expression)) return true;
289
+ return (0, _fxts_core.pipe)(expression, cases(isNodeType("ConditionalExpression"), checkConditionalExpression(propertyChecker), (0, _fxts_core.pipeLazy)(extractObjectExpression, cases(_fxts_core.isObject, checkObjectExpression(propertyChecker), (0, _fxts_core.always)(false)))));
290
+ };
277
291
  /**
278
292
  * Extracts the first argument if it's an ObjectExpression.
279
293
  */
@@ -299,7 +313,7 @@ const createPropertySearcher = (propertyChecker) => {
299
313
  case "ReturnStatement": return checkReturnStatement(propertyChecker)(node);
300
314
  case "BlockStatement": return checkAllReturnPaths(propertyChecker)(node);
301
315
  case "NewExpression": return (0, _fxts_core.pipe)(node, extractFirstObjectExpression, (0, _fxts_core.when)(_fxts_core.isObject, checkObjectExpression(propertyChecker)), Boolean);
302
- default: return false;
316
+ default: return checkBranchWith(propertyChecker)(node);
303
317
  }
304
318
  };
305
319
  };
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { always, every, fromEntries, head, isEmpty, isObject, keys, map, negate,
2
2
  import parser from "@typescript-eslint/parser";
3
3
  //#region deno.json
4
4
  var name = "@fedify/lint";
5
- var version = "2.2.10";
5
+ var version = "2.2.11";
6
6
  //#endregion
7
7
  //#region src/lib/const.ts
8
8
  /**
@@ -246,7 +246,21 @@ const checkObjectExpression = (propertyChecker) => (obj) => obj.properties.some(
246
246
  * @returns A function that checks the ConditionalExpression
247
247
  */
248
248
  const checkConditionalExpression = (propertyChecker) => (node) => [node.consequent, node.alternate].every(checkBranchWith(propertyChecker));
249
- const checkBranchWith = (propertyChecker) => (branch) => pipe(branch, cases(isNodeType("ConditionalExpression"), checkConditionalExpression(propertyChecker), pipeLazy(extractObjectExpression, cases(isObject, checkObjectExpression(propertyChecker), always(false)))));
249
+ const unwrapTypeScriptExpression = (node) => {
250
+ switch (node.type) {
251
+ case "TSAsExpression":
252
+ case "TSSatisfiesExpression":
253
+ case "TSNonNullExpression":
254
+ case "TSTypeAssertion": return unwrapTypeScriptExpression(node.expression);
255
+ default: return node;
256
+ }
257
+ };
258
+ const isNullLiteral = (node) => node.type === "Literal" && node.value === null;
259
+ const checkBranchWith = (propertyChecker) => (branch) => {
260
+ const expression = unwrapTypeScriptExpression(branch);
261
+ if (isNullLiteral(expression)) return true;
262
+ return pipe(expression, cases(isNodeType("ConditionalExpression"), checkConditionalExpression(propertyChecker), pipeLazy(extractObjectExpression, cases(isObject, checkObjectExpression(propertyChecker), always(false)))));
263
+ };
250
264
  /**
251
265
  * Extracts the first argument if it's an ObjectExpression.
252
266
  */
@@ -272,7 +286,7 @@ const createPropertySearcher = (propertyChecker) => {
272
286
  case "ReturnStatement": return checkReturnStatement(propertyChecker)(node);
273
287
  case "BlockStatement": return checkAllReturnPaths(propertyChecker)(node);
274
288
  case "NewExpression": return pipe(node, extractFirstObjectExpression, when(isObject, checkObjectExpression(propertyChecker)), Boolean);
275
- default: return false;
289
+ default: return checkBranchWith(propertyChecker)(node);
276
290
  }
277
291
  };
278
292
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/lint",
3
- "version": "2.2.10",
3
+ "version": "2.2.11",
4
4
  "description": "Fedify linting rules and plugins",
5
5
  "keywords": [
6
6
  "Fedify",
@@ -47,7 +47,7 @@
47
47
  ],
48
48
  "peerDependencies": {
49
49
  "eslint": ">=9.0.0",
50
- "@fedify/fedify": "^2.2.10"
50
+ "@fedify/fedify": "^2.2.11"
51
51
  },
52
52
  "peerDependenciesMeta": {
53
53
  "eslint": {