Skip to content

Commit

Permalink
style: add new rule for imports (#785)
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 authored Aug 13, 2024
1 parent 53ba39d commit 2a0d29c
Show file tree
Hide file tree
Showing 72 changed files with 343 additions and 296 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"extends": ["plugin:@typescript-eslint/recommended", "prettier"],
"plugins": ["simple-import-sort", "n"],

"parserOptions": {
"project": "./tsconfig.json"
Expand All @@ -11,6 +12,9 @@
},

"rules": {
"n/prefer-node-protocol": "error",
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"import/no-extraneous-dependencies": 0,
"no-underscore-dangle": ["error", {"allow": ["_id"]}],
"@typescript-eslint/lines-between-class-members": ["error", "always", {"exceptAfterSingleLine": true}],
Expand Down
2 changes: 1 addition & 1 deletion client/config/webpack.config.dev.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require('path');
const path = require('node:path');
const ESLintPlugin = require('eslint-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
Expand Down
2 changes: 1 addition & 1 deletion client/config/webpack.config.prod.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const autoprefixer = require('autoprefixer');
const path = require('path');
const path = require('node:path');
const webpack = require('webpack');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
Expand Down
2 changes: 1 addition & 1 deletion client/scripts/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
const {choosePort, prepareUrls} = require('react-dev-utils/WebpackDevServerUtils');
const path = require('path');
const path = require('node:path');
const paths = require('../../shared/config/paths');
const config = require('../config/webpack.config.dev');

Expand Down
17 changes: 8 additions & 9 deletions config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import {spawn} from 'child_process';
import crypto from 'crypto';
import fs from 'fs';
import os from 'os';
import path from 'path';
import yargs from 'yargs/yargs';

import {configSchema} from '@shared/schema/Config';
import {spawn} from 'node:child_process';
import crypto from 'node:crypto';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';

import type {Config} from '@shared/schema/Config';
import type {ClientConnectionSettings} from '@shared/schema/ClientConnectionSettings';
import type {Config} from '@shared/schema/Config';
import {configSchema} from '@shared/schema/Config';
import yargs from 'yargs/yargs';

import {version} from './package.json';

Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@
"eslint-config-prettier": "^8.8.0",
"eslint-config-react-app": "^7.0.1",
"eslint-import-resolver-webpack": "^0.13.2",
"eslint-plugin-n": "^17.10.2",
"eslint-plugin-simple-import-sort": "^12.1.1",
"eslint-webpack-plugin": "^3.2.0",
"express": "^4.18.2",
"express-rate-limit": "^6.7.0",
Expand Down
71 changes: 71 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ process.on('unhandledRejection', (err) => {
throw err;
});

const path = require('path');
const path = require('node:path');
const esbuild = require('esbuild');
const chalk = require('chalk');
const fs = require('fs-extra');
Expand Down
10 changes: 5 additions & 5 deletions scripts/testsetup.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const chalk = require('chalk');
const crypto = require('crypto');
const fs = require('fs');
const os = require('os');
const path = require('path');
const {spawn} = require('child_process');
const crypto = require('node:crypto');
const fs = require('node:fs');
const os = require('node:os');
const path = require('node:path');
const {spawn} = require('node:child_process');

const temporaryRuntimeDirectory = path.resolve(os.tmpdir(), `flood.test.${crypto.randomBytes(12).toString('hex')}`);

Expand Down
6 changes: 3 additions & 3 deletions server/bin/enforce-prerequisites.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fs from 'fs';
import path from 'path';
import fs from 'node:fs';
import path from 'node:path';

import {appDist} from '../../shared/config/paths';
import config from '../../config';
import {appDist} from '../../shared/config/paths';

const staticAssets = [path.join(appDist, 'index.html')];

Expand Down
5 changes: 2 additions & 3 deletions server/bin/migrations/00-UserInDatabase2.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {AccessLevel} from '../../../shared/schema/constants/Auth';
import Users from '../../models/Users';

import type {Credentials} from '../../../shared/schema/Auth';
import type {RTorrentConnectionSettings} from '../../../shared/schema/ClientConnectionSettings';
import {AccessLevel} from '../../../shared/schema/constants/Auth';
import Users from '../../models/Users';
import type {UserInDatabase1} from './types/UserInDatabase1';

const migrationError = (err?: Error) => {
Expand Down
3 changes: 2 additions & 1 deletion server/bin/migrations/02-HistoryEra.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import path from 'node:path';

import fs from 'fs-extra';
import path from 'path';

import config from '../../../config';
import Users from '../../models/Users';
Expand Down
12 changes: 6 additions & 6 deletions server/bin/web-server.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import chalk from 'chalk';
import fastify from 'fastify';
import fs from 'fs';
import fs from 'node:fs';
import type {Server} from 'node:http';
import type {Http2SecureServer} from 'node:http2';

import chalk from 'chalk';
import type {FastifyInstance} from 'fastify';
import type {Http2SecureServer} from 'http2';
import type {Server} from 'http';
import fastify from 'fastify';

import config from '../../config';
import constructRoutes from '../routes';
import packageJSON from '../../package.json';
import constructRoutes from '../routes';

const startWebServer = async () => {
const {ssl = false, floodServerHost: host, floodServerPort: port} = config;
Expand Down
5 changes: 2 additions & 3 deletions server/middleware/appendUserServices.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type {Request, Response, NextFunction} from 'express';

import {getAllServices} from '../services';
import type {NextFunction, Request, Response} from 'express';

import type {ServiceInstances} from '../services';
import {getAllServices} from '../services';

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
Expand Down
11 changes: 5 additions & 6 deletions server/middleware/clientActivityStream.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import type {EventMap} from 'typed-emitter';
import type {Operation} from 'fast-json-patch';
import type {Request, Response} from 'express';
import type {Operation} from 'fast-json-patch';
import type {EventMap} from 'typed-emitter';
import type TypedEmitter from 'typed-emitter';

import type {TransferHistory} from '../../shared/types/TransferData';
import type {DiskUsageSummary} from '../models/DiskUsage';
import DiskUsage from '../models/DiskUsage';
import {getAllServices} from '../services';
import ServerEvent from '../models/ServerEvent';

import type {DiskUsageSummary} from '../models/DiskUsage';
import type {TransferHistory} from '../../shared/types/TransferData';
import {getAllServices} from '../services';

export default async (req: Request, res: Response) => {
const {user} = req;
Expand Down
2 changes: 1 addition & 1 deletion server/middleware/eventStream.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Request, Response, NextFunction} from 'express';
import type {NextFunction, Request, Response} from 'express';

export default (req: Request, res: Response, next: NextFunction) => {
req.socket.setKeepAlive(true);
Expand Down
2 changes: 1 addition & 1 deletion server/middleware/requireAdmin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Request, Response, NextFunction} from 'express';
import type {NextFunction, Request, Response} from 'express';

import {AccessLevel} from '../../shared/schema/constants/Auth';

Expand Down
7 changes: 3 additions & 4 deletions server/models/DiskUsage.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import {EventEmitter} from 'events';
import type TypedEmitter from 'typed-emitter';
import {EventEmitter} from 'node:events';

import type {Disks} from '@shared/types/DiskUsage';

import {isPlatformSupported, diskUsage} from '../util/diskUsageUtil';
import type TypedEmitter from 'typed-emitter';

import type {SupportedPlatform} from '../util/diskUsageUtil';
import {diskUsage, isPlatformSupported} from '../util/diskUsageUtil';

export interface DiskUsageSummary {
id: number;
Expand Down
4 changes: 2 additions & 2 deletions server/models/HistoryEra.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {TransferData, TransferSnapshot} from '@shared/types/TransferData';
import {setInterval} from 'node:timers';

import Datastore from '@seald-io/nedb';
import {setInterval} from 'timers';
import type {TransferData, TransferSnapshot} from '@shared/types/TransferData';

import config from '../../config';

Expand Down
3 changes: 1 addition & 2 deletions server/models/ServerEvent.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type {Response} from 'express';

import type {ServerEvents} from '@shared/types/ServerEvents';
import type {Response} from 'express';

class ServerEvent {
res: Response;
Expand Down
4 changes: 2 additions & 2 deletions server/models/TemporaryStorage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs';
import path from 'path';
import fs from 'node:fs';
import path from 'node:path';

import config from '../../config';

Expand Down
Loading

0 comments on commit 2a0d29c

Please sign in to comment.