Skip to content

Commit

Permalink
add imports linter
Browse files Browse the repository at this point in the history
  • Loading branch information
matej21 committed Feb 3, 2023
1 parent daac4cb commit d994377
Show file tree
Hide file tree
Showing 29 changed files with 185 additions and 42 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
- uses: actions/checkout@v3
- run: npm install -g pnpm@6
- run: pnpm install
- name: "Lint imports"
run: yarn tsx ./scripts/lint/module-import-linter.js
- run: pnpm run eslint:lint

build:
Expand Down
6 changes: 3 additions & 3 deletions ee/admin-server/src/controllers/ApiController.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IncomingMessage, OutgoingHttpHeaders, request as httpRequest, ServerResponse } from 'http'
import { request as httpsRequest, RequestOptions } from 'https'
import { TLSSocket } from 'tls'
import { IncomingMessage, OutgoingHttpHeaders, request as httpRequest, ServerResponse } from 'node:http'
import { request as httpsRequest, RequestOptions } from 'node:https'
import { TLSSocket } from 'node:tls'
import { ApiEndpointResolver } from '../services/ApiEndpointResolver'
import { readAuthCookie, writeAuthCookie } from '../utils/cookies'
import { isProxyRequest } from '../utils/forwared'
Expand Down
4 changes: 2 additions & 2 deletions ee/admin-server/src/controllers/BaseController.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IncomingMessage, ServerResponse } from 'http'
import type { IncomingMessage, ServerResponse } from 'node:http'
import type { Json, Type } from '../utils/schema'
import { Buffer } from 'buffer'
import { Buffer } from 'node:buffer'

export abstract class BaseController<T = {}> {
abstract handle(req: IncomingMessage, res: ServerResponse, params: T): Promise<void>
Expand Down
2 changes: 1 addition & 1 deletion ee/admin-server/src/controllers/CollaborationController.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { randomInt } from 'crypto'
import { randomInt } from 'node:crypto'
import { ClientIdentity, CollaborationStorage, Scope } from '../services/CollaborationStorage'
import { ProjectGroupResolver } from '../services/ProjectGroupResolver'
import { TenantClient } from '../services/TenantClient'
Expand Down
2 changes: 1 addition & 1 deletion ee/admin-server/src/controllers/DeployController.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IncomingMessage, ServerResponse } from 'http'
import type { IncomingMessage, ServerResponse } from 'node:http'
import { array, object, ParseError, string } from '../utils/schema'
import { BaseController } from './BaseController'
import type { TenantClient } from '../services/TenantClient'
Expand Down
4 changes: 2 additions & 2 deletions ee/admin-server/src/controllers/LegacyController.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseController } from './BaseController'
import type { IncomingMessage, ServerResponse } from 'http'
import { URL } from 'url'
import type { IncomingMessage, ServerResponse } from 'node:http'
import { URL } from 'node:url'

const OLD_PROJECT_URL_PATTERN = /^\/p\/([^\/]+)(\/[^\/]+(\/null)?)?/

Expand Down
2 changes: 1 addition & 1 deletion ee/admin-server/src/controllers/LoginController.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IncomingMessage, ServerResponse } from 'http'
import type { IncomingMessage, ServerResponse } from 'node:http'
import { BaseController } from './BaseController'
import { StaticFileHandler } from '../services/StaticFileHandler'
import { ConfigResolver } from '../services/ConfigResolver'
Expand Down
2 changes: 1 addition & 1 deletion ee/admin-server/src/controllers/MeController.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BaseController } from './BaseController'
import type { IncomingMessage, ServerResponse } from 'http'
import type { IncomingMessage, ServerResponse } from 'node:http'
import type { TenantClient } from '../services/TenantClient'
import type { S3Manager } from '../services/S3Manager'
import { readAuthCookie } from '../utils/cookies'
Expand Down
2 changes: 1 addition & 1 deletion ee/admin-server/src/controllers/PanelController.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IncomingMessage, ServerResponse } from 'http'
import type { IncomingMessage, ServerResponse } from 'node:http'
import { BaseController } from './BaseController'
import { StaticFileHandler } from '../services/StaticFileHandler'
import { PanelConfig } from '../config'
Expand Down
4 changes: 2 additions & 2 deletions ee/admin-server/src/controllers/ProjectController.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { BaseController } from './BaseController'
import type { IncomingMessage, ServerResponse } from 'http'
import type { IncomingMessage, ServerResponse } from 'node:http'
import type { TenantClient } from '../services/TenantClient'
import type { S3Manager } from '../services/S3Manager'
import { Readable } from 'stream'
import { Readable } from 'node:stream'
import type { GetObjectCommandOutput } from '@aws-sdk/client-s3'
import { readAuthCookie } from '../utils/cookies'
import { readReadable } from '../utils/readReadable'
Expand Down
2 changes: 1 addition & 1 deletion ee/admin-server/src/dic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { DeployController } from './controllers/DeployController'
import { ProjectController } from './controllers/ProjectController'
import { TenantClient } from './services/TenantClient'
import { ApiController } from './controllers/ApiController'
import * as http from 'http'
import * as http from 'node:http'
import { S3Manager } from './services/S3Manager'
import { MeController } from './controllers/MeController'
import { LegacyController } from './controllers/LegacyController'
Expand Down
4 changes: 2 additions & 2 deletions ee/admin-server/src/services/Router.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IncomingMessage, ServerResponse } from 'http'
import { URL } from 'url'
import { IncomingMessage, ServerResponse } from 'node:http'
import { URL } from 'node:url'
import { readHostFromHeader } from '../utils/readHostFromHeader'
import { BadRequestError } from '../BadRequestError'
import { ProjectGroupResolver } from './ProjectGroupResolver'
Expand Down
4 changes: 2 additions & 2 deletions ee/admin-server/src/services/S3Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import {
PutObjectCommandOutput,
S3Client,
} from '@aws-sdk/client-s3'
import type * as Buffer from 'buffer'
import type * as Buffer from 'node:buffer'
import mime from 'mime'
import { S3LocationResolver } from './S3LocationResolver'
import { Readable } from 'stream'
import { Readable } from 'node:stream'
import { readReadable } from '../utils/readReadable'

export class S3Manager {
Expand Down
6 changes: 3 additions & 3 deletions ee/admin-server/src/services/StaticFileHandler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IncomingMessage, ServerResponse } from 'http'
import { URL } from 'url'
import { IncomingMessage, ServerResponse } from 'node:http'
import { URL } from 'node:url'
import mime from 'mime'
import { readFile } from 'fs/promises'
import { readFile } from 'node:fs/promises'

export type ProcessFile = (path: string, content: Buffer, req: IncomingMessage) => Promise<string | Buffer>

Expand Down
4 changes: 2 additions & 2 deletions ee/admin-server/src/utils/WebSocketProtocol.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { WebSocket, WebSocketServer } from 'ws'
import { IncomingMessage } from 'http'
import { Socket } from 'net'
import { IncomingMessage } from 'node:http'
import { Socket } from 'node:net'
import { intersection, JsonObject, literal, object, ParseError, string, Type, union } from './schema'

interface ProtocolDefinition<C extends Context<unknown>> {
Expand Down
2 changes: 1 addition & 1 deletion ee/admin-server/src/utils/cookies.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IncomingMessage, OutgoingMessage } from 'http'
import { IncomingMessage, OutgoingMessage } from 'node:http'
import * as cookie from 'cookie'
import { isRequestSecure } from './forwared'

Expand Down
4 changes: 2 additions & 2 deletions ee/admin-server/src/utils/forwared.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IncomingMessage } from 'http'
import { IncomingMessage } from 'node:http'
import ipaddr from 'ipaddr.js'
import { TLSSocket } from 'tls'
import { TLSSocket } from 'node:tls'

export const isProxyRequest = (req: IncomingMessage): boolean => {
const ip = ipaddr.parse(req.socket.remoteAddress ?? '0.0.0.0')
Expand Down
2 changes: 1 addition & 1 deletion ee/admin-server/src/utils/readHostFromHeader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IncomingMessage } from 'http'
import { IncomingMessage } from 'node:http'
import { BadRequestError } from '../BadRequestError'

export const readHostFromHeader = (req: IncomingMessage): string => {
Expand Down
2 changes: 1 addition & 1 deletion ee/admin-server/src/utils/readReadable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Readable } from 'stream'
import { Readable } from 'node:stream'

export const readReadable = (readable: Readable): Promise<string> => {
return new Promise((resolve, reject) => {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"eslint-plugin-prettier": "3.4.0",
"eslint-plugin-react": "7.24.0",
"eslint-plugin-react-hooks": "4.2.0",
"fast-glob": "^3.2.12",
"jsdom": "^17.0.0",
"prettier": "2.3.2",
"react": "^18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-i18n/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"ae:build": "api-extractor run --local",
"ae:test": "api-extractor run"
},
"devDependencies": {
"dependencies": {
"@contember/admin": "workspace:*"
}
}
4 changes: 2 additions & 2 deletions packages/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,13 @@
"test": "vitest --environment jsdom tests/vitest"
},
"dependencies": {
"@babel/core": "7.17.10",
"@contember/client": "workspace:*",
"@contember/react-binding": "workspace:*",
"@contember/react-client": "workspace:*",
"@contember/react-multipass-rendering": "workspace:*",
"@contember/react-utils": "workspace:*",
"@contember/ui": "workspace:*",
"@formatjs/icu-messageformat-parser": "2.0.11",
"@mangoweb/sass-base": "0.0.8",
"@sindresorhus/slugify": "0.11.0",
"blueimp-md5": "2.18.0",
"buffer": "6.0.3",
Expand All @@ -77,10 +75,12 @@
"react-dom": "^17 || ^18"
},
"devDependencies": {
"@babel/core": "7.17.10",
"@contember/schema": "^1.0.0-rc.16",
"@contember/schema-definition": "^1.0.0-rc.16",
"@contember/schema-migrations": "^1.0.0-rc.16",
"@contember/schema-utils": "^1.0.0-rc.16",
"@mangoweb/sass-base": "0.0.8",
"@playwright/test": "1.20.0",
"@types/blueimp-md5": "2.18.0",
"@types/debounce": "1.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface VariableProps {

export const Variable = memo(({ name, format }: VariableProps): ReactElement => {
const environment = useEnvironment()
const value = environment.getVariableOrElse<undefined, ReactNode>(name, undefined) ?? environment.getParameter(name)
const value = environment.getVariableOrElse<undefined, ReactNode & Environment.Value>(name, undefined) ?? environment.getParameter(name)

const formatted = useMemo(() => (format ? format(value) : value), [format, value])

Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "../../../tsconfig.settings.json",
"compilerOptions": {
"outDir": "../dist/types",
"outDir": "../dist/types"
},
"references": [
{ "path": "../../client/src" },
Expand Down
4 changes: 1 addition & 3 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,8 @@
},
"dependencies": {
"@blueprintjs/icons": "3.29.0",
"@contember/react-multipass-rendering": "workspace:*",
"@contember/react-utils": "workspace:*",
"@mangoweb/sass-base": "0.0.8",
"@popperjs/core": "2.10.2",
"chroma-js": "2.1.2",
"classnames": "2.3.1",
"react-aria": "^3.20.0",
"react-popper": "^2.3.0",
Expand All @@ -53,6 +50,7 @@
},
"devDependencies": {
"@babel/core": "7.15.5",
"@mangoweb/sass-base": "0.0.8",
"@storybook/addon-actions": "6.5.13",
"@storybook/addon-essentials": "6.5.13",
"@storybook/addon-links": "6.5.13",
Expand Down
7 changes: 3 additions & 4 deletions packages/ui/src/components/Forms/Select/Select.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import classNames from 'classnames'
import { ComponentProps, CSSProperties, ForwardedRef, forwardRef, memo, ReactElement, RefAttributes, useCallback, useMemo, useRef } from 'react'
import ReactSelect, { StylesConfig, useStateManager } from 'react-select'
import SelectClass from 'react-select/dist/declarations/src/Select'
import ReactSelect, { StylesConfig, useStateManager, SelectInstance } from 'react-select'
import { useComponentClassName } from '../../../auxiliary'
import { noop } from '../../../utils'
import { getPortalRoot } from '../../Portal'
Expand All @@ -21,8 +20,8 @@ export type SelectOptionWithKey<V = string> =
& Omit<SelectOption<V>, 'key'>
& { key: string }

export type HTMLReactSelectElement<V> = SelectClass<SelectOption<V>, false, never>
export type HTMLReactSelectElementWithKey<V> = SelectClass<SelectOptionWithKey<V>, false, never>
export type HTMLReactSelectElement<V> = SelectInstance<SelectOption<V>, false, never>
export type HTMLReactSelectElementWithKey<V> = SelectInstance<SelectOptionWithKey<V>, false, never>

export type SelectProps<V> = Omit<ControlProps<V>, 'type' | keyof ControlConstraintProps<any>> & {
options: SelectOption<V>[]
Expand Down
1 change: 0 additions & 1 deletion packages/ui/src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"outDir": "../dist/types"
},
"references": [
{ "path": "../../react-multipass-rendering/src" },
{ "path": "../../react-utils/src" }
]
}
2 changes: 2 additions & 0 deletions pnpm-lock.yaml

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

Loading

0 comments on commit d994377

Please sign in to comment.