Skip to content

Commit

Permalink
Consistent type imports
Browse files Browse the repository at this point in the history
  • Loading branch information
james-pre committed May 21, 2024
1 parent 2067b99 commit 6a96d90
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 21 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"@typescript-eslint/no-namespace": "warn",
"@typescript-eslint/prefer-as-const": "warn",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/consistent-type-assertions": "warn"
"@typescript-eslint/consistent-type-assertions": "warn",
"@typescript-eslint/consistent-type-imports": "warn"
},
"ignorePatterns": ["tests/fixtures"],
"plugins": ["@typescript-eslint"]
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"scripts": {
"format": "prettier --write .",
"format:check": "prettier --check .",
"lint": "eslint src tests && tsc -p tsconfig.json --noEmit",
"lint": "tsc -p tsconfig.json --noEmit && eslint src tests",
"test": "npm run build && tsc -p tests/tsconfig.json --noEmit && cross-env NODE_OPTIONS=--experimental-vm-modules npx jest",
"build": "node scripts/build.js --globalName=ZenFS --entry src/index.ts",
"build:docs": "typedoc --out docs --name ZenFS src/index.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/backends/backend.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { RequiredKeys } from 'utilium';
import { ErrnoError, Errno } from '../error.js';
import { FileSystem } from '../filesystem.js';
import type { FileSystem } from '../filesystem.js';
import { levenshtein } from '../utils.js';

type OptionType = 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function';
Expand Down
2 changes: 1 addition & 1 deletion src/backends/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Errno, ErrnoError } from '../error.js';
import type { FileSystemMetadata } from '../filesystem.js';
import { Stats } from '../stats.js';
import type { Stats } from '../stats.js';
import type { Backend } from './backend.js';
import { IndexFS } from './index/fs.js';
import type { IndexData } from './index/index.js';
Expand Down
3 changes: 2 additions & 1 deletion src/backends/index/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { NoSyncFile, isWriteable, flagToMode } from '../../file.js';
import { Readonly, FileSystem } from '../../filesystem.js';
import type { Stats } from '../../stats.js';
import { decode } from '../../utils.js';
import { Index, IndexData } from './index.js';
import type { IndexData } from './index.js';
import { Index } from './index.js';

export abstract class IndexFS extends Readonly(FileSystem) {
protected index: Index = new Index();
Expand Down
3 changes: 2 additions & 1 deletion src/backends/index/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { isJSON } from 'utilium';
import { Errno, ErrnoError } from '../../error.js';
import { Stats, StatsLike } from '../../stats.js';
import type { StatsLike } from '../../stats.js';
import { Stats } from '../../stats.js';
import { encode } from '../../utils.js';
import { basename, dirname } from '../../emulation/path.js';

Expand Down
9 changes: 6 additions & 3 deletions src/backends/overlay.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { FileSystem, FileSystemMetadata } from '../filesystem.js';
import type { FileSystemMetadata } from '../filesystem.js';
import { FileSystem } from '../filesystem.js';
import { ErrnoError, Errno } from '../error.js';
import { File, PreloadFile, parseFlag } from '../file.js';
import type { File } from '../file.js';
import { PreloadFile, parseFlag } from '../file.js';
import { Stats } from '../stats.js';
import { LockedFS } from './locked.js';
import { dirname } from '../emulation/path.js';
import { Cred, rootCred } from '../cred.js';
import type { Cred } from '../cred.js';
import { rootCred } from '../cred.js';
import { decode, encode } from '../utils.js';
import type { Backend } from './backend.js';
/**
Expand Down
3 changes: 2 additions & 1 deletion src/emulation/async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import type { FileContents } from '../filesystem.js';
import { BigIntStats, type Stats } from '../stats.js';
import { nop, normalizeMode, type Callback } from '../utils.js';
import { R_OK } from './constants.js';
import { Dirent, type Dir } from './dir.js';
import type { Dirent } from './dir.js';
import { type Dir } from './dir.js';
import * as promises from './promises.js';
import { fd2file } from './shared.js';
import { ReadStream, WriteStream } from './streams.js';
Expand Down
3 changes: 2 additions & 1 deletion src/emulation/promises.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import type { ReadableStream as TReadableStream } from 'node:stream/web';
import type { Interface as ReadlineInterface } from 'readline';
import type { ReadableStreamController } from 'stream/web';
import { Errno, ErrnoError } from '../error.js';
import { ActionType, File, isAppendable, isReadable, isWriteable, parseFlag, pathExistsAction, pathNotExistsAction } from '../file.js';
import type { File } from '../file.js';
import { ActionType, isAppendable, isReadable, isWriteable, parseFlag, pathExistsAction, pathNotExistsAction } from '../file.js';
import type { FileContents } from '../filesystem.js';
import { BigIntStats, FileType, type Stats } from '../stats.js';
import { normalizeMode, normalizeOptions, normalizePath, normalizeTime } from '../utils.js';
Expand Down
5 changes: 3 additions & 2 deletions src/emulation/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import type { BigIntStatsFs, StatsFs } from 'node:fs';
import { InMemory } from '../backends/memory.js';
import { Cred, rootCred } from '../cred.js';
import type { Cred } from '../cred.js';
import { rootCred } from '../cred.js';
import { Errno, ErrnoError } from '../error.js';
import type { File } from '../file.js';
import { FileSystem } from '../filesystem.js';
import type { FileSystem } from '../filesystem.js';
import { size_max } from '../inode.js';
import { ZenFsType } from '../stats.js';
import { normalizePath } from '../utils.js';
Expand Down
2 changes: 1 addition & 1 deletion src/emulation/streams.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type * as Node from 'fs';
import { Readable, Writable } from 'readable-stream';
import { Callback } from '../utils.js';
import type { Callback } from '../utils.js';
import { ErrnoError, Errno } from '../error.js';

export class ReadStream extends Readable implements Node.ReadStream {
Expand Down
5 changes: 3 additions & 2 deletions src/emulation/sync.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Buffer } from 'buffer';
import type * as fs from 'node:fs';
import { Errno, ErrnoError } from '../error.js';
import { ActionType, File, isAppendable, isReadable, isWriteable, parseFlag, pathExistsAction, pathNotExistsAction } from '../file.js';
import { FileContents } from '../filesystem.js';
import type { File } from '../file.js';
import { ActionType, isAppendable, isReadable, isWriteable, parseFlag, pathExistsAction, pathNotExistsAction } from '../file.js';
import type { FileContents } from '../filesystem.js';
import { BigIntStats, FileType, type Stats } from '../stats.js';
import { normalizeMode, normalizeOptions, normalizePath, normalizeTime } from '../utils.js';
import { COPYFILE_EXCL, F_OK, S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO, S_IFLNK, S_IFMT, S_IFREG, S_IFSOCK } from './constants.js';
Expand Down
2 changes: 1 addition & 1 deletion src/stats.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type * as Node from 'fs';
import { Cred } from './cred.js';
import type { Cred } from './cred.js';
import { S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO, S_IFLNK, S_IFMT, S_IFREG, S_IFSOCK, S_IRWXG, S_IRWXO, S_IRWXU } from './emulation/constants.js';
import { size_max } from './inode.js';

Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { OptionalTuple } from 'utilium';
import { ErrnoError, Errno } from './error.js';
import { Cred } from './cred.js';
import type { Cred } from './cred.js';
import { dirname, resolve, type AbsolutePath } from './emulation/path.js';
import { FileSystem } from './filesystem.js';
import type { FileSystem } from './filesystem.js';
import type * as fs from 'node:fs';

declare global {
Expand Down
2 changes: 1 addition & 1 deletion tests/fs/assignment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

import { fs as zen } from '../../src/index.js';
import * as node from 'fs';
import type * as node from 'fs';

type Mock = {
[K in Exclude<keyof typeof node, 'ReadStream' | 'WriteStream'>]: Omit<(typeof node)[K], '__promisify__' | 'native'>;
Expand Down
3 changes: 2 additions & 1 deletion tests/port/channel.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { MessageChannel } from 'node:worker_threads';
import { Port, attachFS } from '../../src/backends/port/fs.js';
import { InMemory, StoreFS, configure, fs, resolveMountConfig, type InMemoryStore } from '../../src/index.js';
import type { StoreFS } from '../../src/index.js';
import { InMemory, configure, fs, resolveMountConfig, type InMemoryStore } from '../../src/index.js';

describe('FS with MessageChannel', () => {
const { port1, port2 } = new MessageChannel(),
Expand Down

0 comments on commit 6a96d90

Please sign in to comment.