Skip to content

Commit 9bd76ec

Browse files
committed
✨ Rewrite
1 parent 430974a commit 9bd76ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+12352
-625
lines changed

.eslintrc.js

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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-ignore': '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+
},
34+
overrides: [
35+
{
36+
files: ['*.test.ts', '*.test.tsx'],
37+
rules: {
38+
// Allow testing runtime errors to suppress TS errors
39+
'@typescript-eslint/ban-ts-ignore': 'off',
40+
},
41+
},
42+
],
43+
settings: {
44+
react: {
45+
pragma: 'React',
46+
version: 'detect',
47+
},
48+
},
49+
};

.eslintrc.json

-23
This file was deleted.

.gitignore

+7-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,10 @@ package-lock.json
2525
/docs/.next
2626
/docs/package-lock.json
2727

28-
example
28+
/supports/default/node_modules
29+
/supports/default/.next
30+
/supports/default/package-lock.json
31+
32+
/supports/typescript/node_modules
33+
/supports/typescript/.next
34+
/supports/typescript/package-lock.json

.prettierrc

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

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -422,3 +422,5 @@ How to contribute:
422422
## ⚖️ License
423423

424424
The MIT License [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
425+
426+
<!-- https://github.com/siddharthkp/bundlesize -->

package.json

+41-37
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-papaparse",
3-
"version": "3.1.2",
3+
"version": "3.2.2",
44
"description": "Fast and powerful React CSV parser for the browser that supports web workers and streaming large files. Converts CSV to JSON and JSON to CSV.",
55
"author": "Bunlong <[email protected]>",
66
"license": "MIT",
@@ -40,57 +40,61 @@
4040
"comma",
4141
"tab",
4242
"pipe",
43-
"workers"
43+
"workers",
44+
"typescript"
4445
],
4546
"homepage": "https://react-papaparse.js.org",
46-
"main": "dist/index.js",
47-
"module": "dist/index.es.js",
48-
"jsnext:main": "dist/index.es.js",
47+
"main": "dist/react-papaparse.js",
48+
"module": "dist/react-papaparse.es.js",
49+
"jsnext:main": "dist/react-papaparse.es.js",
50+
"types": "dist/react-papaparse.d.ts",
51+
"@comment unpkg": "dist/react-papaparse.umd.js",
4952
"engines": {
5053
"node": ">=8",
5154
"npm": ">=5"
5255
},
5356
"scripts": {
54-
"test": "mocha --require @babel/register",
57+
"test": "mocha -r ts-node/register test/*.test.ts",
5558
"build": "rollup -c",
56-
"dev": "rollup -c -w"
57-
},
58-
"peerDependencies": {
59-
"react": "^16.4.1",
60-
"react-dom": "^16.4.1"
59+
"prettier": "prettier --write './src/*.ts' './src/*.tsx' --config ./.prettierrc",
60+
"lint:check": "eslint ./src --ext .tsx,.ts --report-unused-disable-directives",
61+
"dev": "rollup -c -w",
62+
"prepare": "npm run build",
63+
"predeploy": "cd docs && npm install && npm run build",
64+
"deploy": "gh-pages -d docs/build"
6165
},
6266
"devDependencies": {
63-
"@babel/core": "^7.8.3",
64-
"@babel/plugin-external-helpers": "^7.8.3",
67+
"@babel/core": "^7.9.6",
6568
"@babel/plugin-proposal-class-properties": "^7.8.3",
66-
"@babel/preset-env": "^7.8.3",
67-
"@babel/preset-react": "^7.8.3",
68-
"@babel/register": "^7.9.0",
69-
"@rollup/plugin-commonjs": "^11.0.2",
70-
"@rollup/plugin-node-resolve": "^7.1.1",
71-
"babel-eslint": "^10.0.3",
72-
"eslint": "^6.8.0",
73-
"eslint-config-standard": "^14.1.0",
74-
"eslint-config-standard-react": "^9.2.0",
75-
"eslint-plugin-import": "^2.20.0",
76-
"eslint-plugin-node": "^11.1.0",
77-
"eslint-plugin-promise": "^4.2.1",
78-
"eslint-plugin-react": "^7.18.0",
79-
"eslint-plugin-standard": "^4.0.1",
80-
"jest": "^24.9.0",
81-
"mocha": "^7.1.0",
82-
"react": "^16.4.1",
83-
"react-dom": "^16.4.1",
84-
"rollup": "^1.29.0",
85-
"rollup-plugin-babel": "^4.3.3",
86-
"rollup-plugin-peer-deps-external": "^2.2.2",
87-
"rollup-plugin-terser": "^5.3.0"
69+
"@babel/preset-env": "^7.9.6",
70+
"@rollup/plugin-commonjs": "^11.1.0",
71+
"@rollup/plugin-node-resolve": "^7.1.3",
72+
"@types/mocha": "^7.0.2",
73+
"@types/react": "^16.9.34",
74+
"@types/react-dom": "^16.9.7",
75+
"@typescript-eslint/eslint-plugin": "^2.31.0",
76+
"@typescript-eslint/parser": "^2.31.0",
77+
"eslint": "^7.0.0",
78+
"eslint-plugin-react": "^7.19.0",
79+
"eslint-plugin-react-hooks": "^4.0.0",
80+
"jest": "^26.0.1",
81+
"mocha": "^7.1.2",
82+
"prettier": "^2.0.5",
83+
"react": "^16.13.1",
84+
"react-dom": "^16.13.1",
85+
"rollup": "^2.8.2",
86+
"rollup-plugin-babel": "^4.4.0",
87+
"rollup-plugin-terser": "^5.3.0",
88+
"rollup-plugin-typescript2": "^0.27.0",
89+
"ts-node": "^8.10.1",
90+
"tslib": "^1.11.2",
91+
"typescript": "^3.8.3"
8892
},
8993
"files": [
9094
"dist"
9195
],
9296
"dependencies": {
93-
"papaparse": "^5.1.1",
94-
"prop-types": "^15.7.2"
97+
"@types/papaparse": "^5.0.3",
98+
"papaparse": "^5.1.1"
9599
}
96100
}

rollup.config.js

+37-17
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,55 @@
1-
import babel from 'rollup-plugin-babel'
2-
import { terser } from 'rollup-plugin-terser'
3-
import resolve from '@rollup/plugin-node-resolve'
4-
import commonjs from '@rollup/plugin-commonjs'
5-
import external from 'rollup-plugin-peer-deps-external'
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';
65
import builtins from 'builtin-modules'
7-
import pkg from './package.json'
6+
import { terser } from "rollup-plugin-terser";
7+
import pkg from './package.json';
88

99
export default {
10-
input: 'src/index.js',
10+
input: 'src/react-papaparse.ts',
1111
output: [
1212
{
1313
file: pkg.main,
1414
format: 'cjs',
15-
sourcemap: true
15+
exports: 'named',
1616
},
1717
{
1818
file: pkg.module,
19-
format: 'es',
20-
sourcemap: true
21-
}
19+
format: 'esm',
20+
exports: 'named',
21+
},
22+
// {
23+
// file: `dist/${pkg.name}.min.es.js`,
24+
// format: 'es',
25+
// exports: 'named',
26+
// sourcemap: true
27+
// },
28+
// {
29+
// name: 'ReactPapaparse',
30+
// file: `dist/${pkg.name}.umd.js`,
31+
// format: 'umd',
32+
// exports: 'named',
33+
// globals: {
34+
// react: 'React',
35+
// },
36+
// },
2237
],
2338
external: builtins,
2439
plugins: [
40+
typescript({
41+
tsconfig: './tsconfig.json',
42+
clean: true,
43+
}),
2544
babel({
26-
exclude: 'node_modules/**'
45+
exclude: 'node_modules/**',
2746
}),
2847
resolve({
2948
preferBuiltins: true
3049
}),
31-
commonjs(),
32-
terser(),
33-
external()
34-
]
35-
}
50+
commonjs({
51+
extensions: ['.js', '.ts', '.tsx']
52+
}),
53+
terser()
54+
],
55+
};

0 commit comments

Comments
 (0)