Skip to content

Commit 16a7a4b

Browse files
authored
chore: fix linting, formatting, and git hooks configs (#291)
1 parent 9bd2f39 commit 16a7a4b

File tree

7 files changed

+62
-25
lines changed

7 files changed

+62
-25
lines changed

.eslintrc.cjs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,40 @@ module.exports = {
33
env: {
44
browser: true,
55
es6: true,
6-
'vitest-globals/env': true
6+
'vitest-globals/env': true,
77
},
8-
extends: ['standard', 'plugin:vitest-globals/recommended'],
8+
extends: [
9+
'standard',
10+
'plugin:vitest-globals/recommended',
11+
'plugin:svelte/recommended',
12+
'prettier',
13+
],
914
plugins: ['svelte', 'simple-import-sort'],
1015
rules: {
11-
'max-len': ['warn', { code: 100 }],
1216
'simple-import-sort/imports': 'error',
13-
'no-multiple-empty-lines': ['error', { max: 2, maxBOF: 2, maxEOF: 0 }],
1417
},
1518
overrides: [
19+
{
20+
files: ['*.ts'],
21+
parser: '@typescript-eslint/parser',
22+
extends: [
23+
'plugin:@typescript-eslint/recommended',
24+
'plugin:@typescript-eslint/stylistic',
25+
'prettier',
26+
],
27+
rules: {
28+
'@typescript-eslint/ban-types': [
29+
'error',
30+
{ types: { '{}': false }, extendDefaults: true },
31+
],
32+
'@typescript-eslint/no-explicit-any': 'off',
33+
'import/export': 'off',
34+
},
35+
},
1636
],
1737
parserOptions: {
1838
ecmaVersion: 2022,
1939
sourceType: 'module',
2040
},
41+
ignorePatterns: ['!/.*'],
2142
}

.husky/commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx --no-install commitlint --edit $1

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx --no-install lint-staged

.prettierrc.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
semi: false
22
singleQuote: true
3+
trailingComma: es5
4+
plugins:
5+
- prettier-plugin-svelte
6+
overrides:
7+
- files: "*.svelte"
8+
options:
9+
parser: svelte

package.json

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
],
4242
"scripts": {
4343
"toc": "doctoc README.md",
44-
"lint": "eslint src --fix",
44+
"lint": "(prettier . --check || true) && eslint .",
45+
"format": "prettier . --write && eslint . --fix",
4546
"test": "vitest run src",
4647
"test:watch": "npm run test -- --watch",
4748
"test:update": "npm run test -- --updateSnapshot --coverage",
@@ -61,10 +62,13 @@
6162
"@commitlint/config-conventional": "^17.6.6",
6263
"@sveltejs/vite-plugin-svelte": "^2.4.2",
6364
"@testing-library/jest-dom": "^5.16.5",
65+
"@typescript-eslint/eslint-plugin": "^6.19.1",
66+
"@typescript-eslint/parser": "^6.19.1",
6467
"@vitest/coverage-c8": "^0.33.0",
6568
"all-contributors-cli": "^6.26.0",
6669
"doctoc": "^2.2.1",
6770
"eslint": "^8.43.0",
71+
"eslint-config-prettier": "^9.1.0",
6872
"eslint-config-standard": "^17.1.0",
6973
"eslint-plugin-import": "^2.27.5",
7074
"eslint-plugin-n": "^16.0.1",
@@ -77,30 +81,28 @@
7781
"lint-staged": "^13.2.3",
7882
"npm-run-all": "^4.1.5",
7983
"prettier": "^3.0.0",
84+
"prettier-plugin-svelte": "^3.1.2",
8085
"svelte": "^4.0.1",
86+
"svelte-jester": "^3.0.0",
87+
"typescript": "^5.3.3",
8188
"vite": "^4.3.9",
8289
"vitest": "^0.33.0"
8390
},
84-
"husky": {
85-
"hooks": {
86-
"pre-commit": "lint-staged",
87-
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
88-
}
89-
},
9091
"lint-staged": {
91-
"README.md": [
92+
"{README.md,.all-contributorsrc}": [
9293
"npm run toc",
93-
"prettier --parser markdown --write",
94-
"git add"
95-
],
96-
".all-contributorsrc": [
9794
"npm run contributors:generate",
98-
"git add"
95+
"npx --no-install prettier --write README.md .all-contributorsrc",
96+
"git add README.md .all-contributorsrc"
97+
],
98+
"src/**/*": [
99+
"npx --no-install vitest related --run"
100+
],
101+
"*.{js,cjs,ts,svelte,json,yml,yaml}": [
102+
"npx --no-install prettier --check"
99103
],
100-
"**/*.js": [
101-
"npm run lint",
102-
"npm test",
103-
"git add"
104+
"*.{js,cjs,ts,svelte}": [
105+
"npx --no-install eslint"
104106
]
105107
},
106108
"commitlint": {

types/index.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
// Project: https://github.com/testing-library/svelte-testing-library
33
// Definitions by: Rahim Alwer <https://github.com/mihar-22>
44

5-
import {queries, Queries, BoundFunction, EventType} from '@testing-library/dom'
6-
7-
import { SvelteComponent, ComponentProps, ComponentConstructorOptions } from 'svelte'
5+
import {BoundFunction, EventType,Queries, queries} from '@testing-library/dom'
6+
import { ComponentConstructorOptions,ComponentProps, SvelteComponent } from 'svelte'
87

98
export * from '@testing-library/dom'
109

vite.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { defineConfig } from 'vite'
21
import { svelte } from '@sveltejs/vite-plugin-svelte'
2+
import { defineConfig } from 'vite'
33

44
// https://vitejs.dev/config/
55
export default defineConfig({

0 commit comments

Comments
 (0)