diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..fc3acea --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,19 @@ +module.exports = { + root: true, + env: { + node: true, + }, + plugins: [ + '@typescript-eslint', + ], + extends: [ + 'eslint:recommended', + "plugin:react/recommended", + 'plugin:@typescript-eslint/recommended', + ], + rules: { + "@typescript-eslint/no-explicit-any": "off", + "no-console": process.env.NODE_ENV === "production" ? "warn" : "off", + "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off" + } +} \ No newline at end of file diff --git a/package.json b/package.json index 2d60330..d9a663e 100644 --- a/package.json +++ b/package.json @@ -23,10 +23,15 @@ "@types/node": "^16.11.59", "@types/react": "^18.0.21", "@types/react-dom": "^18.0.6", + "@typescript-eslint/eslint-plugin": "^5.40.0", + "@typescript-eslint/parser": "^5.40.0", + "eslint": "^8.25.0", + "eslint-plugin-react": "^7.31.10", "gh-pages": "^3.1.0" }, "scripts": { "start": "react-scripts start", + "prebuild": "eslint \"src/**/*.ts\" -c .eslintrc.js", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject", diff --git a/src/font-face.d.ts b/src/font-face.d.ts index f4ea744..33d596c 100644 --- a/src/font-face.d.ts +++ b/src/font-face.d.ts @@ -13,8 +13,8 @@ declare global { type FontFaceLoadStatus = 'unloaded' | 'loading' | 'loaded' | 'error'; type FontFaceSetStatus = 'loading' | 'loaded'; - interface FontFace extends FontFaceDescriptors { - new(family: string, source: string | ArrayBuffer, descriptors?: FontFaceDescriptors): FontFace; + class FontFace extends FontFaceDescriptors { + constructor(family: string, source: string | ArrayBuffer, descriptors?: FontFaceDescriptors): FontFace; readonly status: FontFaceLoadStatus; readonly loaded: Promise; variationSettings: CSSOMString; @@ -36,7 +36,7 @@ declare global { readonly status: FontFaceSetStatus; readonly ready: Promise; add(font: FontFace): void; - check(font: string, text?: string): Boolean; // throws exception + check(font: string, text?: string): boolean; // throws exception load(font: string, text?: string): Promise delete(font: FontFace): void; clear(): void;