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 some react warnings #5877

Merged
merged 1 commit into from
Aug 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/amo/components/Addon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ const slugIsPositiveID = (slug) => {

export class AddonBase extends React.Component {
static propTypes = {
RatingManager: PropTypes.element,
addon: PropTypes.object.isRequired,
RatingManager: PropTypes.func,
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, didn't expect that but seems this is ok..

addon: PropTypes.object,
clientApp: PropTypes.string.isRequired,
config: PropTypes.object,
defaultInstallSource: PropTypes.string.isRequired,
Expand All @@ -82,9 +82,9 @@ export class AddonBase extends React.Component {
params: PropTypes.object.isRequired,
}).isRequired,
installStatus: PropTypes.string.isRequired,
userAgentInfo: PropTypes.object.isRequired,
addonsByAuthors: PropTypes.array.isRequired,
addonsByAuthors: PropTypes.array,
setCurrentStatus: PropTypes.func.isRequired,
userAgentInfo: PropTypes.object.isRequired,
};

static defaultProps = {
Expand Down
2 changes: 1 addition & 1 deletion src/amo/components/LandingPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class LandingPageBase extends React.Component {
// This is a bug; addonTypeOfResults is used in
// `componentWillReceiveProps()`.
// eslint-disable-next-line react/no-unused-prop-types
addonTypeOfResults: PropTypes.string.isRequired,
addonTypeOfResults: PropTypes.string,
// This is a bug; context is used in `setViewContextType()`.
// eslint-disable-next-line react/no-unused-prop-types
context: PropTypes.string.isRequired,
Expand Down
10 changes: 5 additions & 5 deletions src/amo/components/LanguageTools/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ export class LanguageToolsBase extends React.Component<Props> {
</Tr>
);
})
: Array(50).fill(
// eslint-disable-next-line react/jsx-indent
<Tr>
: Array.from(Array(50)).map((_, i) => (
// eslint-disable-next-line react/jsx-indent, react/no-array-index-key
<Tr key={`LoadingText-${i}`}>
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 need to specify keys all the time when we use map (or .fill but it is not exactly the same thing).

Copy link
Contributor

Choose a reason for hiding this comment

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

yeh i think any child in an array or iterator we do, right?

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

<Td>
<LoadingText />
</Td>
Expand All @@ -245,8 +245,8 @@ export class LanguageToolsBase extends React.Component<Props> {
<Td>
<LoadingText />
</Td>
</Tr>,
)}
</Tr>
))}
</Tbody>
</Table>
</Card>
Expand Down
4 changes: 2 additions & 2 deletions src/core/components/InstallButton/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class InstallButtonBase extends React.Component {
headerURL: PropTypes.string,
i18n: PropTypes.object.isRequired,
iconURL: PropTypes.string,
id: PropTypes.string,
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
install: PropTypes.func.isRequired,
installTheme: PropTypes.func.isRequired,
// See ReactRouterLocationType in 'core/types/router'
Expand All @@ -98,7 +98,7 @@ export class InstallButtonBase extends React.Component {
uninstall: PropTypes.func.isRequired,
updateURL: PropTypes.string,
useButton: PropTypes.bool,
userAgentInfo: PropTypes.string.isRequired,
userAgentInfo: PropTypes.object.isRequired,
version: PropTypes.string,
_InstallTrigger: PropTypes.object,
_config: PropTypes.object,
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/InstallSwitch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class InstallSwitchBase extends React.Component {
headerURL: PropTypes.string,
i18n: PropTypes.object.isRequired,
iconURL: PropTypes.string,
id: PropTypes.string,
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
install: PropTypes.func.isRequired,
installTheme: PropTypes.func.isRequired,
installURL: PropTypes.string,
Expand Down
6 changes: 3 additions & 3 deletions src/core/installAddon.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ export class WithInstallHelpers extends React.Component {
// See ReactRouterLocationType from 'core/types/router'
location: PropTypes.object,
platformFiles: PropTypes.object,
name: PropTypes.string.isRequired,
status: PropTypes.string.isRequired,
type: PropTypes.string.isRequired,
name: PropTypes.string,
status: PropTypes.string,
type: PropTypes.string,
userAgentInfo: PropTypes.object.isRequired,
};

Expand Down
2 changes: 1 addition & 1 deletion src/core/middleware/security.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function getNoScriptStyles(
`src/${appName}/noscript.css`,
);
try {
return fs.readFileSync(cssPath);
return fs.readFileSync(cssPath, 'utf8');
Copy link
Member Author

Choose a reason for hiding this comment

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

Don't recall the error but we should really pass the encoding in readFileSync()

} catch (e) {
if (e.code !== 'ENOENT') {
_log.info(`noscript styles could not be parsed from ${cssPath}`);
Expand Down