Skip to content

Commit

Permalink
chore: run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
danocmx committed Oct 12, 2024
1 parent a3f3385 commit d21bf22
Show file tree
Hide file tree
Showing 21 changed files with 105 additions and 72 deletions.
23 changes: 23 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"eslint-plugin-import": "^2.27.5",
"mocha": "^10.0.0",
"nyc": "^17.0.0",
"prettier": "^3.3.3",
"semantic-release": "^24.0.0",
"typescript": "^5.0.3"
},
Expand Down
5 changes: 1 addition & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,7 @@ export class Format {
attributes: StrigifySKUAttributes | ItemAttributes,
options?: StringifyOptions
): string;
stringify(
sku: string,
options?: StringifyOptions
): string;
stringify(sku: string, options?: StringifyOptions): string;
stringify(
attributesOrSku: StrigifySKUAttributes | ItemAttributes | string,
options: StringifyOptions = {}
Expand Down
6 changes: 3 additions & 3 deletions src/parseEconItem/ParsedEcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export default class ParsedEcon {
target: this.nameAttrs.target as string,
output: this.nameAttrs.output,
outputQuality: this.nameAttrs.outputQuality,
}
}
: undefined
);

Expand Down Expand Up @@ -284,9 +284,9 @@ export default class ParsedEcon {
paintDefindex: this.schema.getDefindex(
this.descriptions.paint
),
}
}
: {}),
}
}
: {}),

parts: this.descriptions.parts,
Expand Down
6 changes: 4 additions & 2 deletions src/parseEconItem/ParsedEcon/ItemName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default class ItemName {
target,
outputQuality: outputQuality as string,
},
}
}
: {}),
});
}
Expand Down Expand Up @@ -113,7 +113,9 @@ export default class ItemName {
return name;
}

private shouldAddItemNumber(itemNumber?: ItemNumber): itemNumber is ItemNumber {
private shouldAddItemNumber(
itemNumber?: ItemNumber
): itemNumber is ItemNumber {
return !!itemNumber && !this.origin.endsWith(` #${itemNumber.value}`);
}
}
12 changes: 6 additions & 6 deletions src/parseEconItem/ParsedEcon/getCrateNumber.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import ParsedEcon from "../ParsedEcon";
import ParsedEcon from '../ParsedEcon';

export default function getCrateNumber(econ: ParsedEcon): number {
if (!econ.options.retrieveCrateNumber) return 0;
if (econ.nameAttrs.itemNumber || econ.descriptions.itemNumber) return 0;

const search = econ.options.useTrueDefindex ? econ.trueDefindex : econ.name;
if (!econ.options.retrieveCrateNumber) return 0;
if (econ.nameAttrs.itemNumber || econ.descriptions.itemNumber) return 0;

return econ.schema.getCrateNumber(search);
const search = econ.options.useTrueDefindex ? econ.trueDefindex : econ.name;

return econ.schema.getCrateNumber(search);
}
15 changes: 9 additions & 6 deletions src/parseEconItem/ParsedEcon/getDescriptions/item-number.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import { EconDescription } from "../../../types";
import { EconDescription } from '../../../types';

export function isMedal(description: EconDescription): boolean {
return description.value.startsWith('Medal no. ');
return description.value.startsWith('Medal no. ');
}

export function isCrate(description: EconDescription): boolean {
return description.value.startsWith('Crate Series ') && description.color === '7ea9d1';
return (
description.value.startsWith('Crate Series ') &&
description.color === '7ea9d1'
);
}

export function getMedal(description: EconDescription): number {
return parseInt(description.value.replace('Medal no. ', ''));
return parseInt(description.value.replace('Medal no. ', ''));
}

export function getCrate(description: EconDescription): number {
return parseInt(description.value.replace('Crate Series #', ''));
}
return parseInt(description.value.replace('Crate Series #', ''));
}
11 changes: 7 additions & 4 deletions src/parseEconItem/ParsedEcon/getNameAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ export default function (econ: ParsedEcon): NameAttributes {
}

const usableItem = getUsableItem(
attributes.itemNumber ? removeItemNumber(name, attributes.itemNumber) : name
attributes.itemNumber
? removeItemNumber(name, attributes.itemNumber)
: name
);
if (usableItem) {
Object.assign(attributes, usableItem);
Expand All @@ -51,7 +53,7 @@ export default function (econ: ParsedEcon): NameAttributes {

/**
* Returns a string that can be used for retrieving item number.
* @param econ
* @param econ
* @returns name
*/
function getNameForItemNumber(econ: ParsedEcon) {
Expand All @@ -62,7 +64,8 @@ function getNameForItemNumber(econ: ParsedEcon) {

return econ.item.name;
}
if (!econ.options.itemNumberFromFraudWarning) return econ.itemName.getOrigin();
if (!econ.options.itemNumberFromFraudWarning)
return econ.itemName.getOrigin();
const warning = econ.item.fraudwarnings?.find((f) =>
f.startsWith('This item has been renamed.')
);
Expand All @@ -74,7 +77,7 @@ function getNameForItemNumber(econ: ParsedEcon) {

/**
* Checks if item has been renamed based on fraudwarnings and symbols.
* @param econ
* @param econ
* @returns if it has been renamed
*/
function hasBeenRenamed(econ: ParsedEcon) {
Expand Down
8 changes: 4 additions & 4 deletions src/parseEconItem/ParsedEcon/getUses.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import ParsedEcon from '../ParsedEcon';

export default function getUses(econ: ParsedEcon): number {
if (!econ.item?.app_data?.quantity) {
return 0;
}
if (!econ.item?.app_data?.quantity) {
return 0;
}

const uses = parseInt(econ.item?.app_data?.quantity);
return isNaN(uses) ? 0 : uses;
return isNaN(uses) ? 0 : uses;
}
23 changes: 14 additions & 9 deletions src/parseString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,20 @@ function parseString(
};

if (inNumbers) {
const convertedAttributes = getConvertedIntAttributes(schema, itemName, {
killstreak: attributes.killstreak,
wear: attributes.wear,
effect: attributes.effect,
quality: attributes.quality.value,
outputQuality:
attributes.usableItem && attributes.usableItem.outputQuality,
texture: attributes.texture,
});
const convertedAttributes = getConvertedIntAttributes(
schema,
itemName,
{
killstreak: attributes.killstreak,
wear: attributes.wear,
effect: attributes.effect,
quality: attributes.quality.value,
outputQuality:
attributes.usableItem &&
attributes.usableItem.outputQuality,
texture: attributes.texture,
}
);

if (!convertedAttributes.killstreak)
delete convertedAttributes.killstreak;
Expand Down
2 changes: 1 addition & 1 deletion src/parseString/Attributes/getEffect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const HAT_NAME_EXCEPTIONS: [string, string][] = [
['Accursed Apparition', 'Accursed'],
['Taunt: The Hot Wheeler', 'Hot'],
['Frostbite Bonnet', 'Frostbite'],
['Cool Warm Sweater', 'Cool']
['Cool Warm Sweater', 'Cool'],
];

function isException(name: string, effect: string): boolean {
Expand Down
2 changes: 1 addition & 1 deletion src/parseString/Attributes/getItemNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function (name: string): ItemNumber | null {
function getType(name: string): ItemNumber['type'] {
const [_, type] = (name.match(/\b(Medal|Crate|Case|Munition)\b/) || []) as [
any,
'Medal' | 'Crate' | 'Case' | 'Munition'
'Medal' | 'Crate' | 'Case' | 'Munition',
];

// Same thing, different name.
Expand Down
5 changes: 1 addition & 4 deletions src/parseString/Attributes/getQuality/isVintage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ export default function (name: string): boolean {
);
}

const VINTAGE_EXCEPTIONS = [
'Vintage Merryweather',
'Vintage Tyrolean',
];
const VINTAGE_EXCEPTIONS = ['Vintage Merryweather', 'Vintage Tyrolean'];

function isVintageException(name: string): boolean {
return VINTAGE_EXCEPTIONS.some((exception) => name.includes(exception));
Expand Down
12 changes: 7 additions & 5 deletions src/parseString/Attributes/getUsableItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ function isStrangifierChemistrySet(name: string): boolean {

const KIT_EXCEPTIONS = [
"Killer's Kit",
"Coffin Kit",
"Summer Starter Kit",
"Chiromancer's Kit"
'Coffin Kit',
'Summer Starter Kit',
"Chiromancer's Kit",
];

function getItemIfTarget(name: string): string | void {
Expand All @@ -68,9 +68,11 @@ function getItemIfTarget(name: string): string | void {
return;
}

return KIT_EXCEPTIONS.some((exception) => name.includes(exception)) ? undefined : 'Kit';
return KIT_EXCEPTIONS.some((exception) => name.includes(exception))
? undefined
: 'Kit';
}

function isChemistrySet(name: string): boolean {
return name.includes(' Chemistry Set') ;
return name.includes(' Chemistry Set');
}
4 changes: 3 additions & 1 deletion src/parseString/Attributes/isFestivized.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export default function (name: string): boolean {
return name.includes('Festivized ') && !name.includes('Festivized Formation');
return (
name.includes('Festivized ') && !name.includes('Festivized Formation')
);
}
8 changes: 2 additions & 6 deletions src/shared/getTexture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@ import isNumber from '../util/isNumber';

import { ISchema } from '../types/schema';

const TEXTURE_EXCEPTIONS = [
['Health and Hell', 'Health and Hell (Green)'],
];
const TEXTURE_EXCEPTIONS = [['Health and Hell', 'Health and Hell (Green)']];

const TEXTURE_TO_EFFECT_EXCEPTIONS = [
['Rainbow', 'Rainbow Reverie'],
]
const TEXTURE_TO_EFFECT_EXCEPTIONS = [['Rainbow', 'Rainbow Reverie']];

/**
* Iterates over effects object to get matching effect.
Expand Down
7 changes: 5 additions & 2 deletions src/stringify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default function (
? getOutput(
schema.getName(output),
schema.getQualityName(outputQuality as number)
)
)
: schema.getName(target as string)
} `;
}
Expand Down Expand Up @@ -189,7 +189,10 @@ function canAddKillstreak(
}

function isKillstreakKitOrFabricator(name: string, target?: string): boolean {
return !!(target && (name.includes(' Kit') || name.includes(' Fabricator'))); // This checks for fabricator too.
return !!(
target &&
(name.includes(' Kit') || name.includes(' Fabricator'))
); // This checks for fabricator too.
}

function isUniqueHat(
Expand Down
12 changes: 3 additions & 9 deletions src/toSKU/guards.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { SKUAttributes } from '../types';

export function hasTargetDefindex(
attributes: SKUAttributes
): attributes is {
export function hasTargetDefindex(attributes: SKUAttributes): attributes is {
targetDefindex: number;
defindex: number;
quality: number;
Expand All @@ -11,9 +9,7 @@ export function hasTargetDefindex(
return Object.prototype.hasOwnProperty.call(attributes, 'targetDefindex');
}

export function hasOutputDefindex(
attributes: SKUAttributes
): attributes is {
export function hasOutputDefindex(attributes: SKUAttributes): attributes is {
outputDefindex: number;
outputQuality: number;
defindex: number;
Expand All @@ -23,9 +19,7 @@ export function hasOutputDefindex(
return Object.prototype.hasOwnProperty.call(attributes, 'outputDefindex');
}

export function hasOutputQuality(
attributes: SKUAttributes
): attributes is {
export function hasOutputQuality(attributes: SKUAttributes): attributes is {
outputQuality: number;
defindex: number;
quality: number;
Expand Down
6 changes: 3 additions & 3 deletions src/types/econ.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
export type EconOptions = {
/**
* Uses defined from wiki link econ item has.
*
*
* Defaults to false.
*/
useTrueDefindex?: boolean;
/**
* Retrieves item number from fraudwarning if item has been renamed.
*
*
* Defaults to false.
*/
itemNumberFromFraudWarning?: boolean;
/**
* Retrieves crate number for crates.
*
*
* Defaults to false.
*/
retrieveCrateNumber?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export type EconItem = {
market_name: string;
market_hash_name: string;
tags: EconTag[];
app_data?: { def_index: number, quality: number, quantity?: string };
app_data?: { def_index: number; quality: number; quantity?: string };
type: string;

tradable: number | boolean;
Expand Down
Loading

0 comments on commit d21bf22

Please sign in to comment.