@vitest/eslint-plugin 1.0.5 → 1.1.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/README.md CHANGED
@@ -46,7 +46,7 @@ Add `vitest` to the plugins section of your `.eslintrc` configuration file. You
46
46
 
47
47
  ```json
48
48
  {
49
- "plugins": ["@vitest"]
49
+ "plugins": ["vitest"]
50
50
  }
51
51
  ```
52
52
 
@@ -69,7 +69,7 @@ If you're using old Eslint configuration, make sure to use legacy key like the f
69
69
 
70
70
  ```js
71
71
  {
72
- "extends": ["plugin:@vitest/legacy-recommended"] // or legacy-all
72
+ "extends": ["plugin:vitest/legacy-recommended"] // or legacy-all
73
73
  }
74
74
  ```
75
75
 
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.4";
26
+ const version = "1.1.0";
28
27
 
29
28
  function createEslintRule(rule) {
30
29
  const createRule = utils.ESLintUtils.RuleCreator(
@@ -394,7 +393,8 @@ const lowerCaseTitle = createEslintRule({
394
393
  },
395
394
  fixable: "code",
396
395
  messages: {
397
- lowerCaseTitle: "`{{ method }}`s should begin with lowercase"
396
+ lowerCaseTitle: "`{{ method }}`s should begin with lowercase",
397
+ fullyLowerCaseTitle: "`{{ method }}`s should be lowercase"
398
398
  },
399
399
  schema: [
400
400
  {
@@ -457,7 +457,7 @@ const lowerCaseTitle = createEslintRule({
457
457
  if (ignores.includes(vitestFnCall.name) || lowercaseFirstCharacterOnly && (!firstCharacter || firstCharacter === firstCharacter.toLowerCase()) || !lowercaseFirstCharacterOnly && description === description.toLowerCase())
458
458
  return;
459
459
  context.report({
460
- messageId: "lowerCaseTitle",
460
+ messageId: lowercaseFirstCharacterOnly ? "lowerCaseTitle" : "fullyLowerCaseTitle",
461
461
  node: node.arguments[0],
462
462
  data: {
463
463
  method: vitestFnCall.name
@@ -2537,9 +2537,6 @@ const isBooleanEqualityMatcher = (expectFnCall) => {
2537
2537
  };
2538
2538
  const isInstanceOfBinaryExpression = (node, className) => node.type === utils.AST_NODE_TYPES.BinaryExpression && node.operator === "instanceof" && isSupportedAccessor(node.right, className);
2539
2539
  const hasOnlyOneArgument = (call) => call.arguments.length === 1;
2540
- function getFilename(url) {
2541
- return path.parse(path.basename(node_url.fileURLToPath(url))).name;
2542
- }
2543
2540
 
2544
2541
  const RULE_NAME$t = "prefer-to-be-object";
2545
2542
  const preferToBeObject = createEslintRule({
@@ -4257,7 +4254,7 @@ const createPaddingRule = (name, description, configs, deprecated = false) => {
4257
4254
  });
4258
4255
  };
4259
4256
 
4260
- const RULE_NAME$7 = getFilename((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
4257
+ const RULE_NAME$7 = "padding-around-after-all-blocks";
4261
4258
  const config$6 = [
4262
4259
  {
4263
4260
  paddingType: PaddingType.Always,
@@ -4272,7 +4269,7 @@ const config$6 = [
4272
4269
  ];
4273
4270
  const paddingAroundAfterAllBlocks = createPaddingRule(RULE_NAME$7, "Enforce padding around `afterAll` blocks", config$6);
4274
4271
 
4275
- const RULE_NAME$6 = getFilename((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
4272
+ const RULE_NAME$6 = "padding-around-after-each-blocks";
4276
4273
  const config$5 = [
4277
4274
  {
4278
4275
  paddingType: PaddingType.Always,
@@ -4287,7 +4284,7 @@ const config$5 = [
4287
4284
  ];
4288
4285
  const paddingAroundAfterEachBlocks = createPaddingRule(RULE_NAME$6, "Enforce padding around `afterEach` blocks", config$5);
4289
4286
 
4290
- const RULE_NAME$5 = getFilename((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
4287
+ const RULE_NAME$5 = "padding-around-before-all-blocks";
4291
4288
  const config$4 = [
4292
4289
  {
4293
4290
  paddingType: PaddingType.Always,
@@ -4302,7 +4299,7 @@ const config$4 = [
4302
4299
  ];
4303
4300
  const paddingAroundBeforeAllBlocks = createPaddingRule(RULE_NAME$5, "Enforce padding around `beforeAll` blocks", config$4);
4304
4301
 
4305
- const RULE_NAME$4 = getFilename((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
4302
+ const RULE_NAME$4 = "padding-around-before-each-blocks";
4306
4303
  const config$3 = [
4307
4304
  {
4308
4305
  paddingType: PaddingType.Always,
@@ -4321,7 +4318,7 @@ const paddingAroundBeforeEachBlocks = createPaddingRule(
4321
4318
  config$3
4322
4319
  );
4323
4320
 
4324
- const RULE_NAME$3 = getFilename((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
4321
+ const RULE_NAME$3 = "padding-around-describe-blocks";
4325
4322
  const config$2 = [
4326
4323
  {
4327
4324
  paddingType: PaddingType.Always,
@@ -4348,7 +4345,7 @@ const paddingAroundDescribeBlocks = createPaddingRule(
4348
4345
  config$2
4349
4346
  );
4350
4347
 
4351
- const RULE_NAME$2 = getFilename((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
4348
+ const RULE_NAME$2 = "padding-around-expect-groups";
4352
4349
  const config$1 = [
4353
4350
  {
4354
4351
  paddingType: PaddingType.Always,
@@ -4372,7 +4369,7 @@ const paddingAroundExpectGroups = createPaddingRule(
4372
4369
  config$1
4373
4370
  );
4374
4371
 
4375
- const RULE_NAME$1 = getFilename((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
4372
+ const RULE_NAME$1 = "padding-around-test-blocks";
4376
4373
  const config = [
4377
4374
  {
4378
4375
  paddingType: PaddingType.Always,
@@ -4403,7 +4400,7 @@ const paddingAroundTestBlocks = createPaddingRule(
4403
4400
  config
4404
4401
  );
4405
4402
 
4406
- const RULE_NAME = getFilename((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
4403
+ const RULE_NAME = "padding-around-all";
4407
4404
  const paddingAroundAll = createPaddingRule(
4408
4405
  RULE_NAME,
4409
4406
  "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.4";
7
+ const version = "1.1.0";
9
8
 
10
9
  function createEslintRule(rule) {
11
10
  const createRule = ESLintUtils.RuleCreator(
@@ -375,7 +374,8 @@ const lowerCaseTitle = createEslintRule({
375
374
  },
376
375
  fixable: "code",
377
376
  messages: {
378
- lowerCaseTitle: "`{{ method }}`s should begin with lowercase"
377
+ lowerCaseTitle: "`{{ method }}`s should begin with lowercase",
378
+ fullyLowerCaseTitle: "`{{ method }}`s should be lowercase"
379
379
  },
380
380
  schema: [
381
381
  {
@@ -438,7 +438,7 @@ const lowerCaseTitle = createEslintRule({
438
438
  if (ignores.includes(vitestFnCall.name) || lowercaseFirstCharacterOnly && (!firstCharacter || firstCharacter === firstCharacter.toLowerCase()) || !lowercaseFirstCharacterOnly && description === description.toLowerCase())
439
439
  return;
440
440
  context.report({
441
- messageId: "lowerCaseTitle",
441
+ messageId: lowercaseFirstCharacterOnly ? "lowerCaseTitle" : "fullyLowerCaseTitle",
442
442
  node: node.arguments[0],
443
443
  data: {
444
444
  method: vitestFnCall.name
@@ -2518,9 +2518,6 @@ const isBooleanEqualityMatcher = (expectFnCall) => {
2518
2518
  };
2519
2519
  const isInstanceOfBinaryExpression = (node, className) => node.type === AST_NODE_TYPES.BinaryExpression && node.operator === "instanceof" && isSupportedAccessor(node.right, className);
2520
2520
  const hasOnlyOneArgument = (call) => call.arguments.length === 1;
2521
- function getFilename(url) {
2522
- return parse(basename(fileURLToPath(url))).name;
2523
- }
2524
2521
 
2525
2522
  const RULE_NAME$t = "prefer-to-be-object";
2526
2523
  const preferToBeObject = createEslintRule({
@@ -4238,7 +4235,7 @@ const createPaddingRule = (name, description, configs, deprecated = false) => {
4238
4235
  });
4239
4236
  };
4240
4237
 
4241
- const RULE_NAME$7 = getFilename(import.meta.url);
4238
+ const RULE_NAME$7 = "padding-around-after-all-blocks";
4242
4239
  const config$6 = [
4243
4240
  {
4244
4241
  paddingType: PaddingType.Always,
@@ -4253,7 +4250,7 @@ const config$6 = [
4253
4250
  ];
4254
4251
  const paddingAroundAfterAllBlocks = createPaddingRule(RULE_NAME$7, "Enforce padding around `afterAll` blocks", config$6);
4255
4252
 
4256
- const RULE_NAME$6 = getFilename(import.meta.url);
4253
+ const RULE_NAME$6 = "padding-around-after-each-blocks";
4257
4254
  const config$5 = [
4258
4255
  {
4259
4256
  paddingType: PaddingType.Always,
@@ -4268,7 +4265,7 @@ const config$5 = [
4268
4265
  ];
4269
4266
  const paddingAroundAfterEachBlocks = createPaddingRule(RULE_NAME$6, "Enforce padding around `afterEach` blocks", config$5);
4270
4267
 
4271
- const RULE_NAME$5 = getFilename(import.meta.url);
4268
+ const RULE_NAME$5 = "padding-around-before-all-blocks";
4272
4269
  const config$4 = [
4273
4270
  {
4274
4271
  paddingType: PaddingType.Always,
@@ -4283,7 +4280,7 @@ const config$4 = [
4283
4280
  ];
4284
4281
  const paddingAroundBeforeAllBlocks = createPaddingRule(RULE_NAME$5, "Enforce padding around `beforeAll` blocks", config$4);
4285
4282
 
4286
- const RULE_NAME$4 = getFilename(import.meta.url);
4283
+ const RULE_NAME$4 = "padding-around-before-each-blocks";
4287
4284
  const config$3 = [
4288
4285
  {
4289
4286
  paddingType: PaddingType.Always,
@@ -4302,7 +4299,7 @@ const paddingAroundBeforeEachBlocks = createPaddingRule(
4302
4299
  config$3
4303
4300
  );
4304
4301
 
4305
- const RULE_NAME$3 = getFilename(import.meta.url);
4302
+ const RULE_NAME$3 = "padding-around-describe-blocks";
4306
4303
  const config$2 = [
4307
4304
  {
4308
4305
  paddingType: PaddingType.Always,
@@ -4329,7 +4326,7 @@ const paddingAroundDescribeBlocks = createPaddingRule(
4329
4326
  config$2
4330
4327
  );
4331
4328
 
4332
- const RULE_NAME$2 = getFilename(import.meta.url);
4329
+ const RULE_NAME$2 = "padding-around-expect-groups";
4333
4330
  const config$1 = [
4334
4331
  {
4335
4332
  paddingType: PaddingType.Always,
@@ -4353,7 +4350,7 @@ const paddingAroundExpectGroups = createPaddingRule(
4353
4350
  config$1
4354
4351
  );
4355
4352
 
4356
- const RULE_NAME$1 = getFilename(import.meta.url);
4353
+ const RULE_NAME$1 = "padding-around-test-blocks";
4357
4354
  const config = [
4358
4355
  {
4359
4356
  paddingType: PaddingType.Always,
@@ -4384,7 +4381,7 @@ const paddingAroundTestBlocks = createPaddingRule(
4384
4381
  config
4385
4382
  );
4386
4383
 
4387
- const RULE_NAME = getFilename(import.meta.url);
4384
+ const RULE_NAME = "padding-around-all";
4388
4385
  const paddingAroundAll = createPaddingRule(
4389
4386
  RULE_NAME,
4390
4387
  "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.5",
3
+ "version": "1.1.1",
4
4
  "license": "MIT",
5
5
  "description": "Eslint plugin for vitest",
6
6
  "repository": "vitest-dev/eslint-plugin-vitest",