-
Notifications
You must be signed in to change notification settings - Fork 734
Fix Typography lint catching non truthy props #1137
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
0b85a8e
72ec0c3
fc5c00a
3d74107
283cd9a
ef30ba2
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 |
---|---|---|
|
@@ -312,6 +312,86 @@ ruleTester.run('typography-deprecation', rule, { | |
{ | ||
options: options, | ||
code: `${fullClassValidRenamed}`, | ||
}, | ||
{ | ||
options: options, | ||
code: ` | ||
${ourImport} | ||
import {List} from 'another-source'; | ||
<List.Item title={'bla'} />` | ||
}, | ||
{ | ||
options: options, | ||
code: ` | ||
import React, {Component} from 'react'; | ||
import {Typography} from 'our-source'; | ||
import {List} from 'another-source'; | ||
export default class OurList extends Component { | ||
render() { | ||
const titleVal = 'bla'; | ||
return ( | ||
<List.Item title={titleVal}/> | ||
) | ||
} | ||
}` | ||
}, | ||
{ | ||
options: options, | ||
code: ` | ||
import React, {Component} from 'react'; | ||
import {Typography, List} from 'our-source'; | ||
export default class OurList extends Component { | ||
render() { | ||
const titleVal = 'bla'; | ||
return ( | ||
<List.Item title={titleVal}/> | ||
) | ||
} | ||
}` | ||
}, | ||
{ | ||
options: options, | ||
code: ` | ||
import React, {Component} from 'react'; | ||
import {Typography, List} from 'our-source'; | ||
export default class OurList extends Component { | ||
render() { | ||
const titleVal = this.props.title; | ||
const subtitleVal = this.props.subtitle; | ||
return ( | ||
<List.Item title={titleVal} subtitle={subtitleVal}/> | ||
) | ||
} | ||
}` | ||
}, | ||
{ | ||
options: options, | ||
code: ` | ||
import React, {Component} from 'react'; | ||
import {Typography, List} from 'our-source'; | ||
export default class OurList extends Component { | ||
render() { | ||
const {title, subtitle} = this.props; | ||
return ( | ||
<List.Item title={title} subtitle={subtitle}/> | ||
) | ||
} | ||
}` | ||
}, | ||
{ | ||
options: options, | ||
code: ` | ||
import React, {Component} from 'react'; | ||
import {Typography, List} from 'our-source'; | ||
export default class OurList extends Component { | ||
render() { | ||
const {title: titleVal, subtitle: subtitleVal} = this.props; | ||
return ( | ||
<List.Item title={titleVal} subtitle={subtitleVal}/> | ||
) | ||
} | ||
}`, | ||
errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}] | ||
} | ||
], | ||
invalid: [ | ||
|
@@ -439,6 +519,196 @@ ruleTester.run('typography-deprecation', rule, { | |
options: options, | ||
code: `${fullClassTest2}`, | ||
errors: [{message: error}] | ||
} | ||
}, | ||
{ | ||
options: options, | ||
code: ` | ||
import React, {Component} from 'react'; | ||
import {Typography, Text} from 'our-source'; | ||
export default class OurList extends Component { | ||
render() { | ||
const titleVal = true; | ||
return ( | ||
<Text title={titleVal}/> | ||
) | ||
} | ||
}`, | ||
errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}] | ||
}, | ||
{ | ||
options: options, | ||
code: ` | ||
import React, {Component} from 'react'; | ||
import {Typography, Text} from 'our-source'; | ||
export default class OurList extends Component { | ||
render() { | ||
const {isTitle} = this.props; | ||
const titleVal = this.props.isTitle; | ||
const subtitleVal = !this.props.isTitle; | ||
return ( | ||
<Text title={titleVal} subtitle={subtitleVal}/> | ||
) | ||
} | ||
}`, | ||
errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}] | ||
}, | ||
{ | ||
options: options, | ||
code: ` | ||
import React, {Component} from 'react'; | ||
import {Typography, Text} from 'our-source'; | ||
export default class OurList extends Component { | ||
render() { | ||
const {isTitle} = this.props; | ||
const titleVal = isTitle; | ||
const subtitleVal = !isTitle; | ||
return ( | ||
<Text title={titleVal} subtitle={subtitleVal}/> | ||
) | ||
} | ||
}`, | ||
errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}] | ||
}, | ||
{ | ||
options: options, | ||
code: ` | ||
import React, {Component} from 'react'; | ||
import {Typography, TextField} from 'our-source'; | ||
export default class OurList extends Component { | ||
render() { | ||
const titleVal = true; | ||
return ( | ||
<TextField title={titleVal}/> | ||
) | ||
} | ||
}`, | ||
errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}] | ||
}, | ||
{ | ||
options: options, | ||
code: ` | ||
import React, {Component} from 'react'; | ||
import {Typography, TextField} from 'our-source'; | ||
export default class OurList extends Component { | ||
render() { | ||
const {isTitle} = this.props; | ||
const titleVal = this.props.isTitle; | ||
const subtitleVal = !this.props.isTitle; | ||
return ( | ||
<TextField title={titleVal} subtitle={subtitleVal}/> | ||
) | ||
} | ||
}`, | ||
errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}] | ||
}, | ||
{ | ||
options: options, | ||
code: ` | ||
import React, {Component} from 'react'; | ||
import {Typography, TextField} from 'our-source'; | ||
export default class OurList extends Component { | ||
render() { | ||
const {isTitle} = this.props; | ||
const titleVal = isTitle; | ||
const subtitleVal = !isTitle; | ||
return ( | ||
<TextField title={titleVal} subtitle={subtitleVal}/> | ||
) | ||
} | ||
}`, | ||
errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}] | ||
}, | ||
// TODO: these tests are not currently supported, they might be supported when prop-value-shape-deprecation is merged (or we'll have to add support) | ||
// { | ||
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. Why are we keeping these? 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. Added comments (TODOs) |
||
// options: options, | ||
// code: ` | ||
// import React, {Component} from 'react'; | ||
// import {Typography, Button} from 'our-source'; | ||
// export default class OurList extends Component { | ||
// render() { | ||
// const titleVal = true; | ||
// return ( | ||
// <Button labelProps={{title: titleVal}}/> | ||
// ) | ||
// } | ||
// }`, | ||
// errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}] | ||
// }, | ||
// { | ||
// options: options, | ||
// code: ` | ||
// import React, {Component} from 'react'; | ||
// import {Typography, Button} from 'our-source'; | ||
// export default class OurList extends Component { | ||
// render() { | ||
// const titleVal = true; | ||
// return ( | ||
// <Button title={titleVal}/> | ||
// ) | ||
// } | ||
// }`, | ||
// errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}] | ||
// }, | ||
// { | ||
// options: options, | ||
// code: ` | ||
// import React, {Component} from 'react'; | ||
// import {Typography, Card} from 'our-source'; | ||
// export default class OurList extends Component { | ||
// render() { | ||
// const titleVal = true; | ||
// return ( | ||
// <Card.Section content={{title: titleVal}}/> | ||
// ) | ||
// } | ||
// }`, | ||
// errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}] | ||
// }, | ||
// { | ||
// options: options, | ||
// code: ` | ||
// import React, {Component} from 'react'; | ||
// import {Typography, TabBar} from 'our-source'; | ||
// export default class OurList extends Component { | ||
// render() { | ||
// const titleVal = true; | ||
// return ( | ||
// <TabBar labelStyle={{title: titleVal}} selectedLabelStyle={{title: titleVal}}/> | ||
// ) | ||
// } | ||
// }`, | ||
// errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}] | ||
// }, | ||
// { | ||
// options: options, | ||
// code: ` | ||
// import React, {Component} from 'react'; | ||
// import {Typography, Label} from 'our-source'; | ||
// export default class OurList extends Component { | ||
// render() { | ||
// const titleVal = true; | ||
// return ( | ||
// <Label labelProps={{title: titleVal}}/> | ||
// ) | ||
// } | ||
// }`, | ||
// errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}] | ||
// }, | ||
// TODO: this is not currently supported, it should be easily supported after the new utils are added | ||
// { | ||
// options: options, | ||
// code: ` | ||
// import React, {Component} from 'react'; | ||
// import {Typography, Text as T} from 'our-source'; | ||
// export default class OurList extends Component { | ||
// render() { | ||
// const titleVal = true; | ||
// return ( | ||
// <T title={titleVal}/> | ||
// ) | ||
// } | ||
// }`, | ||
// errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}] | ||
// }, | ||
], | ||
}); |
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.
That means that if we publish this version, it'll be used in production.
Are we ok with that?
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 think so (does hoping really hard helps? 🤞 ).
Do you have any reservations?