Skip to content

Commit

Permalink
build: add trailing space lint (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinlee11 authored Oct 7, 2024
1 parent b050739 commit b29c499
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 24 deletions.
8 changes: 6 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ module.exports = {
'sourceType': 'module',
},
'plugins': [
'@typescript-eslint'
'@typescript-eslint',
'@stylistic/js',
],
'ignorePatterns': ['**/docs/*', '**/lib/*', '**/bin/*'],
'rules': {
Expand All @@ -107,6 +108,9 @@ module.exports = {
],
'no-console': [
'error'
]
],
'@stylistic/js/no-trailing-spaces': [
'error'
],
}
};
15 changes: 15 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# Can only have this run once, otherwise you get "husky - pre-commit hook exited with code 3 (error)"
if [ -z "$nvm_set" ]; then
export NVM_DIR="$HOME/.nvm"

# This loads nvm.sh, sets the correct PATH before running hook, and ensures the project version of Node
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

# If you have an .nvmrc file, we use the relevant node version
if [[ -f ".nvmrc" ]]; then
nvm use
fi
readonly nvm_set=1
export nvm_set
fi

#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

Expand Down
87 changes: 81 additions & 6 deletions package-lock.json

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

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@commitlint/cli": "^17.4.1",
"@commitlint/config-conventional": "^17.4.0",
"@size-limit/preset-small-lib": "^8.1.1",
"@stylistic/eslint-plugin-js": "^2.9.0",
"@typescript-eslint/eslint-plugin": "^6.1.0",
"@typescript-eslint/parser": "^6.1.0",
"@vitest/coverage-v8": "^0.34.1",
Expand All @@ -62,8 +63,6 @@
"vite-plugin-dts": "^1.7.1",
"vitest": "^0.34.1"
},
"dependencies": {
},
"volta": {
"node": "20.8.1"
}
Expand Down
6 changes: 3 additions & 3 deletions src/api/customers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class Customers {
}

/**
* Search for an existing customer loyalty account by phone number.
* Search for an existing customer loyalty account by phone number.
* If no loyalty account exists, this method returns an empty object.
*
* ```ts
Expand All @@ -65,8 +65,8 @@ export class Customers {
* ```
* @throws {@link Error}
*/
async getLoyaltyAccount(request: GetLoyaltyAccountRequest):
Promise<GetLoyaltyAccountResponse | NoLoyaltyAccountResponse>
async getLoyaltyAccount(request: GetLoyaltyAccountRequest):
Promise<GetLoyaltyAccountResponse | NoLoyaltyAccountResponse>
{
const phone = request.phone;
const loyaltyAccount = await this.buyersServiceClient.getLoyaltyAccount(phone);
Expand Down
2 changes: 1 addition & 1 deletion src/api/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class Resources {
* type: 'category-options',
* filters: {
* category_id: '2'
* }
* }
* },
* 'itemListResource': {
* type: 'item-list',
Expand Down
10 changes: 5 additions & 5 deletions src/helpers/money.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Money as MoneyType } from '../types/helpers/money';

// This works for all the currencies Square currently supports, but have noticed some differentiation from the BE package we
// This works for all the currencies Square currently supports, but have noticed some differentiation from the BE package we
// use for currencies like "IQD" which is considered 0 decimal places from this logic, but 3 decimal places in the BE package
// and the ISO 4217 spec. May need to re-visit if Square expands currency support.
const getCurrencyFractionLength = (currency: string) => {
Expand All @@ -15,7 +15,7 @@ const getCurrencyFractionLength = (currency: string) => {
export class Money {
/**
* Formats the Money object based on the provided locale.
*
*
* @param money - The Money object to format.
* @param formattedLocale - The locale to format the Money object in (BCP 47).
* @returns The formatted amount.
Expand All @@ -26,7 +26,7 @@ export class Money {

/**
* Formats a subunits amount based on the provided currency and locale.
*
*
* @param amount - The amount in subunits.
* @param currency - The currency of the amount (ISO 4217).
* @param formattedLocale - The locale to format the amount in (BCP 47).
Expand All @@ -52,7 +52,7 @@ export class Money {

/**
* Converts a float amount to the lowest subunits for the currency, e.g. 10.00 to 1000 for USD.
*
*
* @param float - The float amount to convert.
* @param currency - The currency of the amount (ISO 4217).
* @returns The amount in subunits.
Expand All @@ -67,7 +67,7 @@ export class Money {

/**
* Converts a subunits amount to a float for the currency, e.g. 1000 subunits to 10.00 for USD.
*
*
* @param subunits - The subunits amount to convert.
* @param currency - The currency of the amount (ISO 4217).
* @returns The amount as a float.
Expand Down
2 changes: 1 addition & 1 deletion src/types/api/cart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ export interface CartError {

export interface CartErrorNext {
/** RFC3339 formatted date-time. */
time: string;
time: string;
/** Human-readable label for time. Dependent on fulfillment type. */
time_formatted: string;
/** UNIX timestamp of pickup/delivery time. */
Expand Down
2 changes: 1 addition & 1 deletion src/types/helpers/datetime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export type localizeDateFormats =
hourNminuteN |
hourNminuteNsecondN |
yearNmonth2day2 |
yearNmonthNdayN |
yearNmonthNdayN |
yearNmonthLdayN |
yearNmonthSdayN |
yearNmonthLdayNhourNminuteN |
Expand Down
2 changes: 1 addition & 1 deletion src/types/helpers/location/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface Address {
address_line_1: string;
administrative_district_level_1: string;
country: string;
email: string;
email: string;
locality: string;
name: string;
phone: string;
Expand Down
2 changes: 1 addition & 1 deletion test/orders.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function createFetchResponse(data: LooseObject, ok: boolean, status: number, red
blob: vi.fn(),
formData: vi.fn(),
text: vi.fn(),
json: () => new Promise((resolve) => resolve(data))
json: () => new Promise((resolve) => resolve(data))
};
}

Expand Down
2 changes: 1 addition & 1 deletion test/resources.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function createFetchResponse(data: LooseObject, ok: boolean, status: number, red
blob: vi.fn(),
formData: vi.fn(),
text: vi.fn(),
json: () => new Promise((resolve) => resolve(data))
json: () => new Promise((resolve) => resolve(data))
};
}

Expand Down

0 comments on commit b29c499

Please sign in to comment.