@vitest/eslint-plugin 0.0.0-0 β†’ 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 VeritΓ© Mugabo Makuza
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1 +1,185 @@
1
- Stub
1
+ ## eslint-plugin-vitest
2
+
3
+ ![npm](https://img.shields.io/npm/v/@vitest/eslint-plugin)
4
+ [![ci](https://github.com/vitest-dev/eslint-plugin-vitest/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/veritem/eslint-plugin-vitest/actions/workflows/ci.yml)
5
+
6
+ Eslint plugin for vitest
7
+
8
+ ### Installation
9
+
10
+ You'll first need to install [ESLint](https://eslint.org/):
11
+
12
+ ```sh
13
+ npm i eslint --save-dev
14
+ ```
15
+
16
+ Next, install `@vitest/eslint-plugin`
17
+
18
+ ```sh
19
+ npm install @vitest/eslint-plugin --save
20
+ ```
21
+
22
+ ### Usage
23
+
24
+ Make sure you're running eslint `v9.0.0` or higher for the latest version of this plugin to work. The following example is how your `eslint.config.js` should be setup for this plugin to work for you.
25
+
26
+ ```js
27
+ import vitest from "@vitest/eslint-plugin";
28
+
29
+ export default [
30
+ {
31
+ files: ["tests/**"], // or any other pattern
32
+ plugins: {
33
+ vitest
34
+ },
35
+ rules: {
36
+ ...vitest.configs.recommended.rules, // you can also use vitest.configs.all.rules to enable all rules
37
+ "vitest/max-nested-describe": ["error", { "max": 3 }] // you can also modify rules' behavior using option like this
38
+ },
39
+ },
40
+ ];
41
+ ```
42
+
43
+ If you're not using the latest version of eslint (version `v8.57.0` or lower) you can setup this plugin using the following configuration
44
+
45
+ Add `vitest` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
46
+
47
+ ```json
48
+ {
49
+ "plugins": ["vitest"]
50
+ }
51
+ ```
52
+
53
+ Then configure the rules you want to use under the rules section.
54
+
55
+ ```json
56
+ {
57
+ "rules": {
58
+ "vitest/max-nested-describe": [
59
+ "error",
60
+ {
61
+ "max": 3
62
+ }
63
+ ]
64
+ }
65
+ }
66
+ ```
67
+
68
+ If you're using old Eslint configuration, make sure to use legacy key like the following
69
+
70
+ ```js
71
+ {
72
+ "extends": ["plugin:@vitest/legacy-recommended"] // or legacy-all
73
+ }
74
+ ```
75
+
76
+
77
+ #### Enabling with type-testing
78
+
79
+ Vitest ships with an optional [type-testing feature](https://vitest.dev/guide/testing-types), which is disabled by default.
80
+
81
+ If you're using this feature, you should also enabled `typecheck` in the settings for this plugin. This ensures that rules like [expect-expect](docs/rules/expect-expect.md) account for type-related assertions in tests.
82
+
83
+ ```js
84
+ import vitest from "@vitest/eslint-plugin";
85
+
86
+ export default [
87
+ {
88
+ files: ["tests/**"], // or any other pattern
89
+ plugins: {
90
+ vitest,
91
+ },
92
+ rules: {
93
+ ...vitest.configs.recommended.rules,
94
+ },
95
+ settings: {
96
+ vitest: {
97
+ typecheck: true
98
+ }
99
+ },
100
+ languageOptions: {
101
+ globals: {
102
+ ...vitest.environments.env.globals,
103
+ },
104
+ },
105
+ },
106
+ ]
107
+ ```
108
+
109
+ ### Rules
110
+
111
+ <!-- begin auto-generated rules list -->
112
+
113
+ πŸ’Ό Configurations enabled in.\
114
+ ⚠️ Configurations set to warn in.\
115
+ 🌐 Set in the `all` configuration.\
116
+ βœ… Set in the `recommended` configuration.\
117
+ πŸ”§ Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).\
118
+ πŸ’‘ Manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).\
119
+ ❌ Deprecated.
120
+
121
+ | NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  | Description | πŸ’Ό | ⚠️ | πŸ”§ | πŸ’‘ | ❌ |
122
+ | :----------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------- | :- | :- | :- | :- | :- |
123
+ | [consistent-test-filename](docs/rules/consistent-test-filename.md) | require .spec test file pattern | | 🌐 | | | |
124
+ | [consistent-test-it](docs/rules/consistent-test-it.md) | enforce using test or it but not both | | 🌐 | πŸ”§ | | |
125
+ | [expect-expect](docs/rules/expect-expect.md) | enforce having expectation in test body | βœ… | | | | |
126
+ | [max-expects](docs/rules/max-expects.md) | enforce a maximum number of expect per test | | 🌐 | | | |
127
+ | [max-nested-describe](docs/rules/max-nested-describe.md) | require describe block to be less than set max value or default value | | 🌐 | | | |
128
+ | [no-alias-methods](docs/rules/no-alias-methods.md) | disallow alias methods | | 🌐 | πŸ”§ | | |
129
+ | [no-commented-out-tests](docs/rules/no-commented-out-tests.md) | disallow commented out tests | βœ… | | | | |
130
+ | [no-conditional-expect](docs/rules/no-conditional-expect.md) | disallow conditional expects | | 🌐 | | | |
131
+ | [no-conditional-in-test](docs/rules/no-conditional-in-test.md) | disallow conditional tests | | 🌐 | | | |
132
+ | [no-conditional-tests](docs/rules/no-conditional-tests.md) | disallow conditional tests | | 🌐 | | | |
133
+ | [no-disabled-tests](docs/rules/no-disabled-tests.md) | disallow disabled tests | | 🌐 | | | |
134
+ | [no-done-callback](docs/rules/no-done-callback.md) | disallow using a callback in asynchronous tests and hooks | | 🌐 | | πŸ’‘ | ❌ |
135
+ | [no-duplicate-hooks](docs/rules/no-duplicate-hooks.md) | disallow duplicate hooks and teardown hooks | | 🌐 | | | |
136
+ | [no-focused-tests](docs/rules/no-focused-tests.md) | disallow focused tests | | 🌐 | πŸ”§ | | |
137
+ | [no-hooks](docs/rules/no-hooks.md) | disallow setup and teardown hooks | | 🌐 | | | |
138
+ | [no-identical-title](docs/rules/no-identical-title.md) | disallow identical titles | βœ… | | πŸ”§ | | |
139
+ | [no-import-node-test](docs/rules/no-import-node-test.md) | disallow importing `node:test` | βœ… | | πŸ”§ | | |
140
+ | [no-interpolation-in-snapshots](docs/rules/no-interpolation-in-snapshots.md) | disallow string interpolation in snapshots | | 🌐 | πŸ”§ | | |
141
+ | [no-large-snapshots](docs/rules/no-large-snapshots.md) | disallow large snapshots | | 🌐 | | | |
142
+ | [no-mocks-import](docs/rules/no-mocks-import.md) | disallow importing from __mocks__ directory | | 🌐 | | | |
143
+ | [no-restricted-matchers](docs/rules/no-restricted-matchers.md) | disallow the use of certain matchers | | 🌐 | | | |
144
+ | [no-restricted-vi-methods](docs/rules/no-restricted-vi-methods.md) | disallow specific `vi.` methods | | 🌐 | | | |
145
+ | [no-standalone-expect](docs/rules/no-standalone-expect.md) | disallow using `expect` outside of `it` or `test` blocks | | 🌐 | | | |
146
+ | [no-test-prefixes](docs/rules/no-test-prefixes.md) | disallow using `test` as a prefix | | 🌐 | πŸ”§ | | |
147
+ | [no-test-return-statement](docs/rules/no-test-return-statement.md) | disallow return statements in tests | | 🌐 | | | |
148
+ | [prefer-called-with](docs/rules/prefer-called-with.md) | enforce using `toBeCalledWith()` or `toHaveBeenCalledWith()` | | 🌐 | πŸ”§ | | |
149
+ | [prefer-comparison-matcher](docs/rules/prefer-comparison-matcher.md) | enforce using the built-in comparison matchers | | 🌐 | πŸ”§ | | |
150
+ | [prefer-each](docs/rules/prefer-each.md) | enforce using `each` rather than manual loops | | 🌐 | | | |
151
+ | [prefer-equality-matcher](docs/rules/prefer-equality-matcher.md) | enforce using the built-in quality matchers | | 🌐 | | πŸ’‘ | |
152
+ | [prefer-expect-assertions](docs/rules/prefer-expect-assertions.md) | enforce using expect assertions instead of callbacks | | 🌐 | | πŸ’‘ | |
153
+ | [prefer-expect-resolves](docs/rules/prefer-expect-resolves.md) | enforce using `expect().resolves` over `expect(await ...)` syntax | | 🌐 | πŸ”§ | | |
154
+ | [prefer-hooks-in-order](docs/rules/prefer-hooks-in-order.md) | enforce having hooks in consistent order | | 🌐 | | | |
155
+ | [prefer-hooks-on-top](docs/rules/prefer-hooks-on-top.md) | enforce having hooks before any test cases | | 🌐 | | | |
156
+ | [prefer-lowercase-title](docs/rules/prefer-lowercase-title.md) | enforce lowercase titles | | 🌐 | πŸ”§ | | |
157
+ | [prefer-mock-promise-shorthand](docs/rules/prefer-mock-promise-shorthand.md) | enforce mock resolved/rejected shorthands for promises | | 🌐 | πŸ”§ | | |
158
+ | [prefer-snapshot-hint](docs/rules/prefer-snapshot-hint.md) | enforce including a hint with external snapshots | | 🌐 | | | |
159
+ | [prefer-spy-on](docs/rules/prefer-spy-on.md) | enforce using `vi.spyOn` | | 🌐 | πŸ”§ | | |
160
+ | [prefer-strict-equal](docs/rules/prefer-strict-equal.md) | enforce strict equal over equal | | 🌐 | | πŸ’‘ | |
161
+ | [prefer-to-be](docs/rules/prefer-to-be.md) | enforce using toBe() | | 🌐 | πŸ”§ | | |
162
+ | [prefer-to-be-falsy](docs/rules/prefer-to-be-falsy.md) | enforce using toBeFalsy() | | 🌐 | πŸ”§ | | |
163
+ | [prefer-to-be-object](docs/rules/prefer-to-be-object.md) | enforce using toBeObject() | | 🌐 | πŸ”§ | | |
164
+ | [prefer-to-be-truthy](docs/rules/prefer-to-be-truthy.md) | enforce using `toBeTruthy` | | 🌐 | πŸ”§ | | |
165
+ | [prefer-to-contain](docs/rules/prefer-to-contain.md) | enforce using toContain() | | 🌐 | πŸ”§ | | |
166
+ | [prefer-to-have-length](docs/rules/prefer-to-have-length.md) | enforce using toHaveLength() | | 🌐 | πŸ”§ | | |
167
+ | [prefer-todo](docs/rules/prefer-todo.md) | enforce using `test.todo` | | 🌐 | πŸ”§ | | |
168
+ | [require-hook](docs/rules/require-hook.md) | require setup and teardown to be within a hook | | 🌐 | | | |
169
+ | [require-local-test-context-for-concurrent-snapshots](docs/rules/require-local-test-context-for-concurrent-snapshots.md) | require local Test Context for concurrent snapshot tests | βœ… | | | | |
170
+ | [require-to-throw-message](docs/rules/require-to-throw-message.md) | require toThrow() to be called with an error message | | 🌐 | | | |
171
+ | [require-top-level-describe](docs/rules/require-top-level-describe.md) | enforce that all tests are in a top-level describe | | 🌐 | | | |
172
+ | [valid-describe-callback](docs/rules/valid-describe-callback.md) | enforce valid describe callback | βœ… | | | | |
173
+ | [valid-expect](docs/rules/valid-expect.md) | enforce valid `expect()` usage | βœ… | | | | |
174
+ | [valid-title](docs/rules/valid-title.md) | enforce valid titles | βœ… | | πŸ”§ | | |
175
+
176
+ <!-- end auto-generated rules list -->
177
+
178
+ #### Credits
179
+
180
+ - [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest)
181
+ Most of the rules in this plugin are essentially ports of Jest plugin rules with minor modifications
182
+
183
+ ### Licence
184
+
185
+ [MIT](https://github.com/veritem/eslint-plugin-vitest/blob/main/LICENSE) Licence &copy; 2022 - present [veritem](https://github.com/veritem) and contributors