This commit is contained in:
Nathan Bierema 2020-08-21 19:35:20 -04:00
parent d1a789e8b6
commit 128f1f02d3
13 changed files with 46 additions and 19 deletions

2
.gitattributes vendored
View File

@ -1,5 +1,7 @@
*.js text eol=lf *.js text eol=lf
*.jsx text eol=lf *.jsx text eol=lf
*.ts text eol=lf
*.tsx text eol=lf
*.json text eol=lf *.json text eol=lf
*.css text eol=lf *.css text eol=lf
*.html text eol=lf *.html text eol=lf

View File

@ -8,5 +8,11 @@
"plugin:@typescript-eslint/recommended-requiring-type-checking", "plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:prettier/recommended", "plugin:prettier/recommended",
"prettier/@typescript-eslint" "prettier/@typescript-eslint"
] ],
"rules": {
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off"
}
} }

View File

@ -9,5 +9,11 @@
"plugin:jest/style", "plugin:jest/style",
"plugin:prettier/recommended", "plugin:prettier/recommended",
"prettier/@typescript-eslint" "prettier/@typescript-eslint"
] ],
"rules": {
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off"
}
} }

View File

@ -20,5 +20,11 @@
"react": { "react": {
"version": "detect" "version": "detect"
} }
},
"rules": {
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off"
} }
} }

View File

@ -11,5 +11,11 @@
"plugin:prettier/recommended", "plugin:prettier/recommended",
"prettier/@typescript-eslint", "prettier/@typescript-eslint",
"prettier/react" "prettier/react"
] ],
"rules": {
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off"
}
} }

View File

@ -266,7 +266,7 @@ export const getBase16Theme = (
: undefined; : undefined;
}; };
export const invertTheme = (theme: Theme): Theme => { export const invertTheme = (theme: Theme | undefined): Theme | undefined => {
if (typeof theme === 'string') { if (typeof theme === 'string') {
return `${theme}:inverted`; return `${theme}:inverted`;
} }

View File

@ -31,7 +31,7 @@
}, },
"scripts": { "scripts": {
"start": "cd examples && npm start", "start": "cd examples && npm start",
"build": "npm run build:types && npm run build:js && npm build:umd && npm build:umd:min", "build": "npm run build:types && npm run build:js && npm run build:umd && npm run build:umd:min",
"build:types": "tsc --emitDeclarationOnly", "build:types": "tsc --emitDeclarationOnly",
"build:js": "babel src --out-dir lib --extensions \".ts,.tsx\" --source-maps inline", "build:js": "babel src --out-dir lib --extensions \".ts,.tsx\" --source-maps inline",
"build:umd": "rimraf ./umd && webpack --progress --config webpack.config.umd.js", "build:umd": "rimraf ./umd && webpack --progress --config webpack.config.umd.js",
@ -50,7 +50,6 @@
"react-base16-styling": "^0.7.0" "react-base16-styling": "^0.7.0"
}, },
"peerDependencies": { "peerDependencies": {
"react": "^16.3.0", "react": "^16.3.0"
"react-dom": "^16.3.0"
} }
} }

View File

@ -6,7 +6,9 @@ import { CircularPropsPassedThroughJSONNode } from './types';
// Returns the "n Items" string for this node, // Returns the "n Items" string for this node,
// generating and caching it if it hasn't been created yet. // generating and caching it if it hasn't been created yet.
function createItemString(data: any) { function createItemString(data: any) {
return `${data.length} ${data.length !== 1 ? 'items' : 'item'}`; return `${(data as unknown[]).length} ${
(data as unknown[]).length !== 1 ? 'items' : 'item'
}`;
} }
interface Props extends CircularPropsPassedThroughJSONNode { interface Props extends CircularPropsPassedThroughJSONNode {

View File

@ -57,7 +57,10 @@ const JSONNode: React.FunctionComponent<Props> = ({
return <JSONIterableNode {...nestedNodeProps} />; return <JSONIterableNode {...nestedNodeProps} />;
case 'String': case 'String':
return ( return (
<JSONValueNode {...simpleNodeProps} valueGetter={(raw) => `"${raw}"`} /> <JSONValueNode
{...simpleNodeProps}
valueGetter={(raw: string) => `"${raw}"`}
/>
); );
case 'Number': case 'Number':
return <JSONValueNode {...simpleNodeProps} />; return <JSONValueNode {...simpleNodeProps} />;

View File

@ -18,7 +18,7 @@ function getEntries(
sortObjectKeys?: ((a: any, b: any) => number) | boolean | undefined, sortObjectKeys?: ((a: any, b: any) => number) | boolean | undefined,
from = 0, from = 0,
to = Infinity to = Infinity
) { ): { entries: { key: string | number; value: any }[]; hasMore?: boolean } {
let res; let res;
if (type === 'Object') { if (type === 'Object') {
@ -37,7 +37,7 @@ function getEntries(
res = { res = {
entries: collection entries: collection
.slice(from, to + 1) .slice(from, to + 1)
.map((val, idx) => ({ key: idx + from, value: val })), .map((val: unknown, idx: number) => ({ key: idx + from, value: val })),
}; };
} else { } else {
let idx = 0; let idx = 0;

View File

@ -3,7 +3,7 @@ const path = require('path');
module.exports = (env = {}) => ({ module.exports = (env = {}) => ({
mode: env.production ? 'production' : 'development', mode: env.production ? 'production' : 'development',
entry: { entry: {
app: ['./src/index.js'], app: ['./src/index'],
}, },
output: { output: {
library: 'ReactJsonTree', library: 'ReactJsonTree',
@ -15,12 +15,15 @@ module.exports = (env = {}) => ({
module: { module: {
rules: [ rules: [
{ {
test: /\.js$/, test: /\.(js|ts)x?$/,
loader: 'babel-loader', loader: 'babel-loader',
exclude: /node_modules/, exclude: /node_modules/,
}, },
], ],
}, },
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
externals: { externals: {
react: { react: {
root: 'React', root: 'React',
@ -28,11 +31,5 @@ module.exports = (env = {}) => ({
commonjs: 'react', commonjs: 'react',
amd: 'react', amd: 'react',
}, },
'react-dom': {
root: 'ReactDOM',
commonjs2: 'react-dom',
commonjs: 'react-dom',
amd: 'react-dom',
},
}, },
}); });