Skip to content

Commit 711b240

Browse files
committed
Init
0 parents  commit 711b240

23 files changed

+2631
-0
lines changed

.babelrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"presets": [
3+
"@babel/preset-env",
4+
"@babel/preset-react"
5+
] // ,
6+
// "plugins": ["@babel/plugin-proposal-class-properties"]
7+
}

.eslintrc.js

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
extends: [
4+
'plugin:@typescript-eslint/recommended',
5+
'plugin:react/recommended',
6+
],
7+
parserOptions: {
8+
ecmaVersion: 2018,
9+
sourceType: 'module',
10+
},
11+
plugins: ['react-hooks'],
12+
rules: {
13+
curly: 'error',
14+
'@typescript-eslint/indent': 'off',
15+
'@typescript-eslint/no-non-null-assertion': 'off',
16+
'@typescript-eslint/no-empty-function': 'off',
17+
'@typescript-eslint/ban-ts-comment': 'warn',
18+
'@typescript-eslint/no-explicit-any': 'off',
19+
'@typescript-eslint/explicit-function-return-type': 'off',
20+
'@typescript-eslint/no-empty-function': 'off',
21+
'@typescript-eslint/no-object-literal-type-assertion': 'off',
22+
'react-hooks/rules-of-hooks': 'error',
23+
'react-hooks/exhaustive-deps': 'error',
24+
'react/display-name': 'warn',
25+
'no-console': 'error',
26+
'@typescript-eslint/no-this-alias': [
27+
'error',
28+
{
29+
'allowDestructuring': true, // Allow `const { props, state } = this`; false by default
30+
'allowedNames': ['self'] // Allow `const self = this`; `[]` by default
31+
}
32+
],
33+
'@typescript-eslint/explicit-module-boundary-types': 'off',
34+
},
35+
overrides: [
36+
{
37+
files: ['*.spec.ts', '*.spec.tsx'],
38+
rules: {
39+
// Allow testing runtime errors to suppress TS errors
40+
'@typescript-eslint/ban-ts-comment': 'off',
41+
'@typescript-eslint/explicit-module-boundary-types': 'off',
42+
},
43+
},
44+
],
45+
settings: {
46+
react: {
47+
pragma: 'React',
48+
version: 'detect',
49+
},
50+
},
51+
};

.gitignore

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# See https://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# dependencies
4+
node_modules
5+
6+
# builds
7+
build
8+
dist
9+
10+
# misc
11+
.DS_Store
12+
.env
13+
.env.local
14+
.env.development.local
15+
.env.test.local
16+
.env.production.local
17+
18+
npm-debug.log*
19+
yarn-debug.log*
20+
yarn-error.log*
21+
22+
package-lock.json
23+
24+
/supports/javascript/node_modules
25+
/supports/javascript/package-lock.json

.npmignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# ***
2+
# *
3+
# * https://docs.npmjs.com/cli/v6/using-npm/developers
4+
# *
5+
# ***
6+
7+
/docs
8+
/src
9+
/supports
10+
/test
11+
.gitignore

.prettierrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"trailingComma": "all",
3+
"singleQuote": true
4+
}

.travis.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
language: node_js
2+
node_js:
3+
- 14
4+
- 13
5+
- 12
6+
- 11
7+
- 10

LICENSE

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2021 Bunlong
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in
8+
all copies or substantial portions of the Software.
9+
10+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
11+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
15+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
16+
THE SOFTWARE.

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# react-xls
2+
3+
react-xls is the fastest in-browser excel ( .xls & .xlsx ) parser for React.

jest.config.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = {
2+
roots: ['<rootDir>/test'],
3+
transform: {
4+
'^.+\\.tsx?$': 'ts-jest',
5+
},
6+
globals: {
7+
'ts-jest': {
8+
tsconfig: 'tsconfig.jest.json',
9+
},
10+
},
11+
testMatch: ['**/?(*.)+(spec|test).ts?(x)'],
12+
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$'],
13+
setupFiles: ['<rootDir>/setup.ts'],
14+
moduleFileExtensions: ['ts', 'tsx', 'js'],
15+
};

package.json

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
{
2+
"name": "react-xls",
3+
"version": "0.0.0",
4+
"description": "react-xls is the fastest in-browser excel ( .xls & .xlsx ) parser for React.",
5+
"author": "Bunlong <[email protected]>",
6+
"license": "MIT",
7+
"repository": {
8+
"type": "git",
9+
"url": "git+https://github.com/Bunlong/react-xls.git"
10+
},
11+
"bugs": {
12+
"url": "https://github.com/Bunlong/react-xls.git/issues"
13+
},
14+
"keywords": [
15+
"react",
16+
"react-xls",
17+
"excel",
18+
"xls",
19+
"xlsx",
20+
"xlsb",
21+
"xlsm",
22+
"spreadsheet"
23+
],
24+
"homepage": "",
25+
"main": "dist/react-xls.js",
26+
"module": "dist/react-xls.es.js",
27+
"jsnext:main": "dist/react-xls.es.js",
28+
"types": "dist/react-xls.d.ts",
29+
"@comment unpkg": "dist/react-xls.umd.js",
30+
"engines": {
31+
"node": ">=8",
32+
"npm": ">=5"
33+
},
34+
"scripts": {
35+
"build": "rollup -c",
36+
"@comment prettier": "prettier --write './src/*.ts' './src/*.tsx' --config ./.prettierrc",
37+
"prettier": "prettier --write './src/*.ts' './src/utils/*.ts' --config ./.prettierrc",
38+
"lint:check": "eslint ./src --ext .tsx,.ts --report-unused-disable-directives",
39+
"bundlesize": "npm run build && bundlesize",
40+
"dev": "rollup -c -w",
41+
"test": "jest --runInBand",
42+
"prepare": "npm run build",
43+
"predeploy": "cd docs && npm install && npm run build",
44+
"deploy": "gh-pages -d docs/build"
45+
},
46+
"devDependencies": {
47+
"@babel/core": "^7.15.0",
48+
"@babel/plugin-proposal-class-properties": "^7.14.5",
49+
"@babel/preset-env": "^7.15.0",
50+
"@rollup/plugin-babel": "^5.3.0",
51+
"@rollup/plugin-commonjs": "^20.0.0",
52+
"@rollup/plugin-node-resolve": "^13.0.4",
53+
"@types/react": "^17.0.17",
54+
"@types/react-dom": "^17.0.9",
55+
"@typescript-eslint/eslint-plugin": "^4.29.1",
56+
"@typescript-eslint/parser": "^4.29.1",
57+
"bundlesize": "^0.18.1",
58+
"eslint": "^7.32.0",
59+
"eslint-plugin-react": "^7.24.0",
60+
"eslint-plugin-react-hooks": "^4.2.0",
61+
"jest": "^27.0.6",
62+
"mutationobserver-shim": "^0.3.7",
63+
"prettier": "^2.3.2",
64+
"react": "^17.0.2",
65+
"react-dom": "^17.0.2",
66+
"rollup": "^2.56.2",
67+
"rollup-plugin-peer-deps-external": "^2.2.4",
68+
"rollup-plugin-terser": "^7.0.2",
69+
"rollup-plugin-typescript2": "^0.30.0",
70+
"ts-jest": "^27.0.4",
71+
"tslib": "^2.3.1",
72+
"typescript": "^4.3.5"
73+
},
74+
"files": [
75+
"dist"
76+
],
77+
"bundlesize": [
78+
{
79+
"path": "./dist/react-xls.es.js",
80+
"maxSize": "50 kB"
81+
}
82+
],
83+
"peerDependencies": {
84+
"react": "^17.0.2",
85+
"react-dom": "^17.0.2"
86+
},
87+
"browser": {
88+
"fs": false
89+
}
90+
}

rollup.config.js

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import typescript from 'rollup-plugin-typescript2';
2+
import babel from '@rollup/plugin-babel';
3+
import commonjs from '@rollup/plugin-commonjs';
4+
import resolve from '@rollup/plugin-node-resolve';
5+
import { terser } from "rollup-plugin-terser";
6+
import pkg from './package.json';
7+
8+
// import external from 'rollup-plugin-peer-deps-external';
9+
// import builtins from 'builtin-modules'
10+
11+
export default {
12+
input: 'src/react-xls.ts',
13+
output: [
14+
{
15+
file: pkg.main,
16+
format: 'cjs',
17+
exports: 'named',
18+
},
19+
{
20+
file: pkg.module,
21+
format: 'esm',
22+
exports: 'named',
23+
},
24+
],
25+
// external: builtins,
26+
external: [
27+
'react',
28+
'react-dom',
29+
'fs',
30+
'util',
31+
'stream',
32+
'buffer',
33+
'zlib',
34+
'assert'
35+
],
36+
plugins: [
37+
typescript({
38+
tsconfig: './tsconfig.json',
39+
clean: true,
40+
}),
41+
babel({
42+
exclude: 'node_modules/**',
43+
}),
44+
resolve({
45+
preferBuiltins: true
46+
}),
47+
commonjs({
48+
extensions: ['.js', '.ts', '.tsx'],
49+
}),
50+
terser()
51+
],
52+
};

setup.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// require('mutationobserver-shim');

src/react-xls.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { useXLS } from './useXLS';

src/useXLS.tsx

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from 'react';
2+
3+
export function useXLS(): any {
4+
const Component = React.useMemo(
5+
() =>
6+
() => {
7+
return (
8+
<p>React hooks</p>
9+
);
10+
},
11+
[]
12+
);
13+
14+
return {
15+
Component,
16+
};
17+
}

0 commit comments

Comments
 (0)