-
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.
Refactor to keep things more functional (#6)
* feat: unified package parsing * chore(deps): use std lib v0.185.0 * chore(deps): use deno.land version of zod * feat: allow remote packages * fix: language for @types * fix: combine deps * test: fix number of expected errors
- Loading branch information
Showing
21 changed files
with
540 additions
and
325 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,78 +1,105 @@ | ||
import { Range } from "https://deno.land/[email protected]/semver/mod.ts"; | ||
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts"; | ||
import { matched_types, mismatches } from "./check_types.ts"; | ||
|
||
Deno.test("will not complain on types without an associated pacakge", () => { | ||
const mismatches = matched_types([ | ||
{ name: "@types/node", range: new Range("~8.11") }, | ||
{ name: "typescript", range: new Range("^4.9") }, | ||
]); | ||
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts"; | ||
import { mismatches, types_matching_dependencies } from "./check_types.ts"; | ||
|
||
Deno.test("will not complain on types without an associated package", () => { | ||
const mismatches = types_matching_dependencies({ | ||
devDependencies: { | ||
"@types/node": "~18.11", | ||
}, | ||
dependencies: { | ||
"typescript": "^4.9", | ||
}, | ||
}); | ||
|
||
assertEquals(mismatches, []); | ||
}); | ||
|
||
Deno.test("will find potential mismatches on types with an associated pacakge", () => { | ||
const matched = matched_types([ | ||
{ name: "@types/react", range: new Range("~16.1") }, | ||
{ name: "react", range: new Range("^16.1") }, | ||
]); | ||
Deno.test("will find potential mismatches on types with an associated package", () => { | ||
const matched = types_matching_dependencies( | ||
{ | ||
devDependencies: { | ||
"@types/react": "~16.1", | ||
}, | ||
dependencies: { | ||
"react": "^16.1", | ||
}, | ||
}, | ||
); | ||
|
||
assertEquals(matched, [ | ||
{ | ||
name: "react", | ||
range: new Range("^16.1"), | ||
type_range: new Range("~16.1"), | ||
name_untyped: "react", | ||
version_untyped: ("^16.1"), | ||
name_typed: "@types/react", | ||
version_typed: ("~16.1"), | ||
}, | ||
]); | ||
}); | ||
|
||
Deno.test("will error on caret ranges", () => { | ||
const mismatched = mismatches(matched_types([ | ||
{ name: "@types/react", range: new Range("^17") }, | ||
{ name: "react", range: new Range("^17") }, | ||
])); | ||
const mismatched = mismatches(types_matching_dependencies({ | ||
devDependencies: { | ||
"@types/react": "^17", | ||
}, | ||
dependencies: { | ||
"react": "^17.0", | ||
}, | ||
})); | ||
|
||
assertEquals(mismatched, [ | ||
["react", "Invalid notation. Only pinned and tilde (~) ranges allowed"], | ||
]); | ||
}); | ||
|
||
Deno.test("will error on wide ranges", () => { | ||
const mismatched = mismatches(matched_types([ | ||
{ name: "@types/react", range: new Range(">=17") }, | ||
{ name: "react", range: new Range("^17") }, | ||
])); | ||
const mismatched = mismatches(types_matching_dependencies({ | ||
devDependencies: { | ||
"@types/react": ">=17", | ||
}, | ||
dependencies: { | ||
"react": "^17.0", | ||
}, | ||
})); | ||
|
||
assertEquals(mismatched, [ | ||
["react", "Invalid notation. Only pinned and tilde (~) ranges allowed"], | ||
]); | ||
}); | ||
|
||
// TODO: check that these are valid? | ||
Deno.test("will allow pinned versions", () => { | ||
const mismatched = mismatches(matched_types([ | ||
{ name: "@types/react", range: new Range("17") }, | ||
{ name: "react", range: new Range("17") }, | ||
])); | ||
const mismatched = mismatches(types_matching_dependencies({ | ||
devDependencies: { | ||
"@types/react": "17", | ||
}, | ||
dependencies: { | ||
"react": "17", | ||
}, | ||
})); | ||
|
||
assertEquals(mismatched, []); | ||
}); | ||
|
||
Deno.test("will error on invalid major ranges", () => { | ||
const mismatched = mismatches(matched_types([ | ||
{ name: "@types/react", range: new Range("~17.1") }, | ||
{ name: "react", range: new Range("~18.1") }, | ||
])); | ||
const mismatched = mismatches(types_matching_dependencies({ | ||
devDependencies: { "@types/react": "~17.1" }, | ||
dependencies: { "react": "~18.1" }, | ||
})); | ||
|
||
assertEquals(mismatched, [ | ||
["react", "Mismatching major versions"], | ||
]); | ||
}); | ||
|
||
Deno.test("will error on invalid minor ranges", () => { | ||
const mismatched = mismatches(matched_types([ | ||
{ name: "@types/react", range: new Range("~17.1") }, | ||
{ name: "react", range: new Range("~17.0") }, | ||
])); | ||
const mismatched = mismatches(types_matching_dependencies({ | ||
devDependencies: { | ||
"@types/react": "~17.1", | ||
}, | ||
dependencies: { | ||
"react": "~17.0", | ||
}, | ||
})); | ||
|
||
assertEquals(mismatched, [ | ||
["react", "Mismatching minor versions"], | ||
|
@@ -81,10 +108,16 @@ Deno.test("will error on invalid minor ranges", () => { | |
|
||
Deno.test("will allow known errors ", () => { | ||
const mismatched = mismatches( | ||
matched_types([ | ||
{ name: "@types/scheduler", range: new Range("~0.16.2") }, | ||
{ name: "scheduler", range: new Range("~0.23.0") }, | ||
]), | ||
types_matching_dependencies( | ||
{ | ||
devDependencies: { | ||
"@types/scheduler": "~0.16.2", | ||
}, | ||
dependencies: { | ||
"scheduler": "~0.23.0", | ||
}, | ||
}, | ||
), | ||
{ | ||
known_issues: { | ||
"scheduler@~0.23.0": { | ||
|
Oops, something went wrong.