Skip to content

Commit

Permalink
Fies pretier
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfarrell76 committed Dec 7, 2023
1 parent ee7af1e commit 35e20f6
Show file tree
Hide file tree
Showing 25 changed files with 550 additions and 586 deletions.
5 changes: 0 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ module.exports = {

/**
* We prefer to use types instead of interfaces
*
* @see https://www.notion.so/transcend/Use-Type-instead-of-Interface-b3868d0885724b6894647018323a57b2
*/
'@typescript-eslint/prefer-interface': 0,
Expand All @@ -98,7 +97,6 @@ module.exports = {

/**
* We use a custom pre-commit for import orders
*
* @see pre_commit_hooks/ordered_imports.js
*/
'import/order': 0,
Expand Down Expand Up @@ -144,22 +142,19 @@ module.exports = {

/**
* Type signatures should be combined if possible:
*
* @see https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/unified-signatures.md
*/
'@typescript-eslint/unified-signatures': ['error'],

/**
* Group overrides next to each other
*
* @see https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md
*/
'@typescript-eslint/adjacent-overload-signatures': ['error'],

/**
* Explicitly specify return types to functions. This improves type safety
* and also allows compiler to optimize
*
* @see https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-function-return-type.md
* @see https://www.notion.so/transcend/4ef10ad243b746d9b2a84f8bb4a1b01a?v=8eb2ce8c21d54b43a916e7f93a563950&p=36b3bd33e054443084d2759537e6423b
*/
Expand Down
1,044 changes: 522 additions & 522 deletions .pnp.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repos:
- repo: https://github.com/pre-commit/mirrors-prettier
# Use the sha / tag you want to point at, this needs
# to stay in sync with the package.json version
rev: 'v2.3.2'
rev: 'v2.7.1'
hooks:
- id: prettier
args: [--write, --list-different]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ const {existsSync} = require(`fs`);
const {createRequire} = require(`module`);
const {resolve} = require(`path`);

const relPnpApiPath = "../../../../.pnp.cjs";
const relPnpApiPath = "../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = createRequire(absPnpApiPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require prettier/bin/prettier.cjs
// Setup the environment to be able to require prettier/bin-prettier.js
require(absPnpApiPath).setup();
}
}

// Defer to the real prettier/bin/prettier.cjs your application uses
module.exports = absRequire(`prettier/bin/prettier.cjs`);
// Defer to the real prettier/bin-prettier.js your application uses
module.exports = absRequire(`prettier/bin-prettier.js`);
File renamed without changes.
6 changes: 3 additions & 3 deletions .yarn/sdks/prettier/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "prettier",
"version": "3.1.0-sdk",
"main": "./index.cjs",
"version": "2.8.8-sdk",
"main": "./index.js",
"type": "commonjs",
"bin": "./bin/prettier.cjs"
"bin": "./bin-prettier.js"
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Transcend Inc.",
"name": "@transcend-io/type-utils",
"description": "Small package containing useful typescript utilities.",
"version": "1.2.0",
"version": "1.2.1",
"homepage": "https://github.com/transcend-io/type-utils",
"repository": {
"type": "git",
Expand Down Expand Up @@ -44,7 +44,7 @@
"eslint-plugin-import": "2.29.0",
"eslint-plugin-jsdoc": "^46.9.0",
"mocha": "^10.2.0",
"prettier": "^3.1.0",
"prettier": "^2.7.1",
"ts-node": "^10.9.1",
"typescript": "^5.3.2"
},
Expand Down
3 changes: 0 additions & 3 deletions src/apply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import type { ObjByString, StringKeys } from './types';
* Apply a function to each value of an object. Similar to lodash.mapValues but should preserve the typing of the keys.
*
* This allows one to define an object keys in an enum and then the resulting map should keep the same typing
*
* @param obj - The object to apply the function to
* @param applyFunc - The function to apply
* @returns The updated object
Expand Down Expand Up @@ -35,7 +34,6 @@ export function apply<TInput extends ObjByString, TOutput>(
* Apply a function to each value of an object. Similar to lodash.mapValues but should preserve the typing of the keys.
*
* This allows one to define an object keys in an enum and then the resulting map should keep the same typing
*
* @param obj - The object to apply the function to
* @param applyFunc - The function to apply
* @returns The updated object
Expand Down Expand Up @@ -69,7 +67,6 @@ export async function asyncApply<TInput extends ObjByString, TOutput>(

/**
* Convert a typescript enum to a mapping of [value]: [value] and then call apply on that
*
* @param enm - The object to apply the function to
* @param applyFunc - The function to apply
* @returns The updated object
Expand Down
1 change: 0 additions & 1 deletion src/codecTools/FixedLengthArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export interface FixedLengthArrayBrand<T> extends Array<T> {

/**
* The refinement for encoding/decoding strings of fixed length
*
* @param min - The array min length
* @param max - The array max length
* @param a - The array type
Expand Down
1 change: 0 additions & 1 deletion src/codecTools/FixedLengthString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export type FixedLengthStringBrand<N extends number> = {

/**
* The refinement for encoding/decoding strings of fixed length
*
* @param len - The string's length
* @returns The fixed length string codec
*/
Expand Down
1 change: 0 additions & 1 deletion src/codecTools/decodeCodec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export const CODEC_ERROR_MESSAGE = 'Failed to decode codec:';

/**
* Decode a codec, returning the value if contents are validated, else throws an error
*
* @param codec - The codec to decode with
* @param txt - The text to JSON parse
* @param parse - If a string is provided, assume it is JSON and call JSON.parse on it
Expand Down
1 change: 0 additions & 1 deletion src/codecTools/dictionary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export interface DictionaryC<
/**
* Helper to encode/decode a record with partial keys.
* Copied from https://github.com/gcanti/io-ts/issues/429#issuecomment-655394345
*
* @param keys - The possible dictionary keys
* @param values - The possible dictionary values
* @param name - (Optional) name of this dictionary
Expand Down
1 change: 0 additions & 1 deletion src/codecTools/isCodecError.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* Checks the error message to see if it is an io-ts codec error
*
* @param err - The error obj
* @returns whether it is a io-ts codec error
*/
Expand Down
1 change: 0 additions & 1 deletion src/codecTools/partialRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export interface PartialRecordC<

/**
* Like t.record, but where the keys are all optional to include
*
* @param domain - The key type, like `'a' | 'b' | 'c'`. In this example, 0 or more of those keys would need to be present.
* @param codomain - The value type
* @param name - The optional name of the record type
Expand Down
1 change: 0 additions & 1 deletion src/codecTools/toJsonSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ type MappableType =

/**
* Convert an io-ts codec to a JSON Schema (v7)
*
* @param _type - an io-ts codec
* @param strict - whether to enable strict mode
* @returns a JSON schema object
Expand Down
4 changes: 0 additions & 4 deletions src/enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export type EnumInput<T, TKey extends string = string> =

/**
* Convert a list of strings to an "enum" object
*
* @param attributes - The attributes of the enum
* @returns The input to become an enum
*/
Expand All @@ -38,7 +37,6 @@ export function listToEnum(attributes: string[]): Enumerate<string> {

/**
* Create an enum object with a proxy handler that will throw an error when a property is access that is not in the enum
*
* @param attributes - The enums to merge into a single enum (all properties)
* @returns The object proxy with error logger when a value is accessed outside of enum
*/
Expand All @@ -55,7 +53,6 @@ export function createEnum<T = string, TKey extends string = string>(

/**
* Filter an enum and return the keys that remain
*
* @param obj - The object to filter
* @param filterFunc - The function to filter the enum key/values by
* @returns The object keys that remained
Expand All @@ -79,7 +76,6 @@ export function filterEnum<T extends ObjByString>(

/**
* Make an enum compatible with types -- in separate file because Logger/enums and Enum/index circular dependency
*
* @param x - The enum
* @returns The object proxy with error logger when a value is accessed outside of enum
*/
Expand Down
1 change: 0 additions & 1 deletion src/getEntries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { ObjByString } from './types';

/**
* Object.entries that actually preserves entries as types.
*
* @param o - The object to get the entries from
* @returns The entries of the object preserving type
*/
Expand Down
3 changes: 0 additions & 3 deletions src/getKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { StringKeys } from './types';
/* eslint-disable @typescript-eslint/ban-types */
/**
* Object.keys for string keys only
*
* @param o - The object to get the keys from
* @returns The string keys of the object preserving type
*/
Expand All @@ -14,8 +13,6 @@ export function getStringKeys<T extends {}>(o: T): StringKeys<T>[] {

/**
* Object.keys that actually preserves keys as types.
*
*
* @param o - The object to get the keys from
* @returns The keys of the object preserving type
*/
Expand Down
9 changes: 3 additions & 6 deletions src/getValues.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
/**
* Object.values that actually preserves values as types.
*
* @param o - The object to get the values from
* @returns The values of the object preserving type
*/
export function getValues<TVal>(
o: {
[k in string | number | symbol]: TVal;
},
): TVal[] {
export function getValues<TVal>(o: {
[k in string | number | symbol]: TVal;
}): TVal[] {
return Object.values(o) as TVal[];
}
1 change: 0 additions & 1 deletion src/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export type Gql<TGraphQLType extends object> = string & {
* I like being able to create un-named fragments that can be constructed into a graphql statement.
* It is nice to wrap the fragment in a gql tag to get editor highlighting, however the need to co-localize each fragment definition with the
* resulting graphql statement is a pain, and thus why graphql-tag is not used.
*
* @param strings - The template string
* @param expressions - The expressions injected into the template
* @returns The gql string that was the inputs
Expand Down
1 change: 0 additions & 1 deletion src/groupBy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*
* Returns a map of identifiers to elements from a given
* list that return that identifier.
*
* @param iterable - the list to group by keys
* @param getKey - the function to apply to an element of the list to get the key it should belong in
* @returns a map of identifiers to values that mapped to that identifier
Expand Down
10 changes: 3 additions & 7 deletions src/invert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { getEntries } from './getEntries';
/**
* Invert an object so that the values look up the keys.
* If the object has an array as the value, each item in the array will be inverted.
*
* @param obj - The object to invert
* @param throwOnDuplicate - When true, throw error if duplicate key detected
* @returns The inverted object
Expand Down Expand Up @@ -54,15 +53,12 @@ export function invert<TKey extends string, TValue extends string | string[]>(

/**
* Safely invert an object to be { [key in TValue]: TKey[] }
*
* @param obj - The object to invert
* @returns The inverted object
*/
export function invertSafe<TKey extends string, TValue extends string>(
obj: {
[key in TKey]: TValue | TValue[];
},
): {
export function invertSafe<TKey extends string, TValue extends string>(obj: {
[key in TKey]: TValue | TValue[];
}): {
[key in TValue]: TKey[];
} {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
7 changes: 3 additions & 4 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,9 @@ export type Requirize<T, K extends keyof T> = Identity<
/**
* Convert keys of a type to strings
*/
export type Stringify<T, K extends keyof T> = Omit<T, K> &
{
[P in keyof T]: string;
};
export type Stringify<T, K extends keyof T> = Omit<T, K> & {
[P in keyof T]: string;
};

/**
* Extract string keys from an object
Expand Down
9 changes: 3 additions & 6 deletions src/valuesOf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ import { invert } from './invert';

/**
* We care about the values of an enum. This does not come out of the box with io-ts so we have to invert the enum first.
*
* @param enm - The enum to invert
* @returns The io-ts keyof
*/
export function valuesOf<TEnum extends string>(
enm: {
[k in string]: TEnum;
},
): t.KeyofC<{ [k in TEnum]: unknown }> {
export function valuesOf<TEnum extends string>(enm: {
[k in string]: TEnum;
}): t.KeyofC<{ [k in TEnum]: unknown }> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return t.keyof(invert(enm) as any);
}
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ __metadata:
fp-ts: "npm:^2.16.1"
io-ts: "npm:^2.2.21"
mocha: "npm:^10.2.0"
prettier: "npm:^3.1.0"
prettier: "npm:^2.7.1"
ts-node: "npm:^10.9.1"
typescript: "npm:^5.3.2"
languageName: unknown
Expand Down Expand Up @@ -3809,12 +3809,12 @@ __metadata:
languageName: node
linkType: hard

"prettier@npm:^3.1.0":
version: 3.1.0
resolution: "prettier@npm:3.1.0"
"prettier@npm:^2.7.1":
version: 2.8.8
resolution: "prettier@npm:2.8.8"
bin:
prettier: bin/prettier.cjs
checksum: a45ea70aa97fde162ea4c4aba3dfc7859aa6a732a1db34458d9535dc3c2c16d3bc3fb5689e6cd76aa835562555303b02d9449fd2e15af3b73c8053557e25c5b6
prettier: bin-prettier.js
checksum: 463ea8f9a0946cd5b828d8cf27bd8b567345cf02f56562d5ecde198b91f47a76b7ac9eae0facd247ace70e927143af6135e8cf411986b8cb8478784a4d6d724a
languageName: node
linkType: hard

Expand Down

0 comments on commit 35e20f6

Please sign in to comment.