From ebf100bcb0d847795e37040caf6c0202378d3c88 Mon Sep 17 00:00:00 2001 From: mason Date: Sat, 14 Dec 2024 22:33:51 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20fix:=20use=20explicit=20return?= =?UTF-8?q?=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AlphabeticOrUnderscoreOrHyphenString.ts | 12 +++++++----- AlphabeticOrUnderscoreString.ts | 2 +- AlphabeticString.ts | 2 +- AwesomeString.ts | 2 +- LowercaseAlphabeticString.ts | 2 +- PrometheusMetricName.ts | 2 +- PrometheusMetricNameWithoutColon.ts | 13 ++++++++----- 7 files changed, 20 insertions(+), 15 deletions(-) diff --git a/AlphabeticOrUnderscoreOrHyphenString.ts b/AlphabeticOrUnderscoreOrHyphenString.ts index cd5fb19..5841094 100644 --- a/AlphabeticOrUnderscoreOrHyphenString.ts +++ b/AlphabeticOrUnderscoreOrHyphenString.ts @@ -1,11 +1,13 @@ import { ValidatedString } from './ValidatedString.ts'; - const isAlphabeticOrUnderscoreOrHyphen = (s: string) => /^[a-zA-Z_-]+$/.test(s); -const { factory, type } = ValidatedString.create(isAlphabeticOrUnderscoreOrHyphen, { - name: 'AlphabeticOrUnderscoreOrHyphenString', - description: 'must contain only letters (A-Z, a-z), underscores, or hyphens', -}); +const { factory, type } = ValidatedString.create( + isAlphabeticOrUnderscoreOrHyphen, + { + name: 'AlphabeticOrUnderscoreOrHyphenString', + description: 'must contain only letters (A-Z, a-z), underscores, or hyphens', + }, +); export type AlphabeticOrUnderscoreOrHyphenString = typeof type; export const AlphabeticOrUnderscoreOrHyphenString = factory; diff --git a/AlphabeticOrUnderscoreString.ts b/AlphabeticOrUnderscoreString.ts index 3b5c795..541c4a2 100644 --- a/AlphabeticOrUnderscoreString.ts +++ b/AlphabeticOrUnderscoreString.ts @@ -1,6 +1,6 @@ import { ValidatedString } from './ValidatedString.ts'; -const isAlphabeticOrUnderscore = (s: string) => /^[a-zA-Z_]+$/.test(s); +const isAlphabeticOrUnderscore = (s: string): boolean => /^[a-zA-Z_]+$/.test(s); const { factory, type } = ValidatedString.create(isAlphabeticOrUnderscore, { name: 'AlphabeticOrUnderscoreString', diff --git a/AlphabeticString.ts b/AlphabeticString.ts index 16889e7..f795563 100644 --- a/AlphabeticString.ts +++ b/AlphabeticString.ts @@ -1,6 +1,6 @@ import { ValidatedString } from './ValidatedString.ts'; -const isAlphabetic = (s: string) => /^[a-zA-Z]+$/.test(s); +const isAlphabetic = (s: string): boolean => /^[a-zA-Z]+$/.test(s); const { factory, type } = ValidatedString.create(isAlphabetic, { name: 'AlphabeticString', diff --git a/AwesomeString.ts b/AwesomeString.ts index bfe7dfc..7d5270e 100644 --- a/AwesomeString.ts +++ b/AwesomeString.ts @@ -1,6 +1,6 @@ import { ValidatedString } from './ValidatedString.ts'; -const isAwesome = (s: string) => s === 'awesome'; +const isAwesome = (s: string): boolean => s === 'awesome'; const { factory, type } = ValidatedString.create(isAwesome); export type AwesomeString = typeof type; diff --git a/LowercaseAlphabeticString.ts b/LowercaseAlphabeticString.ts index 183c732..dabce80 100644 --- a/LowercaseAlphabeticString.ts +++ b/LowercaseAlphabeticString.ts @@ -1,6 +1,6 @@ import { ValidatedString } from './ValidatedString.ts'; -const isLowercaseAlpha = (s: string) => /^[a-z]+$/.test(s); +const isLowercaseAlpha = (s: string): boolean => /^[a-z]+$/.test(s); const { factory, type } = ValidatedString.create(isLowercaseAlpha, { name: 'LowercaseAlphabeticString', diff --git a/PrometheusMetricName.ts b/PrometheusMetricName.ts index a23fc82..8265452 100644 --- a/PrometheusMetricName.ts +++ b/PrometheusMetricName.ts @@ -1,6 +1,6 @@ import { ValidatedString } from './ValidatedString.ts'; -const isPrometheusMetricName = (s: string) => /^[a-zA-Z_:][a-zA-Z0-9_:]*$/.test(s); +const isPrometheusMetricName = (s: string): boolean => /^[a-zA-Z_:][a-zA-Z0-9_:]*$/.test(s); const { factory, type } = ValidatedString.create(isPrometheusMetricName, { name: 'PrometheusMetricName', diff --git a/PrometheusMetricNameWithoutColon.ts b/PrometheusMetricNameWithoutColon.ts index 7e4b580..4895478 100644 --- a/PrometheusMetricNameWithoutColon.ts +++ b/PrometheusMetricNameWithoutColon.ts @@ -1,11 +1,14 @@ import { ValidatedString } from './ValidatedString.ts'; -const isPrometheusMetricNameWithoutColon = (s: string) => /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s); +const isPrometheusMetricNameWithoutColon = (s: string): boolean => /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s); -const { factory, type } = ValidatedString.create(isPrometheusMetricNameWithoutColon, { - name: 'PrometheusMetricNameWithoutColon', - description: 'must start with a letter or underscore, followed by letters, digits, or underscores', -}); +const { factory, type } = ValidatedString.create( + isPrometheusMetricNameWithoutColon, + { + name: 'PrometheusMetricNameWithoutColon', + description: 'must start with a letter or underscore, followed by letters, digits, or underscores', + }, +); export type PrometheusMetricNameWithoutColon = typeof type; export const PrometheusMetricNameWithoutColon = factory;