Skip to content

Commit 298f54a

Browse files
committed
* update all libraries to latest
* add typescript config * update dev plumbing
1 parent 0d5ae53 commit 298f54a

34 files changed

+49922
-10230
lines changed

.babelrc

Lines changed: 0 additions & 20 deletions
This file was deleted.

.eslintignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/.idea
2+
/build
3+
/coverage
24
/dist
3-
build
4-
node_modules
55
/docs
66
/examples
7+
/node_modules

.eslintrc.js

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
module.exports = {
2+
extends: [
3+
'airbnb',
4+
'prettier',
5+
'plugin:@typescript-eslint/eslint-recommended',
6+
'plugin:@typescript-eslint/recommended',
7+
'plugin:react/recommended',
8+
'plugin:react/jsx-runtime',
9+
],
10+
env: {
11+
browser: true,
12+
node: true,
13+
jest: true,
14+
es6: true,
15+
},
16+
plugins: ['@typescript-eslint', 'prettier', 'react', 'react-hooks'],
17+
parserOptions: {
18+
project: ['tsconfig.eslint.json'],
19+
tsconfigRootDir: __dirname,
20+
},
21+
rules: {
22+
'@typescript-eslint/no-empty-function': 0,
23+
'@typescript-eslint/no-explicit-any': 0,
24+
'@typescript-eslint/ban-ts-comment': [
25+
'error',
26+
{ 'ts-ignore': 'allow-with-description' },
27+
],
28+
'prettier/prettier': 'error',
29+
'react-hooks/rules-of-hooks': 'error',
30+
'react-hooks/exhaustive-deps': 'error',
31+
'consistent-return': 0,
32+
'padded-blocks': 0,
33+
'spaced-comment': 0,
34+
semi: ['error', 'always'],
35+
quotes: [
36+
'error',
37+
'single',
38+
{
39+
avoidEscape: true,
40+
allowTemplateLiterals: true,
41+
},
42+
],
43+
'arrow-body-style': [0],
44+
'class-methods-use-this': 0,
45+
'comma-dangle': [
46+
'error',
47+
{
48+
arrays: 'only-multiline',
49+
objects: 'only-multiline',
50+
imports: 'only-multiline',
51+
exports: 'only-multiline',
52+
functions: 'ignore',
53+
},
54+
],
55+
'function-paren-newline': 0,
56+
'import/extensions': 0,
57+
'import/imports-first': 0,
58+
'import/newline-after-import': 0,
59+
'import/no-dynamic-require': 0,
60+
'import/no-extraneous-dependencies': 0,
61+
'import/no-named-as-default': 0,
62+
'import/no-unresolved': 2,
63+
'import/no-webpack-loader-syntax': 0,
64+
'import/prefer-default-export': 0,
65+
'jsx-a11y/mouse-events-have-key-events': 0,
66+
'lines-between-class-members': 0,
67+
'newline-per-chained-call': 0,
68+
'no-confusing-arrow': 0,
69+
'no-console': 1,
70+
'no-underscore-dangle': 0,
71+
'no-use-before-define': 0,
72+
'no-param-reassign': 1,
73+
'no-plusplus': 0,
74+
'no-prototype-builtins': 0,
75+
'no-shadow': 1,
76+
'object-curly-newline': 0,
77+
'one-var': 0,
78+
'one-var-declaration-per-line': [2, 'initializations'],
79+
'prefer-destructuring': 1,
80+
'prefer-template': 2,
81+
'react/destructuring-assignment': 1,
82+
'react/forbid-prop-types': [1, { forbid: ['any', 'array'] }],
83+
'react/function-component-definition': 0,
84+
'react/jsx-curly-brace-presence': 0,
85+
'react/jsx-filename-extension': [
86+
1,
87+
{ extensions: ['.js', '.jsx', '.ts', '.tsx'] },
88+
],
89+
'react/jsx-props-no-spreading': 0,
90+
'react/no-children-prop': 1,
91+
'react/no-did-update-set-state': 0,
92+
'react/require-default-props': 0,
93+
'react/sort-comp': [
94+
1,
95+
{
96+
order: [
97+
'static-methods',
98+
'instance-variables',
99+
'lifecycle',
100+
'render',
101+
'/^render.+$/',
102+
'/^on.+$/',
103+
'/^handle.+$/',
104+
'everything-else',
105+
],
106+
},
107+
],
108+
},
109+
settings: {
110+
'import/resolver': {
111+
typescript: {},
112+
},
113+
},
114+
};

.eslintrc.json

Lines changed: 0 additions & 94 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ coverage
55
dist
66
node_modules
77
npm-debug.log
8+
/stats.html

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx lint-staged

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ jest
66
src
77
test
88
jest.config.js
9-
rollup.config.js
9+
rollup.config.mjs

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
10.15.3
1+
18.15.0

.prettierrc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
{
2-
"printWidth": 120,
3-
"trailingComma": "es5",
4-
"tabWidth": 2,
5-
"semi": true,
62
"singleQuote": true,
7-
"jsxBracketSameLine": false
3+
"trailingComma": "all",
4+
"useTabs": false,
5+
"tabWidth": 2
86
}

docs/3d-cubes/3d-cubes-4f5effff8612d47bb681.js

Lines changed: 18025 additions & 28 deletions
Large diffs are not rendered by default.

docs/3d-cubes/3d-cubes-bfca8c6c57c71bdcd6ce.js

Lines changed: 19057 additions & 38 deletions
Large diffs are not rendered by default.

getRollupConfig.mjs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import commonjs from '@rollup/plugin-commonjs';
2+
import resolve from '@rollup/plugin-node-resolve';
3+
import json from '@rollup/plugin-json';
4+
import replace from '@rollup/plugin-replace';
5+
import esbuild from 'rollup-plugin-esbuild';
6+
import sourcemaps from 'rollup-plugin-sourcemaps';
7+
import filesize from 'rollup-plugin-filesize';
8+
import { visualizer } from 'rollup-plugin-visualizer';
9+
10+
export const isProductionBuild = () => process.env.NODE_ENV === 'production';
11+
12+
export const getBuildFormat = () => process.env.FORMAT;
13+
14+
export function getRollupTSConfig(dest, format, merge = {}) {
15+
const prod = isProductionBuild();
16+
17+
return {
18+
input: merge.input || 'src/index.ts',
19+
output: {
20+
exports: 'named',
21+
file: dest,
22+
format,
23+
sourcemap: !prod,
24+
...(merge.output || {}),
25+
},
26+
plugins: [
27+
sourcemaps(),
28+
json(),
29+
resolve({
30+
browser: true,
31+
preferBuiltins: false,
32+
mainFields: ['main', 'jsnext'],
33+
}),
34+
esbuild({
35+
exclude: '**/node_modules/**',
36+
target: 'es2017',
37+
minify: prod,
38+
}),
39+
...(merge.beforePlugins || []),
40+
commonjs(),
41+
replace({
42+
__DEV__: prod ? 'false' : 'true',
43+
'process.env.NODE_ENV': prod ? '"production"' : '"development"',
44+
preventAssignment: true,
45+
}),
46+
filesize(),
47+
visualizer(),
48+
].filter(Boolean),
49+
external: merge.external,
50+
};
51+
}

index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* eslint-disable global-require */
2+
/* eslint-disable import/no-unresolved */
3+
if (['test', 'development'].includes(process.env.NODE_ENV)) {
4+
module.exports = require('./dist/index.cjs-dev');
5+
} else {
6+
module.exports = require('./dist/index.cjs');
7+
}

jest.config.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module.exports = {
2-
collectCoverageFrom: ['src/**/*.js'],
2+
preset: 'ts-jest',
3+
testEnvironment: 'jsdom',
4+
collectCoverageFrom: ['src/**/*.{js,ts,jsx,tsx}'],
35
coverageThreshold: {
46
global: {
57
statements: 95,
@@ -9,8 +11,11 @@ module.exports = {
911
},
1012
},
1113
moduleDirectories: ['node_modules', 'src'],
12-
setupFiles: ['raf/polyfill', '<rootDir>/jest/enzyme-setup.js'],
13-
setupFilesAfterEnv: ['<rootDir>/jest/test-bundler.js'],
14-
testRegex: '.*\\.test\\.js$',
15-
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
14+
setupFiles: ['raf/polyfill', '<rootDir>/jest/enzyme-setup.ts'],
15+
setupFilesAfterEnv: ['<rootDir>/jest/test-bundler.ts'],
16+
testRegex: '.*\\.test\\.(ts|js|tsx|jsx)$',
17+
watchPlugins: [
18+
'jest-watch-typeahead/filename',
19+
'jest-watch-typeahead/testname',
20+
],
1621
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { configure } from 'enzyme';
2-
import Adapter from 'enzyme-adapter-react-16';
2+
import Adapter from '@cfaester/enzyme-adapter-react-18';
33

44
configure({ adapter: new Adapter() });

jest/test-bundler.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

jest/test-bundler.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// import matchers from 'expect/build/matchers';
2+
//
3+
// // toMatchObject is supposed to match arrays of objects too, but it isn't currently working.
4+
// expect.extend({
5+
// toAllMatchObject(actualArray, objectMatcher) {
6+
// const results = actualArray.map((item) =>
7+
// matchers.toMatchObject(item, objectMatcher),
8+
// );
9+
// const pass = results.reduce((acc, result) => acc && result.pass, true);
10+
// const message = pass ? () => {} : results.find((res) => !res.pass).message;
11+
//
12+
// return {
13+
// message,
14+
// pass,
15+
// };
16+
// },
17+
// });

0 commit comments

Comments
 (0)