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

Add typed-css-modules-webpack-plugin to support type checking #3192

Merged
merged 1 commit into from
May 8, 2020

Conversation

onursumer
Copy link
Member

@onursumer onursumer commented May 4, 2020

Fix cBioPortal/cbioportal#7455

  • Configure typed-css-mdoules-webpack-plugin to auto generate typings for every scss module (files matching the pattern *.module.scss)
  • For each scss module file, it generates a TS type definition file in the form of *.module.scss.d.ts
  • Works for both build and watch modes.

Checks

  • Has tests or has a separate issue that describes the types of test that should be created. If no test is included it should explicitly be mentioned in the PR why there is no test.
  • The commit log is comprehensible. It follows 7 rules of great commit messages. For most PRs a single commit should suffice, in some cases multiple topical commits can be useful. During review it is ok to see tiny commits (e.g. Fix reviewer comments), but right before the code gets merged to master or rc branch, any such commits should be squashed since they are useless to the other developers. Definitely avoid merge commits, use rebase instead.
  • Is this PR adding logic based on one or more clinical attributes? If yes, please make sure validation for this attribute is also present in the data validation / data loading layers (in backend repo) and documented in File-Formats Clinical data section!

@onursumer onursumer requested a review from alisman May 4, 2020 21:52
@onursumer onursumer force-pushed the typed-css-modules branch 2 times, most recently from cd06422 to 478b243 Compare May 6, 2020 02:58
@@ -1,5 +1,5 @@
.centered-modal-dialog {
// TODO centering doesn't work on the patient view, disabling for now...
// TODO centering does not work on the patient view, disabling for now...
Copy link
Member Author

Choose a reason for hiding this comment

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

parser doesn't like the ' character

import classNames from 'classnames';

const styles = styles_any as {
Copy link
Member Author

Choose a reason for hiding this comment

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

we don't need to manually add styles anymore

Comment on lines +184 to +186
new TypedCssModulesPlugin({
globPattern: 'src/**/*.module.scss',
}),
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 does the magic

@@ -0,0 +1,3 @@

Copy link
Member Author

Choose a reason for hiding this comment

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

The corresponding styling file is empty

@@ -335,7 +335,9 @@ export default class FixedHeaderTable<T> extends React.Component<
{selectionOperation}{' '}
<i
className={
styles[selectionOperation.toLowerCase()]
(styles as any)[
Copy link
Member Author

Choose a reason for hiding this comment

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

Need to do as any when referencing with a variable string

//> div:nth-child(2) {
// margin-top:0px !important;
//}
/*> div:nth-child(2) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Parser doesn't like line comments

@onursumer onursumer marked this pull request as ready for review May 6, 2020 17:59
readonly "noGroupsMessage": string;
readonly "survivalPlotHeader": string;
readonly "survivalPlotHeaderContainer": string;
readonly "survivalTypeOptions": string;
Copy link
Contributor

Choose a reason for hiding this comment

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

is this auto created or do we have to go in and add this every time we add a class?

Copy link
Member Author

Choose a reason for hiding this comment

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

auto created, and works fine in the watch mode.

@@ -0,0 +1,3 @@

Copy link
Contributor

Choose a reason for hiding this comment

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

empty file?

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, we have an empty style file :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, the empty one was the other file. Good catch!

Here the source scss doesn't really have any named references, it shouldn't be defined as a module but probably a regular scss.

Copy link
Member Author

Choose a reason for hiding this comment

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

seems like we don't even import local.module.scss anywhere, probably safe to remove it completely.

@@ -10,7 +10,8 @@ import {
} from 'cbioportal-frontend-commons';
import SampleManager from '../SampleManager';

import styles from './styles.module.scss';
// TODO styles.module.scss is empty!
// import styles from './styles.module.scss';
Copy link
Contributor

Choose a reason for hiding this comment

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

remove comments?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, eventually we should either remove those invalid usage or update them

@@ -194,7 +194,8 @@ export default class OQLTextArea extends React.Component<
break;
}
this.geneQuery
? classNames.push(styles.notEmpty)
? // TODO no such style called `notEmpty`
classNames.push(/* styles.notEmpty */ '')
Copy link
Contributor

Choose a reason for hiding this comment

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

get rid of this altogether then?

Copy link
Member Author

Choose a reason for hiding this comment

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

most likely we will end up removing all the invalid references before merging the PR, but keeping them for now just in case someone wants to comment.

@@ -82,7 +84,7 @@ export default class Sift extends React.Component<ISiftProps, {}> {
<td>
<span
className={
tooltipStyles[
(tooltipStyles as any)[
`sift-${this.props.siftPrediction}`
Copy link
Contributor

Choose a reason for hiding this comment

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

instead you could try tooltipStyles[`sift-$....` as keyof tooltipStyles`]. Not sure if it would work but it might

Copy link
Member Author

Choose a reason for hiding this comment

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

hmm, I'll give it a try

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 doesn't seem to work, leaving it as any for now

@@ -43,7 +43,9 @@ export default class Sift extends React.Component<ISiftProps, {}> {
<span
className={classNames(
annotationStyles['annotation-item-text'],
tooltipStyles[`sift-${this.props.siftPrediction}`]
(tooltipStyles as any)[
`sift-${this.props.siftPrediction}`
Copy link
Contributor

Choose a reason for hiding this comment

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

same thing here as below vvv

@onursumer onursumer force-pushed the typed-css-modules branch 2 times, most recently from 544a6d4 to bbda3c8 Compare May 6, 2020 22:04
@@ -16,6 +16,7 @@
*pegjs
*.template
*.ejs
*module.scss.d.ts
Copy link
Member Author

Choose a reason for hiding this comment

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

ignore auto generated module typing files

@onursumer onursumer force-pushed the typed-css-modules branch 5 times, most recently from dd91731 to 9eb7572 Compare May 7, 2020 22:25
…s modules

Signed-off-by: Onur Sumer <s.onur.sumer@gmail.com>
@alisman alisman merged commit 2208647 into cBioPortal:master May 8, 2020
@alisman alisman deleted the typed-css-modules branch May 8, 2020 14:29
@inodb inodb added the chore This PR is related to code maintenance label May 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore This PR is related to code maintenance
Projects
None yet
4 participants