configure lint staged (#588)

* chore: upgrade monorepo deps

* chore: configure lint-staged

* refactor: lenient use of any
This commit is contained in:
Carlos Valente
2023-11-13 22:04:55 +01:00
committed by GitHub
parent 140daef7e7
commit a41fe8806b
22 changed files with 1107 additions and 514 deletions
+2
View File
@@ -1,4 +1,5 @@
{ {
"root": true,
"parserOptions": { "parserOptions": {
"ecmaVersion": 2020 "ecmaVersion": 2020
}, },
@@ -41,6 +42,7 @@
} }
], ],
"@typescript-eslint/no-non-null-assertion": "warn", "@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unused-vars": [ "@typescript-eslint/no-unused-vars": [
"error", "error",
{ {
+7
View File
@@ -29,31 +29,38 @@ jobs:
# Run code quality per package # Run code quality per package
- name: React - Run linter - name: React - Run linter
if: always()
run: pnpm lint run: pnpm lint
working-directory: ./apps/client working-directory: ./apps/client
- name: Server - Run linter - name: Server - Run linter
if: always()
run: pnpm lint run: pnpm lint
working-directory: ./apps/server working-directory: ./apps/server
- name: Utils - Run linter - name: Utils - Run linter
if: always()
run: pnpm lint run: pnpm lint
working-directory: ./packages/utils working-directory: ./packages/utils
- name: Types - Run linter - name: Types - Run linter
if: always()
run: pnpm lint run: pnpm lint
working-directory: ./packages/types working-directory: ./packages/types
# We choose to run tests separately # We choose to run tests separately
- name: React - Run unit tests - name: React - Run unit tests
if: always()
run: pnpm test:pipeline run: pnpm test:pipeline
working-directory: ./apps/client working-directory: ./apps/client
- name: Server - Run unit tests - name: Server - Run unit tests
if: always()
run: pnpm test:pipeline run: pnpm test:pipeline
working-directory: ./apps/server working-directory: ./apps/server
- name: Utils - Run unit tests - name: Utils - Run unit tests
if: always()
run: pnpm test:pipeline run: pnpm test:pipeline
working-directory: ./packages/utils working-directory: ./packages/utils
+4
View File
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
pnpm lint
+8 -9
View File
@@ -63,17 +63,16 @@
"@testing-library/react": "^13.1.1", "@testing-library/react": "^13.1.1",
"@testing-library/user-event": "^14.1.1", "@testing-library/user-event": "^14.1.1",
"@types/color": "^3.0.3", "@types/color": "^3.0.3",
"@types/luxon": "^3.2.0",
"@types/react": "^18.0.26", "@types/react": "^18.0.26",
"@types/react-dom": "^18.0.10", "@types/react-dom": "^18.0.10",
"@types/testing-library__jest-dom": "^5.14.5", "@types/testing-library__jest-dom": "^5.14.5",
"@typescript-eslint/eslint-plugin": "^5.48.1", "@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^5.48.1", "@typescript-eslint/parser": "^6.10.0",
"@vitejs/plugin-react": "^3.0.1", "@vitejs/plugin-react": "^3.0.1",
"eslint": "^8.31.0", "eslint": "^8.53.0",
"eslint-config-prettier": "^8.6.0", "eslint-config-prettier": "^9.0.0",
"eslint-plugin-jest": "^27.1.7", "eslint-plugin-jest": "^27.6.0",
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-react": "^7.32.0", "eslint-plugin-react": "^7.32.0",
"eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-simple-import-sort": "^8.0.0", "eslint-plugin-simple-import-sort": "^8.0.0",
@@ -81,9 +80,9 @@
"jsdom": "^21.1.0", "jsdom": "^21.1.0",
"ontime-types": "workspace:*", "ontime-types": "workspace:*",
"ontime-utils": "workspace:*", "ontime-utils": "workspace:*",
"prettier": "^2.8.3", "prettier": "^3.0.3",
"sass": "^1.57.1", "sass": "^1.57.1",
"typescript": "^4.9.4", "typescript": "^5.2.2",
"vite": "^4.3.1", "vite": "^4.3.1",
"vite-plugin-compression2": "^0.9.0", "vite-plugin-compression2": "^0.9.0",
"vite-plugin-svgr": "^2.4.0", "vite-plugin-svgr": "^2.4.0",
@@ -1,7 +1,7 @@
export default function useElectronEvent() { export default function useElectronEvent() {
const isElectron = window?.process?.type === 'renderer'; const isElectron = window?.process?.type === 'renderer';
const sendToElectron = (channel: string, args?: string | Record<string, any>) => { const sendToElectron = (channel: string, args?: string | Record<string, unknown>) => {
if (isElectron) { if (isElectron) {
window?.ipcRenderer.send(channel, args); window?.ipcRenderer.send(channel, args);
} }
+1 -1
View File
@@ -129,7 +129,7 @@ export const socketSend = (message: any) => {
} }
}; };
export const socketSendJson = (type: string, payload?: any) => { export const socketSendJson = (type: string, payload?: unknown) => {
socketSend( socketSend(
JSON.stringify({ JSON.stringify({
type, type,
@@ -3,8 +3,12 @@ import { UseFormRegister } from 'react-hook-form';
import { IconButton, Input, InputGroup, InputRightElement } from '@chakra-ui/react'; import { IconButton, Input, InputGroup, InputRightElement } from '@chakra-ui/react';
import { IoEyeOutline } from '@react-icons/all-files/io5/IoEyeOutline'; import { IoEyeOutline } from '@react-icons/all-files/io5/IoEyeOutline';
interface FormInput {
[key: string]: string;
}
interface ModalPinInputProps { interface ModalPinInputProps {
register: UseFormRegister<any>; register: UseFormRegister<FormInput>;
formName: string; formName: string;
isDisabled?: boolean; isDisabled?: boolean;
} }
@@ -13,7 +13,7 @@ import { EventItemActions } from '../../RundownEntry';
interface BlockActionMenuProps { interface BlockActionMenuProps {
enableDelete?: boolean; enableDelete?: boolean;
showClone?: boolean; showClone?: boolean;
actionHandler: (action: EventItemActions, payload?: any) => void; actionHandler: (action: EventItemActions, payload?: unknown) => void;
className?: string; className?: string;
} }
+4 -1
View File
@@ -3,11 +3,14 @@
"sourceType": "module" "sourceType": "module"
}, },
"env": { "env": {
"browser": true,
"node": true "node": true
}, },
"extends": [ "extends": [
"eslint:recommended" "eslint:recommended"
], ],
"plugins": [], "plugins": [],
"rules": {} "rules": {
"@typescript-eslint/no-var-requires": "off"
}
} }
+3 -3
View File
@@ -14,9 +14,9 @@
"devDependencies": { "devDependencies": {
"electron": "^22.3.5", "electron": "^22.3.5",
"electron-builder": "^23.6.0", "electron-builder": "^23.6.0",
"eslint": "^8.31.0", "eslint": "^8.53.0",
"eslint-config-prettier": "^8.6.0", "eslint-config-prettier": "^9.0.0",
"prettier": "^2.8.3" "prettier": "^3.0.3"
}, },
"scripts": { "scripts": {
"postinstall": "", "postinstall": "",
+3
View File
@@ -5,5 +5,8 @@
"parserOptions": { "parserOptions": {
"ecmaVersion": 2020, "ecmaVersion": 2020,
"sourceType": "module" "sourceType": "module"
},
"globals": {
"globalThis": false
} }
} }
+6 -6
View File
@@ -27,17 +27,17 @@
"@types/node": "^16.11.7", "@types/node": "^16.11.7",
"@types/node-osc": "^6.0.2", "@types/node-osc": "^6.0.2",
"@types/websocket": "^1.0.5", "@types/websocket": "^1.0.5",
"@typescript-eslint/eslint-plugin": "^5.48.1", "@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^5.48.1", "@typescript-eslint/parser": "^6.10.0",
"esbuild": "^0.17.5", "esbuild": "^0.17.5",
"eslint": "^8.31.0", "eslint": "^8.53.0",
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^5.0.1",
"nodemon": "^2.0.20", "nodemon": "^2.0.20",
"ontime-types": "workspace:*", "ontime-types": "workspace:*",
"prettier": "^2.8.3", "prettier": "^3.0.3",
"shx": "^0.3.4", "shx": "^0.3.4",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"typescript": "^4.9.4", "typescript": "^5.2.2",
"vitest": "^0.30.1" "vitest": "^0.30.1"
}, },
"scripts": { "scripts": {
+1 -1
View File
@@ -4,7 +4,7 @@ import { socket } from './WebsocketAdapter.js';
* Utility function to notify clients that the REST data is stale * Utility function to notify clients that the REST data is stale
* @param payload -- possible patch payload * @param payload -- possible patch payload
*/ */
export function sendRefetch(payload: any | null = null) { export function sendRefetch(payload: unknown = null) {
socket.sendAsJson({ socket.sendAsJson({
type: 'ontime-refetch', type: 'ontime-refetch',
payload, payload,
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { describe, expect, it, vi } from 'vitest'; import { describe, expect, it, vi } from 'vitest';
import { Playback } from 'ontime-types'; import { Playback } from 'ontime-types';
+3 -3
View File
@@ -3,11 +3,11 @@ import { deepmerge } from 'ontime-utils';
/** /**
* @description Ensures variable is string, it skips object types * @description Ensures variable is string, it skips object types
* @param {any} val - variable to convert * @param val - variable to convert
* @param {string} [fallback=''] - fallback value * @param {string} [fallback=''] - fallback value
* @returns {string} - value as string or fallback if not possible * @returns {string} - value as string or fallback if not possible
*/ */
export const makeString = (val: any, fallback = ''): string => { export const makeString = (val: unknown, fallback = ''): string => {
if (typeof val === 'string') return val; if (typeof val === 'string') return val;
else if (val == null || val.constructor === Object) return fallback; else if (val == null || val.constructor === Object) return fallback;
return val.toString(); return val.toString();
@@ -56,7 +56,7 @@ export const isEmptyObject = (obj: object) => {
* @param {object} a - any object * @param {object} a - any object
* @param {object} b - a potential partial object of same time as a * @param {object} b - a potential partial object of same time as a
*/ */
export function mergeObject<T extends Record<string, any>>(a: T, b: Partial<Record<keyof T, any>>): T { export function mergeObject<T extends object>(a: T, b: Partial<T>): T {
const merged = { ...a }; const merged = { ...a };
for (const key in b) { for (const key in b) {
+21 -8
View File
@@ -26,6 +26,7 @@
"dev:electron": "turbo run dev --filter=ontime", "dev:electron": "turbo run dev --filter=ontime",
"dev:server": "turbo run dev --filter=ontime-server", "dev:server": "turbo run dev --filter=ontime-server",
"lint": "turbo run lint", "lint": "turbo run lint",
"lint-staged": "turbo run lint-staged --concurrency=1",
"build": "turbo run build", "build": "turbo run build",
"build:local": "turbo run build:local", "build:local": "turbo run build:local",
"dist-win": "turbo run dist-win", "dist-win": "turbo run dist-win",
@@ -38,15 +39,27 @@
}, },
"devDependencies": { "devDependencies": {
"@playwright/test": "^1.34.3", "@playwright/test": "^1.34.3",
"@types/node": "^18.11.18", "@types/node": "^16.11.7",
"@typescript-eslint/eslint-plugin": "^5.48.0", "@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^5.48.0", "@typescript-eslint/parser": "^6.10.0",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"eslint": "^8.31.0", "eslint": "^8.53.0",
"eslint-config-prettier": "^8.6.0", "eslint-config-prettier": "^9.0.0",
"eslint-plugin-playwright": "^0.12.0", "eslint-plugin-playwright": "^0.12.0",
"prettier": "^2.8.2", "husky": "^8.0.3",
"turbo": "^1.8.8", "lint-staged": "^15.1.0",
"typescript": "^4.8.3" "prettier": "^3.0.3",
"turbo": "^1.10.16",
"typescript": "^5.2.2"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
"pnpm lint"
]
} }
} }
+5 -5
View File
@@ -7,15 +7,15 @@
"description": "shared typings for ontime", "description": "shared typings for ontime",
"scripts": { "scripts": {
"cleanup": "rm -rf .turbo && rm -rf node_modules", "cleanup": "rm -rf .turbo && rm -rf node_modules",
"lint": "eslint ." "lint": "eslint . --quiet"
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"devDependencies": { "devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.48.1", "@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^5.48.1", "@typescript-eslint/parser": "^6.10.0",
"eslint": "^8.31.0", "eslint": "^8.53.0",
"typescript": "^4.9.4" "typescript": "^5.2.2"
} }
} }
+7 -7
View File
@@ -17,15 +17,15 @@
}, },
"devDependencies": { "devDependencies": {
"@types/luxon": "^3.2.0", "@types/luxon": "^3.2.0",
"@typescript-eslint/eslint-plugin": "^5.48.1", "@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^5.48.1", "@typescript-eslint/parser": "^6.10.0",
"eslint": "^8.31.0", "eslint": "^8.53.0",
"eslint-config-prettier": "^8.6.0", "eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-simple-import-sort": "^8.0.0", "eslint-plugin-simple-import-sort": "^8.0.0",
"ontime-types": "workspace:*", "ontime-types": "workspace:*",
"prettier": "^2.8.3", "prettier": "^3.0.3",
"typescript": "^4.9.4", "typescript": "^5.2.2",
"vitest": "^0.30.1" "vitest": "^0.30.1"
} }
} }
+1 -1
View File
@@ -1,4 +1,4 @@
export function isNumeric(num: any) { export function isNumeric(num: unknown) {
if (typeof num === 'number' && !isNaN(num)) { if (typeof num === 'number' && !isNaN(num)) {
return true; return true;
} }
@@ -8,7 +8,7 @@ import { dayInMs } from '../timeConstants.js';
* @param {EndAction} [fallback] * @param {EndAction} [fallback]
*/ */
export function validateEndAction(maybeAction: unknown, fallback = EndAction.None) { export function validateEndAction(maybeAction: unknown, fallback = EndAction.None) {
return Object.values(EndAction).includes(maybeAction as any) ? (maybeAction as EndAction) : fallback; return Object.values(EndAction).includes(maybeAction as EndAction) ? (maybeAction as EndAction) : fallback;
} }
/** /**
@@ -17,7 +17,7 @@ export function validateEndAction(maybeAction: unknown, fallback = EndAction.Non
* @param {TimerType} [fallback] * @param {TimerType} [fallback]
*/ */
export function validateTimerType(maybeTimerType: unknown, fallback = TimerType.CountDown) { export function validateTimerType(maybeTimerType: unknown, fallback = TimerType.CountDown) {
return Object.values(TimerType).includes(maybeTimerType as any) ? (maybeTimerType as TimerType) : fallback; return Object.values(TimerType).includes(maybeTimerType as TimerType) ? (maybeTimerType as TimerType) : fallback;
} }
/** /**
+1000 -458
View File
File diff suppressed because it is too large Load Diff
+21 -6
View File
@@ -1,18 +1,33 @@
{ {
"$schema": "https://turbo.build/schema.json", "$schema": "https://turbo.build/schema.json",
"pipeline":{ "pipeline":{
"dev": {}, "dev": {
"dev:server": {}, "cache": false
"dev:test": {}, },
"dev:server": {
"cache": false
},
"dev:test": {
"cache": false
},
"test": {},
"test:pipeline": {},
"lint": {
"cache": false
},
"lint-staged": {
"outputs": [],
"cache": false
},
"typecheck": {
"cache": false
},
"build": {}, "build": {},
"build:local": {}, "build:local": {},
"build:docker": {}, "build:docker": {},
"test": {},
"test:pipeline": {},
"e2e": { "e2e": {
"dependsOn": ["^build"] "dependsOn": ["^build"]
}, },
"lint": {},
"dist-win": {}, "dist-win": {},
"dist-mac": {}, "dist-mac": {},
"dist-linux": {}, "dist-linux": {},