Skip to content

Commit

Permalink
Adds type support for the package. (#16)
Browse files Browse the repository at this point in the history
* Added type support.

* Updated estlintrc location

* Fixed types defintion.

* Fixed unnecessarily disabled eslint rule and fixed eslint errors.
  • Loading branch information
deepakjosp authored Jan 26, 2024
1 parent e5876bb commit d268ee9
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 19 deletions.
4 changes: 1 addition & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
const defaultConfig = require("@bigbinary/neeto-commons-frontend/configs/eslint/index.js");
const defaultConfig = require("@bigbinary/neeto-commons-frontend/configs/nanos/eslint/index.js");

const { mergeDeepLeft } = require("ramda");

module.exports = mergeDeepLeft(
{
rules: {
"@bigbinary/neeto/no-missing-localization": "off",
"@bigbinary/neeto/webpack-aliases-and-jsconfig-paths-should-be-in-sync":
"off",
},
},
defaultConfig
Expand Down
7 changes: 0 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ yalc.lock
/index.cjs.js.map
/index.mjs
/index.mjs.map
/index.d.ts
# Ignore bundler config
/.bundle

Expand Down Expand Up @@ -232,9 +231,3 @@ dump.rdb
# Ignore yalc generated files
yalc.lock
/.yalc

/index.cjs.js
/index.cjs.js.map
/index.mjs
/index.mjs.map
/index.d.ts
11 changes: 11 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
type ConfigType = {
mode?: "default" | "global" | "scoped";
unbindOnUnmount?: boolean;
enabled?: boolean;
};

export default function useHotkeys(
hotkey: string | string[],
handler: (event: React.KeyboardEvent) => void,
config?: ConfigType
): React.MutableRefObject | null;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"prepare": "husky install",
"build": "NODE_ENV=production rollup -c"
},
"types": "index.d.ts",
"engines": {
"node": ">=18.12",
"npm": ">=9",
Expand Down
4 changes: 3 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const globals = Object.fromEntries(
keys(packageJSON.peerDependencies).map(lib => [lib, lib])
);

const buildFilesMatchPattern = 'index.{cjs.js,cjs.js.map,mjs,mjs.map}';

export default {
input: "./src/index.js",
output: [
Expand All @@ -39,7 +41,7 @@ export default {
],
plugins: [
// To delete previously existing bundle.
cleaner({ targets: globSync(path.resolve(__dirname, `index.*`)) }),
cleaner({ targets: globSync(path.resolve(__dirname, buildFilesMatchPattern)) }),
// To automatically externalize peerDependencies in a rollup bundle.
peerDepsExternal(),
// To use third party modules from node_modules
Expand Down
11 changes: 3 additions & 8 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ export const MAC_TO_WINDOWS_KEYS_MAP = {
delete: "backspace",
};

export const OS = {
mac: "OS X",
windows: "Windows",
};
// eslint-disable-next-line @bigbinary/neeto/hard-coded-strings-should-be-localized
export const OS = { mac: "OS X", windows: "Windows" };

export const KEY_NAMES = {
delete: "delete",
backspace: "backspace",
};
export const KEY_NAMES = { delete: "delete", backspace: "backspace" };
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect, useRef } from "react";

import { mergeLeft } from "ramda";

import { DEFAULT_CONFIG, MODES } from "src/constants";
import {
bindHotKey,
Expand Down

0 comments on commit d268ee9

Please sign in to comment.