Skip to content

Commit

Permalink
Merge branch 'next' into fix/finance/maskedNumber-defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT committed Oct 29, 2023
2 parents ac10f9a + a83db8b commit 28e419a
Show file tree
Hide file tree
Showing 45 changed files with 72 additions and 59 deletions.
24 changes: 21 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ module.exports = defineConfig({
'unicorn/prefer-at': 'off',
// TODO @Shinigami92 2023-09-23: prefer-string-replace-all should be turned on when we drop support for Node 14.
'unicorn/prefer-string-replace-all': 'off',
// TODO @ST-DDT 2023-10-28: The following rule should be turned on when we switch to esm.
'unicorn/prefer-top-level-await': 'off',

// TODO @Shinigami92 2023-09-23: The following rules currently conflict with our code.
// Each rule should be checked whether it should be enabled/configured and the problems fixed, or stay disabled permanently.
'unicorn/better-regex': 'off',
'unicorn/consistent-function-scoping': 'off',
'unicorn/filename-case': 'off',
'unicorn/import-style': 'off',
'unicorn/no-array-callback-reference': 'off',
'unicorn/no-array-reduce': 'off',
Expand All @@ -60,7 +61,6 @@ module.exports = defineConfig({
'unicorn/prefer-module': 'off',
'unicorn/prefer-negative-index': 'off',
'unicorn/prefer-string-slice': 'off',
'unicorn/prefer-top-level-await': 'off',
'unicorn/prevent-abbreviations': 'off',
'unicorn/require-array-join-separator': 'off',
'unicorn/switch-case-braces': 'off',
Expand Down Expand Up @@ -139,8 +139,26 @@ module.exports = defineConfig({
},
},
{
files: ['src/locales/**/*.ts'],
files: ['src/locale/**/*.ts'],
rules: {
'unicorn/filename-case': 'off', // our locale files have a custom naming scheme
},
},
{
files: ['src/definitions/**/*.ts', 'src/locales/**/*.ts'],
rules: {
'unicorn/filename-case': [
'error',
{
case: 'snakeCase',
// TODO @ST-DDT 2023-10-21: rename the definitions in v9
ignore: [
/chemicalElement\.ts$/,
/directoryPaths\.ts$/,
/mimeTypes\.ts$/,
],
},
],
'unicorn/text-encoding-identifier-case': 'off',
},
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"build": "run-s build:clean build:code build:types",
"generate": "run-s generate:locales generate:api-docs",
"generate:api-docs": "tsx ./scripts/apidoc.ts",
"generate:locales": "tsx ./scripts/generateLocales.ts",
"generate:locales": "tsx ./scripts/generate-locales.ts",
"docs:build": "run-s docs:prepare docs:build:run",
"docs:build:run": "vitepress build docs",
"docs:build:ci": "run-s build docs:build",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { DeclarationReflection, ProjectReflection } from 'typedoc';
import { ReflectionKind } from 'typedoc';
import type { Method } from '../../docs/.vitepress/components/api-docs/method';
import { writeApiDocsModule } from './apiDocsWriter';
import { analyzeModule, processModuleMethods } from './moduleMethods';
import { analyzeModule, processModuleMethods } from './module-methods';
import { analyzeSignature } from './signature';
import { extractModuleFieldName, selectApiSignature } from './typedoc';
import type { ModuleSummary } from './utils';
import { writeApiDocsModule } from './writer';

export async function processFakerClasses(
project: ProjectReflection
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { DeclarationReflection, ProjectReflection } from 'typedoc';
import { ReflectionKind } from 'typedoc';
import type { Method } from '../../docs/.vitepress/components/api-docs/method';
import { writeApiDocsModule } from './apiDocsWriter';
import { processMethods } from './moduleMethods';
import { processMethods } from './module-methods';
import { selectApiSignature } from './typedoc';
import type { ModuleSummary } from './utils';
import { writeApiDocsModule } from './writer';

export async function processFakerUtilities(
project: ProjectReflection
Expand Down
12 changes: 6 additions & 6 deletions scripts/apidoc/generate.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { resolve } from 'node:path';
import { processFakerClasses, processFakerRandomizer } from './faker-class';
import { processFakerUtilities } from './faker-utilities';
import { processModules } from './module-methods';
import { loadProject } from './typedoc';
import { pathOutputDir } from './utils';
import {
writeApiDiffIndex,
writeApiPagesIndex,
writeApiSearchIndex,
writeSourceBaseUrl,
} from './apiDocsWriter';
import { processFakerClasses, processFakerRandomizer } from './fakerClass';
import { processFakerUtilities } from './fakerUtilities';
import { processModules } from './moduleMethods';
import { loadProject } from './typedoc';
import { pathOutputDir } from './utils';
} from './writer';

const pathOutputJson = resolve(pathOutputDir, 'typedoc.json');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type {
SignatureReflection,
} from 'typedoc';
import type { Method } from '../../docs/.vitepress/components/api-docs/method';
import { writeApiDocsModule } from './apiDocsWriter';
import { codeToHtml } from './markdown';
import { analyzeSignature } from './signature';
import {
Expand All @@ -18,6 +17,7 @@ import {
} from './typedoc';
import type { ModuleSummary } from './utils';
import { adjustUrls } from './utils';
import { writeApiDocsModule } from './writer';

/**
* Analyzes and writes the documentation for modules and their methods such as `faker.animal.cat()`.
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion scripts/apidoc/typedoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
DefaultParameterAwareSerializer,
parameterDefaultReader,
patchProjectParameterDefaults,
} from './parameterDefaults';
} from './parameter-defaults';
import { mapByName } from './utils';

type CommentHolder = Pick<Reflection, 'comment'>;
Expand Down
File renamed without changes.
File renamed without changes.
17 changes: 6 additions & 11 deletions src/modules/finance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,20 +353,15 @@ export class FinanceModule {
// set defaults
const { ellipsis = true, length = 4, parens = true } = options;

// create a template for length
let template = '';
let template = this.faker.string.numeric({ length });

for (let i = 0; i < length; i++) {
template = `${template}#`;
if (ellipsis) {
template = `...${template}`;
}

//prefix with ellipsis
template = ellipsis ? ['...', template].join('') : template;

template = parens ? ['(', template, ')'].join('') : template;

//generate random numbers
template = this.faker.helpers.replaceSymbolWithNumber(template);
if (parens) {
template = `(${template})`;
}

return template;
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/lorem/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Faker } from '../..';
import { bindThisToMemberFunctions } from '../../internal/bind-this-to-member-functions';
import { filterWordListByLength } from '../word/filterWordListByLength';
import { filterWordListByLength } from '../word/filter-word-list-by-length';

/**
* Module to generate random texts and words.
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/modules/word/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Faker } from '../..';
import { FakerError } from '../../errors/faker-error';
import { bindThisToMemberFunctions } from '../../internal/bind-this-to-member-functions';
import { filterWordListByLength } from './filterWordListByLength';
import { filterWordListByLength } from './filter-word-list-by-length';

/**
* Module to return various types of words.
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/mersenne.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
import { generateMersenne32Randomizer } from '../src/internal/mersenne';
import type { Randomizer } from '../src/randomizer';
import { seededRuns } from './support/seededRuns';
import { seededRuns } from './support/seeded-runs';
import { times } from './support/times';

const NON_SEEDED_BASED_RUN = 25;
Expand Down
2 changes: 1 addition & 1 deletion test/modules/airline.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import { Aircraft, faker } from '../../src';
import { seededTests } from './../support/seededRuns';
import { seededTests } from '../support/seeded-runs';
import { times } from './../support/times';

const NON_SEEDED_BASED_RUN = 5;
Expand Down
2 changes: 1 addition & 1 deletion test/modules/animal.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import { faker } from '../../src';
import { seededTests } from './../support/seededRuns';
import { seededTests } from '../support/seeded-runs';
import { times } from './../support/times';

const NON_SEEDED_BASED_RUN = 5;
Expand Down
2 changes: 1 addition & 1 deletion test/modules/color.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import { CssFunction, CssSpace, faker } from '../../src';
import { seededTests } from './../support/seededRuns';
import { seededTests } from '../support/seeded-runs';
import { times } from './../support/times';

const NON_SEEDED_BASED_RUN = 5;
Expand Down
2 changes: 1 addition & 1 deletion test/modules/commerce.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import validator from 'validator';
import { describe, expect, it } from 'vitest';
import { faker } from '../../src';
import { seededTests } from './../support/seededRuns';
import { seededTests } from '../support/seeded-runs';
import { times } from './../support/times';

const NON_SEEDED_BASED_RUN = 5;
Expand Down
2 changes: 1 addition & 1 deletion test/modules/company.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import { faker } from '../../src';
import { seededTests } from './../support/seededRuns';
import { seededTests } from '../support/seeded-runs';
import { times } from './../support/times';

const NON_SEEDED_BASED_RUN = 5;
Expand Down
2 changes: 1 addition & 1 deletion test/modules/database.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import { faker } from '../../src';
import { seededTests } from './../support/seededRuns';
import { seededTests } from '../support/seeded-runs';
import { times } from './../support/times';

const NON_SEEDED_BASED_RUN = 5;
Expand Down
2 changes: 1 addition & 1 deletion test/modules/datatype.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import { faker, FakerError } from '../../src';
import { seededTests } from './../support/seededRuns';
import { seededTests } from '../support/seeded-runs';
import { times } from './../support/times';

const NON_SEEDED_BASED_RUN = 25;
Expand Down
2 changes: 1 addition & 1 deletion test/modules/date.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { afterEach, describe, expect, it } from 'vitest';
import { faker, fakerAZ, FakerError } from '../../src';
import { seededTests } from './../support/seededRuns';
import { seededTests } from '../support/seeded-runs';
import { times } from './../support/times';

const converterMap = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import validator from 'validator';
import { describe, expect, it } from 'vitest';
import { faker } from '../../src';
import ibanLib from '../../src/modules/finance/iban';
import { times } from './../support/times';
import { times } from '../support/times';

const NON_SEEDED_BASED_RUN = 25;

Expand Down
2 changes: 1 addition & 1 deletion test/modules/finance.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { faker, fakerZH_CN } from '../../src';
import { FakerError } from '../../src/errors/faker-error';
import ibanLib from '../../src/modules/finance/iban';
import { luhnCheck } from '../../src/modules/helpers/luhn-check';
import { seededTests } from './../support/seededRuns';
import { seededTests } from '../support/seeded-runs';
import { times } from './../support/times';

const NON_SEEDED_BASED_RUN = 5;
Expand Down
2 changes: 1 addition & 1 deletion test/modules/git.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import validator from 'validator';
import { describe, expect, it } from 'vitest';
import { faker } from '../../src';
import { seededTests } from './../support/seededRuns';
import { seededTests } from '../support/seeded-runs';
import { times } from './../support/times';

const NON_SEEDED_BASED_RUN = 5;
Expand Down
2 changes: 1 addition & 1 deletion test/modules/hacker.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import { faker } from '../../src';
import { seededTests } from './../support/seededRuns';
import { seededTests } from '../support/seeded-runs';
import { times } from './../support/times';

const NON_SEEDED_BASED_RUN = 5;
Expand Down
2 changes: 1 addition & 1 deletion test/modules/helpers.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest';
import { faker, FakerError } from '../../src';
import { luhnCheck } from '../../src/modules/helpers/luhn-check';
import { seededTests } from './../support/seededRuns';
import { seededTests } from '../support/seeded-runs';
import { times } from './../support/times';
import './../vitest-extensions';

Expand Down
2 changes: 1 addition & 1 deletion test/modules/image.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import isDataURI from 'validator/lib/isDataURI';
import { describe, expect, it } from 'vitest';
import { faker } from '../../src';
import { seededTests } from './../support/seededRuns';
import { seededTests } from '../support/seeded-runs';

describe('image', () => {
seededTests(faker, 'image', (t) => {
Expand Down
2 changes: 1 addition & 1 deletion test/modules/internet.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import validator from 'validator';
import { describe, expect, it } from 'vitest';
import { allFakers, faker } from '../../src';
import { seededTests } from './../support/seededRuns';
import { seededTests } from '../support/seeded-runs';
import { times } from './../support/times';

const NON_SEEDED_BASED_RUN = 5;
Expand Down
2 changes: 1 addition & 1 deletion test/modules/location.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import { faker, fakerEN_CA, fakerEN_US, FakerError } from '../../src';
import { seededTests } from './../support/seededRuns';
import { seededTests } from '../support/seeded-runs';
import { times } from './../support/times';

function degreesToRadians(degrees: number) {
Expand Down
2 changes: 1 addition & 1 deletion test/modules/lorem.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import validator from 'validator';
import { describe, expect, it } from 'vitest';
import { faker } from '../../src';
import { seededTests } from './../support/seededRuns';
import { seededTests } from '../support/seeded-runs';
import { times } from './../support/times';

const NON_SEEDED_BASED_RUN = 5;
Expand Down
2 changes: 1 addition & 1 deletion test/modules/music.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import { faker } from '../../src';
import { seededTests } from './../support/seededRuns';
import { seededTests } from '../support/seeded-runs';
import { times } from './../support/times';

const NON_SEEDED_BASED_RUN = 5;
Expand Down
2 changes: 1 addition & 1 deletion test/modules/number.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import validator from 'validator';
import { describe, expect, it } from 'vitest';
import { faker, FakerError } from '../../src';
import { seededTests } from './../support/seededRuns';
import { seededTests } from '../support/seeded-runs';

describe('number', () => {
seededTests(faker, 'number', (t) => {
Expand Down
2 changes: 1 addition & 1 deletion test/modules/person.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import { faker, fakerAZ, fakerMK, fakerUK, Sex } from '../../src';
import { seededTests } from './../support/seededRuns';
import { seededTests } from '../support/seeded-runs';
import { times } from './../support/times';

const NON_SEEDED_BASED_RUN = 5;
Expand Down
2 changes: 1 addition & 1 deletion test/modules/phone.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest';
import { faker } from '../../src';
import { luhnCheck } from '../../src/modules/helpers/luhn-check';
import { seededTests } from './../support/seededRuns';
import { seededTests } from '../support/seeded-runs';
import { times } from './../support/times';

const NON_SEEDED_BASED_RUN = 25;
Expand Down
2 changes: 1 addition & 1 deletion test/modules/random.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import { Faker, faker, FakerError, fakerZH_CN } from '../../src';
import { seededTests } from './../support/seededRuns';
import { seededTests } from '../support/seeded-runs';
import { times } from './../support/times';

const NON_SEEDED_BASED_RUN = 5;
Expand Down
2 changes: 1 addition & 1 deletion test/modules/science.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import { faker } from '../../src';
import { seededTests } from './../support/seededRuns';
import { seededTests } from '../support/seeded-runs';
import { times } from './../support/times';

const NON_SEEDED_BASED_RUN = 5;
Expand Down
2 changes: 1 addition & 1 deletion test/modules/string.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import { faker, FakerError } from '../../src';
import { seededTests } from './../support/seededRuns';
import { seededTests } from '../support/seeded-runs';
import { times } from './../support/times';

const NON_SEEDED_BASED_RUN = 5;
Expand Down
2 changes: 1 addition & 1 deletion test/modules/system.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import validator from 'validator';
import { describe, expect, it } from 'vitest';
import { faker, fakerSK } from '../../src';
import { seededTests } from './../support/seededRuns';
import { seededTests } from '../support/seeded-runs';
import { times } from './../support/times';

const NON_SEEDED_BASED_RUN = 5;
Expand Down

0 comments on commit 28e419a

Please sign in to comment.