Skip to content

Commit

Permalink
refactor: verbatimModuleSyntax needs to be true
Browse files Browse the repository at this point in the history
  • Loading branch information
danielo515 committed Jul 8, 2024
1 parent 8ddaaf8 commit 4f78e56
Show file tree
Hide file tree
Showing 70 changed files with 195 additions and 172 deletions.
10 changes: 3 additions & 7 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
"root": true,
"parser": "@typescript-eslint/parser",
"env": { "node": true },
"plugins": [
"@typescript-eslint",
"fp-ts",
"@stylistic",
"newline-function-call"
],
"plugins": ["@typescript-eslint", "fp-ts", "@stylistic", "newline-function-call"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
Expand All @@ -26,6 +21,7 @@
"arrow-parens": ["error", "always"],
"fp-ts/no-lib-imports": "error",
"@stylistic/function-call-argument-newline": ["error", "consistent"],
"newline-function-call/function-call-argument-newline": ["error"]
"newline-function-call/function-call-argument-newline": ["error"],
"@typescript-eslint/consistent-type-imports": "error"
}
}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@
"type-fest": "^4.6.0",
"valibot": "^0.19.0"
}
}
}
7 changes: 4 additions & 3 deletions src/API.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { App, parseFrontMatterAliases } from "obsidian";
import type { App} from "obsidian";
import { parseFrontMatterAliases } from "obsidian";

import * as std from "@std";
import { E, flow } from "@std";
import { FormModal } from "./FormModal";
import FormResult from "./core/FormResult";
import type FormResult from "./core/FormResult";
import { type FormDefinition, type FormOptions } from "./core/formDefinition";
import { MigrationError } from "./core/formDefinitionSchema";
import { exampleModalDefinition } from "./exampleModalDefinition";
import ModalFormPlugin from "./main";
import type ModalFormPlugin from "./main";
import { log_error, log_notice } from "./utils/Log";
import { ModalFormError } from "./utils/ModalFormError";
import { enrich_tfile, resolve_tfile } from "./utils/files";
Expand Down
2 changes: 1 addition & 1 deletion src/FormModal.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { App } from "obsidian";
import { FormDefinition } from "src/core/formDefinition";
import type { FormDefinition } from "src/core/formDefinition";
import { makeFormEngine } from "src/store/formStore";
import { onMount } from "svelte";
import RenderField from "./views/components/Form/RenderField.svelte";
Expand Down
6 changes: 4 additions & 2 deletions src/FormModal.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { throttle } from "@std";
import { App, Modal, Setting } from "obsidian";
import type { App} from "obsidian";
import { Modal, Setting } from "obsidian";
import { mount, unmount } from "svelte";
import FormModalComponent from "./FormModal.svelte";
import FormResult, { type ModalFormData } from "./core/FormResult";
import { formDataFromFormDefaults } from "./core/formDataFromFormDefaults";
import type { FormDefinition, FormOptions } from "./core/formDefinition";
import { FormEngine, makeFormEngine } from "./store/formStore";
import type { FormEngine} from "./store/formStore";
import { makeFormEngine } from "./store/formStore";
import { log_notice } from "./utils/Log";

export type SubmitFn = (formResult: FormResult) => void;
Expand Down
5 changes: 3 additions & 2 deletions src/ModalFormSettingTab.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { App, PluginSettingTab, Setting } from "obsidian";
import ModalFormPlugin from "./main";
import type { App} from "obsidian";
import { PluginSettingTab, Setting } from "obsidian";
import type ModalFormPlugin from "./main";
import { isValidOpenPosition } from "./core/settings";

export class ModalFormSettingTab extends PluginSettingTab {
Expand Down
3 changes: 2 additions & 1 deletion src/core/FormResult.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
jest.mock("obsidian");
import FormResult, { ModalFormData } from "./FormResult";
import type { ModalFormData } from "./FormResult";
import FormResult from "./FormResult";

describe("FormResult", () => {
const formData: ModalFormData = {
Expand Down
10 changes: 6 additions & 4 deletions src/core/findInputDefinitionSchema.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { A, NonEmptyArray, ParsingFn, parse, pipe } from "@std";
import type { NonEmptyArray, ParsingFn} from "@std";
import { A, parse, pipe } from "@std";
import * as E from "fp-ts/Either";
import { BaseSchema, ValiError } from "valibot";
import { AllFieldTypes } from "./formDefinition";
import { FieldMinimal, FieldMinimalSchema } from "./formDefinitionSchema";
import type { BaseSchema, ValiError } from "valibot";
import type { AllFieldTypes } from "./formDefinition";
import type { FieldMinimal} from "./formDefinitionSchema";
import { FieldMinimalSchema } from "./formDefinitionSchema";
import { InputTypeToParserMap } from "./input/InputDefinitionSchema";

export function stringifyIssues(error: ValiError): NonEmptyArray<string> {
Expand Down
2 changes: 1 addition & 1 deletion src/core/formDataFromDefaults.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FormDefinition } from "./formDefinition";
import type { FormDefinition } from "./formDefinition";
import { formDataFromFormDefaults } from "./formDataFromFormDefaults";

describe("formDataFromFormOptions", () => {
Expand Down
5 changes: 3 additions & 2 deletions src/core/formDataFromFormDefaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import * as R from 'fp-ts/Record';
import * as O from 'fp-ts/Option';
import { log_error } from "../utils/Log";
import { ModalFormError } from "../utils/ModalFormError";
import { FormDefinition } from './formDefinition';
import type { FormDefinition } from './formDefinition';
import { A, pipe } from '@std';
import { ModalFormData, isPrimitiveArray, isPrimitive, Val } from './FormResult';
import type { ModalFormData, Val } from './FormResult';
import { isPrimitiveArray, isPrimitive } from './FormResult';


/**
Expand Down
31 changes: 14 additions & 17 deletions src/core/formDefinition.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { input } from "@core";
import type { input } from "@core";
import { A, O, pipe } from "@std";
import { Simplify } from "type-fest";
import type { Simplify } from "type-fest";
import { is, safeParse, type Output } from "valibot";
import {
FieldDefinitionSchema,
FieldListSchema,
FormDefinitionBasicSchema,
FormDefinitionLatestSchema,
MigrationError,
} from "./formDefinitionSchema";
import type { FieldDefinitionSchema, FormDefinitionLatestSchema } from "./formDefinitionSchema";
import { FieldListSchema, FormDefinitionBasicSchema, MigrationError } from "./formDefinitionSchema";
import type {
basicInput,
inputDataviewSource,
inputNoteFromFolder,
inputSelectFixed,
inputSlider,
inputType,
multiselect,
selectFromNotes,
} from "./input/InputDefinitionSchema";
import {
InputBasicSchema,
InputDataviewSourceSchema,
Expand All @@ -18,14 +23,6 @@ import {
InputTypeSchema,
MultiselectSchema,
SelectFromNotesSchema,
basicInput,
inputDataviewSource,
inputNoteFromFolder,
inputSelectFixed,
inputSlider,
inputType,
multiselect,
selectFromNotes,
} from "./input/InputDefinitionSchema";

export const InputTypeReadable: Record<AllFieldTypes, string> = {
Expand Down
4 changes: 2 additions & 2 deletions src/core/formDefinitionSchema.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { input } from "@core";
import { parse, pipe } from "@std";
import * as E from "fp-ts/Either";
import type { ValiError } from "valibot";
import {
ValiError,
array,
boolean,
is,
Expand All @@ -16,7 +16,7 @@ import {
type Output,
} from "valibot";
import { findFieldErrors, stringifyIssues } from "./findInputDefinitionSchema";
import { FormDefinition } from "./formDefinition";
import type { FormDefinition } from "./formDefinition";
import { InputTypeSchema, nonEmptyString } from "./input/InputDefinitionSchema";
import { ParsedTemplateSchema } from "./template/templateSchema";

Expand Down
10 changes: 6 additions & 4 deletions src/core/input/InputDefinitionSchema.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { ParsingFn, parseC, trySchemas } from "@std";
import type { ParsingFn} from "@std";
import { parseC, trySchemas } from "@std";
import { absurd } from "fp-ts/function";
import {
import type {
BaseSchema,
Output,
Output} from "valibot";
import {
array,
boolean,
enumType,
Expand All @@ -16,7 +18,7 @@ import {
toTrimmed,
union,
} from "valibot";
import { AllFieldTypes, AllSources } from "../formDefinition";
import type { AllFieldTypes, AllSources } from "../formDefinition";

/**
* Here are the definition for the input types.
Expand Down
2 changes: 1 addition & 1 deletion src/core/input/dependentFields.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { input } from "@core";
import * as v from "valibot";
import { FieldDefinition } from "../formDefinition";
import type { FieldDefinition } from "../formDefinition";
import * as deps from "./dependentFields";
import { ConditionSchema } from "./dependentFields";

Expand Down
2 changes: 1 addition & 1 deletion src/core/input/dependentFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Str } from "@std";
import * as Eq from "fp-ts/Eq";
import { absurd } from "fp-ts/function";
import * as v from "valibot";
import { FieldDefinition } from "../formDefinition";
import type { FieldDefinition } from "../formDefinition";
const isSet = v.object({ dependencyName: v.string(), type: v.literal("isSet") });
const booleanValue = v.object({
dependencyName: v.string(),
Expand Down
2 changes: 1 addition & 1 deletion src/core/objectSelect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as O from "fp-ts/Option";
import * as NEA from "fp-ts/NonEmptyArray";
import { filterWithIndex } from "fp-ts/Record";
import { object, optional, array, string, coerce } from "valibot";
import { NonEmptyArray } from "fp-ts/NonEmptyArray";
import type { NonEmptyArray } from "fp-ts/NonEmptyArray";

const KeysSchema = array(coerce(string(), String))

Expand Down
3 changes: 2 additions & 1 deletion src/core/settings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Output, ValiError, array, boolean, enumType, is, object, optional, unknown } from "valibot";
import type { Output, ValiError} from "valibot";
import { array, boolean, enumType, is, object, optional, unknown } from "valibot";
import type { FormDefinition } from "./formDefinition";
import type { MigrationError } from "./formDefinitionSchema";
import * as E from 'fp-ts/Either';
Expand Down
11 changes: 8 additions & 3 deletions src/core/template/templateParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Either, O, pipe } from "@std";
import type { Either } from "@std";
import { O, pipe } from "@std";
import * as A from "fp-ts/Array";
import * as E from "fp-ts/Either";
import * as R from "fp-ts/Record";
Expand All @@ -8,8 +9,12 @@ import { stringifyYaml } from "obsidian";
import * as P from "parser-ts/Parser";
import * as C from "parser-ts/char";
import * as S from "parser-ts/string";
import { ModalFormData } from "../FormResult";
import type { FrontmatterCommand, TemplateText, TemplateVariable } from "./templateSchema";
import type { ModalFormData } from "../FormResult";
import {
type FrontmatterCommand,
type TemplateText,
type TemplateVariable,
} from "./templateSchema";
type Token = TemplateText | TemplateVariable | FrontmatterCommand;
export type ParsedTemplate = Token[];

Expand Down
3 changes: 2 additions & 1 deletion src/core/template/templateSchema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Output, array, literal, object, string, union } from "valibot";
import type { Output} from "valibot";
import { array, literal, object, string, union } from "valibot";

const TemplateTextSchema = object({
_tag: literal("text"),
Expand Down
2 changes: 1 addition & 1 deletion src/core/templater/builder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import FormResult from "../FormResult";
import type FormResult from "../FormResult";

/**
* This is a dummy declare so we can use the FormResult
Expand Down
11 changes: 7 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { A, E, O, pipe } from "@std";
import { Platform, Plugin, WorkspaceLeaf } from "obsidian";
import type { WorkspaceLeaf } from "obsidian";
import { Platform, Plugin } from "obsidian";
import { API } from "src/API";
import { ModalFormSettingTab } from "src/ModalFormSettingTab";
import FormResult from "src/core/FormResult";
import { FormWithTemplate, type FormDefinition } from "src/core/formDefinition";
import type FormResult from "src/core/FormResult";
import type { FormWithTemplate} from "src/core/formDefinition";
import { type FormDefinition } from "src/core/formDefinition";
import {
getDefaultSettings,
parseSettings,
Expand All @@ -14,8 +16,9 @@ import { exampleModalDefinition } from "src/exampleModalDefinition";
import { ModalFormError } from "src/utils/ModalFormError";
import { EDIT_FORM_VIEW, EditFormView } from "src/views/EditFormView";
import { MANAGE_FORMS_VIEW, ManageFormsView } from "src/views/ManageFormsView";
import type {
InvalidData} from "./core/formDefinitionSchema";
import {
InvalidData,
MigrationError,
formNeedsMigration,
migrateToLatest,
Expand Down
14 changes: 9 additions & 5 deletions src/std/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as A from "fp-ts/Array";
import type {
Either} from "fp-ts/Either";
import {
Either,
ap,
bimap,
chainW,
Expand All @@ -18,12 +19,15 @@ import {
tryCatch,
tryCatchK,
} from "fp-ts/Either";
import { NonEmptyArray, concatAll as concatAllNea } from "fp-ts/NonEmptyArray";
import * as _O from "fp-ts/Option";
import { Semigroup, concatAll } from "fp-ts/Semigroup";
import type { NonEmptyArray} from "fp-ts/NonEmptyArray";
import { concatAll as concatAllNea } from "fp-ts/NonEmptyArray";
import type * as _O from "fp-ts/Option";
import type { Semigroup} from "fp-ts/Semigroup";
import { concatAll } from "fp-ts/Semigroup";
import * as TE from "fp-ts/TaskEither";
import { absurd as _absurd, flow as f, pipe as p } from "fp-ts/function";
import { BaseSchema, Output, ValiError, parse as parseV } from "valibot";
import type { BaseSchema, Output, ValiError} from "valibot";
import { parse as parseV } from "valibot";
export type Option<T> = _O.Option<T>;
export type { Either, Left, Right } from "fp-ts/Either";
export type { NonEmptyArray } from "fp-ts/NonEmptyArray";
Expand Down
10 changes: 6 additions & 4 deletions src/store/formStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ import * as R from "fp-ts/Record";
// and the errors that are present in the form. It is used by the Form component to render the form and to update the

import { input } from "@core";
import { NonEmptyArray, flow, pipe } from "@std";
import type { NonEmptyArray} from "@std";
import { flow, pipe } from "@std";
import * as A from "fp-ts/Array";
import * as E from "fp-ts/Either";
import * as O from "fp-ts/Option";
import { Option } from "fp-ts/Option";
import type { Option } from "fp-ts/Option";
import { fromEntries, toEntries } from "fp-ts/Record";
import { absurd } from "fp-ts/function";
import { FieldDefinition } from "src/core/formDefinition";
import type { FieldDefinition } from "src/core/formDefinition";
import { valueMeetsCondition } from "src/core/input";
import { Readable, Writable, derived, get, writable } from "svelte/store";
import type { Readable, Writable} from "svelte/store";
import { derived, get, writable } from "svelte/store";

type Rule = { tag: "required"; message: string }; //| { tag: 'minLength', length: number, message: string } | { tag: 'maxLength', length: number, message: string } | { tag: 'pattern', pattern: RegExp, message: string };
function requiredRule(fieldName: string, message?: string): Rule {
Expand Down
6 changes: 4 additions & 2 deletions src/store/store.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { A, pipe } from '@std';
import { FormDefinition, duplicateForm } from 'src/core/formDefinition';
import type { FormDefinition} from 'src/core/formDefinition';
import { duplicateForm } from 'src/core/formDefinition';
import { MigrationError } from 'src/core/formDefinitionSchema';
import { ModalFormSettings, getDefaultSettings } from 'src/core/settings';
import type { ModalFormSettings} from 'src/core/settings';
import { getDefaultSettings } from 'src/core/settings';
import { writable, derived } from 'svelte/store';

const settings = writable({ ...getDefaultSettings() });
Expand Down
5 changes: 3 additions & 2 deletions src/suggesters/FormPickerModal.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { App, FuzzySuggestModal } from "obsidian";
import { FormDefinition } from "src/core/formDefinition";
import type { App} from "obsidian";
import { FuzzySuggestModal } from "obsidian";
import type { FormDefinition } from "src/core/formDefinition";

export class FormPickerModal<Definition extends FormDefinition> extends FuzzySuggestModal<Definition> {
constructor(app: App, protected forms: Definition[], protected onSelected: (form: Definition) => void) {
Expand Down
5 changes: 3 additions & 2 deletions src/suggesters/NewNoteModal.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { App, Modal, Setting } from "obsidian";
import { FormWithTemplate } from "src/core/formDefinition";
import type { App} from "obsidian";
import { Modal, Setting } from "obsidian";
import type { FormWithTemplate } from "src/core/formDefinition";
import { FolderSuggest } from "./suggestFolder";
import { GenericSuggest } from "./suggestGeneric";
import { log_notice } from "src/utils/Log";
Expand Down
Loading

0 comments on commit 4f78e56

Please sign in to comment.