@vitest/eslint-plugin 1.6.9 → 1.6.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.
Files changed (3) hide show
  1. package/dist/index.cjs +102 -61
  2. package/dist/index.mjs +102 -61
  3. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -4,7 +4,7 @@ let node_path = require("node:path");
4
4
  let _typescript_eslint_scope_manager = require("@typescript-eslint/scope-manager");
5
5
 
6
6
  //#region package.json
7
- var version = "1.6.9";
7
+ var version = "1.6.11";
8
8
 
9
9
  //#endregion
10
10
  //#region src/utils/index.ts
@@ -1806,18 +1806,22 @@ var consistent_each_for_default = createEslintRule({
1806
1806
  type: "object",
1807
1807
  properties: {
1808
1808
  test: {
1809
+ description: "Preferred method for `test`.",
1809
1810
  type: "string",
1810
1811
  enum: ["each", "for"]
1811
1812
  },
1812
1813
  it: {
1814
+ description: "Preferred method for `it`.",
1813
1815
  type: "string",
1814
1816
  enum: ["each", "for"]
1815
1817
  },
1816
1818
  describe: {
1819
+ description: "Preferred method for `describe`.",
1817
1820
  type: "string",
1818
1821
  enum: ["each", "for"]
1819
1822
  },
1820
1823
  suite: {
1824
+ description: "Preferred method for `suite`.",
1821
1825
  type: "string",
1822
1826
  enum: ["each", "for"]
1823
1827
  }
@@ -1871,10 +1875,12 @@ var consistent_test_filename_default = createEslintRule({
1871
1875
  additionalProperties: false,
1872
1876
  properties: {
1873
1877
  pattern: {
1878
+ description: "Regex pattern for files that should be treated as tests.",
1874
1879
  type: "string",
1875
1880
  format: "regex"
1876
1881
  },
1877
1882
  allTestPattern: {
1883
+ description: "Regex pattern used to identify all possible test files.",
1878
1884
  type: "string",
1879
1885
  format: "regex"
1880
1886
  }
@@ -1930,10 +1936,12 @@ var consistent_test_it_default = createEslintRule({
1930
1936
  type: "object",
1931
1937
  properties: {
1932
1938
  fn: {
1939
+ description: "Preferred global test function keyword.",
1933
1940
  type: "string",
1934
1941
  enum: [TestCaseName.test, TestCaseName.it]
1935
1942
  },
1936
1943
  withinDescribe: {
1944
+ description: "Preferred test function keyword inside `describe`.",
1937
1945
  type: "string",
1938
1946
  enum: [TestCaseName.test, TestCaseName.it]
1939
1947
  }
@@ -2038,6 +2046,7 @@ var consistent_vitest_vi_default = createEslintRule({
2038
2046
  schema: [{
2039
2047
  type: "object",
2040
2048
  properties: { fn: {
2049
+ description: "Preferred utility keyword to enforce.",
2041
2050
  type: "string",
2042
2051
  enum: [UtilName.vi, UtilName.vitest]
2043
2052
  } },
@@ -2120,10 +2129,12 @@ var expect_expect_default = createEslintRule({
2120
2129
  type: "object",
2121
2130
  properties: {
2122
2131
  assertFunctionNames: {
2132
+ description: "List of function names treated as assertions.",
2123
2133
  type: "array",
2124
2134
  items: { type: "string" }
2125
2135
  },
2126
2136
  additionalTestBlockFunctions: {
2137
+ description: "Additional functions that should be treated as test blocks.",
2127
2138
  type: "array",
2128
2139
  items: { type: "string" }
2129
2140
  }
@@ -2271,7 +2282,10 @@ var max_expects_default = createEslintRule({
2271
2282
  type: "suggestion",
2272
2283
  schema: [{
2273
2284
  type: "object",
2274
- properties: { max: { type: "number" } },
2285
+ properties: { max: {
2286
+ description: "Maximum number of `expect` calls allowed in a test.",
2287
+ type: "number"
2288
+ } },
2275
2289
  additionalProperties: false
2276
2290
  }],
2277
2291
  defaultOptions: [{ max: 5 }]
@@ -2316,7 +2330,10 @@ var max_nested_describe_default = createEslintRule({
2316
2330
  },
2317
2331
  schema: [{
2318
2332
  type: "object",
2319
- properties: { max: { type: "number" } },
2333
+ properties: { max: {
2334
+ description: "Maximum allowed nesting depth for `describe` blocks.",
2335
+ type: "number"
2336
+ } },
2320
2337
  additionalProperties: false
2321
2338
  }],
2322
2339
  messages: { maxNestedDescribe: "Nested describe block should be less than set max value" },
@@ -2768,16 +2785,6 @@ var no_duplicate_hooks_default = createEslintRule({
2768
2785
  //#endregion
2769
2786
  //#region src/rules/no-focused-tests.ts
2770
2787
  const RULE_NAME$64 = "no-focused-tests";
2771
- const isTestOrDescribe = (node) => {
2772
- return node.type === "Identifier" && [
2773
- "it",
2774
- "test",
2775
- "describe"
2776
- ].includes(node.name);
2777
- };
2778
- const isOnly = (node) => {
2779
- return node.type === "Identifier" && node.name === "only";
2780
- };
2781
2788
  var no_focused_tests_default = createEslintRule({
2782
2789
  name: RULE_NAME$64,
2783
2790
  meta: {
@@ -2789,7 +2796,10 @@ var no_focused_tests_default = createEslintRule({
2789
2796
  fixable: "code",
2790
2797
  schema: [{
2791
2798
  type: "object",
2792
- properties: { fixable: { type: "boolean" } },
2799
+ properties: { fixable: {
2800
+ description: "Whether the rule should provide an autofix.",
2801
+ type: "boolean"
2802
+ } },
2793
2803
  additionalProperties: false
2794
2804
  }],
2795
2805
  messages: { noFocusedTests: "Focused tests are not allowed" },
@@ -2797,40 +2807,21 @@ var no_focused_tests_default = createEslintRule({
2797
2807
  },
2798
2808
  create: (context, options) => {
2799
2809
  const fixable = options[0].fixable;
2800
- return {
2801
- ExpressionStatement(node) {
2802
- if (node.expression.type === "CallExpression") {
2803
- const { callee } = node.expression;
2804
- if (callee.type === "MemberExpression" && isTestOrDescribe(callee.object) && isOnly(callee.property)) context.report({
2805
- node: callee.property,
2806
- messageId: "noFocusedTests",
2807
- fix: (fixer) => fixable ? fixer.removeRange([callee.property.range[0] - 1, callee.property.range[1]]) : null
2808
- });
2809
- if (callee.type === "TaggedTemplateExpression") {
2810
- const tagCall = callee.tag.type === "MemberExpression" ? callee.tag.object : null;
2811
- if (!tagCall) return;
2812
- if (tagCall.type === "MemberExpression" && isTestOrDescribe(tagCall.object) && isOnly(tagCall.property)) context.report({
2813
- node: tagCall.property,
2814
- messageId: "noFocusedTests",
2815
- fix: (fixer) => fixable ? fixer.removeRange([tagCall.property.range[0] - 1, tagCall.property.range[1]]) : null
2816
- });
2817
- }
2818
- }
2819
- },
2820
- CallExpression(node) {
2821
- if (node.callee.type === "CallExpression") {
2822
- const { callee } = node.callee;
2823
- if (callee.type === "MemberExpression" && callee.object.type === "MemberExpression" && isTestOrDescribe(callee.object.object) && isOnly(callee.object.property) && callee.property.type === "Identifier" && callee.property.name === "each") {
2824
- const onlyCallee = callee.object.property;
2825
- context.report({
2826
- node: callee.object.property,
2827
- messageId: "noFocusedTests",
2828
- fix: (fixer) => fixable ? fixer.removeRange([onlyCallee.range[0] - 1, onlyCallee.range[1]]) : null
2829
- });
2830
- }
2831
- }
2832
- }
2833
- };
2810
+ return { CallExpression(node) {
2811
+ const vitestFnCall = parseVitestFnCall(node, context);
2812
+ if (!vitestFnCall) return;
2813
+ const isTestOrDescribe = [
2814
+ "it",
2815
+ "test",
2816
+ "describe"
2817
+ ].includes(vitestFnCall.name);
2818
+ const onlyNode = vitestFnCall.members.find((m) => getAccessorValue(m) === "only");
2819
+ if (isTestOrDescribe && onlyNode) context.report({
2820
+ node: onlyNode,
2821
+ messageId: "noFocusedTests",
2822
+ fix: (fixer) => fixable ? fixer.removeRange([onlyNode.range[0] - 1, onlyNode.range[1]]) : null
2823
+ });
2824
+ } };
2834
2825
  }
2835
2826
  });
2836
2827
 
@@ -3160,9 +3151,16 @@ var no_large_snapshots_default = createEslintRule({
3160
3151
  schema: [{
3161
3152
  type: "object",
3162
3153
  properties: {
3163
- maxSize: { type: "number" },
3164
- inlineMaxSize: { type: "number" },
3154
+ maxSize: {
3155
+ description: "Maximum number of lines allowed in external snapshots.",
3156
+ type: "number"
3157
+ },
3158
+ inlineMaxSize: {
3159
+ description: "Maximum number of lines allowed in inline snapshots.",
3160
+ type: "number"
3161
+ },
3165
3162
  allowedSnapshots: {
3163
+ description: "Allowed snapshot names by absolute snapshot file path.",
3166
3164
  type: "object",
3167
3165
  additionalProperties: { type: "array" }
3168
3166
  }
@@ -3238,6 +3236,7 @@ var no_restricted_matchers_default = createEslintRule({
3238
3236
  },
3239
3237
  type: "suggestion",
3240
3238
  schema: [{
3239
+ description: "Restricted matcher chains mapped to optional custom messages.",
3241
3240
  type: "object",
3242
3241
  additionalProperties: { type: ["string", "null"] }
3243
3242
  }],
@@ -3282,6 +3281,7 @@ var no_restricted_vi_methods_default = createEslintRule({
3282
3281
  recommended: false
3283
3282
  },
3284
3283
  schema: [{
3284
+ description: "Restricted `vi` methods mapped to optional custom messages.",
3285
3285
  type: "object",
3286
3286
  additionalProperties: { type: ["string", "null"] }
3287
3287
  }],
@@ -3340,6 +3340,7 @@ var no_standalone_expect_default = createEslintRule({
3340
3340
  schema: [{
3341
3341
  type: "object",
3342
3342
  properties: { additionalTestBlockFunctions: {
3343
+ description: "Additional functions that should be treated as test blocks.",
3343
3344
  type: "array",
3344
3345
  items: { type: "string" }
3345
3346
  } },
@@ -4369,9 +4370,18 @@ var prefer_expect_assertions_default = createEslintRule({
4369
4370
  schema: [{
4370
4371
  type: "object",
4371
4372
  properties: {
4372
- onlyFunctionsWithAsyncKeyword: { type: "boolean" },
4373
- onlyFunctionsWithExpectInLoop: { type: "boolean" },
4374
- onlyFunctionsWithExpectInCallback: { type: "boolean" }
4373
+ onlyFunctionsWithAsyncKeyword: {
4374
+ description: "Only check test functions declared with the async keyword.",
4375
+ type: "boolean"
4376
+ },
4377
+ onlyFunctionsWithExpectInLoop: {
4378
+ description: "Only check test functions that contain `expect` inside loops.",
4379
+ type: "boolean"
4380
+ },
4381
+ onlyFunctionsWithExpectInCallback: {
4382
+ description: "Only check test functions that contain `expect` in callbacks.",
4383
+ type: "boolean"
4384
+ }
4375
4385
  },
4376
4386
  additionalProperties: false
4377
4387
  }],
@@ -4685,6 +4695,7 @@ var prefer_hooks_on_top_default = createEslintRule({
4685
4695
  //#endregion
4686
4696
  //#region src/rules/prefer-import-in-mock.ts
4687
4697
  const RULE_NAME$30 = "prefer-import-in-mock";
4698
+ const MOCK_METHODS = new Set(["mock", "doMock"]);
4688
4699
  var prefer_import_in_mock_default = createEslintRule({
4689
4700
  name: RULE_NAME$30,
4690
4701
  meta: {
@@ -4694,7 +4705,10 @@ var prefer_import_in_mock_default = createEslintRule({
4694
4705
  messages: { preferImport: "Replace '{{path}}' with import('{{path}}')" },
4695
4706
  schema: [{
4696
4707
  type: "object",
4697
- properties: { fixable: { type: "boolean" } },
4708
+ properties: { fixable: {
4709
+ description: "Whether the rule should provide an autofix.",
4710
+ type: "boolean"
4711
+ } },
4698
4712
  additionalProperties: false
4699
4713
  }],
4700
4714
  defaultOptions: [{ fixable: true }]
@@ -4705,7 +4719,7 @@ var prefer_import_in_mock_default = createEslintRule({
4705
4719
  if (node.callee.type !== _typescript_eslint_utils.AST_NODE_TYPES.MemberExpression) return;
4706
4720
  if (parseVitestFnCall(node, context)?.type !== "vi") return false;
4707
4721
  const { property } = node.callee;
4708
- if (property.type != _typescript_eslint_utils.AST_NODE_TYPES.Identifier || property.name != "mock") return;
4722
+ if (property.type != _typescript_eslint_utils.AST_NODE_TYPES.Identifier || !MOCK_METHODS.has(property.name)) return;
4709
4723
  const pathArg = node.arguments[0];
4710
4724
  if (pathArg && pathArg.type === _typescript_eslint_utils.AST_NODE_TYPES.Literal) context.report({
4711
4725
  messageId: "preferImport",
@@ -4822,6 +4836,7 @@ var prefer_lowercase_title_default = createEslintRule({
4822
4836
  type: "object",
4823
4837
  properties: {
4824
4838
  ignore: {
4839
+ description: "Functions whose titles should be ignored when checking case.",
4825
4840
  type: "array",
4826
4841
  items: {
4827
4842
  type: "string",
@@ -4833,12 +4848,19 @@ var prefer_lowercase_title_default = createEslintRule({
4833
4848
  }
4834
4849
  },
4835
4850
  allowedPrefixes: {
4851
+ description: "Title prefixes that are exempt from this rule.",
4836
4852
  type: "array",
4837
4853
  items: { type: "string" },
4838
4854
  additionalItems: false
4839
4855
  },
4840
- ignoreTopLevelDescribe: { type: "boolean" },
4841
- lowercaseFirstCharacterOnly: { type: "boolean" }
4856
+ ignoreTopLevelDescribe: {
4857
+ description: "Ignore the first top-level `describe` title.",
4858
+ type: "boolean"
4859
+ },
4860
+ lowercaseFirstCharacterOnly: {
4861
+ description: "Only require the first character to be lowercase.",
4862
+ type: "boolean"
4863
+ }
4842
4864
  },
4843
4865
  additionalProperties: false
4844
4866
  }],
@@ -5010,6 +5032,7 @@ var prefer_snapshot_hint_default = createEslintRule({
5010
5032
  },
5011
5033
  messages: { missingHint: "You should provide a hint for this snapshot" },
5012
5034
  schema: [{
5035
+ description: "When to require snapshot hints.",
5013
5036
  type: "string",
5014
5037
  enum: ["always", "multi"]
5015
5038
  }],
@@ -5638,6 +5661,7 @@ var require_hook_default = createEslintRule({
5638
5661
  schema: [{
5639
5662
  type: "object",
5640
5663
  properties: { allowedFunctionCalls: {
5664
+ description: "Function calls that are allowed outside of hooks.",
5641
5665
  type: "array",
5642
5666
  items: { type: "string" }
5643
5667
  } },
@@ -5811,7 +5835,10 @@ var require_mock_type_parameters_default = createEslintRule({
5811
5835
  fixable: "code",
5812
5836
  schema: [{
5813
5837
  type: "object",
5814
- properties: { checkImportFunctions: { type: "boolean" } },
5838
+ properties: { checkImportFunctions: {
5839
+ description: "Also require type parameters for `importActual` and `importMock`.",
5840
+ type: "boolean"
5841
+ } },
5815
5842
  additionalProperties: false
5816
5843
  }],
5817
5844
  defaultOptions: [{ checkImportFunctions: false }]
@@ -5883,6 +5910,7 @@ var require_top_level_describe_default = createEslintRule({
5883
5910
  schema: [{
5884
5911
  type: "object",
5885
5912
  properties: { maxNumberOfTopLevelDescribes: {
5913
+ description: "Maximum number of `describe` blocks allowed at the top level.",
5886
5914
  type: "number",
5887
5915
  minimum: 1
5888
5916
  } },
@@ -6264,16 +6292,22 @@ var valid_expect_default = createEslintRule({
6264
6292
  schema: [{
6265
6293
  type: "object",
6266
6294
  properties: {
6267
- alwaysAwait: { type: "boolean" },
6295
+ alwaysAwait: {
6296
+ description: "Require awaiting every async assertion.",
6297
+ type: "boolean"
6298
+ },
6268
6299
  asyncMatchers: {
6300
+ description: "Matchers that should be considered async assertions.",
6269
6301
  type: "array",
6270
6302
  items: { type: "string" }
6271
6303
  },
6272
6304
  minArgs: {
6305
+ description: "Minimum number of arguments allowed for `expect`.",
6273
6306
  type: "number",
6274
6307
  minimum: 1
6275
6308
  },
6276
6309
  maxArgs: {
6310
+ description: "Maximum number of arguments allowed for `expect`.",
6277
6311
  type: "number",
6278
6312
  minimum: 1
6279
6313
  }
@@ -6494,9 +6528,16 @@ var valid_title_default = createEslintRule({
6494
6528
  schema: [{
6495
6529
  type: "object",
6496
6530
  properties: {
6497
- ignoreTypeOfDescribeName: { type: "boolean" },
6498
- allowArguments: { type: "boolean" },
6531
+ ignoreTypeOfDescribeName: {
6532
+ description: "Skip validating `describe` titles that come from `typeof`.",
6533
+ type: "boolean"
6534
+ },
6535
+ allowArguments: {
6536
+ description: "Allow dynamic arguments as titles.",
6537
+ type: "boolean"
6538
+ },
6499
6539
  disallowedWords: {
6540
+ description: "Words that are not allowed in test titles.",
6500
6541
  type: "array",
6501
6542
  items: { type: "string" }
6502
6543
  }
package/dist/index.mjs CHANGED
@@ -4,7 +4,7 @@ import { isAbsolute, posix } from "node:path";
4
4
  import { DefinitionType } from "@typescript-eslint/scope-manager";
5
5
 
6
6
  //#region package.json
7
- var version = "1.6.9";
7
+ var version = "1.6.11";
8
8
 
9
9
  //#endregion
10
10
  //#region src/utils/index.ts
@@ -1806,18 +1806,22 @@ var consistent_each_for_default = createEslintRule({
1806
1806
  type: "object",
1807
1807
  properties: {
1808
1808
  test: {
1809
+ description: "Preferred method for `test`.",
1809
1810
  type: "string",
1810
1811
  enum: ["each", "for"]
1811
1812
  },
1812
1813
  it: {
1814
+ description: "Preferred method for `it`.",
1813
1815
  type: "string",
1814
1816
  enum: ["each", "for"]
1815
1817
  },
1816
1818
  describe: {
1819
+ description: "Preferred method for `describe`.",
1817
1820
  type: "string",
1818
1821
  enum: ["each", "for"]
1819
1822
  },
1820
1823
  suite: {
1824
+ description: "Preferred method for `suite`.",
1821
1825
  type: "string",
1822
1826
  enum: ["each", "for"]
1823
1827
  }
@@ -1871,10 +1875,12 @@ var consistent_test_filename_default = createEslintRule({
1871
1875
  additionalProperties: false,
1872
1876
  properties: {
1873
1877
  pattern: {
1878
+ description: "Regex pattern for files that should be treated as tests.",
1874
1879
  type: "string",
1875
1880
  format: "regex"
1876
1881
  },
1877
1882
  allTestPattern: {
1883
+ description: "Regex pattern used to identify all possible test files.",
1878
1884
  type: "string",
1879
1885
  format: "regex"
1880
1886
  }
@@ -1930,10 +1936,12 @@ var consistent_test_it_default = createEslintRule({
1930
1936
  type: "object",
1931
1937
  properties: {
1932
1938
  fn: {
1939
+ description: "Preferred global test function keyword.",
1933
1940
  type: "string",
1934
1941
  enum: [TestCaseName.test, TestCaseName.it]
1935
1942
  },
1936
1943
  withinDescribe: {
1944
+ description: "Preferred test function keyword inside `describe`.",
1937
1945
  type: "string",
1938
1946
  enum: [TestCaseName.test, TestCaseName.it]
1939
1947
  }
@@ -2038,6 +2046,7 @@ var consistent_vitest_vi_default = createEslintRule({
2038
2046
  schema: [{
2039
2047
  type: "object",
2040
2048
  properties: { fn: {
2049
+ description: "Preferred utility keyword to enforce.",
2041
2050
  type: "string",
2042
2051
  enum: [UtilName.vi, UtilName.vitest]
2043
2052
  } },
@@ -2120,10 +2129,12 @@ var expect_expect_default = createEslintRule({
2120
2129
  type: "object",
2121
2130
  properties: {
2122
2131
  assertFunctionNames: {
2132
+ description: "List of function names treated as assertions.",
2123
2133
  type: "array",
2124
2134
  items: { type: "string" }
2125
2135
  },
2126
2136
  additionalTestBlockFunctions: {
2137
+ description: "Additional functions that should be treated as test blocks.",
2127
2138
  type: "array",
2128
2139
  items: { type: "string" }
2129
2140
  }
@@ -2271,7 +2282,10 @@ var max_expects_default = createEslintRule({
2271
2282
  type: "suggestion",
2272
2283
  schema: [{
2273
2284
  type: "object",
2274
- properties: { max: { type: "number" } },
2285
+ properties: { max: {
2286
+ description: "Maximum number of `expect` calls allowed in a test.",
2287
+ type: "number"
2288
+ } },
2275
2289
  additionalProperties: false
2276
2290
  }],
2277
2291
  defaultOptions: [{ max: 5 }]
@@ -2316,7 +2330,10 @@ var max_nested_describe_default = createEslintRule({
2316
2330
  },
2317
2331
  schema: [{
2318
2332
  type: "object",
2319
- properties: { max: { type: "number" } },
2333
+ properties: { max: {
2334
+ description: "Maximum allowed nesting depth for `describe` blocks.",
2335
+ type: "number"
2336
+ } },
2320
2337
  additionalProperties: false
2321
2338
  }],
2322
2339
  messages: { maxNestedDescribe: "Nested describe block should be less than set max value" },
@@ -2768,16 +2785,6 @@ var no_duplicate_hooks_default = createEslintRule({
2768
2785
  //#endregion
2769
2786
  //#region src/rules/no-focused-tests.ts
2770
2787
  const RULE_NAME$64 = "no-focused-tests";
2771
- const isTestOrDescribe = (node) => {
2772
- return node.type === "Identifier" && [
2773
- "it",
2774
- "test",
2775
- "describe"
2776
- ].includes(node.name);
2777
- };
2778
- const isOnly = (node) => {
2779
- return node.type === "Identifier" && node.name === "only";
2780
- };
2781
2788
  var no_focused_tests_default = createEslintRule({
2782
2789
  name: RULE_NAME$64,
2783
2790
  meta: {
@@ -2789,7 +2796,10 @@ var no_focused_tests_default = createEslintRule({
2789
2796
  fixable: "code",
2790
2797
  schema: [{
2791
2798
  type: "object",
2792
- properties: { fixable: { type: "boolean" } },
2799
+ properties: { fixable: {
2800
+ description: "Whether the rule should provide an autofix.",
2801
+ type: "boolean"
2802
+ } },
2793
2803
  additionalProperties: false
2794
2804
  }],
2795
2805
  messages: { noFocusedTests: "Focused tests are not allowed" },
@@ -2797,40 +2807,21 @@ var no_focused_tests_default = createEslintRule({
2797
2807
  },
2798
2808
  create: (context, options) => {
2799
2809
  const fixable = options[0].fixable;
2800
- return {
2801
- ExpressionStatement(node) {
2802
- if (node.expression.type === "CallExpression") {
2803
- const { callee } = node.expression;
2804
- if (callee.type === "MemberExpression" && isTestOrDescribe(callee.object) && isOnly(callee.property)) context.report({
2805
- node: callee.property,
2806
- messageId: "noFocusedTests",
2807
- fix: (fixer) => fixable ? fixer.removeRange([callee.property.range[0] - 1, callee.property.range[1]]) : null
2808
- });
2809
- if (callee.type === "TaggedTemplateExpression") {
2810
- const tagCall = callee.tag.type === "MemberExpression" ? callee.tag.object : null;
2811
- if (!tagCall) return;
2812
- if (tagCall.type === "MemberExpression" && isTestOrDescribe(tagCall.object) && isOnly(tagCall.property)) context.report({
2813
- node: tagCall.property,
2814
- messageId: "noFocusedTests",
2815
- fix: (fixer) => fixable ? fixer.removeRange([tagCall.property.range[0] - 1, tagCall.property.range[1]]) : null
2816
- });
2817
- }
2818
- }
2819
- },
2820
- CallExpression(node) {
2821
- if (node.callee.type === "CallExpression") {
2822
- const { callee } = node.callee;
2823
- if (callee.type === "MemberExpression" && callee.object.type === "MemberExpression" && isTestOrDescribe(callee.object.object) && isOnly(callee.object.property) && callee.property.type === "Identifier" && callee.property.name === "each") {
2824
- const onlyCallee = callee.object.property;
2825
- context.report({
2826
- node: callee.object.property,
2827
- messageId: "noFocusedTests",
2828
- fix: (fixer) => fixable ? fixer.removeRange([onlyCallee.range[0] - 1, onlyCallee.range[1]]) : null
2829
- });
2830
- }
2831
- }
2832
- }
2833
- };
2810
+ return { CallExpression(node) {
2811
+ const vitestFnCall = parseVitestFnCall(node, context);
2812
+ if (!vitestFnCall) return;
2813
+ const isTestOrDescribe = [
2814
+ "it",
2815
+ "test",
2816
+ "describe"
2817
+ ].includes(vitestFnCall.name);
2818
+ const onlyNode = vitestFnCall.members.find((m) => getAccessorValue(m) === "only");
2819
+ if (isTestOrDescribe && onlyNode) context.report({
2820
+ node: onlyNode,
2821
+ messageId: "noFocusedTests",
2822
+ fix: (fixer) => fixable ? fixer.removeRange([onlyNode.range[0] - 1, onlyNode.range[1]]) : null
2823
+ });
2824
+ } };
2834
2825
  }
2835
2826
  });
2836
2827
 
@@ -3160,9 +3151,16 @@ var no_large_snapshots_default = createEslintRule({
3160
3151
  schema: [{
3161
3152
  type: "object",
3162
3153
  properties: {
3163
- maxSize: { type: "number" },
3164
- inlineMaxSize: { type: "number" },
3154
+ maxSize: {
3155
+ description: "Maximum number of lines allowed in external snapshots.",
3156
+ type: "number"
3157
+ },
3158
+ inlineMaxSize: {
3159
+ description: "Maximum number of lines allowed in inline snapshots.",
3160
+ type: "number"
3161
+ },
3165
3162
  allowedSnapshots: {
3163
+ description: "Allowed snapshot names by absolute snapshot file path.",
3166
3164
  type: "object",
3167
3165
  additionalProperties: { type: "array" }
3168
3166
  }
@@ -3238,6 +3236,7 @@ var no_restricted_matchers_default = createEslintRule({
3238
3236
  },
3239
3237
  type: "suggestion",
3240
3238
  schema: [{
3239
+ description: "Restricted matcher chains mapped to optional custom messages.",
3241
3240
  type: "object",
3242
3241
  additionalProperties: { type: ["string", "null"] }
3243
3242
  }],
@@ -3282,6 +3281,7 @@ var no_restricted_vi_methods_default = createEslintRule({
3282
3281
  recommended: false
3283
3282
  },
3284
3283
  schema: [{
3284
+ description: "Restricted `vi` methods mapped to optional custom messages.",
3285
3285
  type: "object",
3286
3286
  additionalProperties: { type: ["string", "null"] }
3287
3287
  }],
@@ -3340,6 +3340,7 @@ var no_standalone_expect_default = createEslintRule({
3340
3340
  schema: [{
3341
3341
  type: "object",
3342
3342
  properties: { additionalTestBlockFunctions: {
3343
+ description: "Additional functions that should be treated as test blocks.",
3343
3344
  type: "array",
3344
3345
  items: { type: "string" }
3345
3346
  } },
@@ -4369,9 +4370,18 @@ var prefer_expect_assertions_default = createEslintRule({
4369
4370
  schema: [{
4370
4371
  type: "object",
4371
4372
  properties: {
4372
- onlyFunctionsWithAsyncKeyword: { type: "boolean" },
4373
- onlyFunctionsWithExpectInLoop: { type: "boolean" },
4374
- onlyFunctionsWithExpectInCallback: { type: "boolean" }
4373
+ onlyFunctionsWithAsyncKeyword: {
4374
+ description: "Only check test functions declared with the async keyword.",
4375
+ type: "boolean"
4376
+ },
4377
+ onlyFunctionsWithExpectInLoop: {
4378
+ description: "Only check test functions that contain `expect` inside loops.",
4379
+ type: "boolean"
4380
+ },
4381
+ onlyFunctionsWithExpectInCallback: {
4382
+ description: "Only check test functions that contain `expect` in callbacks.",
4383
+ type: "boolean"
4384
+ }
4375
4385
  },
4376
4386
  additionalProperties: false
4377
4387
  }],
@@ -4685,6 +4695,7 @@ var prefer_hooks_on_top_default = createEslintRule({
4685
4695
  //#endregion
4686
4696
  //#region src/rules/prefer-import-in-mock.ts
4687
4697
  const RULE_NAME$30 = "prefer-import-in-mock";
4698
+ const MOCK_METHODS = new Set(["mock", "doMock"]);
4688
4699
  var prefer_import_in_mock_default = createEslintRule({
4689
4700
  name: RULE_NAME$30,
4690
4701
  meta: {
@@ -4694,7 +4705,10 @@ var prefer_import_in_mock_default = createEslintRule({
4694
4705
  messages: { preferImport: "Replace '{{path}}' with import('{{path}}')" },
4695
4706
  schema: [{
4696
4707
  type: "object",
4697
- properties: { fixable: { type: "boolean" } },
4708
+ properties: { fixable: {
4709
+ description: "Whether the rule should provide an autofix.",
4710
+ type: "boolean"
4711
+ } },
4698
4712
  additionalProperties: false
4699
4713
  }],
4700
4714
  defaultOptions: [{ fixable: true }]
@@ -4705,7 +4719,7 @@ var prefer_import_in_mock_default = createEslintRule({
4705
4719
  if (node.callee.type !== AST_NODE_TYPES.MemberExpression) return;
4706
4720
  if (parseVitestFnCall(node, context)?.type !== "vi") return false;
4707
4721
  const { property } = node.callee;
4708
- if (property.type != AST_NODE_TYPES.Identifier || property.name != "mock") return;
4722
+ if (property.type != AST_NODE_TYPES.Identifier || !MOCK_METHODS.has(property.name)) return;
4709
4723
  const pathArg = node.arguments[0];
4710
4724
  if (pathArg && pathArg.type === AST_NODE_TYPES.Literal) context.report({
4711
4725
  messageId: "preferImport",
@@ -4822,6 +4836,7 @@ var prefer_lowercase_title_default = createEslintRule({
4822
4836
  type: "object",
4823
4837
  properties: {
4824
4838
  ignore: {
4839
+ description: "Functions whose titles should be ignored when checking case.",
4825
4840
  type: "array",
4826
4841
  items: {
4827
4842
  type: "string",
@@ -4833,12 +4848,19 @@ var prefer_lowercase_title_default = createEslintRule({
4833
4848
  }
4834
4849
  },
4835
4850
  allowedPrefixes: {
4851
+ description: "Title prefixes that are exempt from this rule.",
4836
4852
  type: "array",
4837
4853
  items: { type: "string" },
4838
4854
  additionalItems: false
4839
4855
  },
4840
- ignoreTopLevelDescribe: { type: "boolean" },
4841
- lowercaseFirstCharacterOnly: { type: "boolean" }
4856
+ ignoreTopLevelDescribe: {
4857
+ description: "Ignore the first top-level `describe` title.",
4858
+ type: "boolean"
4859
+ },
4860
+ lowercaseFirstCharacterOnly: {
4861
+ description: "Only require the first character to be lowercase.",
4862
+ type: "boolean"
4863
+ }
4842
4864
  },
4843
4865
  additionalProperties: false
4844
4866
  }],
@@ -5010,6 +5032,7 @@ var prefer_snapshot_hint_default = createEslintRule({
5010
5032
  },
5011
5033
  messages: { missingHint: "You should provide a hint for this snapshot" },
5012
5034
  schema: [{
5035
+ description: "When to require snapshot hints.",
5013
5036
  type: "string",
5014
5037
  enum: ["always", "multi"]
5015
5038
  }],
@@ -5638,6 +5661,7 @@ var require_hook_default = createEslintRule({
5638
5661
  schema: [{
5639
5662
  type: "object",
5640
5663
  properties: { allowedFunctionCalls: {
5664
+ description: "Function calls that are allowed outside of hooks.",
5641
5665
  type: "array",
5642
5666
  items: { type: "string" }
5643
5667
  } },
@@ -5811,7 +5835,10 @@ var require_mock_type_parameters_default = createEslintRule({
5811
5835
  fixable: "code",
5812
5836
  schema: [{
5813
5837
  type: "object",
5814
- properties: { checkImportFunctions: { type: "boolean" } },
5838
+ properties: { checkImportFunctions: {
5839
+ description: "Also require type parameters for `importActual` and `importMock`.",
5840
+ type: "boolean"
5841
+ } },
5815
5842
  additionalProperties: false
5816
5843
  }],
5817
5844
  defaultOptions: [{ checkImportFunctions: false }]
@@ -5883,6 +5910,7 @@ var require_top_level_describe_default = createEslintRule({
5883
5910
  schema: [{
5884
5911
  type: "object",
5885
5912
  properties: { maxNumberOfTopLevelDescribes: {
5913
+ description: "Maximum number of `describe` blocks allowed at the top level.",
5886
5914
  type: "number",
5887
5915
  minimum: 1
5888
5916
  } },
@@ -6264,16 +6292,22 @@ var valid_expect_default = createEslintRule({
6264
6292
  schema: [{
6265
6293
  type: "object",
6266
6294
  properties: {
6267
- alwaysAwait: { type: "boolean" },
6295
+ alwaysAwait: {
6296
+ description: "Require awaiting every async assertion.",
6297
+ type: "boolean"
6298
+ },
6268
6299
  asyncMatchers: {
6300
+ description: "Matchers that should be considered async assertions.",
6269
6301
  type: "array",
6270
6302
  items: { type: "string" }
6271
6303
  },
6272
6304
  minArgs: {
6305
+ description: "Minimum number of arguments allowed for `expect`.",
6273
6306
  type: "number",
6274
6307
  minimum: 1
6275
6308
  },
6276
6309
  maxArgs: {
6310
+ description: "Maximum number of arguments allowed for `expect`.",
6277
6311
  type: "number",
6278
6312
  minimum: 1
6279
6313
  }
@@ -6494,9 +6528,16 @@ var valid_title_default = createEslintRule({
6494
6528
  schema: [{
6495
6529
  type: "object",
6496
6530
  properties: {
6497
- ignoreTypeOfDescribeName: { type: "boolean" },
6498
- allowArguments: { type: "boolean" },
6531
+ ignoreTypeOfDescribeName: {
6532
+ description: "Skip validating `describe` titles that come from `typeof`.",
6533
+ type: "boolean"
6534
+ },
6535
+ allowArguments: {
6536
+ description: "Allow dynamic arguments as titles.",
6537
+ type: "boolean"
6538
+ },
6499
6539
  disallowedWords: {
6540
+ description: "Words that are not allowed in test titles.",
6500
6541
  type: "array",
6501
6542
  items: { type: "string" }
6502
6543
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitest/eslint-plugin",
3
- "version": "1.6.9",
3
+ "version": "1.6.11",
4
4
  "license": "MIT",
5
5
  "description": "ESLint plugin for Vitest",
6
6
  "repository": "vitest-dev/eslint-plugin-vitest",