firefox-devtools / firefox-devtools/profiler

[meta] Use absolute imports to import files from other directories

Open
#2,865 1 comment 0 reactions 0 assignees View on GitHub
code maintenance meta
Dominant language
TypeScript
Stars
1.5k
Forks
491
Avg merge
3d 46m
Merged PRs (30d)
27

Description

Please do not claim this issue, but look for other issues that refer to this one. This issue is for tracking migrating to using absolute imports everywhere in the project. The relative imports are hard to maintain, and hard to search. They are tedious to write, so we've decided to move to using all absolute imports. This issue will track the work to do that.

These will be good first issues to help onboard with the process of creating a pull request, and going through review.

The work here is to take a file, and migrate it to use absolute imports. We have webpack set up to use the "firefox-profiler" as an alias for any path into our `src` folder. Here is an example of changing a single file.

```diff
diff --git a/src/types/actions.js b/src/types/actions.js
index bec5763d..67f8aee8 100644
--- a/src/types/actions.js
+++ b/src/types/actions.js
@@ -1,14 +1,14 @@
/* 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
-import { CallTree } from '../profile-logic/call-tree';
+import { CallTree } from 'firefox-profiler/profile-logic/call-tree';
import type JSZip from 'jszip';
import type {
Profile,
Thread,
ThreadIndex,
Pid,
BrowsingContextID,
} from './profile';
@@ -18,21 +18,21 @@ import type {
GlobalTrack,
LocalTrack,
TrackIndex,
MarkerIndex,
OriginsTimeline,
ActiveTabTimeline,
ThreadsKey,
} from './profile-derived';
-import type { FuncToFuncMap } from '../profile-logic/symbolication';
-import type { TemporaryError } from '../utils/errors';
+import type { FuncToFuncMap } from 'firefox-profiler/profile-logic/symbolication';
+import type { TemporaryError } from 'firefox-profiler/utils/errors';
import type { Transform, TransformStacksPerThread } from './transforms';
-import type { IndexIntoZipFileTable } from '../profile-logic/zip-files';
-import type { TabSlug } from '../app-logic/tabs-handling';
+import type { IndexIntoZipFileTable } from 'firefox-profiler/profile-logic/zip-files';
+import type { TabSlug } from 'firefox-profiler/app-logic/tabs-handling';
import type { UrlState, UploadState, State } from './state';
import type { CssPixels, StartEndRange } from './units';

export type DataSource =
| 'none'
| 'from-file'
| 'from-addon'
| 'local'
```

Note that we only change the imports that use `../` to move up the directory tree. The imports that import from the current directory, or a subdirectory of the current directory, do not need to be changed.

┆Issue is synchronized with this [Jira Task](https://mozilla-hub.atlassian.net/browse/FP-319)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.