ESLint improvements for Profile Metadata

signup-info-prompt
kibigo! 2017-06-23 18:43:30 -07:00
parent 67adbcc60c
commit 414dfb3955
1 changed files with 11 additions and 11 deletions

View File

@ -41,12 +41,12 @@ const messages = defineMessages({
@kibi@glitch.social <3 @kibi@glitch.social <3
*/ */
const NEW_LINE = /(?:^|\r?\n|<br\s*\/?>)/g const NEW_LINE = /(?:^|\r?\n|<br\s*\/?>)/g;
const YAML_OPENER = /---/; const YAML_OPENER = /---/;
const YAML_CLOSER = /(?:---|\.\.\.)/; const YAML_CLOSER = /(?:---|\.\.\.)/;
const YAML_STRING = /(?:"(?:[^"\n]){1,32}"|'(?:[^'\n]){1,32}'|(?:[^'":\n]){1,32})/g; const YAML_STRING = /(?:"(?:[^"\n]){1,32}"|'(?:[^'\n]){1,32}'|(?:[^'":\n]){1,32})/g;
const YAML_LINE = new RegExp("\\s*" + YAML_STRING.source + "\\s*:\\s*" + YAML_STRING.source + "\\s*", "g"); const YAML_LINE = new RegExp('\\s*' + YAML_STRING.source + '\\s*:\\s*' + YAML_STRING.source + '\\s*', 'g');
const BIO_REGEX = new RegExp(NEW_LINE.source + "*" + YAML_OPENER.source + NEW_LINE.source + "+(?:" + YAML_LINE.source + NEW_LINE.source + "+){0,4}" + YAML_CLOSER.source + NEW_LINE.source + "*"); const BIO_REGEX = new RegExp(NEW_LINE.source + '*' + YAML_OPENER.source + NEW_LINE.source + '+(?:' + YAML_LINE.source + NEW_LINE.source + '+){0,4}' + YAML_CLOSER.source + NEW_LINE.source + '*');
const processBio = (data) => { const processBio = (data) => {
let props = { text: data, metadata: [] }; let props = { text: data, metadata: [] };
@ -56,12 +56,12 @@ const processBio = (data) => {
let start = props.text.indexOf(yaml); let start = props.text.indexOf(yaml);
let end = start + yaml.length; let end = start + yaml.length;
props.text = props.text.substr(0, start) + props.text.substr(end); props.text = props.text.substr(0, start) + props.text.substr(end);
yaml = yaml.replace(NEW_LINE, "\n"); yaml = yaml.replace(NEW_LINE, '\n');
let metadata = (yaml ? yaml.match(YAML_LINE) : []) || []; let metadata = (yaml ? yaml.match(YAML_LINE) : []) || [];
for (let i = 0; i < metadata.length; i++) { for (let i = 0; i < metadata.length; i++) {
let result = metadata[i].match(YAML_STRING); let result = metadata[i].match(YAML_STRING);
if (result[0][0] === '"' || result[0][0] === "'") result[0] = result[0].substr(1, result[0].length - 2); if (result[0][0] === '"' || result[0][0] === '\'') result[0] = result[0].substr(1, result[0].length - 2);
if (result[1][0] === '"' || result[1][0] === "'") result[0] = result[1].substr(1, result[1].length - 2); if (result[1][0] === '"' || result[1][0] === '\'') result[0] = result[1].substr(1, result[1].length - 2);
props.metadata.push(result); props.metadata.push(result);
} }
return props; return props;
@ -199,7 +199,7 @@ export default class Header extends ImmutablePureComponent {
data.push( data.push(
<div <div
className='account__metadata-item' className='account__metadata-item'
title={metadata[i][0] + ":" + metadata[i][1]} title={metadata[i][0] + ':' + metadata[i][1]}
key={i} key={i}
> >
<span dangerouslySetInnerHTML={{ __html: emojify(metadata[i][0]) }} /> <span dangerouslySetInnerHTML={{ __html: emojify(metadata[i][0]) }} />