MEW-01-011: remove dangerouslySetInnerHTML / Add Lint Rule (#955)

This commit is contained in:
William O'Beirne 2018-01-29 15:51:02 -05:00 committed by Daniel Ternyak
parent 9ee30b957d
commit 9fd00a4f70
3 changed files with 22 additions and 20 deletions

View File

@ -105,12 +105,9 @@ export default class Header extends PureComponent<Props, State> {
return ( return (
<div className="Header"> <div className="Header">
{ANNOUNCEMENT_MESSAGE && ( {ANNOUNCEMENT_MESSAGE && (
<div <div className={`Header-announcement is-${ANNOUNCEMENT_TYPE}`}>
className={`Header-announcement is-${ANNOUNCEMENT_TYPE}`} {ANNOUNCEMENT_MESSAGE}
dangerouslySetInnerHTML={{ </div>
__html: ANNOUNCEMENT_MESSAGE
}}
/>
)} )}
<section className="Header-branding"> <section className="Header-branding">

View File

@ -1,3 +1,4 @@
import React from 'react'; // For ANNOUNCEMENT_MESSAGE jsx
import { getValues } from '../utils/helpers'; import { getValues } from '../utils/helpers';
export const languages = require('./languages.json'); export const languages = require('./languages.json');
@ -8,20 +9,23 @@ export const N_FACTOR = 1024;
// Displays at the top of the site, make message empty string to remove. // Displays at the top of the site, make message empty string to remove.
// Type can be primary, warning, danger, success, or info. // Type can be primary, warning, danger, success, or info.
// HTML is allowed inside of the message. // Message must be a JSX element if you want to use HTML.
export const ANNOUNCEMENT_TYPE = 'warning'; export const ANNOUNCEMENT_TYPE = 'warning';
export const ANNOUNCEMENT_MESSAGE = ` export const ANNOUNCEMENT_MESSAGE = (
This is an Alpha build of MyEtherWallet v4. Please only use for testing, <div>
or use v3 at <a href='https://myetherwallet.com'>https://myetherwallet.com</a>. This is an Alpha build of MyEtherWallet v4. Please only use for testing, or use v3 at{' '}
<br/> <a href="https://myetherwallet.com">{'https://myetherwallet.com'}</a>.
<span class="hidden-xs"> <br />
If you're interested in recieving updates about the MyEtherWallet V4 Alpha, you can subscribe via <span className="hidden-xs">
<a href="http://myetherwallet.us16.list-manage.com/subscribe?u=afced8afb6eb2968ba407a144&id=15a7c74eab"> If you're interested in recieving updates about the MyEtherWallet V4 Alpha, you can subscribe
via{' '}
<a href="https://myetherwallet.us16.list-manage.com/subscribe?u=afced8afb6eb2968ba407a144&id=15a7c74eab">
mailchimp mailchimp
</a> </a>{' '}
:) :)
</span> </span>
`; </div>
);
const etherScan = 'https://etherscan.io'; const etherScan = 'https://etherscan.io';
const blockChainInfo = 'https://blockchain.info'; const blockChainInfo = 'https://blockchain.info';

View File

@ -25,7 +25,8 @@
"comment-format": false, "comment-format": false,
"ordered-imports": false, "ordered-imports": false,
"react-anchor-blank-noopener": true, "react-anchor-blank-noopener": true,
"no-external-http-link": true "no-external-http-link": true,
"react-no-dangerous-html": true
}, },
"rulesDirectory": ["node_modules/tslint-microsoft-contrib", "custom_linting_rules"] "rulesDirectory": ["node_modules/tslint-microsoft-contrib", "custom_linting_rules"]
} }