Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 60 additions & 7 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineConfig } from 'eslint/config';
import js from '@eslint/js';
import tseslint from 'typescript-eslint';
import tsParser from '@typescript-eslint/parser';
import tsPlugin from '@typescript-eslint/eslint-plugin';
import babelPlugin from '@babel/eslint-plugin';
import reactPlugin from 'eslint-plugin-react';
import importPlugin from 'eslint-plugin-import';
Expand All @@ -11,7 +12,7 @@ import jestDomPlugin from 'eslint-plugin-jest-dom';
import prettierConfig from 'eslint-config-prettier';
import globals from 'globals';

export default [
export default defineConfig(
// Global ignores
{
ignores: [
Expand All @@ -27,8 +28,8 @@ export default [
// Base JavaScript config
js.configs.recommended,

// TypeScript config
...tsPlugin.configs['flat/recommended'],
// TypeScript config with type checking
...tseslint.configs.recommendedTypeChecked,

// React config
reactPlugin.configs.flat.recommended,
Expand All @@ -50,6 +51,7 @@ export default [
ecmaFeatures: {
jsx: true,
},
// Note: projectService is configured per file type below
},
},
plugins: {
Expand Down Expand Up @@ -178,6 +180,40 @@ export default [
},
],
'@typescript-eslint/no-require-imports': 'off',

// Disable "no-unsafe" checks which complain about using "any" freely.
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-return': 'off',

// Disable this one due to false positives when narrowing return types,
// see https://github.com/typescript-eslint/typescript-eslint/issues/6951
// (it can make `yarn ts` fail after `yarn lint-fix`)
'@typescript-eslint/no-unnecessary-type-assertion': 'off',

'@typescript-eslint/no-unnecessary-condition': [
'error',
{
allowConstantLoopConditions: 'only-allowed-literals',
checkTypePredicates: true,
},
],

// Consider enabling these in the future
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/only-throw-error': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/await-thenable': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/no-base-to-string': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/prefer-promise-reject-errors': 'off',
'@typescript-eslint/no-array-delete': 'off',
},
linterOptions: {
// This property is specified both here in addition to the command line in
Expand All @@ -189,6 +225,23 @@ export default [
},
},

// TypeScript files - enable type checking
{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},

// JavaScript files - disable type-aware rules (they can't run on JS anyway)
{
files: ['**/*.js', '**/*.mjs', '**/*.cjs'],
...tseslint.configs.disableTypeChecked,
},

// Source files - enable stricter TypeScript rules
{
files: ['src/**/*.ts', 'src/**/*.tsx'],
Expand Down Expand Up @@ -255,7 +308,7 @@ export default [
},
},

// __mocks__ directory configuration
// __mocks__ directory configuration - globals
{
files: ['__mocks__/**/*'],
languageOptions: {
Expand All @@ -266,5 +319,5 @@ export default [
},

// Prettier config (must be last to override other formatting rules)
prettierConfig,
];
prettierConfig
);
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
"stylelint-config-idiomatic-order": "^10.0.0",
"stylelint-config-standard": "^39.0.0",
"typescript": "^5.8.3",
"typescript-eslint": "^8.44.0",
"webpack": "^5.101.3",
"webpack-cli": "^6.0.1",
"webpack-dev-server": "^5.2.2",
Expand Down
1 change: 0 additions & 1 deletion src/actions/profile-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,6 @@ export function isolateProcess(
for (const localTrack of localTracks) {
if (
localTrack.type === 'thread' &&
localTrack.threadIndex !== undefined &&
oldSelectedThreadIndexes.has(localTrack.threadIndex)
) {
newSelectedThreadIndexes.add(localTrack.threadIndex);
Expand Down
6 changes: 1 addition & 5 deletions src/actions/receive-profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ async function _extractJsonFromResponse(
message = 'The network request to load the profile was aborted.';
} else if (fileType === 'application/json') {
message = 'The profile’s JSON could not be decoded.';
} else if (fileType === null && arrayBuffer !== null) {
} else if (arrayBuffer !== null) {
// If the content type is not specified, use a raw array buffer
// to fallback to other supported profile formats.
return arrayBuffer;
Expand Down Expand Up @@ -1163,10 +1163,6 @@ export function retrieveProfileOrZipFromUrl(
serializedProfile,
profileUrl
);
if (profile === undefined) {
throw new Error('Unable to parse the profile.');
}

await dispatch(loadProfile(profile, {}, initialLoad));
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/app-logic/url-handling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ const _upgraders: {
// will not be preserved.
const transforms = parseTransforms(query.transforms);

if (!transforms || transforms.length === 0) {
if (transforms.length === 0) {
// We don't have any transforms to upgrade.
return;
}
Expand Down
1 change: 1 addition & 0 deletions src/app-logic/web-channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export type ResponseFromBrowser =
| GetSymbolTableResponse
| QuerySymbolicationApiResponse
| GetPageFaviconsResponse
// eslint-disable-next-line @typescript-eslint/no-duplicate-type-constituents
| OpenScriptInTabDebuggerResponse;

type StatusQueryResponse = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/app/CompareHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type State = {
};

class CompareHomeImpl extends PureComponent<Props, State> {
override state = { profile1: '', profile2: '' };
override state: State = { profile1: '', profile2: '' };

handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const { name, value } = event.target;
Expand Down
2 changes: 1 addition & 1 deletion src/components/app/FooterLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class FooterLinks extends PureComponent<{}, State> {
this.setState({ hide: true });
};

override state = {
override state: State = {
hide: false,
};

Expand Down
4 changes: 2 additions & 2 deletions src/components/app/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ActionButtons extends React.PureComponent<
> {
_fileInput: HTMLInputElement | null = null;

override state = {
override state: ActionButtonsState = {
isLoadFromUrlPressed: false,
};

Expand Down Expand Up @@ -129,7 +129,7 @@ class LoadFromUrl extends React.PureComponent<
LoadFromUrlProps,
LoadFromUrlState
> {
override state = {
override state: LoadFromUrlState = {
value: '',
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/app/KeyboardShortcut.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type State = {
* Display a list of shortcuts that overlays the screen.
*/
export class KeyboardShortcut extends React.PureComponent<Props, State> {
override state = {
override state: State = {
isOpen: false,
// The eslint error is a false positive due to how it's used, see the line:
// `focusAfterClosed.focus()`
Expand Down
4 changes: 2 additions & 2 deletions src/components/app/ListOfPublishedProfiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class PublishedProfile extends React.PureComponent<
PublishedProfileProps,
PublishedProfileState
> {
override state = {
override state: PublishedProfileState = {
confirmDialogIsOpen: false,
};

Expand Down Expand Up @@ -162,7 +162,7 @@ type State = {
export class ListOfPublishedProfiles extends PureComponent<Props, State> {
_isMounted = false;

override state = {
override state: State = {
uploadedProfileInformationList: null,
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/app/MenuButtons/MetaInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type Props = ConnectedProps<{}, StateProps, DispatchProps>;
* This component formats the profile's meta information into a dropdown panel.
*/
class MetaInfoPanelImpl extends React.PureComponent<Props, State> {
override state = { showsMoreInfo: false };
override state: State = { showsMoreInfo: false };

/**
* This method provides information about the symbolication status, and a button
Expand Down
2 changes: 1 addition & 1 deletion src/components/app/MenuButtons/Permalink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class MenuButtonsPermalink extends React.PureComponent<Props, State> {
this._permalinkTextField = elem;
};

override state = {
override state: State = {
fullUrl: '',
shortUrl: '',
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/app/ProfileName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type State = {
* state), and then when active, it switches to an input, which is only fixed in size.
*/
class ProfileNameImpl extends React.PureComponent<Props, State> {
override state = {
override state: State = {
focusedWithKey: null,
focusGeneration: 0,
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/js-tracer/Canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const ROW_LABEL_OFFSET_LEFT: CssPixels = 5;
const FONT_SIZE: CssPixels = 10;

class JsTracerCanvasImpl extends React.PureComponent<Props, State> {
override state = {
override state: State = {
hasFirstDraw: false,
};
_textMeasurement: TextMeasurement | null = null;
Expand Down
2 changes: 1 addition & 1 deletion src/components/js-tracer/Chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class JsTracerChartLoader extends React.PureComponent<
ChartLoaderProps,
ChartLoaderState
> {
override state = {
override state: ChartLoaderState = {
// The loader needs to be mounted before rendering the chart, as it has expensive
// selectors.
readyToRenderExpensiveChart: false,
Expand Down
2 changes: 1 addition & 1 deletion src/components/network-chart/NetworkChartRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ export class NetworkChartRow extends React.PureComponent<
NetworkChartRowProps,
State
> {
override state = {
override state: State = {
pageX: 0,
pageY: 0,
hovered: false,
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/ButtonWithPanel/ArrowPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type State = {

export class ArrowPanel extends React.PureComponent<Props, State> {
closeTimeout: NodeJS.Timeout | null = null;
override state = {
override state: State = {
open: false,
isClosing: false,
openGeneration: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/Draggable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class Draggable<T> extends React.PureComponent<Props<T>, State> {
mouseMoveHandler: (param: MouseEvent) => void;
mouseUpHandler: (param: MouseEvent) => void;
} | null = null;
override state = {
override state: State = {
dragging: false,
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/MarkerSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type State = {
};

class MarkerSettingsImpl extends PureComponent<Props, State> {
override state = {
override state: State = {
isMarkerFiltersMenuVisible: false,
isFilterMenuVisibleOnMouseDown: false,
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/PanelSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Props = {
type State = { searchFieldFocused: boolean };

export class PanelSearch extends React.PureComponent<Props, State> {
override state = { searchFieldFocused: false };
override state: State = { searchFieldFocused: false };
_onSearchFieldIdleAfterChange = (value: string) => {
this.props.onSearch(value);
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/Reorderable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class Reorderable extends React.PureComponent<Props, State> {
},
};

override state = {
override state: State = {
phase: 'RESTING' as const,
manipulatingIndex: -1,
destinationIndex: -1,
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/TreeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ export class TreeView<
initialWidth: CssPixels;
} | null = null;

override state = {
override state: TreeViewState = {
// This contains the current widths, while or after the user resizes them.
fixedColumnWidths: null,

Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/VirtualList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export class VirtualList<Item> extends React.PureComponent<
VirtualListState
> {
_container: { current: HTMLDivElement | null } = React.createRef();
override state = { scrollTop: 0, containerHeight: 0 };
override state: VirtualListState = { scrollTop: 0, containerHeight: 0 };

override componentDidMount() {
document.addEventListener('copy', this._onCopy, false);
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/Warning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type State = {
};

export class Warning extends PureComponent<Props, State> {
override state = { isNoticeDisplayed: true };
override state: State = { isNoticeDisplayed: true };

_onHideClick = () => {
this.setState({
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/WithSize.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function withSize<Props>(
Wrapped: React.ComponentType<PropsWithSize<Props>>
): React.ComponentType<Props> {
return class WithSizeWrapper extends React.PureComponent<Props, State> {
override state = { width: 0, height: 0 };
override state: State = { width: 0, height: 0 };
_container: HTMLElement | null = null;

override componentDidMount() {
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/thread/SampleGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class ThreadSampleGraphCanvas extends React.PureComponent<CanvasProps> {
}

export class ThreadSampleGraphImpl extends PureComponent<Props, State> {
override state = {
override state: State = {
hoveredPixelState: null,
mouseX: 0,
mouseY: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/components/timeline/FullTimeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class TimelineSettingsHiddenTracks extends React.PureComponent<{
}

class FullTimelineImpl extends React.PureComponent<Props, State> {
override state = {
override state: State = {
initialSelected: null,
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/timeline/Markers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ type State = {
};

class TimelineMarkers extends React.PureComponent<Props, State> {
override state = {
override state: State = {
hoveredMarkerIndex: null,
mouseDownMarker: null,
mouseX: 0,
Expand Down
Loading