refactor: improve type safety and code style
Some checks failed
CI / build-and-test (push) Failing after 24m31s
Some checks failed
CI / build-and-test (push) Failing after 24m31s
This commit is contained in:
@@ -3,21 +3,31 @@ import globals from 'globals'
|
||||
import reactHooks from 'eslint-plugin-react-hooks'
|
||||
import reactRefresh from 'eslint-plugin-react-refresh'
|
||||
import tseslint from 'typescript-eslint'
|
||||
import { defineConfig, globalIgnores } from 'eslint/config'
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
export default tseslint.config(
|
||||
{
|
||||
ignores: ['dist'],
|
||||
},
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
js.configs.recommended,
|
||||
tseslint.configs.recommended,
|
||||
reactHooks.configs.flat.recommended,
|
||||
reactRefresh.configs.vite,
|
||||
],
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
languageOptions: {
|
||||
ecmaVersion: 2020,
|
||||
globals: globals.browser,
|
||||
},
|
||||
plugins: {
|
||||
'react-hooks': reactHooks,
|
||||
'react-refresh': reactRefresh,
|
||||
},
|
||||
rules: {
|
||||
...reactHooks.configs.recommended.rules,
|
||||
'react-refresh/only-export-components': [
|
||||
'warn',
|
||||
{ allowConstantExport: true },
|
||||
],
|
||||
},
|
||||
},
|
||||
])
|
||||
)
|
||||
|
||||
@@ -34,7 +34,7 @@ export class EnvBuilder implements IBuilder<Env> {
|
||||
|
||||
private params(): this {
|
||||
const tag = `<parameter name="{name}" value="{val}" />`;
|
||||
for (let p of this.src.params) {
|
||||
for (const p of this.src.params) {
|
||||
this.stack.push(this.ident);
|
||||
this.stack.push(tag
|
||||
.replace("{name}", p.name ?? "!ERR!")
|
||||
|
||||
@@ -11,7 +11,7 @@ export interface IBuilder<T> {
|
||||
|
||||
export class Builder {
|
||||
public static getEnv(env: Env): IBuilder<Env> {
|
||||
let b = new EnvBuilder();
|
||||
const b = new EnvBuilder();
|
||||
b.src = env;
|
||||
return b;
|
||||
};
|
||||
|
||||
@@ -8,7 +8,6 @@ interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
||||
variant?: ButtonVariant;
|
||||
size?: ButtonSize;
|
||||
icon?: LucideIcon;
|
||||
iconPosition?: 'left' | 'right';
|
||||
isLoading?: boolean;
|
||||
}
|
||||
|
||||
@@ -33,7 +32,6 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
||||
variant = 'primary',
|
||||
size = 'md',
|
||||
icon: Icon,
|
||||
iconPosition = 'left',
|
||||
isLoading = false,
|
||||
disabled,
|
||||
children,
|
||||
|
||||
@@ -34,7 +34,7 @@ export const Card = forwardRef<HTMLDivElement, CardProps>(
|
||||
|
||||
Card.displayName = 'Card';
|
||||
|
||||
interface CardHeaderProps extends HTMLAttributes<HTMLDivElement> {}
|
||||
type CardHeaderProps = HTMLAttributes<HTMLDivElement>;
|
||||
|
||||
export const CardHeader = forwardRef<HTMLDivElement, CardHeaderProps>(
|
||||
({ className = '', children, ...props }, ref) => {
|
||||
@@ -52,7 +52,7 @@ export const CardHeader = forwardRef<HTMLDivElement, CardHeaderProps>(
|
||||
|
||||
CardHeader.displayName = 'CardHeader';
|
||||
|
||||
interface CardBodyProps extends HTMLAttributes<HTMLDivElement> {}
|
||||
type CardBodyProps = HTMLAttributes<HTMLDivElement>;
|
||||
|
||||
export const CardBody = forwardRef<HTMLDivElement, CardBodyProps>(
|
||||
({ className = '', children, ...props }, ref) => {
|
||||
@@ -66,7 +66,7 @@ export const CardBody = forwardRef<HTMLDivElement, CardBodyProps>(
|
||||
|
||||
CardBody.displayName = 'CardBody';
|
||||
|
||||
interface CardFooterProps extends HTMLAttributes<HTMLDivElement> {}
|
||||
type CardFooterProps = HTMLAttributes<HTMLDivElement>;
|
||||
|
||||
export const CardFooter = forwardRef<HTMLDivElement, CardFooterProps>(
|
||||
({ className = '', children, ...props }, ref) => {
|
||||
|
||||
@@ -97,7 +97,7 @@ export class Config {
|
||||
* Updates template by adding placeholders for environment params
|
||||
*/
|
||||
public updateTemplateFromEnv(env: Env): void {
|
||||
let templateObj: Record<string, any> = {};
|
||||
let templateObj: Record<string, string> = {};
|
||||
|
||||
// Try to parse existing template
|
||||
try {
|
||||
|
||||
@@ -36,8 +36,8 @@ const cfgTemplate = `
|
||||
|
||||
|
||||
test("read from a file", async ({expect})=>{
|
||||
let sut = new ConfigReader();
|
||||
let file = new File([cfgTemplate],'cfg.json.xml',{type:'application/xml'});
|
||||
const sut = new ConfigReader();
|
||||
const file = new File([cfgTemplate],'cfg.json.xml',{type:'application/xml'});
|
||||
|
||||
// define a missing jsdom text() function,
|
||||
// that presents in the real DOM
|
||||
@@ -46,15 +46,15 @@ test("read from a file", async ({expect})=>{
|
||||
writable: true
|
||||
});
|
||||
|
||||
let cfg = await sut.parseFromFile(file);
|
||||
const cfg = await sut.parseFromFile(file);
|
||||
|
||||
expect(cfg).not.toBeUndefined();
|
||||
});
|
||||
|
||||
test("load environments and params", ({expect})=>{
|
||||
let sut = new ConfigReader();
|
||||
const sut = new ConfigReader();
|
||||
|
||||
let cfg = sut.parseFromString(cfgTemplate);
|
||||
const cfg = sut.parseFromString(cfgTemplate);
|
||||
|
||||
expect(cfg?.envs).toHaveLength(3);
|
||||
expect(cfg?.envs.map(x=>x.name))
|
||||
@@ -64,9 +64,9 @@ test("load environments and params", ({expect})=>{
|
||||
});
|
||||
|
||||
test("load template", ({expect})=>{
|
||||
let sut = new ConfigReader();
|
||||
const sut = new ConfigReader();
|
||||
|
||||
let cfg = sut.parseFromString(cfgTemplate);
|
||||
const cfg = sut.parseFromString(cfgTemplate);
|
||||
|
||||
expect(cfg?.template).toBeDefined();
|
||||
expect(cfg?.template.content.length).toBeGreaterThan(20);
|
||||
|
||||
Reference in New Issue
Block a user