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
*.jsx text eol=lf
*.ts text eol=lf
*.tsx text eol=lf
*.json text eol=lf
*.css text eol=lf
*.html text eol=lf

View File

@ -8,5 +8,11 @@
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:prettier/recommended",
"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:prettier/recommended",
"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": {
"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",
"prettier/@typescript-eslint",
"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;
};
export const invertTheme = (theme: Theme): Theme => {
export const invertTheme = (theme: Theme | undefined): Theme | undefined => {
if (typeof theme === 'string') {
return `${theme}:inverted`;
}

View File

@ -31,7 +31,7 @@
},
"scripts": {
"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:js": "babel src --out-dir lib --extensions \".ts,.tsx\" --source-maps inline",
"build:umd": "rimraf ./umd && webpack --progress --config webpack.config.umd.js",
@ -50,7 +50,6 @@
"react-base16-styling": "^0.7.0"
},
"peerDependencies": {
"react": "^16.3.0",
"react-dom": "^16.3.0"
"react": "^16.3.0"
}
}

View File

@ -6,7 +6,9 @@ import { CircularPropsPassedThroughJSONNode } from './types';
// Returns the "n Items" string for this node,
// generating and caching it if it hasn't been created yet.
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 {

View File

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

View File

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

View File

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