Skip to content

Commit ace75bb

Browse files
committed
chore(core): cleanup unnecessary items
1 parent 5e76c99 commit ace75bb

File tree

9 files changed

+53
-157
lines changed

9 files changed

+53
-157
lines changed

.eslintignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Build files
22
dist
33

4-
# Rollup configs
5-
rollup.config.js
4+
#prettier config
5+
prettier.config.cjs
66

77
# lint-staged config
88
lint-staged.config.cjs

.eslintrc.json

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
"browser": true,
44
"es6": true
55
},
6-
"extends": [
7-
"eslint:recommended",
8-
"plugin:@typescript-eslint/recommended",
9-
"plugin:prettier/recommended"
10-
],
6+
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
117
// Specifying Parser
128
"parser": "@typescript-eslint/parser",
139
"parserOptions": {
@@ -22,20 +18,8 @@
2218
// Configuring third-party plugins
2319
"plugins": ["@typescript-eslint"],
2420
// Resolve imports
25-
2621
"rules": {
2722
"linebreak-style": "off",
28-
// Configure prettier
29-
"prettier/prettier": [
30-
"error",
31-
{
32-
"printWidth": 80,
33-
"endOfLine": "lf",
34-
"singleQuote": false,
35-
"tabWidth": 2,
36-
"trailingComma": "es5"
37-
}
38-
],
3923
// Disallow the `any` type.
4024
"@typescript-eslint/no-explicit-any": "warn",
4125
"@typescript-eslint/ban-types": [

Readme.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@ Then, import it into your project:
2727
CommonJS:
2828

2929
```js
30-
const useDetectScroll = require("@smakss/react-scroll-direction");
30+
const useDetectScroll = require('@smakss/react-scroll-direction');
3131
```
3232

3333
ES Module:
3434

3535
```js
36-
import useDetectScroll from "@smakss/react-scroll-direction";
36+
import useDetectScroll from '@smakss/react-scroll-direction';
3737
```
3838

3939
For TypeScript projects, import the hook and its types:
4040

4141
```ts
4242
import useDetectScroll, {
4343
Axis,
44-
Direction,
45-
} from "@smakss/react-scroll-direction";
44+
Direction
45+
} from '@smakss/react-scroll-direction';
4646
```
4747

4848
## Usage
@@ -68,7 +68,7 @@ const scrollDir = useDetectScroll();
6868
To detect left or right scroll:
6969

7070
```js
71-
const scrollDir = useDetectScroll({ axis: "x" });
71+
const scrollDir = useDetectScroll({ axis: 'x' });
7272

7373
// Returns: "left", "right", or "still"
7474
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"lint-staged": "^15.0.2",
2121
"prettier": "^2.8.8",
2222
"rollup": "^4.2.0",
23-
"typescript": "^5.0.4"
23+
"typescript": "^5.2.2"
2424
},
2525
"engines": {
2626
"node": ">=18.0.0"

prettier.config.cjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
singleQuote: true,
3+
printWidth: 80,
4+
tabWidth: 2,
5+
trailingComma: "none",
6+
semi: true,
7+
};

rollup.config.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
import resolve from "@rollup/plugin-node-resolve";
2-
import commonjs from "@rollup/plugin-commonjs";
3-
import typescript from "@rollup/plugin-typescript";
4-
import packageJson from "./package.json" assert { type: "json" };
1+
import resolve from '@rollup/plugin-node-resolve';
2+
import commonjs from '@rollup/plugin-commonjs';
3+
import typescript from '@rollup/plugin-typescript';
4+
import packageJson from './package.json' assert { type: 'json' };
55

66
export default [
77
{
8-
input: "src/index.ts",
8+
input: 'src/index.ts',
99
output: [
1010
{
1111
file: packageJson.main,
12-
format: "cjs",
13-
exports: "named",
14-
sourcemap: true,
12+
format: 'cjs',
13+
exports: 'named',
14+
sourcemap: true
1515
},
1616
{
1717
file: packageJson.module,
18-
format: "esm",
19-
exports: "named",
20-
sourcemap: true,
21-
},
18+
format: 'esm',
19+
exports: 'named',
20+
sourcemap: true
21+
}
2222
],
2323
plugins: [resolve(), commonjs(), typescript()],
2424
external: [
2525
...Object.keys(packageJson.devDependencies || {}),
26-
...Object.keys(packageJson.peerDependencies || {}),
27-
],
28-
},
26+
...Object.keys(packageJson.peerDependencies || {})
27+
]
28+
}
2929
];

src/index.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import { useState, useEffect, useCallback } from "react";
1+
import { useState, useEffect, useCallback } from 'react';
22

33
/** Enumeration for axis values */
44
export enum Axis {
5-
X = "x",
6-
Y = "y",
5+
X = 'x',
6+
Y = 'y'
77
}
88

99
/** Enumeration for direction values */
1010
export enum Direction {
11-
Up = "up",
12-
Down = "down",
13-
Left = "left",
14-
Right = "right",
15-
Still = "still",
11+
Up = 'up',
12+
Down = 'down',
13+
Left = 'left',
14+
Right = 'right',
15+
Still = 'still'
1616
}
1717

1818
/** Type declaration for scroll properties */
@@ -65,7 +65,7 @@ function useDetectScroll(props: ScrollProps = {}): Direction {
6565
axis = Axis.Y,
6666
scrollUp = axis === Axis.Y ? Direction.Up : Direction.Left,
6767
scrollDown = axis === Axis.Y ? Direction.Down : Direction.Right,
68-
still = Direction.Still,
68+
still = Direction.Still
6969
} = props;
7070

7171
const [scrollDir, setScrollDir] = useState<Direction>(still);
@@ -96,9 +96,9 @@ function useDetectScroll(props: ScrollProps = {}): Direction {
9696
}
9797
};
9898

99-
window.addEventListener("scroll", onScroll);
99+
window.addEventListener('scroll', onScroll);
100100

101-
return () => window.removeEventListener("scroll", onScroll);
101+
return () => window.removeEventListener('scroll', onScroll);
102102
}, [updateScrollDir]);
103103

104104
return scrollDir;

tsconfig.json

Lines changed: 10 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,15 @@
11
{
22
"include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"],
33
"compilerOptions": {
4-
/* Visit https://aka.ms/tsconfig to read more about this file */
5-
6-
/* Projects */
7-
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
8-
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
9-
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
10-
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
11-
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
12-
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
13-
14-
/* Language and Environment */
15-
"target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
16-
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
17-
// "jsx": "preserve", /* Specify what JSX code is generated. */
18-
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
19-
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
20-
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
21-
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
22-
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
23-
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
24-
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
25-
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
26-
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
27-
28-
/* Modules */
29-
"module": "esnext" /* Specify what module code is generated. */,
30-
// "rootDir": "./" /* Specify the root folder within your source files. */,
31-
"moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */,
32-
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
33-
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
34-
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
35-
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
36-
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
37-
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
38-
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
39-
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
40-
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
41-
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
42-
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
43-
"resolveJsonModule": true /* Enable importing .json files. */,
44-
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
45-
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
46-
47-
/* JavaScript Support */
48-
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
49-
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
50-
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
51-
52-
/* Emit */
53-
"declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
54-
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
55-
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
56-
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
57-
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
58-
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
59-
"outDir": "dist" /* Specify an output folder for all emitted files. */,
60-
// "removeComments": true, /* Disable emitting comments. */
61-
// "noEmit": true, /* Disable emitting files from a compilation. */
62-
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
63-
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
64-
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
65-
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
66-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
67-
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
68-
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
69-
// "newLine": "crlf", /* Set the newline character for emitting files. */
70-
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
71-
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
72-
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
73-
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
74-
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
75-
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
76-
77-
/* Interop Constraints */
78-
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
79-
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
80-
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
81-
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
82-
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
83-
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
84-
85-
/* Type Checking */
86-
"strict": true /* Enable all strict type-checking options. */,
87-
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
88-
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
89-
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
90-
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
91-
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
92-
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
93-
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
94-
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
95-
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
96-
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
97-
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
98-
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
99-
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
100-
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
101-
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
102-
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
103-
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
104-
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
105-
106-
/* Completeness */
107-
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
108-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
4+
"target": "ESNext",
5+
"module": "esnext",
6+
"moduleResolution": "node",
7+
"resolveJsonModule": true,
8+
"declaration": true,
9+
"outDir": "dist",
10+
"esModuleInterop": true,
11+
"forceConsistentCasingInFileNames": true,
12+
"strict": true,
13+
"skipLibCheck": true
10914
}
11015
}

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2322,7 +2322,7 @@ type-fest@^1.0.2:
23222322
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-1.4.0.tgz#e9fb813fe3bf1744ec359d55d1affefa76f14be1"
23232323
integrity sha512-yGSza74xk0UG8k+pLh5oeoYirvIiWo5t0/o3zHHAO2tRDiZcxWP7fywNlXhqb6/r6sWvwi+RsyQMWhVLe4BVuA==
23242324

2325-
typescript@^5.0.4:
2325+
typescript@^5.2.2:
23262326
version "5.2.2"
23272327
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.2.2.tgz#5ebb5e5a5b75f085f22bc3f8460fba308310fa78"
23282328
integrity sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==

0 commit comments

Comments
 (0)