Skip to content

Commit 8e36bf7

Browse files
author
Cayla Hamann
committed
Merge remote-tracking branch 'origin' into cayla/fix-linting-errors
2 parents 3465e1e + 9b6ad76 commit 8e36bf7

File tree

4 files changed

+76
-72
lines changed

4 files changed

+76
-72
lines changed

.github/workflows/validate-pr.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,29 @@ jobs:
7575

7676
- name: Jest test
7777
run: yarn test --passWithNoTests
78+
79+
lint:
80+
name: Run Eslint
81+
runs-on: ubuntu-latest
82+
steps:
83+
- name: Checkout repository
84+
uses: actions/checkout@v2
85+
86+
- name: Setup Node.js
87+
uses: actions/setup-node@v2
88+
with:
89+
node-version: 12
90+
91+
- name: Cache dependencies
92+
id: yarn-cache
93+
uses: actions/cache@v2
94+
with:
95+
path: '**/node_modules'
96+
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
97+
98+
- name: Install dependencies
99+
if: steps.yarn-cache.outputs.cache-hit != 'true'
100+
run: yarn install --frozen-lockfile
101+
102+
- name: Run Eslint
103+
run: yarn lint

scripts/actions/add-files-to-translation-queue.js

Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -14,48 +14,61 @@ const { prop } = require('../utils/functional');
1414
* @returns {Promise<Object<string, string[]>>} An updated queue.
1515
*/
1616
const getUpdatedQueue = async (url, queue) => {
17-
const resp = await fetch(url);
18-
const files = await resp.json();
17+
try {
18+
const resp = await fetch(url);
19+
const files = await resp.json();
1920

20-
const mdxFiles = files
21-
.filter((file) => path.extname(file.filename) === '.mdx')
22-
.reduce((files, file) => {
23-
const contents = fs.readFileSync(path.join(process.cwd(), file.filename));
24-
const { data } = frontmatter(contents);
21+
const mdxFiles = files
22+
? files
23+
.filter((file) => path.extname(file.filename) === '.mdx')
24+
.reduce((files, file) => {
25+
const contents = fs.readFileSync(
26+
path.join(process.cwd(), file.filename)
27+
);
28+
const { data } = frontmatter(contents);
2529

26-
return data.translate && data.translate.length
27-
? [...files, { ...file, locales: data.translate }]
28-
: files;
29-
}, []);
30+
return data.translate && data.translate.length
31+
? [...files, { ...file, locales: data.translate }]
32+
: files;
33+
}, [])
34+
: [];
3035

31-
const addedMdxFiles = mdxFiles
32-
.filter((f) => f.status !== 'removed')
33-
.reduce((files, file) => {
34-
return file.locales.reduce(
35-
(acc, locale) => ({
36+
const addedMdxFiles = mdxFiles
37+
.filter((f) => f.status !== 'removed')
38+
.reduce((files, file) => {
39+
return file.locales.reduce(
40+
(acc, locale) => ({
41+
...acc,
42+
[locale]: [...(acc[locale] || []), file.filename],
43+
}),
44+
files
45+
);
46+
}, {});
47+
48+
const removedMdxFileNames = mdxFiles
49+
.filter((f) => f.status === 'removed')
50+
.map(prop('filename'));
51+
52+
const queueFiles =
53+
Object.entries(queue).length === 0 ? Object.entries(queue) : [];
54+
55+
return queueFiles
56+
.map(([locale, files]) => [
57+
locale,
58+
files ? files.filter((f) => !removedMdxFileNames.includes(f)) : [],
59+
])
60+
.reduce(
61+
(acc, [locale, filenames]) => ({
3662
...acc,
37-
[locale]: [...(acc[locale] || []), file.filename],
63+
[locale]: filenames.concat(acc[locale] || []),
3864
}),
39-
files
65+
addedMdxFiles
4066
);
41-
}, {});
42-
43-
const removedMdxFileNames = mdxFiles
44-
.filter((f) => f.status === 'removed')
45-
.map(prop('filename'));
46-
47-
return Object.entries(queue)
48-
.map(([locale, files]) => [
49-
locale,
50-
files.filter((f) => !removedMdxFileNames.includes(f)),
51-
])
52-
.reduce(
53-
(acc, [locale, filenames]) => ({
54-
...acc,
55-
[locale]: filenames.concat(acc[locale] || []),
56-
}),
57-
addedMdxFiles
58-
);
67+
} catch (error) {
68+
console.log(`[!] Unable to get updated queue`);
69+
console.log(error);
70+
process.exit(1);
71+
}
5972
};
6073

6174
/** Entrypoint. */

src/components/TableOfContents.js

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -30,46 +30,14 @@ const TableOfContents = ({ page }) => {
3030
});
3131
}, [mdxAST]);
3232

33-
const raf = useRef();
34-
const navRef = useRef();
35-
const activeRef = useRef();
3633
const headingIds = useMemo(() => headings.map(prop('id')), [headings]);
3734
const activeHash = useActiveHash(headingIds);
38-
const previousActiveHash = usePrevious(activeHash);
39-
const changedActiveHash = activeHash !== previousActiveHash;
40-
4135
const isMobileScreen = useMedia('(max-width: 1240px)');
4236

43-
useEffect(() => {
44-
if (!activeRef.current) {
45-
return;
46-
}
47-
48-
const navRect = navRef.current.getBoundingClientRect();
49-
const activeElementRect = activeRef.current.getBoundingClientRect();
50-
51-
const scrollTop = activeElementRect.top - navRect.top;
52-
const offset = activeRef.current.offsetTop - navRef.current.offsetTop;
53-
const bottom = scrollTop + activeElementRect.height;
54-
const isVisible = bottom <= navRect.height && scrollTop > 0;
55-
56-
if (!isVisible) {
57-
cancelAnimationFrame(raf.current);
58-
59-
raf.current = requestAnimationFrame(() => {
60-
navRef.current.scrollTo({
61-
top: offset - navRect.height / 2,
62-
behavior: 'smooth',
63-
});
64-
});
65-
}
66-
}, [changedActiveHash]);
67-
6837
return headings.length === 0 ? null : (
6938
<PageTools.Section>
7039
<PageTools.Title>On this page</PageTools.Title>
7140
<nav
72-
ref={navRef}
7341
css={css`
7442
max-height: 60vh;
7543
overflow-y: auto;
@@ -88,7 +56,6 @@ const TableOfContents = ({ page }) => {
8856
return (
8957
<li key={id}>
9058
<a
91-
ref={isActive ? activeRef : null}
9259
href={`#${id}`}
9360
className={isActive && !isMobileScreen ? 'active' : null}
9461
css={css`
@@ -112,7 +79,7 @@ const TableOfContents = ({ page }) => {
11279
`}
11380
>
11481
<Icon
115-
name={Icon.TYPE.ARROW_LEFT}
82+
name="fe-arrow-left"
11683
css={css`
11784
display: ${isActive && !isMobileScreen
11885
? 'inline-block'

src/content/docs/serverless-function-monitoring/aws-lambda-monitoring/enable-lambda-monitoring/enable-serverless-monitoring-aws-lambda.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ redirects:
1414
- /docs/serverless-function-monitoring/aws-lambda-monitoring/get-started/enable-serverless-monitoring-aws-lambda
1515
---
1616

17-
This is a test
18-
1917
<Callout variant="tip">
2018
The preferred way of enabling AWS Lambda monitoring with New Relic is via our
2119
Lambda layer. For more information, see [Enable serverless monitoring using

0 commit comments

Comments
 (0)