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

Use .ts extension in relative source imports #591

Merged
merged 8 commits into from
Dec 30, 2024
Prev Previous commit
Next Next commit
test: Fix import paths & add type keywords
eemeli committed Nov 29, 2024
commit 32b91d19949729be60fb84ae5328e26769ee6427
2 changes: 1 addition & 1 deletion config/jest.config.js
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ switch (process.env.npm_lifecycle_event) {
'^yaml$': '<rootDir>/dist/index.js',
'^yaml/cli$': '<rootDir>/dist/cli.mjs',
'^yaml/util$': '<rootDir>/dist/util.js',
'^../src/test-events$': '<rootDir>/dist/test-events.js'
'^../src/test-events.ts$': '<rootDir>/dist/test-events.js'
}
transform['[/\\\\]dist[/\\\\].*\\.mjs$'] = babel
break
4 changes: 2 additions & 2 deletions tests/clone.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isAlias, isScalar, parseDocument, Scalar, visit, YAMLMap } from 'yaml'
import { source } from './_utils'
import { isAlias, isScalar, parseDocument, type Scalar, visit, type YAMLMap } from 'yaml'
import { source } from './_utils.ts'

describe('doc.clone()', () => {
test('has expected members', () => {
14 changes: 7 additions & 7 deletions tests/collection-access.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {
Document,
parseDocument,
Pair,
Scalar,
YAMLMap,
YAMLOMap,
YAMLSeq,
YAMLSet,
type Scalar,
type YAMLMap,
type YAMLOMap,
type YAMLSeq,
type YAMLSet,
isMap,
isSeq,
isMap
parseDocument
} from 'yaml'

describe('Map', () => {
2 changes: 1 addition & 1 deletion tests/cst.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CST, Parser } from 'yaml'
import { source } from './_utils'
import { source } from './_utils.ts'

function cstDoc(src: string) {
const tokens = Array.from(new Parser().parse(src))
4 changes: 2 additions & 2 deletions tests/directives.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { parseDocument, Scalar } from 'yaml'
import { source } from './_utils'
import { parseDocument, type Scalar } from 'yaml'
import { source } from './_utils.ts'

describe('%TAG', () => {
test('parse local tags', () => {
2 changes: 1 addition & 1 deletion tests/doc/YAML-1.1.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { source } from '../_utils'
import { source } from '../_utils.ts'
import { parseAllDocuments } from 'yaml'

test('Use preceding directives if none defined', () => {
2 changes: 1 addition & 1 deletion tests/doc/anchors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Alias, Document, parse, parseDocument, YAMLMap, YAMLSeq } from 'yaml'
import { type Alias, Document, parse, parseDocument, type YAMLMap, type YAMLSeq } from 'yaml'

test('basic', () => {
const src = `- &a 1\n- *a\n`
2 changes: 1 addition & 1 deletion tests/doc/comments.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { source } from '../_utils'
import { source } from '../_utils.ts'
import * as YAML from 'yaml'

describe('parse comments', () => {
4 changes: 2 additions & 2 deletions tests/doc/createNode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Alias, Document, Node, Scalar, YAMLMap, YAMLSeq } from 'yaml'
import { source } from '../_utils'
import { type Alias, Document, type Node, Scalar, YAMLMap, YAMLSeq } from 'yaml'
import { source } from '../_utils.ts'

describe('createNode(value)', () => {
test('boolean', () => {
2 changes: 1 addition & 1 deletion tests/doc/errors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as YAML from 'yaml'
import { source } from '../_utils'
import { source } from '../_utils.ts'

describe('tabs as indentation', () => {
test('fail on map value indented with tab', () => {
4 changes: 2 additions & 2 deletions tests/doc/foldFlowLines.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as YAML from 'yaml'
import { foldFlowLines as fold, FoldOptions } from 'yaml/util'
import { source } from '../_utils'
import { foldFlowLines as fold, type FoldOptions } from 'yaml/util'
import { source } from '../_utils.ts'

const FOLD_FLOW = 'flow'
const FOLD_QUOTED = 'quoted'
2 changes: 1 addition & 1 deletion tests/doc/parse.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { readFileSync } from 'fs'
import { resolve } from 'path'
import * as YAML from 'yaml'
import { source } from '../_utils'
import { source } from '../_utils.ts'

describe('scalars', () => {
test('empty block scalar at end of document', () => {
2 changes: 1 addition & 1 deletion tests/doc/stringify.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { source } from '../_utils'
import { source } from '../_utils.ts'
import * as YAML from 'yaml'
import { Pair, Scalar } from 'yaml'

18 changes: 9 additions & 9 deletions tests/doc/types.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import {
CollectionTag,
type CollectionTag,
Document,
DocumentOptions,
Node,
parse,
ParsedNode,
type DocumentOptions,
type Node,
parseDocument as origParseDocument,
ParseOptions,
parse,
type ParsedNode,
type ParseOptions,
Scalar,
ScalarTag,
type ScalarTag,
Schema,
SchemaOptions,
type SchemaOptions,
stringify,
YAMLMap,
YAMLSeq
} from 'yaml'
import { seqTag, stringifyString, stringTag } from 'yaml/util'
import { source } from '../_utils'
import { source } from '../_utils.ts'

const parseDocument = <T extends Node = ParsedNode>(
source: string,
4 changes: 2 additions & 2 deletions tests/node-to-js.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { parseDocument, YAMLMap, YAMLSeq } from 'yaml'
import { source } from './_utils'
import { parseDocument, type YAMLMap, type YAMLSeq } from 'yaml'
import { source } from './_utils.ts'

describe('scalars', () => {
test('plain', () => {
2 changes: 1 addition & 1 deletion tests/stream.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Composer, Document, Parser, parseDocument } from 'yaml'
import { Composer, type Document, Parser, parseDocument } from 'yaml'

const src = `
#c0\n \n
2 changes: 1 addition & 1 deletion tests/visit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Document, isSeq, parseDocument, Scalar, visit, visitAsync } from 'yaml'
import { Document, isSeq, parseDocument, type Scalar, visit, visitAsync } from 'yaml'

const coll = { items: {} }

4 changes: 2 additions & 2 deletions tests/yaml-test-suite.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { readdirSync, readFileSync } from 'fs'
import { resolve } from 'path'

import { CST, Document, Lexer, parse, parseAllDocuments, Parser } from 'yaml'
import { testEvents } from '../src/test-events' // no public export
import { CST, type Document, Lexer, parse, parseAllDocuments, Parser } from 'yaml'
import { testEvents } from '../src/test-events.ts' // no public export

type TestCase = {
yaml: string