Skip to content

Commit e71e2bc

Browse files
committed
Add formating and linting into system
1 parent dca2c69 commit e71e2bc

File tree

97 files changed

+37398
-35019
lines changed

Some content is hidden

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

97 files changed

+37398
-35019
lines changed

.github/workflows/static.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build and Deploy Docs to Pages
22

33
on:
44
push:
5-
branches: ["main"]
5+
branches: ['main']
66
workflow_dispatch:
77

88
permissions:
@@ -11,7 +11,7 @@ permissions:
1111
id-token: write
1212

1313
concurrency:
14-
group: "pages"
14+
group: 'pages'
1515
cancel-in-progress: false
1616

1717
jobs:
@@ -25,7 +25,7 @@ jobs:
2525
uses: actions/setup-node@v4
2626
with:
2727
node-version: 20
28-
cache: "npm"
28+
cache: 'npm'
2929

3030
- name: Install dependencies
3131
run: npm ci

.husky/pre-commit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env sh
2+
npm run precommit:run

.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
build
3+
coverage
4+
docs-src/.vitepress/cache
5+
docs-src/.vitepress/dist

.prettierrc.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema": "https://json.schemastore.org/prettierrc",
3+
"semi": true,
4+
"singleQuote": true,
5+
"trailingComma": "es5",
6+
"printWidth": 100,
7+
"tabWidth": 2,
8+
"arrowParens": "always"
9+
}

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"i18n-ally.localesPaths": ["src/_locales"],
33
"i18n-ally.sourceLanguage": "en",
4-
"i18n-ally.enabledParsers": ["json"],
4+
"i18n-ally.enabledParsers": ["json"]
55
}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ npm run build:chrome
2828
```
2929

3030
Output: `build/chrome`
31-
- Chrome package: `build/codetweak-chrome.zip`
3231

32+
- Chrome package: `build/codetweak-chrome.zip`
3333

3434
## Development
3535

@@ -64,8 +64,8 @@ npm run docs:build
6464
// ==/UserScript==
6565

6666
(async () => {
67-
document.body.setAttribute("data-codetweak", "ready");
68-
await GM_setValue("lastRun", Date.now());
67+
document.body.setAttribute('data-codetweak', 'ready');
68+
await GM_setValue('lastRun', Date.now());
6969
})();
7070
```
7171

buildScripts/build-chrome.js

Lines changed: 79 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,144 +1,136 @@
1-
import { build } from "esbuild";
2-
import {
3-
rmSync,
4-
mkdirSync,
5-
cpSync,
6-
writeFileSync,
7-
createWriteStream,
8-
} from "fs";
9-
import { join } from "path";
10-
import process from "process";
11-
import archiver from "archiver";
1+
import { build } from 'esbuild';
2+
import { rmSync, mkdirSync, cpSync, writeFileSync, createWriteStream } from 'fs';
3+
import { join } from 'path';
4+
import process from 'process';
5+
import archiver from 'archiver';
126

137
const args = process.argv.slice(2);
14-
const isProduction = args.includes("--production");
15-
const browserFlag = args.find((arg) => arg.startsWith("--browser="));
16-
const browser = browserFlag ? browserFlag.split("=")[1] : "chrome";
8+
const isProduction = args.includes('--production');
9+
const browserFlag = args.find((arg) => arg.startsWith('--browser='));
10+
const browser = browserFlag ? browserFlag.split('=')[1] : 'chrome';
1711

1812
const outdir = `build/${browser}`;
1913
rmSync(outdir, { recursive: true, force: true });
2014
mkdirSync(outdir, { recursive: true });
2115

2216
const staticDirs = [
23-
"assets",
24-
"dashboard",
25-
"editor",
26-
"offscreen",
27-
"popup",
28-
"GM",
29-
"utils",
30-
"ai_dom_editor",
31-
"_locales",
17+
'assets',
18+
'dashboard',
19+
'editor',
20+
'offscreen',
21+
'popup',
22+
'GM',
23+
'utils',
24+
'ai_dom_editor',
25+
'_locales',
3226
];
3327
for (const dir of staticDirs) {
3428
cpSync(`src/${dir}`, join(outdir, dir), { recursive: true });
3529
}
3630

3731
const manifest = {
3832
manifest_version: 3,
39-
name: "__MSG_appName__",
40-
version: "1.0.0",
41-
description: "__MSG_appDescription__",
42-
default_locale: "en",
33+
name: '__MSG_appName__',
34+
version: '1.0.0',
35+
description: '__MSG_appDescription__',
36+
default_locale: 'en',
4337
permissions: [
44-
"storage",
45-
"tabs",
46-
"scripting",
47-
"webNavigation",
48-
"contextMenus",
49-
"notifications",
50-
"offscreen",
51-
"clipboardWrite",
52-
"downloads",
38+
'storage',
39+
'tabs',
40+
'scripting',
41+
'webNavigation',
42+
'contextMenus',
43+
'notifications',
44+
'offscreen',
45+
'clipboardWrite',
46+
'downloads',
5347
],
54-
host_permissions: ["http://*/*", "https://*/*"],
48+
host_permissions: ['http://*/*', 'https://*/*'],
5549
background: {
56-
service_worker: "background/background.js",
57-
type: "module",
50+
service_worker: 'background/background.js',
51+
type: 'module',
5852
},
5953
action: {
60-
default_popup: "popup/popup.html",
54+
default_popup: 'popup/popup.html',
6155
default_icon: {
62-
16: "assets/icons/icon16.png",
63-
48: "assets/icons/icon48.png",
64-
128: "assets/icons/icon128.png",
56+
16: 'assets/icons/icon16.png',
57+
48: 'assets/icons/icon48.png',
58+
128: 'assets/icons/icon128.png',
6559
},
6660
},
6761
icons: {
68-
16: "assets/icons/icon16.png",
69-
48: "assets/icons/icon48.png",
70-
128: "assets/icons/icon128.png",
62+
16: 'assets/icons/icon16.png',
63+
48: 'assets/icons/icon48.png',
64+
128: 'assets/icons/icon128.png',
7165
},
7266
content_scripts: [
7367
{
74-
matches: ["http://*/*", "https://*/*"],
75-
js: ["elementSelector/main.js"],
76-
css: ["assets/styles/elementSelector.css"],
77-
run_at: "document_start",
68+
matches: ['http://*/*', 'https://*/*'],
69+
js: ['elementSelector/main.js'],
70+
css: ['assets/styles/elementSelector.css'],
71+
run_at: 'document_start',
7872
},
7973
{
80-
matches: ["http://*/*", "https://*/*"],
81-
js: ["utils/content_bridge.js"],
82-
run_at: "document_start",
83-
world: "ISOLATED",
74+
matches: ['http://*/*', 'https://*/*'],
75+
js: ['utils/content_bridge.js'],
76+
run_at: 'document_start',
77+
world: 'ISOLATED',
8478
},
8579
{
86-
matches: ["http://*/*", "https://*/*"],
87-
js: ["ai_dom_editor/editor/ai_dom_content.js", "ai_dom_editor/sidebar/ai_dom_sidebar.js"],
88-
run_at: "document_idle",
80+
matches: ['http://*/*', 'https://*/*'],
81+
js: ['ai_dom_editor/editor/ai_dom_content.js', 'ai_dom_editor/sidebar/ai_dom_sidebar.js'],
82+
run_at: 'document_idle',
8983
},
9084
{
91-
matches: ["https://greasyfork.org/*"],
92-
js: ["utils/greasyfork_interceptor.js"],
93-
run_at: "document_start",
85+
matches: ['https://greasyfork.org/*'],
86+
js: ['utils/greasyfork_interceptor.js'],
87+
run_at: 'document_start',
9488
},
9589
],
9690
web_accessible_resources: [
9791
{
98-
resources: ["utils/*", "GM/*", "ai_dom_editor/*"],
99-
matches: ["<all_urls>"],
92+
resources: ['utils/*', 'GM/*', 'ai_dom_editor/*'],
93+
matches: ['<all_urls>'],
10094
},
10195
],
10296
};
10397

104-
writeFileSync(join(outdir, "manifest.json"), JSON.stringify(manifest, null, 2));
98+
writeFileSync(join(outdir, 'manifest.json'), JSON.stringify(manifest, null, 2));
10599
await build({
106100
entryPoints: [
107-
"src/background/background.js",
108-
"src/utils/content_bridge.js",
109-
"src/elementSelector/main.js",
110-
"src/GM/gm_core.js",
111-
"src/utils/greasyfork_interceptor.js",
112-
"src/utils/inject.js",
113-
"src/utils/urls.js",
114-
"src/popup/popup.js",
115-
"src/editor/editor.js",
116-
"src/dashboard/dashboard.js",
117-
"src/ai_dom_editor/editor/ai_dom_content.js",
118-
"src/ai_dom_editor/sidebar/ai_dom_sidebar.js",
119-
"src/ai_dom_editor/editor/ai_dom_editor.js",
120-
"src/ai_dom_editor/settings/ai_settings.js",
101+
'src/background/background.js',
102+
'src/utils/content_bridge.js',
103+
'src/elementSelector/main.js',
104+
'src/GM/gm_core.js',
105+
'src/utils/greasyfork_interceptor.js',
106+
'src/utils/inject.js',
107+
'src/utils/urls.js',
108+
'src/popup/popup.js',
109+
'src/editor/editor.js',
110+
'src/dashboard/dashboard.js',
111+
'src/ai_dom_editor/editor/ai_dom_content.js',
112+
'src/ai_dom_editor/sidebar/ai_dom_sidebar.js',
113+
'src/ai_dom_editor/editor/ai_dom_editor.js',
114+
'src/ai_dom_editor/settings/ai_settings.js',
121115
],
122116
bundle: true,
123117
outdir,
124-
logLevel: "info",
125-
platform: "browser",
118+
logLevel: 'info',
119+
platform: 'browser',
126120
define: {
127-
"process.env.BROWSER": JSON.stringify(browser),
121+
'process.env.BROWSER': JSON.stringify(browser),
128122
},
129123
});
130124
if (isProduction) {
131125
const archiveName = `codetweak-${browser}.zip`;
132-
const output = createWriteStream(join("build", archiveName));
133-
const archive = archiver("zip", { zlib: { level: 9 } });
126+
const output = createWriteStream(join('build', archiveName));
127+
const archive = archiver('zip', { zlib: { level: 9 } });
134128

135-
output.on("close", () => {
136-
console.log(
137-
`Successfully created ${archiveName} (${archive.pointer()} bytes)`
138-
);
129+
output.on('close', () => {
130+
console.log(`Successfully created ${archiveName} (${archive.pointer()} bytes)`);
139131
});
140132

141-
archive.on("error", (err) => {
133+
archive.on('error', (err) => {
142134
throw err;
143135
});
144136

0 commit comments

Comments
 (0)