Skip to content
This repository was archived by the owner on Jul 19, 2023. It is now read-only.

Commit acc6163

Browse files
eh-am0xPoe
andauthored
chore: lint updates (#705)
* Make rules more strict * Add some documentation to explain what the imports mean --------- Co-authored-by: 二手掉包工程师 <rustin.liu@gmail.com>
1 parent a512ee3 commit acc6163

File tree

11 files changed

+39
-17
lines changed

11 files changed

+39
-17
lines changed

‎.eslintrc.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ module.exports = {
66
],
77
plugins: ['unused-imports'],
88
rules: {
9-
'react-hooks/exhaustive-deps': 'warn',
9+
'react/react-in-jsx-scope': 'error',
10+
'react-hooks/exhaustive-deps': 'error',
1011
'no-duplicate-imports': 'off',
1112
'@typescript-eslint/no-duplicate-imports': 'error',
1213
'@typescript-eslint/no-unused-vars': 'off',
1314
'unused-imports/no-unused-imports': 'error',
1415
'unused-imports/no-unused-vars': [
15-
'warn',
16+
'error',
1617
{
1718
vars: 'all',
1819
varsIgnorePattern: '^_',

‎public/README.md‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Frontend
2+
3+
## tl;dr
4+
```
5+
yarn install
6+
yarn dev
7+
```
8+
9+
## Overrides
10+
This repository currently uses `grafana/pyroscope` components, which then are overridden as necessary,
11+
using typescript's alias and webpack alias configuration. See `tsconfig.json` and `webpack.common.js`
12+
for more info.
13+
14+
15+
### Guidelines for imports
16+
17+
It may be confusing to see different imports, so let's go over the most common examples:
18+
19+
`@webapp` -> Refers to `pyroscope-oss`, aka `grafana/pyroscope` repo.
20+
`@pyroscope/webapp` -> Refers to `pyroscope-oss`, aka `grafana/pyroscope` repo.
21+
`@phlare` -> Refers to code in this repository. Note that this is needed since other
22+
downstream repositories may use this repository, and they also may want to override specific files.
23+
24+
In the future, once both `grafana/pyroscope` and `grafana/phlare` are merged, there will
25+
be no need for `@webapp` and similar to happen, since there will be no `grafana/pyroscope` repo anymore.

‎public/app/components/Sidebar.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function Sidebar() {
3737

3838
React.useLayoutEffect(() => {
3939
dispatch(recalculateSidebar());
40-
}, [windowWidth]);
40+
}, [dispatch, windowWidth]);
4141

4242
const toggleCollapse = () => {
4343
const action = collapsed ? uncollapseSidebar : collapseSidebar;

‎public/app/components/SidebarTenant.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
selectIsMultiTenant,
1111
selectTenantID,
1212
actions,
13-
} from '@webapp/redux/reducers/tenant';
13+
} from '@phlare/redux/reducers/tenant';
1414
import { useAppSelector, useAppDispatch } from '@webapp/redux/hooks';
1515
import styles from '@phlare/components/SidebarTenant.module.css';
1616
import cx from 'classnames';

‎public/app/components/TenantWall.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
selectTenancy,
1414
actions,
1515
selectTenantID,
16-
} from '@webapp/redux/reducers/tenant';
16+
} from '@phlare/redux/reducers/tenant';
1717

1818
export function TenantWall({ children }: { children: React.ReactNode }) {
1919
const dispatch = useAppDispatch();
@@ -26,7 +26,7 @@ export function TenantWall({ children }: { children: React.ReactNode }) {
2626

2727
// Don't rerender all the children when this component changes
2828
// For example, when user wants to change the tenant ID
29-
const memoedChildren = React.useMemo(() => children, []);
29+
const memoedChildren = React.useMemo(() => children, [children]);
3030

3131
switch (tenancy) {
3232
case 'unknown':

‎public/app/overrides/components/ExportData.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ interface ExportDataProps {
1010
exportFlamegraphDotComFn?: unknown;
1111
}
1212

13-
export default function ExportData(props: ExportDataProps) {
13+
export default function ExportData(_props: ExportDataProps) {
1414
return <></>;
1515
}

‎public/app/overrides/services/tags.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ async function fetchLabelsSeries<T>(
5151
);
5252
}
5353

54-
export async function fetchTags(query: string, from: number, until: number) {
54+
export async function fetchTags(query: string, _from: number, _until: number) {
5555
return fetchLabelsSeries(query, function (t) {
5656
const labelNames = t.map((a) => a.name);
5757
return Array.from(new Set(labelNames));
@@ -61,8 +61,8 @@ export async function fetchTags(query: string, from: number, until: number) {
6161
export async function fetchLabelValues(
6262
label: string,
6363
query: string,
64-
from: number,
65-
until: number
64+
_from: number,
65+
_until: number
6666
) {
6767
return fetchLabelsSeries(query, function (t) {
6868
const labelValues = t.filter((l) => label === l.name).map((a) => a.value);

‎public/app/overrides/util/baseurl.spec.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import baseurlForAPI, { baseurl } from '@webapp/util/baseurl';
1+
import { baseurl, baseurlForAPI } from '@webapp/util/baseurl';
22

33
function mockSelector(href: string) {
44
const base = document.createElement('base');

‎public/app/redux/store.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import uiStore, {
2121
} from '@webapp/redux/reducers/ui';
2222
import tenantReducer, {
2323
persistConfig as tenantPersistConfig,
24-
} from '@webapp/redux/reducers/tenant';
24+
} from '@phlare/redux/reducers/tenant';
2525

2626
const reducer = combineReducers({
2727
continuous: continuousReducer,

‎scripts/webpack/webpack.common.js‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ module.exports = {
6565
__dirname,
6666
'../../public/app/redux/hooks'
6767
),
68-
'@webapp/redux/reducers/tenant': path.resolve(
69-
__dirname,
70-
'../../public/app/redux/reducers/tenant'
71-
),
7268
'@webapp/services/apps': path.resolve(
7369
__dirname,
7470
'../../public/app/overrides/services/appNames'

0 commit comments

Comments
 (0)