Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace sort-imports with import/order eslint rule #102

Merged
merged 3 commits into from
Jul 2, 2024
Merged
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
15 changes: 7 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ module.exports = {
},
],
curly: 'error',
'import/order': [
'error',
{
groups: [['external', 'builtin']],
'newlines-between': 'always',
},
],
'jsx-a11y/anchor-is-valid': 'off',
'no-console': 'error',
'no-switch-statements/no-switch': 'error',
Expand Down Expand Up @@ -78,14 +85,6 @@ module.exports = {
html: true,
},
],
'sort-imports': [
'error',
{
ignoreCase: true,
allowSeparatedGroups: true,
memberSyntaxSortOrder: ['none', 'all', 'single', 'multiple'],
},
],
'sort-keys': 'error',
'sort-vars': 'error',
},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"eslint": "^7.15.0",
"eslint-config-next": "13.5.6",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-next": "^0.0.0",
"eslint-plugin-no-switch-statements": "^1.0.0",
Expand Down
9 changes: 5 additions & 4 deletions webapp/src/RepoGit.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { Cache } from '@/Cache';
import fs from 'fs';
import fsp from 'fs/promises';
import { Octokit } from '@octokit/rest';
import path from 'path';
import { stringify } from 'yaml';

import { Cache } from '@/Cache';
import { IGit } from '@/utils/git/IGit';
import { LyraConfig } from '@/utils/lyraConfig';
import { Octokit } from '@octokit/rest';
import packageJson from '../package.json';
import path from 'path';
import { ServerProjectConfig } from '@/utils/serverConfig';
import { SimpleGitWrapper } from '@/utils/git/SimpleGitWrapper';
import { stringify } from 'yaml';
import { unflattenObject } from '@/utils/unflattenObject';
import { debug, info, warn } from '@/utils/log';
import { WriteLanguageFileError, WriteLanguageFileErrors } from '@/errors';
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/app/api/messages/[projectName]/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { NextRequest, NextResponse } from 'next/server';

import MessageAdapterFactory from '@/utils/adapters/MessageAdapterFactory';
import { RepoGit } from '@/RepoGit';
import { ServerConfig } from '@/utils/serverConfig';
Expand All @@ -6,7 +8,6 @@ import {
ProjectNameNotFoundError,
ProjectPathNotFoundError,
} from '@/errors';
import { NextRequest, NextResponse } from 'next/server';

export async function GET(
req: NextRequest,
Expand Down
1 change: 1 addition & 0 deletions webapp/src/app/api/projects/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NextResponse } from 'next/server';

import { ServerConfig } from '@/utils/serverConfig';
import { ServerConfigReadingError } from '@/errors';
import { type ProjectItem, type ProjectsResponse } from '@/types';
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/app/api/pull-request/[projectName]/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { NextRequest, NextResponse } from 'next/server';

import { ProjectNameNotFoundError } from '@/errors';
import { RepoGit } from '@/RepoGit';
import { NextRequest, NextResponse } from 'next/server';
import { ServerConfig, ServerProjectConfig } from '@/utils/serverConfig';

/** used to prevent multiple requests from running at the same time */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { NextRequest, NextResponse } from 'next/server';

import { Cache } from '@/Cache';
import { RepoGit } from '@/RepoGit';
import { ServerConfig } from '@/utils/serverConfig';
Expand All @@ -8,7 +10,6 @@ import {
ProjectNameNotFoundError,
ProjectPathNotFoundError,
} from '@/errors';
import { NextRequest, NextResponse } from 'next/server';

export async function PUT(
req: NextRequest,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { NextRequest, NextResponse } from 'next/server';

import { Cache } from '@/Cache';
import {
LanguageNotFound,
LanguageNotSupported,
ProjectNameNotFoundError,
} from '@/errors';
import { NextRequest, NextResponse } from 'next/server';

export async function GET(
req: NextRequest, // keep this here even if unused
Expand Down
5 changes: 3 additions & 2 deletions webapp/src/app/projects/[projectName]/[languageName]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
'use client';

import { Box, Button, Input, Link, Typography } from '@mui/joy';
import { useEffect, useMemo, useState } from 'react';

import { type MessageData } from '@/utils/adapters';
import MessageForm from '@/components/MessageForm';
import { SafeRecord } from '@/utils/types';
import { Box, Button, Input, Link, Typography } from '@mui/joy';
import { useEffect, useMemo, useState } from 'react';

export default function Home(context: {
params: { languageName: string; projectName: string };
Expand Down
5 changes: 3 additions & 2 deletions webapp/src/app/projects/[projectName]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Cache } from '@/Cache';
import MessageAdapterFactory from '@/utils/adapters/MessageAdapterFactory';
import { NextPage } from 'next';
import { notFound } from 'next/navigation';

import { Cache } from '@/Cache';
import MessageAdapterFactory from '@/utils/adapters/MessageAdapterFactory';
import ProjectDashboard from '@/components/ProjectDashboard';
import { RepoGit } from '@/RepoGit';
import { ServerConfig } from '@/utils/serverConfig';
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/app/projects/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
'use client';

import { type ProjectsResponse } from '@/types';
import { useEffect, useState } from 'react';

import { type ProjectsResponse } from '@/types';

export default function Home() {
const [projectsResponse, setProjectsResponse] = useState<ProjectsResponse>({
projects: [],
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/components/HomeDashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { CardGrid } from '@/components/CardGrid';
import { FC } from 'react';
import { Box, Typography } from '@mui/joy';

import { CardGrid } from '@/components/CardGrid';
import ProjectCard, { ProjectCardProps } from '@/components/ProjectCard';

type HomeDashboardProps = {
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/components/MessageForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { type MessageData } from '@/utils/adapters';
import {
Box,
Button,
Expand All @@ -10,6 +9,8 @@ import {
} from '@mui/joy';
import { FC, useEffect, useState } from 'react';

import { type MessageData } from '@/utils/adapters';

type Props = {
message: MessageData;
// eslint-disable-next-line no-unused-vars
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/components/ProjectDashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
'use client';

import { CardGrid } from '@/components/CardGrid';
import { FC } from 'react';
import Link from 'next/link';
import { Box, Typography, useTheme } from '@mui/joy';

import { CardGrid } from '@/components/CardGrid';
import LanguageCard, { LanguageCardProps } from '@/components/LanguageCard';

type ProjectDashboardProps = {
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/store/ProjectStore.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ProjectStore } from './ProjectStore';
import { describe, expect, it } from '@jest/globals';

import { ProjectStore } from './ProjectStore';
import { LanguageNotFound, MessageNotFound } from '@/errors';

describe('ProjectStore', () => {
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/store/Store.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, expect, it } from '@jest/globals';

import { ProjectStore } from '@/store/ProjectStore';
import { Store } from './Store';
import { describe, expect, it } from '@jest/globals';

describe('Store', () => {
describe('getProjectStore()', () => {
Expand Down
5 changes: 3 additions & 2 deletions webapp/src/utils/adapters/TsMessageAdapter.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { type MessageData } from '.';
import mock from 'mock-fs';
import TsMessageAdapter from './TsMessageAdapter';
import { afterEach, describe, expect, it } from '@jest/globals';

import { type MessageData } from '.';
import TsMessageAdapter from './TsMessageAdapter';

describe('TsMessageAdapter', () => {
afterEach(() => {
mock.restore();
Expand Down
1 change: 1 addition & 0 deletions webapp/src/utils/adapters/TsMessageAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'fs/promises';
import path from 'path';

import readTypedMessages from '../readTypedMessages';
import { IMessageAdapter, type MessageData } from '.';

Expand Down
5 changes: 3 additions & 2 deletions webapp/src/utils/adapters/YamlMessageAdapter.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { type MessageData } from '.';
import mock from 'mock-fs';
import YamlMessageAdapter from './YamlMessageAdapter';
import { afterEach, describe, expect, it } from '@jest/globals';

import { type MessageData } from '.';
import YamlMessageAdapter from './YamlMessageAdapter';

describe('YamlMessageAdapter', () => {
describe('getMessages()', () => {
afterEach(() => {
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/utils/adapters/YamlMessageAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import flattenObject from '../flattenObject';
import fs from 'fs/promises';
import { parse } from 'yaml';
import path from 'path';

import flattenObject from '../flattenObject';
import { IMessageAdapter, type MessageData } from '.';

export default class YamlMessageAdapter implements IMessageAdapter {
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/utils/adapters/YamlTranslationAdapter.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import mock from 'mock-fs';
import YamlTranslationAdapter from './YamlTranslationAdapter';
import { afterEach, describe, expect, it } from '@jest/globals';

import YamlTranslationAdapter from './YamlTranslationAdapter';

describe('YamlTranslationAdapter', () => {
describe('getTranslations()', () => {
afterEach(() => {
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/utils/adapters/YamlTranslationAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import flattenObject from '../flattenObject';
import fs from 'fs/promises';
import { parse } from 'yaml';
import path from 'path';

import flattenObject from '../flattenObject';
import { ITranslationAdapter, type TranslationMap } from '.';

export default class YamlTranslationAdapter implements ITranslationAdapter {
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/utils/flattenObject.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import flattenObject from './flattenObject';
import { describe, expect, it } from '@jest/globals';

import flattenObject from './flattenObject';

describe('flattenObject()', () => {
it('returns empty object for empty obj', () => {
const actual = flattenObject({});
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/utils/git/SimpleGitWrapper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { IGit } from './IGit';
import { simpleGit, SimpleGit, SimpleGitOptions } from 'simple-git';

import { IGit } from './IGit';

export class SimpleGitWrapper implements IGit {
private readonly git: SimpleGit;

Expand Down
1 change: 1 addition & 0 deletions webapp/src/utils/lyraConfig.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import mock from 'mock-fs';
import { afterEach, describe, expect, it } from '@jest/globals';

import { LyraConfig, MessageKind } from './lyraConfig';
import { LyraConfigReadingError, ProjectPathNotFoundError } from '@/errors';

Expand Down
1 change: 1 addition & 0 deletions webapp/src/utils/lyraConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import fs from 'fs/promises';
import { parse } from 'yaml';
import path from 'path';
import { z } from 'zod';

import { LyraConfigReadingError, ProjectPathNotFoundError } from '@/errors';

export enum MessageKind {
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/utils/readTypedMessages.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { type MessageData } from './adapters';
import ts from 'typescript';

import { type MessageData } from './adapters';

export default function readTypedMessages(fileName: string): MessageData[] {
const host = ts.createIncrementalCompilerHost(
{},
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/utils/serverConfig.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import mock from 'mock-fs';
import { ServerConfig } from './serverConfig';
import { afterEach, describe, expect, it } from '@jest/globals';

import { ServerConfig } from './serverConfig';
import { ProjectNameNotFoundError, ServerConfigReadingError } from '@/errors';

describe('ServerConfig', () => {
Expand Down
1 change: 1 addition & 0 deletions webapp/src/utils/serverConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import fs from 'fs/promises';
import { parse } from 'yaml';
import path from 'path';
import { z } from 'zod';

import { ProjectNameNotFoundError, ServerConfigReadingError } from '@/errors';

const serverConfigSchema = z.object({
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/utils/unflattenObject.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { unflattenObject } from './unflattenObject';
import { describe, expect, it } from '@jest/globals';

import { unflattenObject } from './unflattenObject';

describe('unflattenObject()', () => {
it('returns empty object for empty obj', () => {
const actual = unflattenObject({});
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2330,7 +2330,7 @@ eslint-module-utils@^2.8.0:
dependencies:
debug "^3.2.7"

eslint-plugin-import@^2.28.1:
eslint-plugin-import@^2.28.1, eslint-plugin-import@^2.29.1:
version "2.29.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.29.1.tgz#d45b37b5ef5901d639c15270d74d46d161150643"
integrity sha512-BbPC0cuExzhiMo4Ff1BTVwHpjjv28C5R+btTOGaCRC7UEz801up0JadwkeSk5Ued6TG34uaczuVuH6qyy5YUxw==
Expand Down