Skip to content

Commit c09677d

Browse files
author
Jason Young
committed
Move from husky to pre-commit
1 parent 08055fc commit c09677d

48 files changed

Lines changed: 858 additions & 1113 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.husky/pre-commit

Lines changed: 0 additions & 83 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: userale-format
5+
name: Prettier Format Check (userale)
6+
entry: bash -c 'cd products/userale && pnpm run format'
7+
language: system
8+
pass_filenames: false
9+
files: ^products/userale/
10+
11+
- id: userale-lint
12+
name: ESLint Check (userale)
13+
entry: bash -c 'cd products/userale && pnpm run lint'
14+
language: system
15+
pass_filenames: false
16+
files: ^products/userale/
17+
18+
- id: userale-build
19+
name: Build Check (userale)
20+
entry: bash -c 'cd products/userale && pnpm run build'
21+
language: system
22+
pass_filenames: false
23+
files: ^products/userale/
24+
25+
- id: userale-test
26+
name: Tests (userale)
27+
entry: bash -c 'cd products/userale && pnpm run test'
28+
language: system
29+
pass_filenames: false
30+
files: ^products/userale/

eslint.config.js

Lines changed: 0 additions & 34 deletions
This file was deleted.

products/userale/eslint.config.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import js from '@eslint/js';
2+
import tseslint from 'typescript-eslint';
3+
import pluginJest from 'eslint-plugin-jest';
4+
5+
export default [
6+
js.configs.recommended,
7+
...tseslint.configs.recommended,
8+
{
9+
files: ['**/*.{ts,tsx,js,jsx}'],
10+
languageOptions: {
11+
parser: tseslint.parser,
12+
sourceType: 'module',
13+
globals: {
14+
window: 'readonly',
15+
document: 'readonly',
16+
navigator: 'readonly',
17+
console: 'readonly',
18+
},
19+
},
20+
plugins: {
21+
'@typescript-eslint': tseslint.plugin,
22+
},
23+
rules: {
24+
'no-cond-assign': 'warn',
25+
'no-constant-condition': 'warn',
26+
'no-unused-vars': 'warn',
27+
'@typescript-eslint/no-unused-vars': 'warn',
28+
'@typescript-eslint/no-explicit-any': 'warn',
29+
},
30+
},
31+
{
32+
files: ['test/**/*.{ts,tsx,js,jsx}'],
33+
plugins: {
34+
jest: pluginJest,
35+
},
36+
languageOptions: {
37+
globals: {
38+
describe: 'readonly',
39+
test: 'readonly',
40+
expect: 'readonly',
41+
beforeEach: 'readonly',
42+
afterEach: 'readonly',
43+
jest: 'readonly',
44+
},
45+
},
46+
rules: {
47+
// Optional Jest-specific rules
48+
},
49+
},
50+
];

products/userale/package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,30 @@
33
"private": true,
44
"version": "1.0.0",
55
"scripts": {
6+
"format": "prettier --ignore-path .gitignore --write 'packages/**/{src,test}/**/*.{ts,js,tsx,jsx}'",
7+
"lint": "eslint 'packages/**/src/**/*.{ts,js,tsx,jsx}' --fix",
68
"build": "pnpm -r run build",
79
"test": "playwright test -c ./test/playwright.config.ts && pnpm -r test",
810
"pretest": "npx playwright install",
911
"example:run": "node example/server/server.js",
1012
"example:watch": "nodemon -w ./example/server example/server/server.js"
1113
},
1214
"devDependencies": {
15+
"@eslint/js": "^9.29.0",
16+
"@ianvs/prettier-plugin-sort-imports": "4.1.1",
1317
"@playwright/test": "^1.52.0",
1418
"@types/node": "^22.15.30",
1519
"body-parser": "^1.20.2",
20+
"eslint": "9.29.0",
21+
"eslint-plugin-jest": "^29.0.1",
1622
"express": "^4.18.2",
1723
"flagon-userale": "workspace:flagon-userale",
1824
"jsonschema": "^1.4.1",
19-
"pnpm": "^10.0.0",
2025
"nodemon": "^3.0.2",
26+
"pnpm": "^10.0.0",
27+
"prettier": "3.6.0",
28+
"typescript": "^5.8.3",
29+
"typescript-eslint": "^7.8.0",
2130
"ws": "^8.18.0"
2231
}
2332
}
Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,41 @@
1-
import { getStoredOptions } from "~/utils/storage";
2-
import { setOptions } from "./messages/config_change";
3-
import { sendToContent } from "~utils/messaging";
1+
import { getStoredOptions } from "~/utils/storage"
2+
import { sendToContent } from "~utils/messaging"
3+
4+
import { setOptions } from "./messages/config_change"
45

56
// Top level await is not supported so immediately execute this async function to set options from storage
6-
(async () => {
7-
const options = await getStoredOptions();
8-
setOptions(options);
9-
})();
7+
8+
;(async () => {
9+
const options = await getStoredOptions()
10+
setOptions(options)
11+
})()
1012

1113
// Takes a tabId and event data, gets the tab, and sends it
1214
function sendTabEvent(tabId: number, data: Record<string, any>, type: string) {
1315
chrome.tabs.get(tabId, (tab) => {
1416
if (!tab) return
1517
sendTabEventFromTab(tab, data, type)
16-
});
18+
})
1719
}
1820

1921
// Sends an event directly from a tab object
20-
function sendTabEventFromTab(tab: chrome.tabs.Tab, data: Record<string, any>, type: string) {
22+
function sendTabEventFromTab(
23+
tab: chrome.tabs.Tab,
24+
data: Record<string, any>,
25+
type: string
26+
) {
2127
const payload = {
2228
type,
2329
tab,
2430
data
25-
};
31+
}
2632

2733
sendToContent(tab.id!, { type: "tab-event", payload }).catch((err) =>
2834
console.warn(`Failed to send ${type} to tab ${tab.id}:`, err.message)
29-
);
35+
)
3036
}
3137

32-
// Tab event handlers
38+
// Tab event handlers
3339
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs
3440

3541
// TODO handle events that are sent when the tab isn't active.
@@ -39,46 +45,46 @@ function sendTabEventFromTab(tab: chrome.tabs.Tab, data: Record<string, any>, ty
3945

4046
chrome.tabs.onActivated.addListener((activeInfo) =>
4147
sendTabEvent(activeInfo.tabId, activeInfo, "tabs.onActivated")
42-
);
48+
)
4349

4450
chrome.tabs.onAttached.addListener((tabId, attachInfo) =>
4551
sendTabEvent(tabId, attachInfo, "tabs.onAttached")
46-
);
52+
)
4753

4854
chrome.tabs.onCreated.addListener((tab) =>
4955
sendTabEventFromTab(tab, {}, "tabs.onCreated")
50-
);
56+
)
5157

5258
chrome.tabs.onDetached.addListener((tabId, detachInfo) =>
5359
sendTabEvent(tabId, detachInfo, "tabs.onDetached")
54-
);
60+
)
5561

5662
chrome.tabs.onMoved.addListener((tabId, moveInfo) =>
5763
sendTabEvent(tabId, moveInfo, "tabs.onMoved")
58-
);
64+
)
5965

6066
chrome.tabs.onRemoved.addListener((tabId, removeInfo) =>
6167
sendTabEvent(tabId, removeInfo, "tabs.onRemoved")
62-
);
68+
)
6369

6470
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) =>
6571
sendTabEventFromTab(tab, changeInfo, "tabs.onUpdated")
66-
);
72+
)
6773

6874
chrome.tabs.onZoomChange.addListener((zoomChangeInfo) =>
6975
sendTabEvent(zoomChangeInfo.tabId, zoomChangeInfo, "tabs.onZoomChange")
70-
);
76+
)
7177

7278
chrome.tabs.onHighlighted.addListener((highlightInfo) => {
73-
// Note: No tabId is available, so send with windowId and tabIds
74-
const data = { ...highlightInfo }
75-
// Loop over highlightInfo.tabIds and call sendTabEvent on each
76-
for (const tabId of highlightInfo.tabIds) {
77-
sendTabEvent(tabId, data, "tabs.onHighlighted")
78-
}
79-
});
79+
// Note: No tabId is available, so send with windowId and tabIds
80+
const data = { ...highlightInfo }
81+
// Loop over highlightInfo.tabIds and call sendTabEvent on each
82+
for (const tabId of highlightInfo.tabIds) {
83+
sendTabEvent(tabId, data, "tabs.onHighlighted")
84+
}
85+
})
8086

8187
chrome.tabs.onReplaced.addListener((addedTabId, removedTabId) => {
82-
const data = { addedTabId, removedTabId }
83-
sendTabEvent(addedTabId, data, "tabs.onReplaced")
84-
});
88+
const data = { addedTabId, removedTabId }
89+
sendTabEvent(addedTabId, data, "tabs.onReplaced")
90+
})
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
import type { PlasmoMessaging } from "@plasmohq/messaging";
2-
import * as userale from "flagon-userale";
3-
import type { StoredOptions } from "~utils/storage";
4-
5-
let allowListRegExp: RegExp;
1+
import * as userale from "flagon-userale"
2+
3+
import type { PlasmoMessaging } from "@plasmohq/messaging"
4+
5+
import type { StoredOptions } from "~utils/storage"
6+
7+
let allowListRegExp: RegExp
68

79
const handler: PlasmoMessaging.MessageHandler = async (req, res) => {
8-
setOptions(req.body);
10+
setOptions(req.body)
911
}
1012

1113
export function setOptions(options: StoredOptions) {
12-
userale.options({url: options.loggingUrl});
13-
allowListRegExp = new RegExp(options.allowList);
14+
userale.options({ url: options.loggingUrl })
15+
allowListRegExp = new RegExp(options.allowList)
1416
}
1517

1618
export function getAllowListRegExp() {
17-
return allowListRegExp;
19+
return allowListRegExp
1820
}
1921

20-
export default handler
22+
export default handler

0 commit comments

Comments
 (0)