Skip to content

Commit 041cda8

Browse files
authored
Replace some "import *" (#327)
- Cases where the change is obviously better
1 parent 6e5fe58 commit 041cda8

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

src/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

4-
import * as validate from "./lib/validate"
5-
64
// Easy to use methods from validate.js
75
export { log } from "./lib/util/logging"
8-
export const compare = validate.compare
9-
export const compareTags = validate.compareTags
6+
export { compare, compareTags } from "./lib/validate"
107

118
// Classes
129
export { OpenApiDiff, Messages, Message, ChangeProperties } from "./lib/validators/openApiDiff"

src/lib/commands/oad.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
import { log } from "../util/logging"
5-
import * as validate from "../validate"
5+
import { compareTags, compare } from "../validate"
66

77
export const command = "compare <old-spec> <new-spec>"
88

@@ -47,8 +47,7 @@ export const handler = (argv: Argv) => {
4747
json: argv.j
4848
}
4949

50-
const compareFunc =
51-
oldTag && newTag ? validate.compareTags(oldSpec, oldTag, newSpec, newTag, vOptions) : validate.compare(oldSpec, newSpec, vOptions)
50+
const compareFunc = oldTag && newTag ? compareTags(oldSpec, oldTag, newSpec, newTag, vOptions) : compare(oldSpec, newSpec, vOptions)
5251

5352
return compareFunc
5453
.then(result => {

src/lib/validate.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
import { log } from "./util/logging"
5-
import * as OpenApiDiff from "./validators/openApiDiff"
5+
import { Options, OpenApiDiff } from "./validators/openApiDiff"
66

77
/**
88
* Wrapper method to compares old and new specifications.
@@ -18,14 +18,14 @@ import * as OpenApiDiff from "./validators/openApiDiff"
1818
* @param {boolean} [options.matchApiVersion] A boolean flag indicating whether to consider api-version while comparing.
1919
*
2020
*/
21-
export function compare(oldSwagger: string, newSwagger: string, options: OpenApiDiff.Options) {
21+
export function compare(oldSwagger: string, newSwagger: string, options: Options) {
2222
if (!options) {
2323
options = {}
2424
}
2525

2626
log.consoleLogLevel = options.consoleLogLevel || log.consoleLogLevel
2727
log.filepath = options.logFilepath || log.filepath
28-
const openApiDiff = new OpenApiDiff.OpenApiDiff(options)
28+
const openApiDiff = new OpenApiDiff(options)
2929

3030
return openApiDiff.compare(oldSwagger, newSwagger)
3131
}
@@ -48,14 +48,14 @@ export function compare(oldSwagger: string, newSwagger: string, options: OpenApi
4848
* @param {boolean} [options.matchApiVersion] A boolean flag indicating whether to consider api-version while comparing.
4949
*
5050
*/
51-
export function compareTags(oldSwagger: string, oldTag: string, newSwagger: string, newTag: string, options: OpenApiDiff.Options) {
51+
export function compareTags(oldSwagger: string, oldTag: string, newSwagger: string, newTag: string, options: Options) {
5252
if (!options) {
5353
options = {}
5454
}
5555

5656
log.consoleLogLevel = options.consoleLogLevel || log.consoleLogLevel
5757
log.filepath = options.logFilepath || log.filepath
58-
const openApiDiff = new OpenApiDiff.OpenApiDiff(options)
58+
const openApiDiff = new OpenApiDiff(options)
5959

6060
return openApiDiff.compare(oldSwagger, newSwagger, oldTag, newTag)
6161
}

0 commit comments

Comments
 (0)