-
-
Notifications
You must be signed in to change notification settings - Fork 46
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
feat: strict eslint #148
feat: strict eslint #148
Conversation
54435a1
to
a0b5130
Compare
"plugin:react/jsx-runtime", | ||
"plugin:storybook/recommended", | ||
"plugin:playwright/recommended", |
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.
this eslint plugin shows playwright errors and problems
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
testDir: "./src/react-components", | ||
/* The base directory, relative to the config file, for snapshot files created with toMatchSnapshot and toHaveScreenshot. */ | ||
snapshotDir: "./__snapshots__", |
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.
lets snapshots be generated inside the same directory as the test. this makes it easier to see which snapshot belongs to which test.
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.
this test doesn't run yet. playwright is set to only run tests inside the react folder. I will still need to figure out a way to run this file since vanillaextract needs to be transpiled before the run.
src/markup/express.ts
Outdated
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.
this file wasn't used? it's a duplicate of what we have inside the src/markup-components.
e5d100e
to
29767f6
Compare
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.
Nice, just a few comments.
8518954
to
0c6ecd2
Compare
0c6ecd2
to
6b0d37e
Compare
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.
Looks good, take a look on the assertions again.
Co-authored-by: Jonas Hungershausen <[email protected]>
6b0d37e
to
1a61738
Compare
if (Array.isArray(value)) { | ||
return { | ||
...accumulator, | ||
[key]: value, | ||
[key + "_list"]: intl.formatList<string>(value), | ||
} | ||
} else if (key.endsWith("_unix")) { | ||
if (typeof value === "number") { | ||
return { | ||
...accumulator, | ||
[key]: intl.formatDate(new Date(value * 1000)), | ||
[key + "_since"]: intl.formatDateTimeRange( | ||
new Date(value), | ||
new Date(), | ||
), | ||
[key + "_since_minutes"]: Math.abs( | ||
(value - new Date().getTime() / 1000) / 60, | ||
).toFixed(2), | ||
[key + "_until"]: intl.formatDateTimeRange( | ||
new Date(), | ||
new Date(value), | ||
), | ||
[key + "_until_minutes"]: Math.abs( | ||
(new Date().getTime() / 1000 - value) / 60, | ||
).toFixed(2), | ||
} | ||
} | ||
} | ||
return { | ||
...accumulator, | ||
[key]: value as string | number, | ||
} | ||
}, | ||
{}, | ||
) | ||
|
||
return intl.formatMessage( |
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.
This needs some review. I am changing the date format as well here to only have 2 decimal places in the minutes we display. For example "the flow has expired 10.00 minutes ago".
Right now it's a bit unwieldy and would display "the flow has expired -10.0004123 minutes ago".
The values are also absolute now. So no more "-10.00".
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.
There are some tests inside the error-flow-nodes.spec file and inside the node.spec.tsx file.
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.
Probably makes more sense to fix this in kratos?
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.
kratos gives back a unix timestamp from where it expired. So the date.
The ui then has to render the time or the minutes from/until that date.
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.
Ah I get it, this basically formats the timestamp in separate keys (until, since, ...). Makes sense to me
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.
yeah exactly. Do you think it's fine to merge?
Related Issue or Design Document
This PR adds stricter type checking to the code base. This allows us to catch bugs early in the library as well as in playwright tests.
Tests were also added to some of the components to ensure they behave as expected, such as the error messages. Translation tests now also checks that template strings exist within the translation based on the english version.
Checklist
If this pull request addresses a security vulnerability,
I confirm that I got approval (please contact [email protected]) from the maintainers to push the changes.
Further comments