Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add eslint-plugin-vitest #37

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,34 @@ ESLint config used by [Dusk](https://dusk.network/) JavaScript apps.
npm i -D @dusk-network/eslint-config
```

The package requires the following peer dependencies:
Your package requires the following dev-dependencies:

- [`eslint`](https://github.com/eslint/eslint) `>=8.57.0`
- [`eslint-config-prettier`](https://github.com/prettier/eslint-config-prettier) `>=9.1.0`
- [`eslint-plugin-import`](https://github.com/import-js/eslint-plugin-import) `>=2.29.1`
- [`eslint-plugin-import-newlines`](https://github.com/SeinopSys/eslint-plugin-import-newlines) `>=1.3.4`
- [`eslint`](https://github.com/eslint/eslint)
- [`eslint-config-prettier`](https://github.com/prettier/eslint-config-prettier)
- [`eslint-plugin-import`](https://github.com/import-js/eslint-plugin-import)
- [`eslint-plugin-import-newlines`](https://github.com/SeinopSys/eslint-plugin-import-newlines)

If you are using Svelte rules the package needs the following optional dependency:
If you are using Svelte rules your package needs the following dev-dependency:

- [`eslint-plugin-svelte`](https://github.com/sveltejs/eslint-plugin-svelte) `>=2.35.1`
- [`eslint-plugin-svelte`](https://github.com/sveltejs/eslint-plugin-svelte)

If you are using Vitest rules your package needs the following dev-dependency:

- [`eslint-plugin-vitest`](https://github.com/veritem/eslint-plugin-vitest)

## Usage

Add the rulesets you want in the `extends` section of your ESLint configuration file.

e.g. to use both JS and Svelte rules:
e.g. to use both JS, Svelte and Vitest rules:

```javascript
// ...

extends: [
"@dusk-network/eslint-config/js",
"@dusk-network/eslint-config/svelte"
"@dusk-network/eslint-config/svelte",
"@dusk-network/eslint-config/vitest"
]

// ...
Expand Down
1 change: 0 additions & 1 deletion js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ module.exports = {
sourceType: "module",
},
plugins: ["import-newlines"],
rules: {},
};
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"url": "https://github.com/dusk-network/eslint-config.git"
},
"scripts": {
"check": "npm run check-rules && npm run check-format && npm run lint",
"check": "npm run check-rules && npm run format && npm run lint",
"format": "prettier . --check",
"format:fix": "prettier . --write",
"check-js": "eslint-find-rules -nd js/index.js && eslint-config-prettier js/index.js",
Expand All @@ -42,23 +42,25 @@
},
"version": "3.2.0",
"devDependencies": {
"@dusk-network/prettier-config": "1.0.0",
"@dusk-network/prettier-config": "1.1.0",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-find-rules": "4.1.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-import-newlines": "1.3.4",
"eslint-plugin-import-newlines": "1.4.0",
"eslint-plugin-svelte": "2.35.1",
"eslint-plugin-vitest": "0.3.26",
"prettier": "3.2.5",
"svelte": "4.2.12"
},
"optionalDependencies": {
"eslint-plugin-svelte": ">=2.35.1"
"eslint-plugin-svelte": ">=2.35.1",
"eslint-plugin-vitest": ">=0.3.26"
},
"peerDependencies": {
"eslint": ">=8.57.0",
"eslint-config-prettier": ">=9.1.0",
"eslint-plugin-import": ">=2.29.1",
"eslint-plugin-import-newlines": ">=1.3.4"
"eslint-plugin-import-newlines": ">=1.4.0"
}
}
1 change: 0 additions & 1 deletion svelte/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ module.exports = {
sourceType: "module",
},
plugins: ["svelte"],
rules: {},
settings: {
"import/parsers": {
espree: [".js"],
Expand Down
3 changes: 3 additions & 0 deletions vitest/base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
rules: {},
};
18 changes: 18 additions & 0 deletions vitest/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const rules = ["./base"].map(require.resolve);

module.exports = {
extends: ["plugin:vitest/recommended", ...rules],
overrides: [
{
files: ["*.spec.js", "*.test.js"],
rules: {
"max-statements": 0,
},
},
],
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
plugins: ["vitest"],
};
Loading