aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-04-18 20:44:55 +0300
committereug-vs <eug-vs@keemail.me>2020-04-18 20:44:55 +0300
commit9272b0af3d7b2fba4738a341a1f2776243e0e515 (patch)
treea0c315933d53e87614e806ba0b151234fb400977
parent2c5fa193541eb8b74974731d01312f73951bca17 (diff)
downloadreact-benzin-9272b0af3d7b2fba4738a341a1f2776243e0e515.tar.gz
style: manually fix some errors
-rw-r--r--.eslintrc.json2
-rw-r--r--src/lib/ContentSection/ContentSection.tsx6
-rw-r--r--src/lib/Markdown/Content.tsx12
-rw-r--r--src/lib/Markdown/Markdown.tsx11
4 files changed, 19 insertions, 12 deletions
diff --git a/.eslintrc.json b/.eslintrc.json
index c5c45a7..a755820 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -12,7 +12,9 @@
"jsx-quotes": ["error", "prefer-double"],
"quotes": ["error", "single"],
"react/prop-types": 0,
+ "react/no-children-prop": 0,
"arrow-body-style": 0,
+ "no-cond-assign": 0,
"arrow-parens": [2, "as-needed"],
"no-multiple-empty-lines": [2, { "max": 2, "maxEOF": 1 } ]
}
diff --git a/src/lib/ContentSection/ContentSection.tsx b/src/lib/ContentSection/ContentSection.tsx
index 6b27bba..28b1ad5 100644
--- a/src/lib/ContentSection/ContentSection.tsx
+++ b/src/lib/ContentSection/ContentSection.tsx
@@ -26,11 +26,11 @@ const useStyles = makeStyles(theme => ({
const ContentSection: React.FC<PropTypes> = ({ sectionName, children, level = 0 }) => {
const classes = useStyles();
- level += 2; // Make everything smaller
- if (level > 6) level = 6;
+ let adjustedLevel = level + 2; // Make everything smaller
+ if (adjustedLevel > 6) adjustedLevel = 6;
type Variant = 'h3' | 'h4' | 'h5' | 'h6';
- const variant: Variant = `h${level}` as Variant;
+ const variant: Variant = `h${adjustedLevel}` as Variant;
return (
<>
diff --git a/src/lib/Markdown/Content.tsx b/src/lib/Markdown/Content.tsx
index d64720b..88409fa 100644
--- a/src/lib/Markdown/Content.tsx
+++ b/src/lib/Markdown/Content.tsx
@@ -40,17 +40,19 @@ const Content: React.FC<ParserPropTypes> = ({ rawLines }) => {
let buffer;
if (denotesCodeBlock(line)) {
- const closeIndex = rawLines.findIndex(line => denotesCodeBlock(line));
+ const closeIndex = rawLines.findIndex(rawLine => denotesCodeBlock(rawLine));
const codeBlockLines = rawLines.splice(0, closeIndex + 1).slice(0, closeIndex);
buffer = <CodeBlock rawLines={codeBlockLines} />;
} else if (denotesDottedList(line)) {
- const closeIndex = rawLines.findIndex(line => !denotesDottedList(line));
+ const closeIndex = rawLines.findIndex(rawLine => !denotesDottedList(rawLine));
const dottedListLines = rawLines.splice(0, closeIndex).slice(0, closeIndex);
dottedListLines.unshift(line);
buffer = <ul>{dottedListLines.map(li => <li><Text line={li.slice(2)} /></li>)}</ul>;
} else if ((buffer = denotesOpenHtml(line))) {
const tag = buffer;
- const closeIndex = denotesClosingHtml(line, tag) ? -1 : rawLines.findIndex(line => denotesClosingHtml(line, tag));
+ const closeIndex = denotesClosingHtml(line, tag) ? -1 : rawLines.findIndex(
+ rawLine => denotesClosingHtml(rawLine, tag),
+ );
const htmlLines = rawLines.splice(0, closeIndex + 1);
htmlLines.unshift(line);
buffer = <div dangerouslySetInnerHTML={{ __html: htmlLines.join('\n') }} />;
@@ -65,8 +67,8 @@ const Content: React.FC<ParserPropTypes> = ({ rawLines }) => {
</>
);
} else if (declaresNoLineBreak(line)) {
- const closeIndex = rawLines.findIndex(line => !declaresNoLineBreak(line));
- const lineBreakLines = rawLines.splice(0, closeIndex).map(line => line.slice(0, -2));
+ const closeIndex = rawLines.findIndex(rawLine => !declaresNoLineBreak(rawLine));
+ const lineBreakLines = rawLines.splice(0, closeIndex).map(rawLine => rawLine.slice(0, -2));
lineBreakLines.unshift(line.slice(0, -2));
lineBreakLines.push(rawLines.splice(0, 1)[0]);
buffer = <p>{lineBreakLines.map(lineBreakLine => <Text line={lineBreakLine} />)}</p>;
diff --git a/src/lib/Markdown/Markdown.tsx b/src/lib/Markdown/Markdown.tsx
index 68967c5..cfcf117 100644
--- a/src/lib/Markdown/Markdown.tsx
+++ b/src/lib/Markdown/Markdown.tsx
@@ -8,10 +8,13 @@ interface PropTypes {
url?: string;
}
-const resolveUrls = (line: string, baseUrl: string): string => {
- return line.replace(/src="(?!http)(.*)"[\s>]/, (match, url, offset, string) => `src="${baseUrl}/${url}?sanitize=true"`)
- .replace(/\[(.*\]?.*)\]\((?!http)(.+?)\)/, (match, text, url, offset, string) => `[${text}](${baseUrl}/${url})`);
-};
+const resolveUrls = (line: string, baseUrl: string): string => line.replace(
+ /src="(?!http)(.*)"[\s>]/,
+ (match, url) => `src="${baseUrl}/${url}?sanitize=true"`,
+).replace(
+ /\[(.*\]?.*)\]\((?!http)(.+?)\)/,
+ (match, text, url) => `[${text}](${baseUrl}/${url})`,
+);
const Markdown: React.FC<PropTypes> = ({ data, url }) => {
const [markdown, setMarkdown] = useState<string>(data || '');