Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalmi committed Mar 27, 2024
1 parent 36d4694 commit 16d6f13
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
'plugin:react-hooks/recommended',
'plugin:prettier/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
ignorePatterns: ['dist', '.eslintrc.cjs', 'node_modules'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh', 'prettier', 'simple-import-sort'],
rules: {
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Ignore artifacts:
build
dist
public
node_modules
15 changes: 8 additions & 7 deletions iris-docs/src/pages/explorer/ExplorerNodeValue.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { JsonValue } from 'irisdb';
import { useEffect, useRef, useState } from 'react';

const VALUE_TRUNCATE_LENGTH = 20;

type ExplorerNodeValueProps = {
value: any;
value: string;
displayName: string;
setValue: (value: any) => void;
setValue: (value: JsonValue) => void;
};

const ExplorerNodeValue: React.FC<ExplorerNodeValueProps> = ({ displayName, value, setValue }) => {
const [showMore, setShowMore] = useState(false);
const [editableValue, setEditableValue] = useState<any>(JSON.stringify(value));
const inputRef = useRef<any>(null);
const [editableValue, setEditableValue] = useState<string>(JSON.stringify(value));
const inputRef = useRef<HTMLSpanElement>(null);

const truncateValue = () => {
if (displayName === 'priv' || displayName === 'key') {
Expand All @@ -23,7 +24,7 @@ const ExplorerNodeValue: React.FC<ExplorerNodeValueProps> = ({ displayName, valu
};

const handleBlur = () => {
let parsedValue;
let parsedValue: JsonValue;
try {
parsedValue = JSON.parse(editableValue);
} catch (e) {
Expand Down Expand Up @@ -54,7 +55,7 @@ const ExplorerNodeValue: React.FC<ExplorerNodeValueProps> = ({ displayName, valu
ref={inputRef}
contentEditable
onBlur={handleBlur}
onInput={(e) => setEditableValue(e.currentTarget.textContent)}
onInput={(e) => setEditableValue(e.currentTarget.textContent || '')}
>
{showMore ? value : truncateValue()}
</span>
Expand All @@ -68,7 +69,7 @@ const ExplorerNodeValue: React.FC<ExplorerNodeValueProps> = ({ displayName, valu
ref={inputRef}
contentEditable
onBlur={handleBlur}
onInput={(e) => setEditableValue(e.currentTarget.textContent)}
onInput={(e) => setEditableValue(e.currentTarget.textContent || '')}
>
{JSON.stringify(value)}
</span>
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
],
"scripts": {
"build": "npm run build --workspaces",
"docs": "typedoc"
"docs": "typedoc",
"lint": "eslint --ext .ts,.tsx --fix ."
},
"devDependencies": {
"eslint": "^8.57.0",
Expand Down

0 comments on commit 16d6f13

Please sign in to comment.