Skip to content

Commit

Permalink
chore: fix linting, formatting, and git hooks configs (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcous authored Jan 26, 2024
1 parent 9bd2f39 commit 16a7a4b
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 25 deletions.
29 changes: 25 additions & 4 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,40 @@ module.exports = {
env: {
browser: true,
es6: true,
'vitest-globals/env': true
'vitest-globals/env': true,
},
extends: ['standard', 'plugin:vitest-globals/recommended'],
extends: [
'standard',
'plugin:vitest-globals/recommended',
'plugin:svelte/recommended',
'prettier',
],
plugins: ['svelte', 'simple-import-sort'],
rules: {
'max-len': ['warn', { code: 100 }],
'simple-import-sort/imports': 'error',
'no-multiple-empty-lines': ['error', { max: 2, maxBOF: 2, maxEOF: 0 }],
},
overrides: [
{
files: ['*.ts'],
parser: '@typescript-eslint/parser',
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/stylistic',
'prettier',
],
rules: {
'@typescript-eslint/ban-types': [
'error',
{ types: { '{}': false }, extendDefaults: true },
],
'@typescript-eslint/no-explicit-any': 'off',
'import/export': 'off',
},
},
],
parserOptions: {
ecmaVersion: 2022,
sourceType: 'module',
},
ignorePatterns: ['!/.*'],
}
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no-install commitlint --edit $1
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no-install lint-staged
7 changes: 7 additions & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
semi: false
singleQuote: true
trailingComma: es5
plugins:
- prettier-plugin-svelte
overrides:
- files: "*.svelte"
options:
parser: svelte
36 changes: 19 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
],
"scripts": {
"toc": "doctoc README.md",
"lint": "eslint src --fix",
"lint": "(prettier . --check || true) && eslint .",
"format": "prettier . --write && eslint . --fix",
"test": "vitest run src",
"test:watch": "npm run test -- --watch",
"test:update": "npm run test -- --updateSnapshot --coverage",
Expand All @@ -61,10 +62,13 @@
"@commitlint/config-conventional": "^17.6.6",
"@sveltejs/vite-plugin-svelte": "^2.4.2",
"@testing-library/jest-dom": "^5.16.5",
"@typescript-eslint/eslint-plugin": "^6.19.1",
"@typescript-eslint/parser": "^6.19.1",
"@vitest/coverage-c8": "^0.33.0",
"all-contributors-cli": "^6.26.0",
"doctoc": "^2.2.1",
"eslint": "^8.43.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^16.0.1",
Expand All @@ -77,30 +81,28 @@
"lint-staged": "^13.2.3",
"npm-run-all": "^4.1.5",
"prettier": "^3.0.0",
"prettier-plugin-svelte": "^3.1.2",
"svelte": "^4.0.1",
"svelte-jester": "^3.0.0",
"typescript": "^5.3.3",
"vite": "^4.3.9",
"vitest": "^0.33.0"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"lint-staged": {
"README.md": [
"{README.md,.all-contributorsrc}": [
"npm run toc",
"prettier --parser markdown --write",
"git add"
],
".all-contributorsrc": [
"npm run contributors:generate",
"git add"
"npx --no-install prettier --write README.md .all-contributorsrc",
"git add README.md .all-contributorsrc"
],
"src/**/*": [
"npx --no-install vitest related --run"
],
"*.{js,cjs,ts,svelte,json,yml,yaml}": [
"npx --no-install prettier --check"
],
"**/*.js": [
"npm run lint",
"npm test",
"git add"
"*.{js,cjs,ts,svelte}": [
"npx --no-install eslint"
]
},
"commitlint": {
Expand Down
5 changes: 2 additions & 3 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
// Project: https://github.com/testing-library/svelte-testing-library
// Definitions by: Rahim Alwer <https://github.com/mihar-22>

import {queries, Queries, BoundFunction, EventType} from '@testing-library/dom'

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

export * from '@testing-library/dom'

Expand Down
2 changes: 1 addition & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'
import { defineConfig } from 'vite'

// https://vitejs.dev/config/
export default defineConfig({
Expand Down

0 comments on commit 16a7a4b

Please sign in to comment.