Skip to content

Commit

Permalink
chore: valid title (#453)
Browse files Browse the repository at this point in the history
* chore: begining of work on valid title

* update

* feat(valid-title): adding class and function names works

* chore(docs): update valid-title docs

* feat(alot): fixed a bunch of bugs
  • Loading branch information
veritem committed May 24, 2024
1 parent 30b8834 commit f8311f4
Show file tree
Hide file tree
Showing 20 changed files with 5,044 additions and 4,097 deletions.
12 changes: 4 additions & 8 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
{
"extends": [
"@veritem"
],
"extends": [ "@veritem" ],
"rules": {
"indent": [
0,
"tab"
],
"indent": [ 0, "tab" ],
"no-case-declarations": 0,
"no-tabs": "off",
"no-mixed-spaces-and-tabs": "off",
"vitest/unbound-method": "off"
}
}
}

33 changes: 29 additions & 4 deletions docs/rules/valid-title.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This rule has an object option:
{
"vitest/valid-title": [
"error",
{
{
"ignoreTypeOfDescribeName": false,
"allowArguments": false,
"disallowedWords": ["skip", "only"],
Expand Down Expand Up @@ -154,9 +154,9 @@ describe('foo', () => {
Examples of **incorrect** code for this rule with the `{ "mustMatch": { "it": ["^should .+\.$"] } }` option:

```js
// The describe title is checked with the default regex, so it's valid
// The describe title is checked with the default regex, so it's valid
describe('foo', () => {
// This check fails because the title does not match the regex
// This check fails because the title does not match the regex
it('Should be a number', () => {
expect(1).toBeNumber()
})
Expand All @@ -168,9 +168,34 @@ Examples of **correct** code for this rule with the `{ "mustMatch": { "describe"
```js
// The describe title is checked with the default regex, so it's valid
describe('foo', () => {
// This check succeeds because the title matches the regex
// This check succeeds because the title matches the regex
it('should be a number.', () => {
expect(1).toBeNumber()
})
})
```

Note: If you'd like to use a function or class names inside `describe`, `test` or `it` blocks as a parameter, you must enable vitest's type checking.

To enable typechecking for vistest make sure settings key is added in your configuration

```js
import vitest from "eslint-plugin-vitest";

export defualt [
{
files: ["tests/**"],
plugins: {
vitest
},
rules: {
...vitest.configs.recommended.rules
},
settings: {
vitest: {
typecheck: true
}
}
}
]
```
4 changes: 1 addition & 3 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ export default [
vitest.configs.recommended,
vitest.configs.env,
{
ignores: ['node_modules/*', 'dist/*', '**/*.md'],
files: ['**/*.ts', '**/*.js'],
plugins: {
vitest,
'@stylistic': stylistic
Expand All @@ -34,5 +32,5 @@ export default [
languageOptions: {
parser
}
}
},
]
23 changes: 10 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"version": "0.5.4",
"license": "MIT",
"description": "Eslint plugin for vitest",
"type": "module",
"repository": "veritem/eslint-plugin-vitest",
"keywords": [
"eslint",
Expand All @@ -13,15 +12,16 @@
"vitest",
"eslint plugin"
],
"author": "Verite Mugabo Makuza <https://veritemugabo.com/>",
"main": "./dist/index.cjs",
"author": "Verite Mugabo <https://veritemugabo.com/>",
"type": "module",
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"require": "./dist/index.cjs",
"default": "./dist/index.mjs",
"types": "./dist/index.d.ts"
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"files": [
Expand Down Expand Up @@ -54,7 +54,7 @@
"eslint": "^8.57.0",
"eslint-doc-generator": "^1.7.1",
"eslint-plugin-eslint-plugin": "^6.1.0",
"eslint-plugin-vitest": "0.5.3",
"eslint-plugin-vitest": "^0.5.4",
"eslint-remote-tester": "^3.0.1",
"eslint-remote-tester-repositories": "^1.0.1",
"ts-node": "^10.9.2",
Expand All @@ -63,18 +63,15 @@
"unbuild": "^2.0.0",
"vitest": "^1.6.0"
},
"engines": {
"node": "^18.0.0 || >= 20.0.0"
},
"peerDependencies": {
"eslint": "^8.57.0 || ^9.0.0",
"eslint": ">= 8.57.0",
"vitest": "*"
},
"peerDependenciesMeta": {
"@typescript-eslint/eslint-plugin": {
"vitest": {
"optional": true
},
"vitest": {
"typescript": {
"optional": true
}
},
Expand Down
Loading

0 comments on commit f8311f4

Please sign in to comment.