-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
- Loading branch information
1 parent
c9cdf33
commit 7538fdc
Showing
15 changed files
with
460 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["es2020"], | ||
"noEmitOnError": true, | ||
"skipLibCheck": false, | ||
"target": "es2020" | ||
}, | ||
"exclude": ["**/__mocks__/**", "**/__tests__/**"], | ||
"extends": "../tsconfig", | ||
"include": ["../dist", "../src"], | ||
"references": [] | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
'compilerOptions': {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
*/ | ||
|
||
export * from './interfaces' | ||
export * from './utils' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Vitest Snapshot v1 | ||
|
||
exports[`unit:utils/loadTsconfig > should return TSConfig object if tsconfig file is found 1`] = ` | ||
{ | ||
"compilerOptions": { | ||
"allowJs": true, | ||
"allowUnreachableCode": false, | ||
"alwaysStrict": false, | ||
"baseUrl": "..", | ||
"checkJs": false, | ||
"declaration": true, | ||
"declarationMap": true, | ||
"emitDecoratorMetadata": true, | ||
"esModuleInterop": true, | ||
"exactOptionalPropertyTypes": true, | ||
"experimentalDecorators": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"importsNotUsedAsValues": "error", | ||
"isolatedModules": true, | ||
"lib": [ | ||
"es2020", | ||
], | ||
"module": "esnext", | ||
"moduleDetection": "force", | ||
"moduleResolution": "node", | ||
"newLine": "lf", | ||
"noEmit": true, | ||
"noEmitOnError": true, | ||
"noErrorTruncation": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"noImplicitAny": true, | ||
"noImplicitOverride": true, | ||
"noImplicitReturns": true, | ||
"noUncheckedIndexedAccess": true, | ||
"noUnusedLocals": false, | ||
"noUnusedParameters": false, | ||
"outDir": "../dist", | ||
"paths": { | ||
"#fixtures/*": [ | ||
"__fixtures__/*", | ||
], | ||
"#src": [ | ||
"src/index", | ||
], | ||
"#src/*": [ | ||
"src/*", | ||
], | ||
"#tests/*": [ | ||
"__tests__/*", | ||
], | ||
}, | ||
"preserveConstEnums": true, | ||
"preserveSymlinks": true, | ||
"pretty": true, | ||
"resolveJsonModule": true, | ||
"rootDir": "..", | ||
"skipLibCheck": false, | ||
"sourceMap": true, | ||
"strict": true, | ||
"strictNullChecks": true, | ||
"strictPropertyInitialization": true, | ||
"target": "es2020", | ||
"useDefineForClassFields": true, | ||
"useUnknownInCatchVariables": true, | ||
}, | ||
"exclude": [ | ||
"**/__mocks__/**", | ||
"**/__tests__/**", | ||
], | ||
"extends": "../tsconfig", | ||
"include": [ | ||
"../dist", | ||
"../src", | ||
], | ||
"references": [], | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* @file Unit Tests - loadTsconfig | ||
* @module tsconfig-utils/utils/tests/unit/loadTsconfig | ||
*/ | ||
|
||
import { ErrorCode, type NodeError } from '@flex-development/errnode' | ||
import { pathToFileURL, type URL } from 'node:url' | ||
import testSubject from '../load-tsconfig' | ||
|
||
describe('unit:utils/loadTsconfig', () => { | ||
it('should return TSConfig object if tsconfig file is found', () => { | ||
// Arrange | ||
const id: URL = pathToFileURL('__fixtures__/tsconfig.build.json') | ||
|
||
// Act + Expect | ||
expect(testSubject(id)).toMatchSnapshot() | ||
}) | ||
|
||
it('should return empty object if tsconfig file is empty', () => { | ||
expect(testSubject('__fixtures__/tsconfig.empty.json')).to.deep.equal({}) | ||
}) | ||
|
||
it('should return null if tsconfig file does not exist', () => { | ||
expect(testSubject('__fixtures__/tsconfig.dev.json')).to.be.null | ||
}) | ||
|
||
describe('throws', () => { | ||
it('should throw if tsconfig file does not contain valid JSON', () => { | ||
// Arrange | ||
const code: ErrorCode = ErrorCode.ERR_OPERATION_FAILED | ||
let error: NodeError | ||
|
||
// Act | ||
try { | ||
testSubject('__fixtures__/tsconfig.invalid-json') | ||
} catch (e: unknown) { | ||
error = e as typeof error | ||
} | ||
|
||
// Expect | ||
expect(error!).to.not.be.undefined | ||
expect(error!).to.have.property('code').equal(code) | ||
}) | ||
|
||
it('should throw if tsconfig file does not convert to plain object', () => { | ||
// Arrange | ||
const code: ErrorCode = ErrorCode.ERR_INVALID_RETURN_VALUE | ||
const message_regex: RegExp = /plain object .+ 'parseJSON'/ | ||
let error: NodeError | ||
|
||
// Act | ||
try { | ||
testSubject('__fixtures__/tsconfig.invalid-schema') | ||
} catch (e: unknown) { | ||
error = e as typeof error | ||
} | ||
|
||
// Expect | ||
expect(error!).to.not.be.undefined | ||
expect(error!).to.have.property('code').equal(code) | ||
expect(error!).to.have.property('message').match(message_regex) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* @file Entry Point - Utilities | ||
* @module tsconfig-utils/utils | ||
*/ | ||
|
||
export { default as loadTsconfig } from './load-tsconfig' |
Oops, something went wrong.