diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..2783902 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,24 @@ +name: Node.js CI (format) + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + format: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [21.x] + + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + - run: npm ci + - run: npm run format:check diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..974b6c7 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,5 @@ +{ + "printWidth": 120, + "tabWidth": 4, + "trailingComma": "none" +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index b1962c5..eecd570 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "async-query": "^1.0.4", "chokidar": "^3.6.0", "copy-webpack-plugin": "^12.0.2", + "prettier": "^3.2.5", "ts-loader": "^9.5.1", "ts-node": "^10.9.2", "twi-ext": "^0.5.2", @@ -5300,6 +5301,21 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", + "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/process": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", diff --git a/package.json b/package.json index 27b66b9..c6d78d9 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,8 @@ "scripts": { "build": "webpack", "watch": "webpack --watch", + "format": "prettier --write ./src/**/*", + "format:check": "prettier --check ./src/**/*", "package": "ts-node ./script/package.ts", "version": "npm run build && git add ." }, @@ -28,6 +30,7 @@ "async-query": "^1.0.4", "chokidar": "^3.6.0", "copy-webpack-plugin": "^12.0.2", + "prettier": "^3.2.5", "ts-loader": "^9.5.1", "ts-node": "^10.9.2", "twi-ext": "^0.5.2", diff --git a/src/image/icon.png b/public/image/icon.png similarity index 100% rename from src/image/icon.png rename to public/image/icon.png diff --git a/src/manifest/v2.json b/src/manifest/v2.json index 8bce1fa..8dad2f7 100644 --- a/src/manifest/v2.json +++ b/src/manifest/v2.json @@ -9,17 +9,9 @@ }, "content_scripts": [ { - "matches": [ - "https://twitter.com/*", - "https://mobile.twitter.com/*", - "https://pro.twitter.com/*" - ], - "js": [ - "js/loader.js" - ] + "matches": ["https://twitter.com/*", "https://mobile.twitter.com/*", "https://pro.twitter.com/*"], + "js": ["js/loader.js"] } ], - "web_accessible_resources": [ - "js/main.js" - ] -} \ No newline at end of file + "web_accessible_resources": ["js/main.js"] +} diff --git a/src/manifest/v3.json b/src/manifest/v3.json index ea13047..4fa32a1 100644 --- a/src/manifest/v3.json +++ b/src/manifest/v3.json @@ -7,33 +7,17 @@ "icons": { "128": "image/icon.png" }, - "host_permissions": [ - "https://twitter.com/*", - "https://mobile.twitter.com/*", - "https://pro.twitter.com/*" - ], + "host_permissions": ["https://twitter.com/*", "https://mobile.twitter.com/*", "https://pro.twitter.com/*"], "content_scripts": [ { - "matches": [ - "https://twitter.com/*", - "https://mobile.twitter.com/*", - "https://pro.twitter.com/*" - ], - "js": [ - "js/loader.js" - ] + "matches": ["https://twitter.com/*", "https://mobile.twitter.com/*", "https://pro.twitter.com/*"], + "js": ["js/loader.js"] } ], "web_accessible_resources": [ { - "resources": [ - "js/main.js" - ], - "matches": [ - "https://twitter.com/*", - "https://mobile.twitter.com/*", - "https://pro.twitter.com/*" - ] + "resources": ["js/main.js"], + "matches": ["https://twitter.com/*", "https://mobile.twitter.com/*", "https://pro.twitter.com/*"] } ] -} \ No newline at end of file +} diff --git a/webpack.config.js b/webpack.config.js index 661c6b1..3fde6c5 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -68,14 +68,14 @@ module.exports = { new CopyFilePlugin({ patterns: [ { - context: "./src/image/", + context: "./public/", from: "**/*", - to: "chrome/image/" + to: "chrome/" }, { - context: "./src/image/", + context: "./public/", from: "**/*", - to: "firefox/image/" + to: "firefox/" }, { from: "./*LICENSE",