Skip to content

Commit

Permalink
Merge pull request #2025 from codecrafters-io/import-sorting
Browse files Browse the repository at this point in the history
import sorting
  • Loading branch information
rohitpaulk authored Jul 27, 2024
2 parents d72e024 + ebf4b79 commit e0e6f9d
Show file tree
Hide file tree
Showing 146 changed files with 706 additions and 436 deletions.
13 changes: 12 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,22 @@ module.exports = {
},
},
plugins: ['ember', '@typescript-eslint'],
extends: ['eslint:recommended', 'plugin:ember/recommended', 'plugin:prettier/recommended'],
extends: ['eslint:recommended', 'plugin:ember/recommended', 'plugin:prettier/recommended', 'plugin:import/recommended', 'plugin:import/typescript'],
env: {
browser: true,
},
rules: {
'import/order': [
'error',
{
groups: [],
'newlines-between': 'never',
// alphabetize: {
// order: 'asc',
// },
},
],
'import/no-unresolved': 'off',
'padding-line-between-statements': [
'error',
{ blankLine: 'always', prev: '*', next: 'return' },
Expand Down
2 changes: 1 addition & 1 deletion app/adapters/application.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import JSONAPIAdapter from '@ember-data/adapter/json-api';
import { inject as service } from '@ember/service';
import config from 'codecrafters-frontend/config/environment';
import posthog from 'posthog-js';
import { posthog } from 'posthog-js';
import type SessionTokenStorageService from 'codecrafters-frontend/services/session-token-storage';
import type VersionTrackerService from 'codecrafters-frontend/services/version-tracker';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Component from '@glimmer/component';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { tracked } from '@glimmer/tracking';

import amazonImage from '/assets/images/company-logos/amazon-company-logo.svg';
import appleImage from '/assets/images/company-logos/apple-company-logo.svg';
import coinbaseImage from '/assets/images/company-logos/coinbase-company-logo.svg';
Expand Down
2 changes: 0 additions & 2 deletions app/components/badges-page/locked-badge-preview.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import Component from '@glimmer/component';

// @ts-ignore
import lockedBadgePreviewImage from '/assets/images/badges/locked-badge-preview.svg';

export interface Signature {
Expand Down
2 changes: 0 additions & 2 deletions app/components/blocks/concept-animation-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { run } from '@ember/runloop';
import { ConceptAnimationBlock } from 'codecrafters-frontend/utils/blocks';

// @ts-ignore
import networkingProtocolsLayers from '/assets/concept-animations/network-protocols/layers.lottie.json';
// @ts-ignore
Expand All @@ -20,7 +19,6 @@ import networkingProtocolsLayer2 from '/assets/concept-animations/network-protoc
import networkingProtocolsLayer3 from '/assets/concept-animations/network-protocols/layer-3.lottie.json';
// @ts-ignore
import networkingProtocolsLayer4 from '/assets/concept-animations/network-protocols/layer-4.lottie.json';

// @ts-ignore
import tcpOverviewConnectionIdentifiers from '/assets/concept-animations/tcp-overview/connection-identifiers.lottie.json';
// @ts-ignore
Expand Down
1 change: 0 additions & 1 deletion app/components/blocks/concept-question-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { inject as service } from '@ember/service';
import Store from '@ember-data/store';
import { ConceptQuestionBlock } from 'codecrafters-frontend/utils/blocks';
import { action } from '@ember/object';

import Prism from 'prismjs';
import 'prismjs/components/prism-rust'; // This is the only one we use in concepts at the moment
import { tracked } from '@glimmer/tracking';
Expand Down
2 changes: 0 additions & 2 deletions app/components/blocks/markdown-block.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import Component from '@glimmer/component';
import { MarkdownBlock } from 'codecrafters-frontend/utils/blocks';
import { action } from '@ember/object';

import Prism from 'prismjs';

import 'prismjs';
import 'prismjs/components/prism-rust'; // This is the only one we use in concepts at the moment

type Signature = {
Expand Down
3 changes: 1 addition & 2 deletions app/components/code-mirror.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { waitFor } from '@ember/test-waiters';

import {
EditorView,
crosshairCursor,
Expand All @@ -18,7 +17,7 @@ import {
rectangularSelection,
scrollPastEnd,
} from '@codemirror/view';
import { type Extension, Compartment, EditorState } from '@codemirror/state';
import { Compartment, EditorState, type Extension } from '@codemirror/state';
import { defaultKeymap, history, historyKeymap, indentWithTab } from '@codemirror/commands';
import { highlightSelectionMatches } from '@codemirror/search';
import { autocompletion, closeBrackets, closeBracketsKeymap, completionKeymap } from '@codemirror/autocomplete';
Expand Down
1 change: 0 additions & 1 deletion app/components/code-walkthrough.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { parse } from 'node-html-parser';
import Prism from 'prismjs';
import showdown from 'showdown';

import 'prismjs';
import 'prismjs/components/prism-c';
import 'prismjs/components/prism-go';
import 'prismjs/components/prism-nim';
Expand Down
1 change: 0 additions & 1 deletion app/components/comment-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { tracked } from '@glimmer/tracking';

import 'prismjs';
import 'prismjs/components/prism-c';
import 'prismjs/components/prism-go';
import 'prismjs/components/prism-nim';
Expand Down
12 changes: 4 additions & 8 deletions app/components/concept.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@ import Component from '@glimmer/component';
import ConceptEngagementModel from 'codecrafters-frontend/models/concept-engagement';
import ConceptModel from 'codecrafters-frontend/models/concept';
import config from 'codecrafters-frontend/config/environment';
import { action } from '@ember/object';
import type { Block } from 'codecrafters-frontend/models/concept';

// @ts-ignore
import { cached } from '@glimmer/tracking';

import { ConceptQuestionBlock } from 'codecrafters-frontend/utils/blocks';
import { inject as service } from '@ember/service';
import { task } from 'ember-concurrency';
import { tracked } from '@glimmer/tracking';
import { TrackedSet } from 'tracked-built-ins';
import { action } from '@ember/object';
import { cached, tracked } from '@glimmer/tracking';
import { inject as service } from '@ember/service';
import { next } from '@ember/runloop';
import { task } from 'ember-concurrency';

interface Signature {
Args: {
Expand Down
3 changes: 1 addition & 2 deletions app/components/course-leaderboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import CourseLeaderboardEntry from 'codecrafters-frontend/utils/course-leaderboa
import fade from 'ember-animated/transitions/fade';
import LeaderboardPoller from 'codecrafters-frontend/utils/leaderboard-poller';
import move from 'ember-animated/motions/move';
import { action } from '@ember/object';
import { action, get } from '@ember/object';
import { fadeIn, fadeOut } from 'ember-animated/motions/opacity';
import { get } from '@ember/object';
import { inject as service } from '@ember/service';
import { tracked } from '@glimmer/tracking';
import type ActionCableConsumerService from 'codecrafters-frontend/services/action-cable-consumer';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import Component from '@glimmer/component';
import CourseExtensionModel from 'codecrafters-frontend/models/course-extension';
import CoursePageStateService from 'codecrafters-frontend/services/course-page-state';
import RepositoryModel from 'codecrafters-frontend/models/repository';
import RepositoryPoller from 'codecrafters-frontend/utils/repository-poller';
import RepositoryStageListItemModel from 'codecrafters-frontend/models/repository-stage-list-item';
import Store from '@ember-data/store';
import { action } from '@ember/object';
import { next } from '@ember/runloop';
import { service } from '@ember/service';
import { task } from 'ember-concurrency';
import { tracked } from '@glimmer/tracking';
import { next } from '@ember/runloop';

// @ts-ignore
import RepositoryPoller from 'codecrafters-frontend/utils/repository-poller';
import CoursePageStateService from 'codecrafters-frontend/services/course-page-state';
import RepositoryStageListItemModel from 'codecrafters-frontend/models/repository-stage-list-item';

type Signature = {
Element: HTMLDivElement;
Expand Down
1 change: 0 additions & 1 deletion app/components/course-page/course-stage-solution-modal.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Component from '@glimmer/component';

import { action } from '@ember/object';

export default class CourseStageSolutionModalComponent extends Component {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type AuthenticatorService from 'codecrafters-frontend/services/authentica
import type AnalyticsEventTrackerService from 'codecrafters-frontend/services/analytics-event-tracker';
import type UserModel from 'codecrafters-frontend/models/user';
import type CommunityCourseStageSolutionCommentModel from 'codecrafters-frontend/models/community-course-stage-solution-comment';
import { IsUnchangedFileComparison, type FileComparison, type UnchangedFileComparison } from 'codecrafters-frontend/utils/file-comparison';
import { type FileComparison, IsUnchangedFileComparison, type UnchangedFileComparison } from 'codecrafters-frontend/utils/file-comparison';
import { tracked } from '@glimmer/tracking';

type Signature = {
Expand Down
1 change: 0 additions & 1 deletion app/components/course-page/share-progress-modal/icon.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Component from '@glimmer/component';
import { capitalize } from '@ember/string';

import discordLogoImage from 'codecrafters-frontend/images/social-icons/discord.svg';
import linkedinLogoImage from 'codecrafters-frontend/images/social-icons/linkedin.svg';
import slackLogoImage from 'codecrafters-frontend/images/social-icons/slack.svg';
Expand Down
2 changes: 1 addition & 1 deletion app/components/dark-mode-toggle-option.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Component from '@glimmer/component';
import { toRight, toLeft } from 'ember-animated/transitions/move-over';
import { toLeft, toRight } from 'ember-animated/transitions/move-over';

export interface Signature {
Element: HTMLButtonElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Store from '@ember-data/store';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { tracked } from '@glimmer/tracking';

import amazonImage from '/assets/images/company-logos/amazon-company-logo.svg';
import appleImage from '/assets/images/company-logos/apple-company-logo.svg';
import coinbaseImage from '/assets/images/company-logos/coinbase-company-logo.svg';
Expand Down
2 changes: 0 additions & 2 deletions app/components/submission-logs-preview.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import Component from '@glimmer/component';
import { AnsiUp } from 'ansi_up';
import { action } from '@ember/object';

// @ts-ignore
import { cached, tracked } from '@glimmer/tracking';
import type SubmissionModel from 'codecrafters-frontend/models/submission';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Component from '@glimmer/component';
import { toRight, toLeft } from 'ember-animated/transitions/move-over';
import { toLeft, toRight } from 'ember-animated/transitions/move-over';

type Signature = {
Element: HTMLButtonElement;
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/demo/code-mirror.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import Controller from '@ember/controller';
import { action } from '@ember/object';
import { service } from '@ember/service';
import { tracked } from '@glimmer/tracking';

import { type Extension } from '@codemirror/state';

import type DarkModeService from 'codecrafters-frontend/services/dark-mode';
import { codeCraftersDark, codeCraftersLight } from 'codecrafters-frontend/utils/code-mirror-themes';

Expand Down
3 changes: 1 addition & 2 deletions app/controllers/loading.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { later } from '@ember/runloop';
import { cancel } from '@ember/runloop';
import { later, cancel } from '@ember/runloop';

export default class LoadingController extends Controller {
cancellable;
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/format-duration.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { helper } from '@ember/component/helper';
import { formatDuration as libFormatDuration, intervalToDuration } from 'date-fns';
import { intervalToDuration, formatDuration as libFormatDuration } from 'date-fns';

const formatDuration = helper(function formatDuration([durationInSeconds]: [number] /*, named*/) {
const duration = intervalToDuration({ start: 0, end: durationInSeconds * 1000 });
Expand Down
2 changes: 1 addition & 1 deletion app/instance-initializers/posthog.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import config from 'codecrafters-frontend/config/environment';
import posthog from 'posthog-js';
import { posthog } from 'posthog-js';

export function initialize() {
if (typeof FastBoot === 'undefined' && config.environment === 'production') {
Expand Down
1 change: 0 additions & 1 deletion app/mixins/votable.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable ember/no-new-mixins */
import Mixin from '@ember/object/mixin';

import type UpvoteModel from 'codecrafters-frontend/models/upvote';
import type AuthenticatorService from 'codecrafters-frontend/services/authenticator';
import type DownvoteModel from 'codecrafters-frontend/models/downvote';
Expand Down
3 changes: 1 addition & 2 deletions app/models/analytics-event.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Model from '@ember-data/model';
import { attr } from '@ember-data/model';
import Model, { attr } from '@ember-data/model';

export default class AnalyticsEvent extends Model {
@attr('string') declare name: string;
Expand Down
3 changes: 1 addition & 2 deletions app/models/autofix-request.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Model from '@ember-data/model';
import Model, { attr, belongsTo } from '@ember-data/model';
import RepositoryModel from 'codecrafters-frontend/models/repository';
import SubmissionModel from 'codecrafters-frontend/models/submission';
import { attr, belongsTo } from '@ember-data/model';

export default class AutofixRequestModel extends Model {
@belongsTo('submission', { async: false, inverse: 'autofixRequests' }) declare submission: SubmissionModel;
Expand Down
3 changes: 1 addition & 2 deletions app/models/badge-award.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import BadgeModel from 'codecrafters-frontend/models/badge';
import Model from '@ember-data/model';
import Model, { attr, belongsTo } from '@ember-data/model';
import UserModel from 'codecrafters-frontend/models/user';
import type CourseStageCompletionModel from 'codecrafters-frontend/models/course-stage-completion';
import { attr, belongsTo } from '@ember-data/model';

export default class BadgeAwardModel extends Model {
@belongsTo('badge', { async: false, inverse: null }) declare badge: BadgeModel;
Expand Down
5 changes: 1 addition & 4 deletions app/models/badge.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import Model from '@ember-data/model';
import { attr, hasMany } from '@ember-data/model';

import Model, { attr, hasMany } from '@ember-data/model';
import lockedBadgePreviewImage from '/assets/images/badges/locked-badge-preview.svg';
import curieBadgeImage from '/assets/images/badges/curie-badge.svg';
import hamiltonBadgeImage from '/assets/images/badges/hamilton-badge.svg';
import hopperBadgeImage from '/assets/images/badges/hopper-badge.svg';
import teslaBadgeImage from '/assets/images/badges/tesla-badge.svg';
import turingBadgeImage from '/assets/images/badges/turing-badge.svg';

import type BadgeAwardModel from './badge-award';

export default class Badge extends Model {
Expand Down
5 changes: 2 additions & 3 deletions app/models/charge.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { attr, belongsTo } from '@ember-data/model';
import { equal } from '@ember/object/computed'; // eslint-disable-line ember/no-computed-properties-in-native-classes
import Model from '@ember-data/model';
import Model, { attr, belongsTo } from '@ember-data/model';
import config from 'codecrafters-frontend/config/environment';
import type UserModel from 'codecrafters-frontend/models/user';
import { equal } from '@ember/object/computed'; // eslint-disable-line ember/no-computed-properties-in-native-classes

export default class Charge extends Model {
@attr('number') declare amount: number;
Expand Down
3 changes: 1 addition & 2 deletions app/models/code-walkthrough.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Model from '@ember-data/model';
import { attr } from '@ember-data/model';
import Model, { attr } from '@ember-data/model';
import redisLogo from '/assets/images/challenge-logos/challenge-logo-redis.svg';
import dockerLogo from '/assets/images/challenge-logos/challenge-logo-docker.svg';
import gitLogo from '/assets/images/challenge-logos/challenge-logo-git.svg';
Expand Down
2 changes: 0 additions & 2 deletions app/models/community-course-stage-solution-comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import AuthenticatorService from 'codecrafters-frontend/services/authenticator';
import Model, { attr, belongsTo } from '@ember-data/model';
import { inject as service } from '@ember/service';
import { memberAction } from 'ember-api-actions';

import VotableMixin from '../mixins/votable';
import IsCommentMixin from '../mixins/is-comment';

import type CommunityCourseStageSolutionModel from 'codecrafters-frontend/models/community-course-stage-solution';
import type LanguageModel from 'codecrafters-frontend/models/language';
import type UserModel from 'codecrafters-frontend/models/user';
Expand Down
14 changes: 6 additions & 8 deletions app/models/community-course-stage-solution.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import Model, { attr, belongsTo, hasMany } from '@ember-data/model';
import ViewableMixin from 'codecrafters-frontend/mixins/viewable'; // eslint-disable-line ember/no-mixins
import VotableMixin from 'codecrafters-frontend/mixins/votable'; // eslint-disable-line ember/no-mixins
import type AuthenticatorService from 'codecrafters-frontend/services/authenticator';
import type CommunitySolutionEvaluationModel from './community-solution-evaluation';
import type CourseStageCommentModel from './course-stage-comment';
import type CourseStageModel from './course-stage';
import type CourseStageScreencastModel from './course-stage-screencast';
import type LanguageModel from './language';
import type TrustedCommunitySolutionEvaluationModel from './trusted-community-solution-evaluation';
import type UserModel from './user';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { memberAction } from 'ember-api-actions';
import { FileComparisonFromJSON, type FileComparison } from 'codecrafters-frontend/utils/file-comparison';

/* eslint-disable ember/no-mixins */
import ViewableMixin from 'codecrafters-frontend/mixins/viewable';
import type CourseStageScreencastModel from './course-stage-screencast';
import VotableMixin from 'codecrafters-frontend/mixins/votable';
import type CommunitySolutionEvaluationModel from './community-solution-evaluation';
import type TrustedCommunitySolutionEvaluationModel from './trusted-community-solution-evaluation';
import { type FileComparison, FileComparisonFromJSON } from 'codecrafters-frontend/utils/file-comparison';

export default class CommunityCourseStageSolutionModel extends Model.extend(ViewableMixin, VotableMixin) {
static defaultIncludedResources = ['user', 'language', 'comments', 'comments.user', 'comments.target', 'course-stage'];
Expand Down
3 changes: 1 addition & 2 deletions app/models/community-solution-evaluation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Model from '@ember-data/model';
import { attr, belongsTo } from '@ember-data/model';
import Model, { attr, belongsTo } from '@ember-data/model';
import type CommunityCourseStageSolutionModel from './community-course-stage-solution';
import { tracked } from '@glimmer/tracking';
import type CommunitySolutionEvaluatorModel from './community-solution-evaluator';
Expand Down
3 changes: 1 addition & 2 deletions app/models/community-solution-evaluator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Model from '@ember-data/model';
import { attr, belongsTo, hasMany } from '@ember-data/model';
import Model, { attr, belongsTo, hasMany } from '@ember-data/model';
import type CourseModel from './course';
import type LanguageModel from './language';
import type CommunitySolutionEvaluationModel from './community-solution-evaluation';
Expand Down
3 changes: 1 addition & 2 deletions app/models/concept-engagement.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import ConceptModel from 'codecrafters-frontend/models/concept';
import UserModel from 'codecrafters-frontend/models/user';
import Model from '@ember-data/model';
import { attr, belongsTo } from '@ember-data/model';
import Model, { attr, belongsTo } from '@ember-data/model';

export default class ConceptEngagementModel extends Model {
@belongsTo('concept', { async: false, inverse: 'engagements' }) declare concept: ConceptModel;
Expand Down
3 changes: 1 addition & 2 deletions app/models/concept-group.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Model, { belongsTo } from '@ember-data/model';
import Model, { belongsTo, attr } from '@ember-data/model';
import UserModel from 'codecrafters-frontend/models/user';
import { attr } from '@ember-data/model';

export default class ConceptGroupModel extends Model {
@belongsTo('user', { async: false, inverse: null }) author!: UserModel;
Expand Down
Loading

0 comments on commit e0e6f9d

Please sign in to comment.