eslint-plugin-flawless 1.4.2 → 1.4.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.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as plugin, t as PLUGIN_NAME } from "./plugin-F1dJgCBi.mjs";
1
+ import { n as plugin, t as PLUGIN_NAME } from "./plugin-rI_n00SA.mjs";
2
2
  //#region src/configs/index.ts
3
3
  const configs = { recommended: {
4
4
  plugins: { [PLUGIN_NAME]: plugin },
package/dist/oxlint.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as plugin, t as PLUGIN_NAME } from "./plugin-F1dJgCBi.mjs";
1
+ import { n as plugin, t as PLUGIN_NAME } from "./plugin-rI_n00SA.mjs";
2
2
  import { definePlugin } from "@oxlint/plugins";
3
3
  //#region src/oxlint.ts
4
4
  /**
@@ -14,7 +14,7 @@ import * as core from "@eslint-react/core";
14
14
  import { getStaticTOMLValue } from "toml-eslint-parser";
15
15
  //#region package.json
16
16
  var name = "eslint-plugin-flawless";
17
- var version = "1.4.2";
17
+ var version = "1.4.3";
18
18
  var repository = {
19
19
  "url": "git+https://github.com/christopher-buss/eslint-plugin-flawless.git",
20
20
  "type": "git"
@@ -3132,9 +3132,8 @@ function resolveVitestName$1(sourceCode, identifier) {
3132
3132
  */
3133
3133
  function isInAssertionArgument(node, sourceCode) {
3134
3134
  let current = node;
3135
- for (;;) {
3135
+ while (current.type !== AST_NODE_TYPES.Program) {
3136
3136
  const { parent } = current;
3137
- if (parent === void 0) return false;
3138
3137
  if (parent.type === AST_NODE_TYPES.ArrowFunctionExpression || parent.type === AST_NODE_TYPES.FunctionDeclaration || parent.type === AST_NODE_TYPES.FunctionExpression) return false;
3139
3138
  if (parent.type === AST_NODE_TYPES.CallExpression) {
3140
3139
  if (current === parent.callee) return false;
@@ -3144,6 +3143,7 @@ function isInAssertionArgument(node, sourceCode) {
3144
3143
  }
3145
3144
  current = parent;
3146
3145
  }
3146
+ return false;
3147
3147
  }
3148
3148
  /**
3149
3149
  * Collects the `?.` tokens along an optional chain's primary spine and the parts
@@ -3205,13 +3205,13 @@ function collectOptionalTokenFixes(chain, sourceCode) {
3205
3205
  function createOnce$10(context) {
3206
3206
  let config;
3207
3207
  let sourceCode;
3208
- let inTestCase = false;
3208
+ const testBlocks = [];
3209
3209
  /**
3210
- * Determines whether a call opens a test block (a resolved vitest `it`/`test`,
3210
+ * Determines whether a call names a test block (a resolved vitest `it`/`test`,
3211
3211
  * or a configured `additionalTestBlockFunctions` name).
3212
3212
  *
3213
3213
  * @param node - The call to inspect.
3214
- * @returns `true` when the call opens a test.
3214
+ * @returns `true` when the call is rooted at a test block name.
3215
3215
  */
3216
3216
  function isTestBlock(node) {
3217
3217
  const root = getRootIdentifier$1(node.callee);
@@ -3220,12 +3220,46 @@ function createOnce$10(context) {
3220
3220
  return name !== null && config.additionalTestBlockFunctions.includes(name);
3221
3221
  }
3222
3222
  /**
3223
+ * Determines whether a test block call is a modifier applied to the block
3224
+ * rather than the call that opens it. In `it.skipIf(cond)("works", fn)` both
3225
+ * calls are rooted at `it`, but only the outer one takes the test body — the
3226
+ * inner one sits in its callee position.
3227
+ *
3228
+ * @param node - The test block call to inspect.
3229
+ * @returns `true` when the call is a modifier in a callee chain.
3230
+ */
3231
+ function isTestBlockModifier(node) {
3232
+ const { parent } = node;
3233
+ return parent.type === AST_NODE_TYPES.CallExpression && parent.callee === node;
3234
+ }
3235
+ /**
3236
+ * Determines whether a node sits in the body of the innermost open test block.
3237
+ * A node reached through that block's callee — a modifier's arguments
3238
+ * (`it.skipIf(cond)`, `it.each(cases)`) or a computed key (`it[flag ? …]`) —
3239
+ * decides whether and how the test runs rather than what it does, so it is not
3240
+ * part of the body.
3241
+ *
3242
+ * @param node - The node to locate.
3243
+ * @returns `true` when the node is inside a test body.
3244
+ */
3245
+ function isInTestBody(node) {
3246
+ const block = testBlocks.at(-1);
3247
+ if (block === void 0) return false;
3248
+ let current = node;
3249
+ while (current.type !== AST_NODE_TYPES.Program) {
3250
+ const { parent } = current;
3251
+ if (parent === block) return current !== block.callee;
3252
+ current = parent;
3253
+ }
3254
+ return false;
3255
+ }
3256
+ /**
3223
3257
  * Reports a conditional node when the traversal is inside a test body.
3224
3258
  *
3225
3259
  * @param node - The `if`/`switch`/ternary/logical construct to flag.
3226
3260
  */
3227
3261
  function maybeReportConditional(node) {
3228
- if (inTestCase) context.report({
3262
+ if (isInTestBody(node)) context.report({
3229
3263
  messageId: MESSAGE_ID$9,
3230
3264
  node
3231
3265
  });
@@ -3238,16 +3272,16 @@ function createOnce$10(context) {
3238
3272
  allowOptionalChaining: options?.allowOptionalChaining ?? DEFAULTS$1.allowOptionalChaining
3239
3273
  };
3240
3274
  ({sourceCode} = context);
3241
- inTestCase = false;
3275
+ testBlocks.length = 0;
3242
3276
  },
3243
3277
  "CallExpression": function(node) {
3244
- if (isTestBlock(node)) inTestCase = true;
3278
+ if (isTestBlock(node) && !isTestBlockModifier(node)) testBlocks.push(node);
3245
3279
  },
3246
3280
  "CallExpression:exit": function(node) {
3247
- if (isTestBlock(node)) inTestCase = false;
3281
+ if (testBlocks.at(-1) === node) testBlocks.pop();
3248
3282
  },
3249
3283
  "ChainExpression": function(node) {
3250
- if (!inTestCase || config.allowOptionalChaining) return;
3284
+ if (config.allowOptionalChaining || !isInTestBody(node)) return;
3251
3285
  context.report({
3252
3286
  fix: (fixer) => {
3253
3287
  return collectOptionalTokenFixes(node, sourceCode).flatMap((optionalFix) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-flawless",
3
- "version": "1.4.2",
3
+ "version": "1.4.3",
4
4
  "description": "Your ESLint plugin description",
5
5
  "keywords": [
6
6
  "eslint",