-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[polaris-migrator] Add a migration to change inline for block comments #10749
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@shopify/polaris-migrator': minor | ||
--- | ||
|
||
Adds new styles-replace-inline-comments general migration | ||
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -11,6 +11,7 @@ module.exports = { | |||
'styles-insert-stylelint-disable', | ||||
), | ||||
'styles-replace-custom-property': resolve('styles-replace-custom-property'), | ||||
'styles-replace-inline-comments': resolve('styles-replace-inline-comments'), | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Correct me if I'm wrong @sam-b-rose but we're not using presets right now, right? Tbh, I didn't even realize this file still existed after the consolidation of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I left this in as a just-in-case we wanted to try to use something like |
||||
'v11-react-update-page-breadcrumbs': resolve( | ||||
'v11-react-update-page-breadcrumbs', | ||||
), | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// single-inline-comment | ||
$single-inline-comment: 1rem; | ||
|
||
// multiline | ||
// comment | ||
$multiline-comment: 1rem; | ||
|
||
.comment { | ||
$top-nested-comment: 1rem; | ||
// nested-sandwidched-comment | ||
$bottom-nested-comment: 1rem; | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we confirm block comments There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I can tell, all comments are stripped in the minify step of our build process. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* single-inline-comment */ | ||
$single-inline-comment: 1rem; | ||
|
||
/* multiline */ | ||
/* comment */ | ||
$multiline-comment: 1rem; | ||
|
||
.comment { | ||
$top-nested-comment: 1rem; | ||
/* nested-sandwidched-comment */ | ||
$bottom-nested-comment: 1rem; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import {check} from '../../../utilities/check'; | ||
|
||
const transform = 'styles-replace-inline-comments'; | ||
const fixtures = ['styles-replace-inline-comments']; | ||
|
||
for (const fixture of fixtures) { | ||
check(__dirname, { | ||
fixture, | ||
transform, | ||
extension: 'scss', | ||
options: { | ||
customSyntax: 'postcss-scss', | ||
reportDescriptionlessDisables: true, | ||
rules: {}, | ||
}, | ||
}); | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,37 @@ | ||||||||||||||||||||||||
import type {API, FileInfo, Options} from 'jscodeshift'; | ||||||||||||||||||||||||
import type {Plugin} from 'postcss'; | ||||||||||||||||||||||||
import postcss from 'postcss'; | ||||||||||||||||||||||||
import stylelint from 'stylelint'; | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
const plugin = (): Plugin => { | ||||||||||||||||||||||||
return { | ||||||||||||||||||||||||
postcssPlugin: 'styles-replace-inline-comments', | ||||||||||||||||||||||||
Comment(comment) { | ||||||||||||||||||||||||
comment.raws.inline = false; | ||||||||||||||||||||||||
comment.raws.right = ' '; | ||||||||||||||||||||||||
comment.raws.left = ' '; | ||||||||||||||||||||||||
}, | ||||||||||||||||||||||||
Comment on lines
+9
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
GPT suggested using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, so looked at this briefly yesterday and I suspect it's a bit more involved than this, because sometimes we want new break lines and some times we don't, and it depends on the I need to take a closer look to fine tune this, so I'll circle back to this in a few days 🤞 |
||||||||||||||||||||||||
}; | ||||||||||||||||||||||||
}; | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
export default async function transformer( | ||||||||||||||||||||||||
file: FileInfo, | ||||||||||||||||||||||||
_: API, | ||||||||||||||||||||||||
options: Options, | ||||||||||||||||||||||||
) { | ||||||||||||||||||||||||
return postcss([ | ||||||||||||||||||||||||
stylelint({ | ||||||||||||||||||||||||
config: { | ||||||||||||||||||||||||
extends: [options.config ?? '@shopify/stylelint-polaris'], | ||||||||||||||||||||||||
Comment on lines
+22
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you help me understand why we're using |
||||||||||||||||||||||||
}, | ||||||||||||||||||||||||
}) as Plugin, | ||||||||||||||||||||||||
plugin(), | ||||||||||||||||||||||||
]) | ||||||||||||||||||||||||
.process(file.source, { | ||||||||||||||||||||||||
from: file.path, | ||||||||||||||||||||||||
syntax: require('postcss-scss'), | ||||||||||||||||||||||||
}) | ||||||||||||||||||||||||
.then((result) => { | ||||||||||||||||||||||||
return result.css; | ||||||||||||||||||||||||
}); | ||||||||||||||||||||||||
} |
Uh oh!
There was an error while loading. Please reload this page.
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.