Skip to content

Commit

Permalink
Rewrite lib with TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
pedro-lb committed Jun 16, 2020
1 parent afd3fd0 commit ca7cf9f
Show file tree
Hide file tree
Showing 16 changed files with 6,291 additions and 5,451 deletions.
21 changes: 21 additions & 0 deletions . npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

# See https://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
node_modules

# builds
build
.rpt2_cache

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
9 changes: 0 additions & 9 deletions .babelrc

This file was deleted.

23 changes: 0 additions & 23 deletions .eslintrc

This file was deleted.

55 changes: 55 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
module.exports = {
env: {
browser: true,
es6: true,
node: true,
},
settings: {
"import/resolver": {
node: {
paths: ["src"],
extensions: [
".js",
".ts",
".jsx",
".tsx",
],
},
},
},
extends: [
"plugin:react-hooks/recommended",
"plugin:react/recommended",
"airbnb",
],
globals: {
Atomics: "readonly",
SharedArrayBuffer: "readonly",
},
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018,
sourceType: "module",
},
plugins: [
"react",
"react-hooks",
"@typescript-eslint",
],
rules: {
"react/jsx-filename-extension": [1, { "extensions": [".tsx", ".jsx"] }],
"react/jsx-props-no-spreading": 0,
"import/prefer-default-export": 0,
"import/extensions": 0,
"no-unused-vars": 0,
"react-hooks/exhaustive-deps": "warn",
"react-hooks/rules-of-hooks": "error",
"jsx-a11y/no-static-element-interactions": 0,
"jsx-a11y/click-events-have-key-events": 0,
"jsx-a11y/label-has-associated-control": 0,
"dot-notation": 0,
},
};
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"eslint.workingDirectories": [
"./src/",
"./",
]
}
68 changes: 30 additions & 38 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,45 +25,37 @@
"react": "^16.8.6"
},
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/plugin-external-helpers": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-proposal-decorators": "^7.0.0",
"@babel/plugin-proposal-do-expressions": "^7.0.0",
"@babel/plugin-proposal-export-default-from": "^7.0.0",
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
"@babel/plugin-proposal-function-bind": "^7.0.0",
"@babel/plugin-proposal-function-sent": "^7.0.0",
"@babel/plugin-proposal-json-strings": "^7.0.0",
"@babel/plugin-proposal-logical-assignment-operators": "^7.0.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
"@babel/plugin-proposal-numeric-separator": "^7.0.0",
"@babel/plugin-proposal-optional-chaining": "^7.0.0",
"@babel/plugin-proposal-pipeline-operator": "^7.0.0",
"@babel/plugin-proposal-throw-expressions": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-syntax-import-meta": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"babel-eslint": "^10.0.1",
"cross-env": "^5.2.0",
"eslint": "5.16.0",
"eslint-config-standard": "^11.0.0",
"eslint-config-standard-react": "^6.0.0",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-promise": "^4.0.0",
"eslint-plugin-react": "^7.10.0",
"eslint-plugin-standard": "^3.1.0",
"gh-pages": "^2.0.1",
"react": "^16.8.6",
"react-scripts": "^3.0.1",
"rollup": "^1.1.2",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-node-resolve": "^4.0.0",
"@svgr/rollup": "^2.4.1",
"@types/classnames": "^2.2.9",
"@types/invariant": "^2.2.33",
"@types/jest": "^23.1.5",
"@types/react": "^16.9.19",
"@types/react-dom": "^16.0.5",
"@types/yup": "^0.26.29",
"@typescript-eslint/eslint-plugin": "^2.19.0",
"@typescript-eslint/parser": "^2.19.0",
"babel-core": "^6.26.3",
"babel-runtime": "^6.26.0",
"cross-env": "^5.1.4",
"eslint": "^6.8.0",
"eslint-config-airbnb": "^18.0.1",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.18.3",
"eslint-plugin-react-hooks": "^4.0.4",
"gh-pages": "^1.2.0",
"react": "16.8.6",
"react-dom": "16.8.6",
"react-scripts-ts": "^3.1.0",
"rollup": "^0.62.0",
"rollup-plugin-babel": "^3.0.7",
"rollup-plugin-commonjs": "^9.1.3",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-peer-deps-external": "^2.2.0",
"rollup-plugin-url": "^2.1.0"
"rollup-plugin-postcss": "^1.6.2",
"rollup-plugin-typescript2": "^0.17.0",
"rollup-plugin-url": "^1.4.0",
"typescript": "^3.7.5"
},
"keywords": [
"hooks",
Expand Down
50 changes: 34 additions & 16 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,50 @@
import babel from 'rollup-plugin-babel'
import commonjs from 'rollup-plugin-commonjs'
import external from 'rollup-plugin-peer-deps-external'
import resolve from 'rollup-plugin-node-resolve'
import url from 'rollup-plugin-url'
import typescript from 'rollup-plugin-typescript2';
import commonjs from 'rollup-plugin-commonjs';
import external from 'rollup-plugin-peer-deps-external';
// import postcss from 'rollup-plugin-postcss-modules';
import postcss from 'rollup-plugin-postcss';
import resolve from 'rollup-plugin-node-resolve';
import url from 'rollup-plugin-url';
import svgr from '@svgr/rollup';

import pkg from './package.json'
import pkg from './package.json';

export default {
input: 'src/index.js',
input: 'src/index.ts',
output: [
{
file: pkg.main,
format: 'cjs',
sourcemap: true
exports: 'named',
sourcemap: true,
},
{
file: pkg.module,
format: 'es',
sourcemap: true
}
exports: 'named',
sourcemap: true,
},
],
plugins: [
external(),
url({ exclude: ['**/*.svg'] }),
babel({
exclude: 'node_modules/**'
postcss({
modules: true,
}),
url(),
svgr(),
resolve(),
commonjs()
]
}
typescript({
rollupCommonJSResolveHack: true,
clean: true,
}),
commonjs({
include: 'node_modules/**',
namedExports: {
// left-hand side can be an absolute path, a path
// relative to the current directory, or the name
// of a module in node_modules
scheduler: ['unstable_runWithPriority', 'LowPriority'],
},
}),
],
};
11 changes: 0 additions & 11 deletions src/.eslintrc

This file was deleted.

File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions src/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Options for useWindowSize hook.
*/
export interface UseWindowSizeOptions {
useDebounce?: boolean;
debounceTimeMs?: number;
}

/**
* Options for parseLayoutResult.
*/
export interface ParseLayoutResultOptions {
width: number
}
File renamed without changes.
77 changes: 0 additions & 77 deletions src/useWindowSize.js

This file was deleted.

Loading

0 comments on commit ca7cf9f

Please sign in to comment.