Skip to content

Commit

Permalink
style: Always use type keyword when approprite on imports & exports
Browse files Browse the repository at this point in the history
  • Loading branch information
eemeli committed Nov 29, 2024
1 parent e502055 commit 39350a9
Show file tree
Hide file tree
Showing 36 changed files with 84 additions and 73 deletions.
5 changes: 5 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export default [
'no-template-curly-in-string': 'warn',
'no-var': 'error',
'prefer-const': ['warn', { destructuring: 'all' }],
'@typescript-eslint/consistent-type-exports': 'error',
'@typescript-eslint/consistent-type-imports': [
'error',
{ fixStyle: 'inline-type-imports' }
],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
Expand Down
2 changes: 1 addition & 1 deletion src/compose/compose-collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {
FlowCollection,
SourceToken
} from '../parse/cst.ts'
import { CollectionTag } from '../schema/types.ts'
import { type CollectionTag } from '../schema/types.ts'
import type { ComposeContext, ComposeNode } from './compose-node.ts'
import type { ComposeErrorHandler } from './composer.ts'
import { resolveBlockMap } from './resolve-block-map.ts'
Expand Down
2 changes: 1 addition & 1 deletion src/compose/compose-doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
} from '../options.ts'
import type * as CST from '../parse/cst.ts'
import {
ComposeContext,
type ComposeContext,
composeEmptyNode,
composeNode
} from './compose-node.ts'
Expand Down
2 changes: 1 addition & 1 deletion src/compose/composer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Directives } from '../doc/directives.ts'
import { Document } from '../doc/Document.ts'
import { ErrorCode, YAMLParseError, YAMLWarning } from '../errors.ts'
import { type ErrorCode, YAMLParseError, YAMLWarning } from '../errors.ts'
import { isCollection, isPair } from '../nodes/identity.ts'
import type { ParsedNode, Range } from '../nodes/Node.ts'
import type {
Expand Down
2 changes: 1 addition & 1 deletion src/compose/resolve-block-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ParsedNode } from '../nodes/Node.ts'
import { Pair } from '../nodes/Pair.ts'
import { YAMLMap } from '../nodes/YAMLMap.ts'
import type { BlockMap } from '../parse/cst.ts'
import { CollectionTag } from '../schema/types.ts'
import { type CollectionTag } from '../schema/types.ts'
import type { ComposeContext, ComposeNode } from './compose-node.ts'
import type { ComposeErrorHandler } from './composer.ts'
import { resolveProps } from './resolve-props.ts'
Expand Down
2 changes: 1 addition & 1 deletion src/compose/resolve-block-scalar.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Range } from '../nodes/Node.ts'
import { type Range } from '../nodes/Node.ts'
import { Scalar } from '../nodes/Scalar.ts'
import type { BlockScalar } from '../parse/cst.ts'
import type { ComposeContext } from './compose-node.ts'
Expand Down
2 changes: 1 addition & 1 deletion src/compose/resolve-block-seq.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { YAMLSeq } from '../nodes/YAMLSeq.ts'
import type { BlockSequence } from '../parse/cst.ts'
import { CollectionTag } from '../schema/types.ts'
import { type CollectionTag } from '../schema/types.ts'
import type { ComposeContext, ComposeNode } from './compose-node.ts'
import type { ComposeErrorHandler } from './composer.ts'
import { resolveProps } from './resolve-props.ts'
Expand Down
4 changes: 2 additions & 2 deletions src/compose/resolve-flow-collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Pair } from '../nodes/Pair.ts'
import { YAMLMap } from '../nodes/YAMLMap.ts'
import { YAMLSeq } from '../nodes/YAMLSeq.ts'
import type { FlowCollection, Token } from '../parse/cst.ts'
import { Schema } from '../schema/Schema.ts'
import { CollectionTag } from '../schema/types.ts'
import { type Schema } from '../schema/Schema.ts'
import { type CollectionTag } from '../schema/types.ts'
import type { ComposeContext, ComposeNode } from './compose-node.ts'
import type { ComposeErrorHandler } from './composer.ts'
import { resolveEnd } from './resolve-end.ts'
Expand Down
4 changes: 2 additions & 2 deletions src/compose/resolve-flow-scalar.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ErrorCode } from '../errors.ts'
import { Range } from '../nodes/Node.ts'
import { type ErrorCode } from '../errors.ts'
import { type Range } from '../nodes/Node.ts'
import { Scalar } from '../nodes/Scalar.ts'
import type { FlowScalar } from '../parse/cst.ts'
import type { ComposeErrorHandler } from './composer.ts'
Expand Down
4 changes: 2 additions & 2 deletions src/compose/util-flow-indent-check.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Token } from '../parse/cst.ts'
import { ComposeErrorHandler } from './composer.ts'
import { type Token } from '../parse/cst.ts'
import { type ComposeErrorHandler } from './composer.ts'
import { containsNewline } from './util-contains-newline.ts'

export function flowIndentCheck(
Expand Down
4 changes: 2 additions & 2 deletions src/doc/Document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import type { Node, NodeType, ParsedNode, Range } from '../nodes/Node.ts'
import { Pair } from '../nodes/Pair.ts'
import type { Scalar } from '../nodes/Scalar.ts'
import { toJS, ToJSContext } from '../nodes/toJS.ts'
import { toJS, type ToJSContext } from '../nodes/toJS.ts'
import type { YAMLMap } from '../nodes/YAMLMap.ts'
import type { YAMLSeq } from '../nodes/YAMLSeq.ts'
import type {
Expand All @@ -26,7 +26,7 @@ import { Schema } from '../schema/Schema.ts'
import { stringifyDocument } from '../stringify/stringifyDocument.ts'
import { anchorNames, createNodeAnchors, findNewAnchor } from './anchors.ts'
import { applyReviver } from './applyReviver.ts'
import { createNode, CreateNodeContext } from './createNode.ts'
import { createNode, type CreateNodeContext } from './createNode.ts'
import { Directives } from './directives.ts'

export type Replacer = any[] | ((key: any, value: any) => unknown)
Expand Down
2 changes: 1 addition & 1 deletion src/doc/anchors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Scalar } from '../nodes/Scalar.ts'
import type { YAMLMap } from '../nodes/YAMLMap.ts'
import type { YAMLSeq } from '../nodes/YAMLSeq.ts'
import { visit } from '../visit.ts'
import { CreateNodeContext } from './createNode.ts'
import { type CreateNodeContext } from './createNode.ts'
import type { Document } from './Document.ts'

/**
Expand Down
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ export { Composer } from './compose/composer.ts'
export { Document } from './doc/Document.ts'
export { Schema } from './schema/Schema.ts'

export { ErrorCode, YAMLError, YAMLParseError, YAMLWarning } from './errors.ts'
export type { ErrorCode } from './errors.ts'
export { YAMLError, YAMLParseError, YAMLWarning } from './errors.ts'

export { Alias } from './nodes/Alias.ts'
export {
Expand All @@ -16,7 +17,7 @@ export {
isScalar,
isSeq
} from './nodes/identity.ts'
export { Node, ParsedNode, Range } from './nodes/Node.ts'
export type { Node, ParsedNode, Range } from './nodes/Node.ts'
export { Pair } from './nodes/Pair.ts'
export { Scalar } from './nodes/Scalar.ts'
export { YAMLMap } from './nodes/YAMLMap.ts'
Expand All @@ -36,8 +37,8 @@ export { Lexer } from './parse/lexer.ts'
export { LineCounter } from './parse/line-counter.ts'
export { Parser } from './parse/parser.ts'

export type { EmptyStream } from './public-api.ts'
export {
EmptyStream,
parse,
parseAllDocuments,
parseDocument,
Expand All @@ -49,11 +50,10 @@ export type { CollectionTag, ScalarTag } from './schema/types.ts'
export type { YAMLOMap } from './schema/yaml-1.1/omap.ts'
export type { YAMLSet } from './schema/yaml-1.1/set.ts'

export {
export type {
asyncVisitor,
asyncVisitorFn,
visit,
visitAsync,
visitor,
visitorFn
} from './visit.ts'
export { visit, visitAsync } from './visit.ts'
4 changes: 2 additions & 2 deletions src/nodes/Alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import type { FlowScalar } from '../parse/cst.ts'
import type { StringifyContext } from '../stringify/stringify.ts'
import { visit } from '../visit.ts'
import { ALIAS, isAlias, isCollection, isPair } from './identity.ts'
import { Node, NodeBase, Range } from './Node.ts'
import { type Node, NodeBase, type Range } from './Node.ts'
import type { Scalar } from './Scalar.ts'
import { toJS, ToJSContext } from './toJS.ts'
import { toJS, type ToJSContext } from './toJS.ts'
import type { YAMLMap } from './YAMLMap.ts'
import type { YAMLSeq } from './YAMLSeq.ts'

Expand Down
4 changes: 2 additions & 2 deletions src/nodes/Node.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { applyReviver } from '../doc/applyReviver.ts'
import type { Document } from '../doc/Document.ts'
import type { ToJSOptions } from '../options.ts'
import { Token } from '../parse/cst.ts'
import { type Token } from '../parse/cst.ts'
import type { StringifyContext } from '../stringify/stringify.ts'
import type { Alias } from './Alias.ts'
import { isDocument, NODE_TYPE } from './identity.ts'
import type { Scalar } from './Scalar.ts'
import { toJS, ToJSContext } from './toJS.ts'
import { toJS, type ToJSContext } from './toJS.ts'
import type { MapLike, YAMLMap } from './YAMLMap.ts'
import type { YAMLSeq } from './YAMLSeq.ts'

Expand Down
2 changes: 1 addition & 1 deletion src/nodes/Pair.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createNode, CreateNodeContext } from '../doc/createNode.ts'
import { createNode, type CreateNodeContext } from '../doc/createNode.ts'
import type { CollectionItem } from '../parse/cst.ts'
import type { Schema } from '../schema/Schema.ts'
import type { StringifyContext } from '../stringify/stringify.ts'
Expand Down
4 changes: 2 additions & 2 deletions src/nodes/Scalar.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { BlockScalar, FlowScalar } from '../parse/cst.ts'
import { SCALAR } from './identity.ts'
import { NodeBase, Range } from './Node.ts'
import { toJS, ToJSContext } from './toJS.ts'
import { NodeBase, type Range } from './Node.ts'
import { toJS, type ToJSContext } from './toJS.ts'

export const isScalarValue = (value: unknown) =>
!value || (typeof value !== 'function' && typeof value !== 'object')
Expand Down
4 changes: 2 additions & 2 deletions src/nodes/YAMLMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import type { BlockMap, FlowCollection } from '../parse/cst.ts'
import type { Schema } from '../schema/Schema.ts'
import type { StringifyContext } from '../stringify/stringify.ts'
import { stringifyCollection } from '../stringify/stringifyCollection.ts'
import { CreateNodeContext } from '../util.ts'
import { type CreateNodeContext } from '../util.ts'
import { addPairToJSMap } from './addPairToJSMap.ts'
import { Collection } from './Collection.ts'
import { isPair, isScalar, MAP } from './identity.ts'
import type { ParsedNode, Range } from './Node.ts'
import { createPair, Pair } from './Pair.ts'
import { isScalarValue, Scalar } from './Scalar.ts'
import { isScalarValue, type Scalar } from './Scalar.ts'
import type { ToJSContext } from './toJS.ts'

export type MapLike =
Expand Down
6 changes: 3 additions & 3 deletions src/nodes/YAMLSeq.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createNode, CreateNodeContext } from '../doc/createNode.ts'
import { createNode, type CreateNodeContext } from '../doc/createNode.ts'
import type { BlockSequence, FlowCollection } from '../parse/cst.ts'
import type { Schema } from '../schema/Schema.ts'
import type { StringifyContext } from '../stringify/stringify.ts'
Expand All @@ -7,8 +7,8 @@ import { Collection } from './Collection.ts'
import { isScalar, SEQ } from './identity.ts'
import type { ParsedNode, Range } from './Node.ts'
import type { Pair } from './Pair.ts'
import { isScalarValue, Scalar } from './Scalar.ts'
import { toJS, ToJSContext } from './toJS.ts'
import { isScalarValue, type Scalar } from './Scalar.ts'
import { toJS, type ToJSContext } from './toJS.ts'

export declare namespace YAMLSeq {
interface Parsed<
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/addPairToJSMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { addMergeToJSMap, isMergeKey } from '../schema/yaml-1.1/merge.ts'
import { createStringifyContext } from '../stringify/stringify.ts'
import { isNode } from './identity.ts'
import type { Pair } from './Pair.ts'
import { toJS, ToJSContext } from './toJS.ts'
import { toJS, type ToJSContext } from './toJS.ts'
import type { MapLike } from './YAMLMap.ts'

export function addPairToJSMap(
Expand Down
4 changes: 2 additions & 2 deletions src/parse/cst-scalar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import type { ComposeContext } from '../compose/compose-node.ts'
import type { ComposeErrorHandler } from '../compose/composer.ts'
import { resolveBlockScalar } from '../compose/resolve-block-scalar.ts'
import { resolveFlowScalar } from '../compose/resolve-flow-scalar.ts'
import { ErrorCode, YAMLParseError } from '../errors.ts'
import { Range } from '../nodes/Node.ts'
import { type ErrorCode, YAMLParseError } from '../errors.ts'
import { type Range } from '../nodes/Node.ts'
import type { Scalar } from '../nodes/Scalar.ts'
import type { StringifyContext } from '../stringify/stringify.ts'
import { stringifyString } from '../stringify/stringifyString.ts'
Expand Down
3 changes: 2 additions & 1 deletion src/parse/cst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ export {
setScalarValue
} from './cst-scalar.ts'
export { stringify } from './cst-stringify.ts'
export { visit, Visitor, VisitPath } from './cst-visit.ts'
export type { Visitor, VisitPath } from './cst-visit.ts'
export { visit } from './cst-visit.ts'

export interface SourceToken {
type:
Expand Down
20 changes: 10 additions & 10 deletions src/parse/parser.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import {
SourceToken,
Token,
FlowScalar,
FlowCollection,
Document,
BlockMap,
BlockScalar,
BlockSequence,
DocumentEnd,
type SourceToken,
type Token,
type FlowScalar,
type FlowCollection,
type Document,
type BlockMap,
type BlockScalar,
type BlockSequence,
type DocumentEnd,
prettyToken,
tokenType,
TokenType
type TokenType
} from './cst.ts'
import { Lexer } from './lexer.ts'

Expand Down
2 changes: 1 addition & 1 deletion src/public-api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Composer } from './compose/composer.ts'
import type { Reviver } from './doc/applyReviver.ts'
import { Document, Replacer } from './doc/Document.ts'
import { Document, type Replacer } from './doc/Document.ts'
import { prettifyError, YAMLParseError } from './errors.ts'
import { warn } from './log.ts'
import { isDocument } from './nodes/identity.ts'
Expand Down
2 changes: 1 addition & 1 deletion src/schema/json/schema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Scalar } from '../../nodes/Scalar.ts'
import { map } from '../common/map.ts'
import { seq } from '../common/seq.ts'
import { CollectionTag, ScalarTag } from '../types.ts'
import type { CollectionTag, ScalarTag } from '../types.ts'

function intIdentify(value: unknown): value is number | bigint {
return typeof value === 'bigint' || Number.isInteger(value)
Expand Down
4 changes: 2 additions & 2 deletions src/schema/tags.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SchemaOptions } from '../options.ts'
import type { SchemaOptions } from '../options.ts'
import { map } from './common/map.ts'
import { nullTag } from './common/null.ts'
import { seq } from './common/seq.ts'
Expand All @@ -8,14 +8,14 @@ import { float, floatExp, floatNaN } from './core/float.ts'
import { int, intHex, intOct } from './core/int.ts'
import { schema as core } from './core/schema.ts'
import { schema as json } from './json/schema.ts'
import type { CollectionTag, ScalarTag } from './types.ts'
import { binary } from './yaml-1.1/binary.ts'
import { merge } from './yaml-1.1/merge.ts'
import { omap } from './yaml-1.1/omap.ts'
import { pairs } from './yaml-1.1/pairs.ts'
import { schema as yaml11 } from './yaml-1.1/schema.ts'
import { set } from './yaml-1.1/set.ts'
import { floatTime, intTime, timestamp } from './yaml-1.1/timestamp.ts'
import type { CollectionTag, ScalarTag } from './types.ts'

const schemas = new Map<string, Array<CollectionTag | ScalarTag>>([
['core', core],
Expand Down
6 changes: 3 additions & 3 deletions src/schema/yaml-1.1/omap.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { isPair, isScalar } from '../../nodes/identity.ts'
import { toJS, ToJSContext } from '../../nodes/toJS.ts'
import { toJS, type ToJSContext } from '../../nodes/toJS.ts'
import { YAMLMap } from '../../nodes/YAMLMap.ts'
import { YAMLSeq } from '../../nodes/YAMLSeq.ts'
import { CreateNodeContext } from '../../util.ts'
import { type CreateNodeContext } from '../../util.ts'
import type { Schema } from '../Schema.ts'
import { CollectionTag } from '../types.ts'
import { type CollectionTag } from '../types.ts'
import { createPairs, resolvePairs } from './pairs.ts'

export class YAMLOMap extends YAMLSeq {
Expand Down
2 changes: 1 addition & 1 deletion src/schema/yaml-1.1/pairs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { isMap, isPair, isSeq } from '../../nodes/identity.ts'
import type { ParsedNode } from '../../nodes/Node.ts'
import { createPair, Pair } from '../../nodes/Pair.ts'
import { Scalar } from '../../nodes/Scalar.ts'
import { YAMLMap } from '../../nodes/YAMLMap.ts'
import type { YAMLMap } from '../../nodes/YAMLMap.ts'
import { YAMLSeq } from '../../nodes/YAMLSeq.ts'
import type { Schema } from '../../schema/Schema.ts'
import type { CollectionTag } from '../types.ts'
Expand Down
6 changes: 3 additions & 3 deletions src/schema/yaml-1.1/set.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { isMap, isPair, isScalar } from '../../nodes/identity.ts'
import { Pair } from '../../nodes/Pair.ts'
import { Scalar } from '../../nodes/Scalar.ts'
import { ToJSContext } from '../../nodes/toJS.ts'
import type { Scalar } from '../../nodes/Scalar.ts'
import type { ToJSContext } from '../../nodes/toJS.ts'
import { findPair, YAMLMap } from '../../nodes/YAMLMap.ts'
import type { Schema } from '../../schema/Schema.ts'
import type { StringifyContext } from '../../stringify/stringify.ts'
import { CreateNodeContext, createPair } from '../../util.ts'
import { type CreateNodeContext, createPair } from '../../util.ts'
import type { CollectionTag } from '../types.ts'

export class YAMLSet<T = unknown> extends YAMLMap<T, Scalar<null> | null> {
Expand Down
4 changes: 2 additions & 2 deletions src/stringify/stringifyCollection.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Collection } from '../nodes/Collection.ts'
import type { Collection } from '../nodes/Collection.ts'
import { isNode, isPair } from '../nodes/identity.ts'
import { stringify, StringifyContext } from './stringify.ts'
import { stringify, type StringifyContext } from './stringify.ts'
import { indentComment, lineComment } from './stringifyComment.ts'

interface StringifyCollectionOptions {
Expand Down
2 changes: 1 addition & 1 deletion src/stringify/stringifyDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { ToStringOptions } from '../options.ts'
import {
createStringifyContext,
stringify,
StringifyContext
type StringifyContext
} from './stringify.ts'
import { indentComment, lineComment } from './stringifyComment.ts'

Expand Down
2 changes: 1 addition & 1 deletion src/stringify/stringifyPair.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { isCollection, isNode, isScalar, isSeq } from '../nodes/identity.ts'
import type { Pair } from '../nodes/Pair.ts'
import { Scalar } from '../nodes/Scalar.ts'
import { stringify, StringifyContext } from './stringify.ts'
import { stringify, type StringifyContext } from './stringify.ts'
import { indentComment, lineComment } from './stringifyComment.ts'

export function stringifyPair(
Expand Down
Loading

0 comments on commit 39350a9

Please sign in to comment.