-
Notifications
You must be signed in to change notification settings - Fork 21
Comments / formatting #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments / formatting #84
Conversation
- refactored WorkflowValidator.validationErrors as errors to keep consistancy with the underlying validator and other validators - added missing comments - fixed README `Add as dependency to your project`, used the scoped name - added imports in README examples - added 'validate parts of a workflow' example in README Signed-off-by: JBBianchi <jb.bianchi@neuroglia.io>
- added prettier & eslint - fixed eslint errors/warnings Signed-off-by: JBBianchi <jb.bianchi@neuroglia.io>
- added husky for pre commit formatting/pre push test - fixed prettier commands - formatted code Signed-off-by: JBBianchi <jb.bianchi@neuroglia.io>
Not sure husky/lint-staged work as expected... |
@antmendoza @tsurdilo are you ok with merging this ? I'm not a 100% sure about the husky/lint-staged config but it's a step forward anyways and shouldn't break anything :) |
I will review it today, thank you @JBBianchi |
Hi @JBBianchi I think that husky is not working for me if I am getting it right. The pre-commit hook will run "npx lint-staged", which run "npm run format" for all the staged files, isn't it? In my case nothing happen any suggestions ? |
lint-staged will run "npm run format" if there is any .ts staged if I understood well but I must admit I don't think it's working. |
- fixed builder for union types - rename "validatorFn" by "buildingFn" in builder(s) - fixed default kind/type for Subflowstate, Function, Eventdef - added file header - "installed" husky - updated lint-staged config Signed-off-by: JBBianchi <jb.bianchi@neuroglia.io>
I fixed lint-staged/husky I think. 1st, I forgot to install husky properly, 2nd I didn't use the proper command to format ( I also added file header and some fixes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
husky is not working for me, no idea why.
Instead it works adding the pre-commit hook like it shows the documentation here https://www.npmjs.com/package/husky
npx husky add .husky/pre-commit "npm test"
Could you check if this is working also for you?
I am gonna merge this anyway, we can fix it in another pr.
Thank you @JBBianchi
|
||
**Anything else we need to know?**: | ||
|
||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also the md files are been formatting, cool !!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prettier supports MD
indeed but I don't really understand why they have been formatted... I thought I specified .ts
only...
import { validators, Specification } from '@severlessworkflow/sdk-typescript'; | ||
|
||
const injectionState: Specification.Injectstate = workflow.states[0]; | ||
const injectionStateValidator: ValidateFunction<Specification.Injectstate> = validators.get('Injectstate'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we create a wrapper (like workflowValidator) to validate individual elements?
(not now, just wondering)
Functions, retries, and event can be defined in different files, so I think at least for those element we have to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+
if I where a user of the sdk, I don't want to learn the keys for each element to retrieve the validator from validators
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 'keys' are the type names of Specification but I agree with you, it could be improved. I need to double check but I don't think we can use the type directly in TS like validator.get(Specification.Injectstate)
because the type doens't exist at runtime. Anyhow, good idea, there is room for improvement here.
One side note though, more regarding the schema, I think Events/Retries/Functions cannot be used by themselves because they are based on custom properties that don't exist in the JSON Schema specification. So they can be "pointed at" but not used alone. I might be wrong though. (See little chat in the JSON Schema Slack)
@@ -0,0 +1,21 @@ | |||
export const fileHeader = `/* | |||
* Copyright 2021-Present The Serverless Workflow Specification Authors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -0,0 +1 @@ | |||
_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am just curious, what this is supposing to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's added by husky. When doing husky install
, it creates .husky/
with that .gitignore
and a _/
with a .sh in it.
Maybe you need to run the |
is there anything I can help with this? if you have some steps i can follow can try on a clean box |
@tsurdilo I would be nice if you could get the project, run Huksy should kick in and, in the end, the file should be prettyfied as |
I think @antmendoza is right, they changed the way to handle hooks. The js/json/package method has been replaced by the .husky directory thing (https://blog.typicode.com/husky-git-hooks-javascript-config/). I'll fix that. |
What this PR does / why we need it:
Improves code quality and consistancy with linting and prettifying.
Adds comments & file headers.
Fixes builder problems.
Linked to #79
Linked to #94
Closes #89
Closes #90
Closes #91
Closes #92
Closes #93