Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
7a111d9
Set up TypeScript support basics.
mstange Aug 8, 2025
971a6a3
Update eslintrc
mstange Aug 8, 2025
9a09f31
Remove .js extension from imports.
mstange Aug 8, 2025
c323b62
Add TypeScript types for various dependencies.
mstange Aug 8, 2025
6d93997
Add handwritten types for dependencies which don't have types in @types.
mstange Aug 8, 2025
806318d
Convert some files under src/types/.
mstange Aug 8, 2025
8ccd2d2
Convert some files under src/utils.
mstange Aug 8, 2025
2c89925
Convert more files under src/types.
mstange Aug 8, 2025
ce97bc1
Convert more files under src/utils.
mstange Aug 8, 2025
2b88259
Convert src/types/mocks/ftl.ts.
mstange Aug 8, 2025
ed02f3f
Convert src/app-logic, src/profile-logic, and the rest of src/types a…
mstange Aug 8, 2025
066d548
Convert src/reducers.
mstange Aug 8, 2025
9b82bcd
Convert src/selectors.
mstange Aug 8, 2025
24fe397
Convert src/actions.
mstange Aug 8, 2025
e52c410
Convert app-logic/create-store.js.
mstange Aug 8, 2025
b109476
Convert the rest of src/utils except for window-console.js.
mstange Aug 8, 2025
900b289
Convert components/shared and components/tooltip.
mstange Aug 8, 2025
782abcc
Convert more components.
mstange Aug 8, 2025
9865247
Convert hooks, context, and the remaining components.
mstange Aug 8, 2025
cb923d8
Convert window-console.js and index.js.
mstange Aug 8, 2025
3883c02
Convert src/symbolicator-cli.
mstange Aug 8, 2025
5ef2034
Convert src/test/fixtures.
mstange Aug 8, 2025
325c2f2
Setup for TypeScript tests.
mstange Aug 8, 2025
19a9bbd
Convert test/types.
mstange Aug 8, 2025
2a13ee1
Convert test/unit.
mstange Aug 8, 2025
42e4810
Convert test/store.
mstange Aug 8, 2025
98c6157
Convert test/components.
mstange Aug 8, 2025
caa1bc6
Convert test/integration.
mstange Aug 8, 2025
43ddbd5
Convert test/url-handling.test.js.
mstange Aug 8, 2025
227668a
Convert __mocks__.
mstange Aug 8, 2025
d847d69
Remove src/types/libdef.
mstange Aug 8, 2025
504f153
Remove various flow remnants.
mstange Aug 8, 2025
fcf4ee7
Remove @flow and @noflow annotations.
mstange Aug 8, 2025
6dc238e
Update readme files.
mstange Aug 8, 2025
26ab457
Rename yarn typecheck to yarn ts.
mstange Aug 8, 2025
25ec877
Remove unnecessary --noEmit - we already have noEmit: true inside tsc…
mstange Aug 14, 2025
9914eb5
Remove "alwaysStrict": false; it makes no difference because we're us…
mstange Aug 14, 2025
d9ec496
Remove unnecessary "baseUrl" prop from tsconfig.
mstange Aug 14, 2025
37daba7
Move global.d.ts into src/types/globals.
mstange Aug 14, 2025
8840445
Run npx yarn-deduplicate.
mstange Aug 14, 2025
fe67997
Rename src/utils/flow.ts to types.ts.
mstange Aug 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ jobs:
- checkout-and-dependencies
- run: yarn license-check

flow:
typecheck:
executor: node
resource_class: large
steps:
- checkout-and-dependencies
- run: yarn flow:ci
- run: yarn ts

alex:
executor: node
Expand Down Expand Up @@ -110,7 +110,7 @@ workflows:
- tests
- lint
- build-prod
- flow
- typecheck
- licence-check
- alex
- yarn_lock
Expand Down
68 changes: 34 additions & 34 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
// @flow
module.exports = {
env: {
browser: true,
es6: true,
es2020: true,
node: true,
},
parser: '@babel/eslint-parser',
plugins: ['@babel', 'react', 'flowtype', 'import'],
parser: '@typescript-eslint/parser',
plugins: ['@babel', '@typescript-eslint', 'react', 'import'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:flowtype/recommended',
'prettier',
],
parserOptions: {
ecmaVersion: '2017',
ecmaVersion: '2022',
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
Expand All @@ -37,8 +36,7 @@ module.exports = {
'react/no-unused-class-component-methods': 'error',
'react/no-this-in-sfc': 'error',
'react/no-typos': 'error',
// Flow provides enough coverage over the prop types, and there can be errors
// with some of the more complicated Flow types.
// TypeScript provides enough coverage over the prop types.
'react/prop-types': 'off',
'react/jsx-curly-brace-presence': [
'error',
Expand All @@ -51,20 +49,10 @@ module.exports = {
'react/no-unused-state': 'error',
'react/jsx-no-bind': 'error',
'react/jsx-no-leaked-render': 'error',
'flowtype/require-valid-file-annotation': [
'error',
'always',
{ annotationStyle: 'line' },
],
// no-dupe-keys crashes with recent eslint. See
// https://github.com/gajus/eslint-plugin-flowtype/pull/266 and
// https://github.com/gajus/eslint-plugin-flowtype/pull/302
// 'flowtype/no-dupe-keys': 'error',

// overriding recommended rules
'no-constant-condition': ['error', { checkLoops: false }],
'no-console': ['error', { allow: ['log', 'warn', 'error'] }],
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],

// possible errors
'array-callback-return': 'error',
Expand All @@ -88,21 +76,6 @@ module.exports = {
'no-self-compare': 'error',
'no-throw-literal': 'error',
'no-unmodified-loop-condition': 'error',
// We use the version from the flowtype plugin so that flow assertions don't
// output an error.
'flowtype/no-unused-expressions': 'error',
// The Object type and Function type aren't particularly useful, and usually hide
// type errors. It also blocks a migration to TypeScript. Disable this rule if
// using the Object or Function as generic type bounds.
'flowtype/no-weak-types': [
'error',
{
any: false,
Object: true,
Function: true,
},
],
'flowtype/no-existential-type': 'error',
'no-useless-call': 'error',
'no-useless-computed-key': 'error',
'no-useless-concat': 'error',
Expand All @@ -118,6 +91,34 @@ module.exports = {
'prefer-spread': 'error',
'no-else-return': 'error',
'no-nested-ternary': 'error',

// Use `import type` everywhere we can.
'@typescript-eslint/consistent-type-imports': 'error',
// Allow `as any` escape hatches
'@typescript-eslint/no-explicit-any': 'off',
// Disable a rule that the TypeScript FAQ disapproves of
'@typescript-eslint/no-empty-object-type': 'off',
// Should enable this soon, mostly finds `catch (e)` with unused e
'@typescript-eslint/no-unused-vars': 'off',
// TypeScript imports react-jsx into .tsx files for us
'react/react-in-jsx-scope': 'off',
// Allow @ts-expect-error annotations with descriptions.
'@typescript-eslint/ban-ts-comment': [
'error',
{
// Allow @ts-expect-error annotations with descriptions.
'ts-expect-error': 'allow-with-description',
// Don't allow @ts-ignore or @ts-nocheck because we want to be notified
// when the error goes away so we can remove the annotation - use
// @ts-expect-error instead
'ts-ignore': true,
'ts-nocheck': true,
'ts-check': false, // allow even without description
},
],
// TODO: Re-enable for src when we update to eslint and switch to the new
// config format
'@typescript-eslint/no-require-imports': 'off',
},
// This property is specified both here in addition to the command line in
// package.json.
Expand All @@ -129,15 +130,14 @@ module.exports = {
react: {
pragma: 'React',
version: '17.0',
flowVersion: '0.96.0',
},
'import/resolver': {
alias: {
map: [
['firefox-profiler', './src'],
['firefox-profiler-res', './res'],
],
extensions: ['.js', '.jpg'],
extensions: ['.js', '.ts', '.tsx', '.jpg'],
},
},
},
Expand Down
17 changes: 0 additions & 17 deletions .flowconfig

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ flow-coverage
coverage
.eslintcache
.prettiercache
.tsbuildinfo
webpack.local-config.js
*.orig
*.rej
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = function (config, serverConfig) {
};
```

[Flow](https://flow.org/) is used for type checking. VSCode users can install the ["Flow Language Support" extension](https://marketplace.visualstudio.com/items?itemName=flowtype.flow-for-vscode), and disable VSCode's built-in TypeScript extension in the workspace via the [setup instructions here](https://github.com/flow/flow-for-vscode#setup).
This project uses [TypeScript](https://www.typescriptlang.org/).

## Using Gitpod

Expand Down Expand Up @@ -87,7 +87,7 @@ When working on a new feature and code changes, it's important that things work
- `yarn test-all` - Test all the things!
- `yarn test` - Run the tests in [`./src/test/`](./src/test/).
- `yarn lint` - Run prettier, stylelint, and eslint to check for correct code formatting.
- `yarn flow` - Check the [Flow types](https://flow.org/) for correctness.
- `yarn ts` - Check for TypeScript type correctness.
- `yarn license-check` - Check the dependencies' licenses.
- `git push` and `git commit`
- We have [husky](https://www.npmjs.com/package/husky) installed to run automated checks when committing and pushing.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ yarn install
yarn start
```

[Flow](https://flow.org/) is used for type checking. VSCode users can install the ["Flow Language Support" extension](https://marketplace.visualstudio.com/items?itemName=flowtype.flow-for-vscode), and disable VSCode's built-in TypeScript extension in the workspace via the [setup instructions here](https://github.com/flow/flow-for-vscode#setup).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I see the same text in CONTRIBUTING.md.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

This project uses [TypeScript](https://www.typescriptlang.org/).

You can also develop the Firefox Profiler online in a pre-configured development environment.

Expand Down
6 changes: 0 additions & 6 deletions __mocks__/copy-to-clipboard.js

This file was deleted.

5 changes: 5 additions & 0 deletions __mocks__/copy-to-clipboard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

module.exports = jest.fn() as (arg: string) => void;
21 changes: 0 additions & 21 deletions __mocks__/gecko-profiler-demangle.js

This file was deleted.

19 changes: 19 additions & 0 deletions __mocks__/gecko-profiler-demangle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// This module replaces the wasm-pack generated module 'gecko-profiler-demangle'
// in our tests.
// The reason for this replacement is the fact that wasm-pack (or rather,
// wasm-bindgen), when targeting the browser + webpack, generates an ES6 module
// that node cannot deal with. Most importantly, it uses the syntax
// "import * as wasm from './gecko_profiler_demangle_bg';" in order to load
// the wasm module, which is currently only supported by webpack.
// The long-term path to make this work correctly is to wait for node to
// support ES6 modules (and WASM as ES6 modules) natively [1]. It's possible
// that in the medium term, wasm-bindgen will get support for outputting JS
// files which work in both webpack and in node natively [2].
// [1] https://medium.com/@giltayar/native-es-modules-in-nodejs-status-and-future-directions-part-i-ee5ea3001f71
// [2] https://github.com/rustwasm/wasm-bindgen/issues/233

// There's only one exported function.
// Do the simplest thing possible: no demangling.
export function demangle_any(s: string): string {
return s;
}
12 changes: 6 additions & 6 deletions babel.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
{
// When spreading props, use inline object with spread elements
// directly instead of Babel's `extend` helper or `Object.assign`.
"useSpread": true
"useSpread": true,
// Automatically import 'react' into .tsx files.
"runtime": "automatic"
}
],
// The "all" property is needed for Flow to properly parse the syntax.
// It has trouble understanding when the flow comment is the second comment.
// See: https://github.com/babel/babel/issues/9845
[
"@babel/preset-flow",
"@babel/preset-typescript",
{
"all": true
"isTSX": true,
"allExtensions": true
}
]
],
Expand Down
1 change: 0 additions & 1 deletion bin/check-warn-yarn-changed.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @noflow
// MIT © Sindre Sorhus - sindresorhus.com
// via https://gist.github.com/sindresorhus/7996717

Expand Down
2 changes: 0 additions & 2 deletions bin/l10n-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// have to be at the project root directory to run it.
// Run with '-y' to automatically skip the prompts.

// @flow

const cp = require('child_process');
const readline = require('readline');
const { promisify } = require('util');
Expand Down
1 change: 0 additions & 1 deletion bin/output-fixing-commands.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// @flow

// This file runs before linting commands and intercept errors so that more
// friendly errors can be output.
Expand Down
2 changes: 0 additions & 2 deletions bin/post-checkout.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @noflow

// Older versions of husky use `GIT_PARAMS`, newer versions use `HUSKY_GIT_PARAMS`.
// To make it easier to move between branches, we support both for now. We can
// remove this thin compatibility layer later.
Expand Down
1 change: 0 additions & 1 deletion bin/post-merge.js
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// @noflow
require('./check-warn-yarn-changed.js')('ORIG_HEAD', 'HEAD');
2 changes: 0 additions & 2 deletions bin/post-rewrite.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @noflow

// Older versions of husky use `GIT_PARAMS`, newer versions use `HUSKY_GIT_PARAMS`.
// To make it easier to move between branches, we support both for now. We can
// remove this thin compatibility layer later.
Expand Down
1 change: 0 additions & 1 deletion bin/pre-install.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// @flow

/*:: type AgentsVersion = { [agentName: string]: string }; */

Expand Down
6 changes: 3 additions & 3 deletions docs-developer/CHANGELOG-formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This file documents all changes in the profiler gecko and processed formats.

Note that this is not an exhaustive list. Processed profile format upgraders can be found in [processed-profile-versioning.js](../src/profile-logic/processed-profile-versioning.js) and gecko profile format upgraders can be found in [gecko-profile-versioning.js](../src/profile-logic/gecko-profile-versioning.js). Please refer to them for older upgraders or for exact implementations.
Note that this is not an exhaustive list. Processed profile format upgraders can be found in [processed-profile-versioning.jt](../src/profile-logic/processed-profile-versioning.ts) and gecko profile format upgraders can be found in [gecko-profile-versioning.jt](../src/profile-logic/gecko-profile-versioning.ts). Please refer to them for older upgraders or for exact implementations.

## Processed profile format

Expand Down Expand Up @@ -118,7 +118,7 @@ We've also cleaned up the ResourceTable format:

### Older Versions

Older versions are not documented in this changelog but can be found in [processed-profile-versioning.js](../src/profile-logic/processed-profile-versioning.js).
Older versions are not documented in this changelog but can be found in [processed-profile-versioning.jt](../src/profile-logic/processed-profile-versioning.ts).

## Gecko profile format

Expand Down Expand Up @@ -149,4 +149,4 @@ The `searchable` property is implemented in the marker schema. Previously all th

### Older Versions

Older versions are not documented in this changelog but can be found in [gecko-profile-versioning.js](../src/profile-logic/gecko-profile-versioning.js).
Older versions are not documented in this changelog but can be found in [gecko-profile-versioning.jt](../src/profile-logic/gecko-profile-versioning.ts).
4 changes: 2 additions & 2 deletions docs-developer/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Firefox Profiler development docs

[profiler.firefox.com](https://profiler.firefox.com) is a client for reading profiles from the profiler component built inside of Firefox, known as the Gecko Profiler. It also can read in formats from [a variety of sources](./loading-in-profiles.md). The front-end client is written using JavaScript and [Flow types](https://flow.org/) using [React](https://facebook.github.io/react/) for the UI components and [Redux](http://redux.js.org/) for the state management. Firefox can interact with this client by directly injecting profiles into the webpage via a WebChannel mechanism. This code lives in Mozilla Central under [devtools/client/performance-new](https://searchfox.org/mozilla-central/source/devtools/client/performance-new)
[profiler.firefox.com](https://profiler.firefox.com) is a client for reading profiles from the profiler component built inside of Firefox, known as the Gecko Profiler. It also can read in formats from [a variety of sources](./loading-in-profiles.md). The front-end client is written in [TypeScript](https://www.typescriptlang.org/) using [React](https://facebook.github.io/react/) for the UI components and [Redux](http://redux.js.org/) for the state management. Firefox can interact with this client by directly injecting profiles into the webpage via a WebChannel mechanism. This code lives in Mozilla Central under [devtools/client/performance-new](https://searchfox.org/mozilla-central/source/devtools/client/performance-new)

## The Docs

Expand All @@ -14,7 +14,7 @@
- [React component testing](../src/test/components)
- [Redux store testing](../src/test/store)
- [Unit testing](../src/test/unit)
- [Flow types - `/src/types`](../src/types)
- [Types - `/src/types`](../src/types)
- [Utility files - `/src/utils`](../src/utils)
- [Profiler architecture](./architecture.md)
- [Loading in profiles from various sources](./loading-in-profiles.md)
Expand Down
Loading