-
Notifications
You must be signed in to change notification settings - Fork 916
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
[CCI] Fix type errors in i18n #3629
[CCI] Fix type errors in i18n #3629
Conversation
Signed-off-by: Alexei Karikov <[email protected]>
Signed-off-by: Alexei Karikov <[email protected]>
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 like this PR, great job! just a few small comments but mostly there 😄
} catch (error: unknown) { | ||
if (error instanceof Error) { | ||
if (error instanceof parser.SyntaxError) { | ||
if (error.name === 'SyntaxError') { | ||
const errorWithContext = createParserErrorMessage(message, { | ||
loc: { | ||
line: error.location.start.line, | ||
column: error.location.start.column - 1, | ||
}, | ||
message: error.message, | ||
}); | ||
throw errorWithContext; | ||
} | ||
} | ||
} | ||
} |
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.
Why is this nesting required? Cant you simply change the if condition to
if (error instanceof parser.SyntaxError && error.name === 'SyntaxError') {
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 wasn't sure if the error would be instance of parser.SyntaxError, so I left it so to get your opinion. I'll change it if it's right
src/dev/run_i18n_check.ts
Outdated
task: ({ config }) => | ||
new Listr(extractDefaultMessages(config, srcPaths), { exitOnError: true }), | ||
task: ({ config }) => { | ||
return new Listr(extractDefaultMessages(config!, srcPaths), { exitOnError: true }); |
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.
You are already handling for a missing config value in the extractDefaultMessages
task, you dont need this change
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.
Can skipOnNoTranslations do a throw error if there is no config? So as not to create more checks. Although these functions will be used anyway and there is no other way to check if the config is in one place
src/dev/run_i18n_integrate.ts
Outdated
{ | ||
title: 'Merging .i18nrc.json files', | ||
task: () => new Listr(mergeConfigs(includeConfig), { exitOnError: true }), | ||
}, | ||
{ | ||
title: 'Extracting Default Messages', | ||
task: ({ config }) => | ||
new Listr(extractDefaultMessages(config, srcPaths), { exitOnError: true }), | ||
new Listr(extractDefaultMessages(config!, srcPaths), { exitOnError: true }), |
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.
same here, you dont need this change
src/dev/run_i18n_integrate.ts
Outdated
config, | ||
log, | ||
}); | ||
if (config) { |
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 like you pattern of throwing an error if config is missing instead of this
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 like you missed this change. The reason i like throwing an error is because it makes it clear why the task failed. The config should never be empty, but if it is, based on this change this task will complete silently, but the other tasks like checkCompatibility
will throw an error. And since we expect config to be defined in this task, I want to know if it did not run.
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #3629 +/- ##
==========================================
- Coverage 66.46% 66.39% -0.07%
==========================================
Files 3205 3209 +4
Lines 61562 61633 +71
Branches 9497 9506 +9
==========================================
+ Hits 40916 40924 +8
- Misses 18375 18425 +50
- Partials 2271 2284 +13
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 52 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@Nicksqain When you add the next commits based on the review feedback, please also add an entry to the |
Signed-off-by: Alexei Karikov <[email protected]>
Signed-off-by: Alexei Karikov <[email protected]>
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.
Thanks for making the changes @Nicksqain. Just a few last comments and this PR should be good to merge :)
src/dev/run_i18n_extract.ts
Outdated
@@ -35,7 +35,7 @@ import { resolve } from 'path'; | |||
import { createFailError, run } from '@osd/dev-utils'; | |||
import { ErrorReporter, serializeToJson, serializeToJson5, writeFileAsync } from './i18n'; | |||
import { extractDefaultMessages, mergeConfigs } from './i18n/tasks'; | |||
|
|||
import { ListrContext } from './run_i18n_check'; |
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.
Nit: This can come from a common source instead of another 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.
I do not know how you import :(
What is considered a common source?
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.
./i18n/tasks. Right?
src/dev/run_i18n_extract.ts
Outdated
{ | ||
title: 'Merging .i18nrc.json files', | ||
task: () => new Listr(mergeConfigs(includeConfig), { exitOnError: true }), | ||
}, | ||
{ | ||
title: 'Extracting Default Messages', | ||
task: ({ config }) => | ||
new Listr(extractDefaultMessages(config, srcPaths), { exitOnError: true }), | ||
new Listr(extractDefaultMessages(config!, srcPaths), { exitOnError: true }), |
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.
new Listr(extractDefaultMessages(config!, srcPaths), { exitOnError: true }), | |
new Listr(extractDefaultMessages(config, srcPaths), { exitOnError: true }), |
update extractDefaultMessages
to accept an optional config just like checkCompatibility
. This should never happen based on the order that they are called in, but should the order ever be swapped, the error will point us to the problem
src/dev/run_i18n_integrate.ts
Outdated
config, | ||
log, | ||
}); | ||
if (config) { |
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 like you missed this change. The reason i like throwing an error is because it makes it clear why the task failed. The config should never be empty, but if it is, based on this change this task will complete silently, but the other tasks like checkCompatibility
will throw an error. And since we expect config to be defined in this task, I want to know if it did not run.
…to common source Signed-off-by: Alexei Karikov <[email protected]>
Signed-off-by: Alexei Karikov <[email protected]>
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.
👍 Awesome job on your pull request! Thanks for the contribution! 🎉
@Nicksqain I did notice however that typescript still complains about the |
@ashwin-pc Where exactly is the typescript error? |
I created an issue for this problem #3606
|
@Nicksqain Given #3606, I'd strongly prefer to update the deprecated dependency, so no need to account for it in this PR. |
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.
Thanks so much!
* Changes related to i18n configs * Added changes to missed commits and also added tasks Listr interface to common source * Update imports for other files that using ListrContext interface Signed-off-by: Alexei Karikov <[email protected]> --------- Signed-off-by: Alexei Karikov <[email protected]> Co-authored-by: Ashwin P Chandran <[email protected]> (cherry picked from commit fd61f7a) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> # Conflicts: # CHANGELOG.md
* Changes related to i18n configs * Added changes to missed commits and also added tasks Listr interface to common source * Update imports for other files that using ListrContext interface Signed-off-by: Alexei Karikov <[email protected]> --------- Signed-off-by: Alexei Karikov <[email protected]> Co-authored-by: Ashwin P Chandran <[email protected]> Signed-off-by: vagimeli <[email protected]>
* Changes related to i18n configs * Added changes to missed commits and also added tasks Listr interface to common source * Update imports for other files that using ListrContext interface Signed-off-by: Alexei Karikov <[email protected]> --------- Signed-off-by: Alexei Karikov <[email protected]> Co-authored-by: Ashwin P Chandran <[email protected]> (cherry picked from commit fd61f7a) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> # Conflicts: # CHANGELOG.md Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* Changes related to i18n configs * Added changes to missed commits and also added tasks Listr interface to common source * Update imports for other files that using ListrContext interface Signed-off-by: Alexei Karikov <[email protected]> --------- Signed-off-by: Alexei Karikov <[email protected]> Co-authored-by: Ashwin P Chandran <[email protected]> Signed-off-by: David Sinclair <[email protected]>
Description
Issues Resolved
#3027
Check List
yarn test:jest
yarn test:jest_integration
yarn test:ftr