Skip to content

Commit 5194d60

Browse files
eslint (#9)
1 parent 324bd2a commit 5194d60

5 files changed

Lines changed: 42 additions & 17 deletions

File tree

eslint.config.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import js from '@eslint/js';
2+
import globals from 'globals';
3+
import reactHooks from 'eslint-plugin-react-hooks';
4+
import reactRefresh from 'eslint-plugin-react-refresh';
5+
import tseslint from 'typescript-eslint';
6+
7+
export default tseslint.config(
8+
{ ignores: ['dist'] },
9+
{
10+
extends: [js.configs.recommended, ...tseslint.configs.recommended],
11+
files: ['**/*.{ts,tsx}'],
12+
languageOptions: {
13+
ecmaVersion: 2020,
14+
globals: globals.browser,
15+
},
16+
plugins: {
17+
'react-hooks': reactHooks,
18+
'react-refresh': reactRefresh,
19+
},
20+
rules: {
21+
...reactHooks.configs.recommended.rules,
22+
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
23+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
24+
},
25+
}
26+
);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "module",
66
"scripts": {
77
"dev": "vite",
8-
"build": "tsc -b && vite build",
8+
"build": "eslint . && tsc -b && vite build",
99
"lint": "eslint .",
1010
"preview": "vite preview",
1111
"test": "vitest run",

src/components/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { useEffect } from 'react';
22
import { Panel, PanelGroup, PanelResizeHandle } from 'react-resizable-panels';
33
import { HexViewer } from './HexViewer/HexViewer';
44
import { AstTree } from './AstTree/AstTree';
5-
import { QueryInput, decodeBase64Url } from './QueryInput';
5+
import { QueryInput } from './QueryInput';
6+
import { decodeBase64Url } from '../core/base64url';
67
import { useStore } from '../store/store';
78
import { ClickHouseFormat } from '../core/types/formats';
89
import logo from '../assets/clickhouse-yellow-badge.svg';

src/components/QueryInput.tsx

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,7 @@ import { useCallback, useRef, useState } from 'react';
22
import { useStore } from '../store/store';
33
import { DEFAULT_QUERY } from '../core/clickhouse/client';
44
import { ClickHouseFormat, FORMAT_METADATA } from '../core/types/formats';
5-
6-
function encodeBase64Url(str: string): string {
7-
const bytes = new TextEncoder().encode(str);
8-
const binary = String.fromCharCode(...bytes);
9-
return btoa(binary).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
10-
}
11-
12-
function decodeBase64Url(encoded: string): string {
13-
const base64 = encoded.replace(/-/g, '+').replace(/_/g, '/');
14-
const binary = atob(base64);
15-
const bytes = Uint8Array.from(binary, (c) => c.charCodeAt(0));
16-
return new TextDecoder().decode(bytes);
17-
}
18-
19-
export { encodeBase64Url, decodeBase64Url };
5+
import { encodeBase64Url } from '../core/base64url';
206

217
export function QueryInput() {
228
const query = useStore((s) => s.query);

src/core/base64url.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export function encodeBase64Url(str: string): string {
2+
const bytes = new TextEncoder().encode(str);
3+
const binary = String.fromCharCode(...bytes);
4+
return btoa(binary).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
5+
}
6+
7+
export function decodeBase64Url(encoded: string): string {
8+
const base64 = encoded.replace(/-/g, '+').replace(/_/g, '/');
9+
const binary = atob(base64);
10+
const bytes = Uint8Array.from(binary, (c) => c.charCodeAt(0));
11+
return new TextDecoder().decode(bytes);
12+
}

0 commit comments

Comments
 (0)