@vitest/eslint-plugin 1.0.4 → 1.1.0

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.cjs CHANGED
@@ -3,7 +3,6 @@
3
3
  const utils = require('@typescript-eslint/utils');
4
4
  const path = require('node:path');
5
5
  const ts = require('typescript');
6
- const node_url = require('node:url');
7
6
  const node_module = require('node:module');
8
7
 
9
8
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
@@ -24,7 +23,7 @@ function _interopNamespaceCompat(e) {
24
23
  const path__namespace = /*#__PURE__*/_interopNamespaceCompat(path);
25
24
  const ts__default = /*#__PURE__*/_interopDefaultCompat(ts);
26
25
 
27
- const version = "1.0.3";
26
+ const version = "1.0.5";
28
27
 
29
28
  function createEslintRule(rule) {
30
29
  const createRule = utils.ESLintUtils.RuleCreator(
@@ -2478,6 +2477,13 @@ const validExpect = createEslintRule({
2478
2477
  });
2479
2478
  }
2480
2479
  if (expect.arguments.length > maxArgs) {
2480
+ if (expect.arguments.length === 2) {
2481
+ const isSecondArgString = expect.arguments[1].type === utils.AST_NODE_TYPES.Literal && typeof expect.arguments[1].value === "string";
2482
+ const isSecondArgTemplateLiteral = expect.arguments[1].type === utils.AST_NODE_TYPES.TemplateLiteral;
2483
+ if (isSecondArgString || isSecondArgTemplateLiteral) {
2484
+ return;
2485
+ }
2486
+ }
2481
2487
  const { start } = expect.arguments[maxArgs].loc;
2482
2488
  const { end } = expect.arguments[expect.arguments.length - 1].loc;
2483
2489
  const loc = {
@@ -2530,9 +2536,6 @@ const isBooleanEqualityMatcher = (expectFnCall) => {
2530
2536
  };
2531
2537
  const isInstanceOfBinaryExpression = (node, className) => node.type === utils.AST_NODE_TYPES.BinaryExpression && node.operator === "instanceof" && isSupportedAccessor(node.right, className);
2532
2538
  const hasOnlyOneArgument = (call) => call.arguments.length === 1;
2533
- function getFilename(url) {
2534
- return path.parse(path.basename(node_url.fileURLToPath(url))).name;
2535
- }
2536
2539
 
2537
2540
  const RULE_NAME$t = "prefer-to-be-object";
2538
2541
  const preferToBeObject = createEslintRule({
@@ -4250,7 +4253,7 @@ const createPaddingRule = (name, description, configs, deprecated = false) => {
4250
4253
  });
4251
4254
  };
4252
4255
 
4253
- const RULE_NAME$7 = getFilename((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
4256
+ const RULE_NAME$7 = "padding-around-after-all-blocks";
4254
4257
  const config$6 = [
4255
4258
  {
4256
4259
  paddingType: PaddingType.Always,
@@ -4265,7 +4268,7 @@ const config$6 = [
4265
4268
  ];
4266
4269
  const paddingAroundAfterAllBlocks = createPaddingRule(RULE_NAME$7, "Enforce padding around `afterAll` blocks", config$6);
4267
4270
 
4268
- const RULE_NAME$6 = getFilename((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
4271
+ const RULE_NAME$6 = "padding-around-after-each-blocks";
4269
4272
  const config$5 = [
4270
4273
  {
4271
4274
  paddingType: PaddingType.Always,
@@ -4280,7 +4283,7 @@ const config$5 = [
4280
4283
  ];
4281
4284
  const paddingAroundAfterEachBlocks = createPaddingRule(RULE_NAME$6, "Enforce padding around `afterEach` blocks", config$5);
4282
4285
 
4283
- const RULE_NAME$5 = getFilename((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
4286
+ const RULE_NAME$5 = "padding-around-before-all-blocks";
4284
4287
  const config$4 = [
4285
4288
  {
4286
4289
  paddingType: PaddingType.Always,
@@ -4295,7 +4298,7 @@ const config$4 = [
4295
4298
  ];
4296
4299
  const paddingAroundBeforeAllBlocks = createPaddingRule(RULE_NAME$5, "Enforce padding around `beforeAll` blocks", config$4);
4297
4300
 
4298
- const RULE_NAME$4 = getFilename((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
4301
+ const RULE_NAME$4 = "padding-around-before-each-blocks";
4299
4302
  const config$3 = [
4300
4303
  {
4301
4304
  paddingType: PaddingType.Always,
@@ -4314,7 +4317,7 @@ const paddingAroundBeforeEachBlocks = createPaddingRule(
4314
4317
  config$3
4315
4318
  );
4316
4319
 
4317
- const RULE_NAME$3 = getFilename((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
4320
+ const RULE_NAME$3 = "padding-around-describe-blocks";
4318
4321
  const config$2 = [
4319
4322
  {
4320
4323
  paddingType: PaddingType.Always,
@@ -4341,7 +4344,7 @@ const paddingAroundDescribeBlocks = createPaddingRule(
4341
4344
  config$2
4342
4345
  );
4343
4346
 
4344
- const RULE_NAME$2 = getFilename((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
4347
+ const RULE_NAME$2 = "padding-around-expect-groups";
4345
4348
  const config$1 = [
4346
4349
  {
4347
4350
  paddingType: PaddingType.Always,
@@ -4365,7 +4368,7 @@ const paddingAroundExpectGroups = createPaddingRule(
4365
4368
  config$1
4366
4369
  );
4367
4370
 
4368
- const RULE_NAME$1 = getFilename((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
4371
+ const RULE_NAME$1 = "padding-around-test-blocks";
4369
4372
  const config = [
4370
4373
  {
4371
4374
  paddingType: PaddingType.Always,
@@ -4396,7 +4399,7 @@ const paddingAroundTestBlocks = createPaddingRule(
4396
4399
  config
4397
4400
  );
4398
4401
 
4399
- const RULE_NAME = getFilename((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
4402
+ const RULE_NAME = "padding-around-all";
4400
4403
  const paddingAroundAll = createPaddingRule(
4401
4404
  RULE_NAME,
4402
4405
  "Enforce padding around vitest functions",
package/dist/index.d.cts CHANGED
@@ -7,7 +7,6 @@ declare const plugin: {
7
7
  version: string;
8
8
  };
9
9
  rules: {
10
- [x: string]: eslint.Rule.RuleModule;
11
10
  "prefer-lowercase-title": eslint.Rule.RuleModule;
12
11
  "max-nested-describe": eslint.Rule.RuleModule;
13
12
  "no-identical-title": eslint.Rule.RuleModule;
@@ -60,6 +59,14 @@ declare const plugin: {
60
59
  "prefer-comparison-matcher": eslint.Rule.RuleModule;
61
60
  "prefer-to-contain": eslint.Rule.RuleModule;
62
61
  "prefer-expect-assertions": eslint.Rule.RuleModule;
62
+ "padding-around-after-all-blocks": eslint.Rule.RuleModule;
63
+ "padding-around-after-each-blocks": eslint.Rule.RuleModule;
64
+ "padding-around-all": eslint.Rule.RuleModule;
65
+ "padding-around-before-all-blocks": eslint.Rule.RuleModule;
66
+ "padding-around-before-each-blocks": eslint.Rule.RuleModule;
67
+ "padding-around-describe-blocks": eslint.Rule.RuleModule;
68
+ "padding-around-expect-groups": eslint.Rule.RuleModule;
69
+ "padding-around-test-blocks": eslint.Rule.RuleModule;
63
70
  };
64
71
  configs: {
65
72
  'legacy-recommended': {
@@ -90,7 +97,6 @@ declare const plugin: {
90
97
  readonly vitest: ESLint.Plugin;
91
98
  };
92
99
  rules: {
93
- readonly [x: `vitest/${string}`]: "warn";
94
100
  readonly "vitest/prefer-lowercase-title": "warn";
95
101
  readonly "vitest/max-nested-describe": "warn";
96
102
  readonly "vitest/no-focused-tests": "warn";
@@ -135,6 +141,14 @@ declare const plugin: {
135
141
  readonly "vitest/prefer-to-contain": "warn";
136
142
  readonly "vitest/prefer-expect-assertions": "warn";
137
143
  readonly "vitest/prefer-to-be": "warn";
144
+ readonly "vitest/padding-around-after-all-blocks": "warn";
145
+ readonly "vitest/padding-around-after-each-blocks": "warn";
146
+ readonly "vitest/padding-around-all": "warn";
147
+ readonly "vitest/padding-around-before-all-blocks": "warn";
148
+ readonly "vitest/padding-around-before-each-blocks": "warn";
149
+ readonly "vitest/padding-around-describe-blocks": "warn";
150
+ readonly "vitest/padding-around-expect-groups": "warn";
151
+ readonly "vitest/padding-around-test-blocks": "warn";
138
152
  };
139
153
  };
140
154
  env: {
package/dist/index.d.mts CHANGED
@@ -7,7 +7,6 @@ declare const plugin: {
7
7
  version: string;
8
8
  };
9
9
  rules: {
10
- [x: string]: eslint.Rule.RuleModule;
11
10
  "prefer-lowercase-title": eslint.Rule.RuleModule;
12
11
  "max-nested-describe": eslint.Rule.RuleModule;
13
12
  "no-identical-title": eslint.Rule.RuleModule;
@@ -60,6 +59,14 @@ declare const plugin: {
60
59
  "prefer-comparison-matcher": eslint.Rule.RuleModule;
61
60
  "prefer-to-contain": eslint.Rule.RuleModule;
62
61
  "prefer-expect-assertions": eslint.Rule.RuleModule;
62
+ "padding-around-after-all-blocks": eslint.Rule.RuleModule;
63
+ "padding-around-after-each-blocks": eslint.Rule.RuleModule;
64
+ "padding-around-all": eslint.Rule.RuleModule;
65
+ "padding-around-before-all-blocks": eslint.Rule.RuleModule;
66
+ "padding-around-before-each-blocks": eslint.Rule.RuleModule;
67
+ "padding-around-describe-blocks": eslint.Rule.RuleModule;
68
+ "padding-around-expect-groups": eslint.Rule.RuleModule;
69
+ "padding-around-test-blocks": eslint.Rule.RuleModule;
63
70
  };
64
71
  configs: {
65
72
  'legacy-recommended': {
@@ -90,7 +97,6 @@ declare const plugin: {
90
97
  readonly vitest: ESLint.Plugin;
91
98
  };
92
99
  rules: {
93
- readonly [x: `vitest/${string}`]: "warn";
94
100
  readonly "vitest/prefer-lowercase-title": "warn";
95
101
  readonly "vitest/max-nested-describe": "warn";
96
102
  readonly "vitest/no-focused-tests": "warn";
@@ -135,6 +141,14 @@ declare const plugin: {
135
141
  readonly "vitest/prefer-to-contain": "warn";
136
142
  readonly "vitest/prefer-expect-assertions": "warn";
137
143
  readonly "vitest/prefer-to-be": "warn";
144
+ readonly "vitest/padding-around-after-all-blocks": "warn";
145
+ readonly "vitest/padding-around-after-each-blocks": "warn";
146
+ readonly "vitest/padding-around-all": "warn";
147
+ readonly "vitest/padding-around-before-all-blocks": "warn";
148
+ readonly "vitest/padding-around-before-each-blocks": "warn";
149
+ readonly "vitest/padding-around-describe-blocks": "warn";
150
+ readonly "vitest/padding-around-expect-groups": "warn";
151
+ readonly "vitest/padding-around-test-blocks": "warn";
138
152
  };
139
153
  };
140
154
  env: {
package/dist/index.d.ts CHANGED
@@ -7,7 +7,6 @@ declare const plugin: {
7
7
  version: string;
8
8
  };
9
9
  rules: {
10
- [x: string]: eslint.Rule.RuleModule;
11
10
  "prefer-lowercase-title": eslint.Rule.RuleModule;
12
11
  "max-nested-describe": eslint.Rule.RuleModule;
13
12
  "no-identical-title": eslint.Rule.RuleModule;
@@ -60,6 +59,14 @@ declare const plugin: {
60
59
  "prefer-comparison-matcher": eslint.Rule.RuleModule;
61
60
  "prefer-to-contain": eslint.Rule.RuleModule;
62
61
  "prefer-expect-assertions": eslint.Rule.RuleModule;
62
+ "padding-around-after-all-blocks": eslint.Rule.RuleModule;
63
+ "padding-around-after-each-blocks": eslint.Rule.RuleModule;
64
+ "padding-around-all": eslint.Rule.RuleModule;
65
+ "padding-around-before-all-blocks": eslint.Rule.RuleModule;
66
+ "padding-around-before-each-blocks": eslint.Rule.RuleModule;
67
+ "padding-around-describe-blocks": eslint.Rule.RuleModule;
68
+ "padding-around-expect-groups": eslint.Rule.RuleModule;
69
+ "padding-around-test-blocks": eslint.Rule.RuleModule;
63
70
  };
64
71
  configs: {
65
72
  'legacy-recommended': {
@@ -90,7 +97,6 @@ declare const plugin: {
90
97
  readonly vitest: ESLint.Plugin;
91
98
  };
92
99
  rules: {
93
- readonly [x: `vitest/${string}`]: "warn";
94
100
  readonly "vitest/prefer-lowercase-title": "warn";
95
101
  readonly "vitest/max-nested-describe": "warn";
96
102
  readonly "vitest/no-focused-tests": "warn";
@@ -135,6 +141,14 @@ declare const plugin: {
135
141
  readonly "vitest/prefer-to-contain": "warn";
136
142
  readonly "vitest/prefer-expect-assertions": "warn";
137
143
  readonly "vitest/prefer-to-be": "warn";
144
+ readonly "vitest/padding-around-after-all-blocks": "warn";
145
+ readonly "vitest/padding-around-after-each-blocks": "warn";
146
+ readonly "vitest/padding-around-all": "warn";
147
+ readonly "vitest/padding-around-before-all-blocks": "warn";
148
+ readonly "vitest/padding-around-before-each-blocks": "warn";
149
+ readonly "vitest/padding-around-describe-blocks": "warn";
150
+ readonly "vitest/padding-around-expect-groups": "warn";
151
+ readonly "vitest/padding-around-test-blocks": "warn";
138
152
  };
139
153
  };
140
154
  env: {
package/dist/index.mjs CHANGED
@@ -1,11 +1,10 @@
1
1
  import { ESLintUtils, AST_NODE_TYPES, AST_TOKEN_TYPES } from '@typescript-eslint/utils';
2
2
  import * as path from 'node:path';
3
- import { isAbsolute, posix, parse, basename } from 'node:path';
3
+ import { isAbsolute, posix } from 'node:path';
4
4
  import ts from 'typescript';
5
- import { fileURLToPath } from 'node:url';
6
5
  import { createRequire } from 'node:module';
7
6
 
8
- const version = "1.0.3";
7
+ const version = "1.0.5";
9
8
 
10
9
  function createEslintRule(rule) {
11
10
  const createRule = ESLintUtils.RuleCreator(
@@ -2459,6 +2458,13 @@ const validExpect = createEslintRule({
2459
2458
  });
2460
2459
  }
2461
2460
  if (expect.arguments.length > maxArgs) {
2461
+ if (expect.arguments.length === 2) {
2462
+ const isSecondArgString = expect.arguments[1].type === AST_NODE_TYPES.Literal && typeof expect.arguments[1].value === "string";
2463
+ const isSecondArgTemplateLiteral = expect.arguments[1].type === AST_NODE_TYPES.TemplateLiteral;
2464
+ if (isSecondArgString || isSecondArgTemplateLiteral) {
2465
+ return;
2466
+ }
2467
+ }
2462
2468
  const { start } = expect.arguments[maxArgs].loc;
2463
2469
  const { end } = expect.arguments[expect.arguments.length - 1].loc;
2464
2470
  const loc = {
@@ -2511,9 +2517,6 @@ const isBooleanEqualityMatcher = (expectFnCall) => {
2511
2517
  };
2512
2518
  const isInstanceOfBinaryExpression = (node, className) => node.type === AST_NODE_TYPES.BinaryExpression && node.operator === "instanceof" && isSupportedAccessor(node.right, className);
2513
2519
  const hasOnlyOneArgument = (call) => call.arguments.length === 1;
2514
- function getFilename(url) {
2515
- return parse(basename(fileURLToPath(url))).name;
2516
- }
2517
2520
 
2518
2521
  const RULE_NAME$t = "prefer-to-be-object";
2519
2522
  const preferToBeObject = createEslintRule({
@@ -4231,7 +4234,7 @@ const createPaddingRule = (name, description, configs, deprecated = false) => {
4231
4234
  });
4232
4235
  };
4233
4236
 
4234
- const RULE_NAME$7 = getFilename(import.meta.url);
4237
+ const RULE_NAME$7 = "padding-around-after-all-blocks";
4235
4238
  const config$6 = [
4236
4239
  {
4237
4240
  paddingType: PaddingType.Always,
@@ -4246,7 +4249,7 @@ const config$6 = [
4246
4249
  ];
4247
4250
  const paddingAroundAfterAllBlocks = createPaddingRule(RULE_NAME$7, "Enforce padding around `afterAll` blocks", config$6);
4248
4251
 
4249
- const RULE_NAME$6 = getFilename(import.meta.url);
4252
+ const RULE_NAME$6 = "padding-around-after-each-blocks";
4250
4253
  const config$5 = [
4251
4254
  {
4252
4255
  paddingType: PaddingType.Always,
@@ -4261,7 +4264,7 @@ const config$5 = [
4261
4264
  ];
4262
4265
  const paddingAroundAfterEachBlocks = createPaddingRule(RULE_NAME$6, "Enforce padding around `afterEach` blocks", config$5);
4263
4266
 
4264
- const RULE_NAME$5 = getFilename(import.meta.url);
4267
+ const RULE_NAME$5 = "padding-around-before-all-blocks";
4265
4268
  const config$4 = [
4266
4269
  {
4267
4270
  paddingType: PaddingType.Always,
@@ -4276,7 +4279,7 @@ const config$4 = [
4276
4279
  ];
4277
4280
  const paddingAroundBeforeAllBlocks = createPaddingRule(RULE_NAME$5, "Enforce padding around `beforeAll` blocks", config$4);
4278
4281
 
4279
- const RULE_NAME$4 = getFilename(import.meta.url);
4282
+ const RULE_NAME$4 = "padding-around-before-each-blocks";
4280
4283
  const config$3 = [
4281
4284
  {
4282
4285
  paddingType: PaddingType.Always,
@@ -4295,7 +4298,7 @@ const paddingAroundBeforeEachBlocks = createPaddingRule(
4295
4298
  config$3
4296
4299
  );
4297
4300
 
4298
- const RULE_NAME$3 = getFilename(import.meta.url);
4301
+ const RULE_NAME$3 = "padding-around-describe-blocks";
4299
4302
  const config$2 = [
4300
4303
  {
4301
4304
  paddingType: PaddingType.Always,
@@ -4322,7 +4325,7 @@ const paddingAroundDescribeBlocks = createPaddingRule(
4322
4325
  config$2
4323
4326
  );
4324
4327
 
4325
- const RULE_NAME$2 = getFilename(import.meta.url);
4328
+ const RULE_NAME$2 = "padding-around-expect-groups";
4326
4329
  const config$1 = [
4327
4330
  {
4328
4331
  paddingType: PaddingType.Always,
@@ -4346,7 +4349,7 @@ const paddingAroundExpectGroups = createPaddingRule(
4346
4349
  config$1
4347
4350
  );
4348
4351
 
4349
- const RULE_NAME$1 = getFilename(import.meta.url);
4352
+ const RULE_NAME$1 = "padding-around-test-blocks";
4350
4353
  const config = [
4351
4354
  {
4352
4355
  paddingType: PaddingType.Always,
@@ -4377,7 +4380,7 @@ const paddingAroundTestBlocks = createPaddingRule(
4377
4380
  config
4378
4381
  );
4379
4382
 
4380
- const RULE_NAME = getFilename(import.meta.url);
4383
+ const RULE_NAME = "padding-around-all";
4381
4384
  const paddingAroundAll = createPaddingRule(
4382
4385
  RULE_NAME,
4383
4386
  "Enforce padding around vitest functions",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitest/eslint-plugin",
3
- "version": "1.0.4",
3
+ "version": "1.1.0",
4
4
  "license": "MIT",
5
5
  "description": "Eslint plugin for vitest",
6
6
  "repository": "vitest-dev/eslint-plugin-vitest",