Skip to content
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

fix(codemods): Do not fail on empty configMod config #25148

Merged
merged 2 commits into from
Oct 11, 2022

Conversation

miroslavstastny
Copy link
Member

Current Behavior

When @fluentui/codemods is run, configMod fails because of its config is empty. Changes from other executed codemods are not saved.

npx @fluentui/codemods
...
File index.ts has had the following mods error:
name:  configMod errorData:  {
  modName: 'configMod',
  error: 'failed to get any mods from json. Perhaps the file is missing or malformed?'
}

New Behavior

Empty configMod config is considered valid, the mod is skipped.

npx @fluentui/codemods
...
File index.ts has had the following mods run: 
name:  configMod logdata:  [ 'No runnable mods were found in the config' ]
...

Related Issue(s)

Fixes #19847

@@ -144,7 +144,7 @@ const configMod: CodeMod = {
results.push(mod.run(file));
}
if (results.length === 0) {
return Err<ModResult, NoOp>({ logs: ['No runabble mods were found in the config'] });
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed from Err to Ok because the log message is swallowed otherwise.

@@ -131,9 +131,9 @@ const configMod: CodeMod = {
run: (file: SourceFile) => {
if (!__configs) {
__configs = getCodeModsFromJson();
if (__configs === undefined || __configs.length === 0) {
if (__configs === undefined) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty array is now OK here, handled by the next condition.

@fabricteam
Copy link
Collaborator

📊 Bundle size report

🤖 This report was generated against b4a703103ebdf240bdce2fd629d8e5783ebb6ad1

@size-auditor
Copy link

size-auditor bot commented Oct 10, 2022

Asset size changes

Size Auditor did not detect a change in bundle size for any component!

Baseline commit: b4a703103ebdf240bdce2fd629d8e5783ebb6ad1 (build)

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit f325b20:

Sandbox Source
@fluentui/react 8 starter Configuration
@fluentui/react-components 9 starter Configuration

return Err<ModResult, ModError>({
error: 'failed to get any mods from json. Perhaps the file is missing or malformed?',
error: 'Failed to get any mods from json. Perhaps the file is missing or malformed?',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This had probably been meant not to fail the codemod pipeline. But it changed in #17932 accidentally

Copy link
Contributor

@Hotell Hotell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ty!

@miroslavstastny miroslavstastny merged commit 90200f6 into microsoft:master Oct 11, 2022
@miroslavstastny miroslavstastny deleted the fix/codemods branch October 11, 2022 10:43
marcosmoura added a commit to marcosmoura/fluentui that referenced this pull request Oct 11, 2022
* master:
  fix: Menu trigger should be focused when menu is closed with keyboard (microsoft#25165)
  fix(codemods): Do not fail on empty configMod config (microsoft#25148)
  fix: Field should have block layout, not inline (microsoft#25126)
  chore: Update Griffel to latest version (microsoft#25075)
NotWoods pushed a commit to NotWoods/fluentui that referenced this pull request Nov 18, 2022
* fix(codemod): Do not fail on empty configMod config

* change file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Running npx @fluentui/codemods in project results in only 'Mod was a NoOp on this file' messages
4 participants