Skip to content

Commit

Permalink
Merge pull request #64 from northword:fix-lint
Browse files Browse the repository at this point in the history
Fix lint and prettier
  • Loading branch information
windingwind authored Jul 13, 2023
2 parents 10d9879 + 79e87f0 commit 18476d9
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 77 deletions.
10 changes: 9 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@
},
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/ban-ts-comment": ["warn", "allow-with-description"],
"@typescript-eslint/ban-ts-comment": [
"warn",
{
"ts-expect-error": "allow-with-description",
"ts-ignore": "allow-with-description",
"ts-nocheck": "allow-with-description",
"ts-check": "allow-with-description"
}
],
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-explicit-any": ["off", { "ignoreRestArgs": true }],
"@typescript-eslint/no-non-null-assertion": "off"
Expand Down
1 change: 1 addition & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"assets": ["build/*.xpi"]
},
"hooks": {
"before:init": "npm run lint",
"after:bump": "npm run build",
"after:release": "echo Successfully released ${name} v${version} to ${repo.repository}."
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ This is also how your plugin will be released and used by others.
<details >
<summary>💡 Start with GitHub Codespace</summary>

*GitHub CodeSpace* enables you getting started without the need to download code/IDE/dependencies locally.
_GitHub CodeSpace_ enables you getting started without the need to download code/IDE/dependencies locally.

Replace the steps above and build you first plugin in 30 seconds!

Expand Down
6 changes: 3 additions & 3 deletions addon/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async function waitForZotero() {
resolve();
}
},
false
false,
);
},
};
Expand Down Expand Up @@ -92,7 +92,7 @@ async function startup({ id, version, resourceURI, rootURI }, reason) {

Services.scriptloader.loadSubScript(
`${rootURI}/chrome/content/scripts/index.js`,
ctx
ctx,
);
}

Expand All @@ -102,7 +102,7 @@ function shutdown({ id, version, resourceURI, rootURI }, reason) {
}
if (typeof Zotero === "undefined") {
Zotero = Components.classes["@zotero.org/Zotero;1"].getService(
Components.interfaces.nsISupports
Components.interfaces.nsISupports,
).wrappedJSObject;
}
Zotero.__addonInstance__.hooks.onShutdown();
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@
},
"homepage": "https://github.com/windingwind/zotero-addon-template#readme",
"dependencies": {
"zotero-plugin-toolkit": "^2.1.3"
"zotero-plugin-toolkit": "^2.1.5"
},
"devDependencies": {
"@types/node": "^20.1.1",
"@types/node": "^20.4.2",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"chokidar-cli": "^3.0.0",
"compressing": "^1.9.0",
"concurrently": "^8.0.1",
"concurrently": "^8.2.0",
"cross-env": "^7.0.3",
"esbuild": "^0.18.1",
"eslint": "^8.40.0",
"esbuild": "^0.18.12",
"eslint": "^8.44.0",
"eslint-config-prettier": "^8.8.0",
"prettier": "3.0.0",
"prettier": "^3.0.0",
"release-it": "^16.1.0",
"replace-in-file": "^7.0.1",
"typescript": "^5.0.4",
"zotero-types": "^1.0.14"
"typescript": "^5.1.6",
"zotero-types": "^1.0.16"
}
}
22 changes: 11 additions & 11 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function dateFormat(fmt, date) {
if (ret) {
fmt = fmt.replace(
ret[1],
ret[1].length == 1 ? opt[k] : opt[k].padStart(ret[1].length, "0")
ret[1].length == 1 ? opt[k] : opt[k].padStart(ret[1].length, "0"),
);
}
}
Expand All @@ -106,7 +106,7 @@ function renameLocaleFiles() {
if (localeSubFile.endsWith(".ftl")) {
renameSync(
path.join(localeSubDir, localeSubFile),
path.join(localeSubDir, `${config.addonRef}-${localeSubFile}`)
path.join(localeSubDir, `${config.addonRef}-${localeSubFile}`),
);
}
}
Expand All @@ -124,7 +124,7 @@ function replaceString() {
const replaceTo = [author, description, homepage, version, buildTime];

replaceFrom.push(
...Object.keys(config).map((k) => new RegExp(`__${k}__`, "g"))
...Object.keys(config).map((k) => new RegExp(`__${k}__`, "g")),
);
replaceTo.push(...Object.values(config));

Expand Down Expand Up @@ -154,7 +154,7 @@ function replaceString() {
const prefixedLines = lines.map((line) => {
// https://regex101.com/r/lQ9x5p/1
const match = line.match(
/^(?<message>[a-zA-Z]\S*)([ ]*=[ ]*)(?<pattern>.*)$/m
/^(?<message>[a-zA-Z]\S*)([ ]*=[ ]*)(?<pattern>.*)$/m,
);
if (match) {
localeMessage.add(match.groups.message);
Expand All @@ -175,7 +175,7 @@ function replaceString() {
if (localeMessage.has(match[2])) {
input = input.replace(
match[0],
`${match[1]}="${config.addonRef}-${match[2]}"`
`${match[1]}="${config.addonRef}-${match[2]}"`,
);
} else {
localeMessageMiss.add(match[2]);
Expand All @@ -191,14 +191,14 @@ function replaceString() {
.filter((f) => f.hasChanged)
.map((f) => `${f.file} : ${f.numReplacements} / ${f.numMatches}`),
replaceResultFlt.filter((f) => f.hasChanged).map((f) => `${f.file} : OK`),
replaceResultXhtml.filter((f) => f.hasChanged).map((f) => `${f.file} : OK`)
replaceResultXhtml.filter((f) => f.hasChanged).map((f) => `${f.file} : OK`),
);

if (localeMessageMiss.size !== 0) {
console.warn(
`[Build] [Warn] Fluent message [${new Array(
...localeMessageMiss
)}] do not exsit in addon's locale files.`
...localeMessageMiss,
)}] do not exsit in addon's locale files.`,
);
}
}
Expand All @@ -221,7 +221,7 @@ async function main() {
console.log(
`[Build] BUILD_DIR=${buildDir}, VERSION=${version}, BUILD_TIME=${buildTime}, ENV=${[
env.NODE_ENV,
]}`
]}`,
);

clearFolder(buildDir);
Expand All @@ -248,12 +248,12 @@ async function main() {
path.join(buildDir, `${name}.xpi`),
{
ignoreBase: true,
}
},
);

console.log("[Build] Addon pack OK");
console.log(
`[Build] Finished in ${(new Date().getTime() - t.getTime()) / 1000} s.`
`[Build] Finished in ${(new Date().getTime() - t.getTime()) / 1000} s.`,
);
}

Expand Down
4 changes: 2 additions & 2 deletions scripts/start.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { execSync } from "child_process";
import { exit } from "process";
import { existsSync, writeFileSync, readFileSync } from "fs";
import path from "path"
import path from "path";
import details from "../package.json" assert { type: "json" };
import cmd from "./zotero-cmd.json" assert { type: "json" };

Expand All @@ -21,7 +21,7 @@ if (existsSync(profilePath)) {
console.log(
`[info] Addon proxy file has been updated. \n
File path: ${addonProxyFilePath} \n
Addon path: ${buildPath} \n`
Addon path: ${buildPath} \n`,
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function onStartup() {
initLocale();
ztoolkit.ProgressWindow.setIconURI(
"default",
`chrome://${config.addonRef}/content/icons/favicon.png`
`chrome://${config.addonRef}/content/icons/favicon.png`,
);

const popupWin = new ztoolkit.ProgressWindow(config.addonName, {
Expand Down Expand Up @@ -97,7 +97,7 @@ async function onNotify(
event: string,
type: string,
ids: Array<string | number>,
extraData: { [key: string]: any }
extraData: { [key: string]: any },
) {
// You can add your code to the corresponding notify type
ztoolkit.log("notify", event, type, ids, extraData);
Expand Down
Loading

0 comments on commit 18476d9

Please sign in to comment.