Skip to content

Commit

Permalink
infra(unicorn): filename-case (#2492)
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT authored Oct 28, 2023
1 parent 9297e5b commit fdafaa4
Show file tree
Hide file tree
Showing 44 changed files with 64 additions and 47 deletions.
21 changes: 19 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ module.exports = defineConfig({
// 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 Down Expand Up @@ -139,8 +138,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.
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
2 changes: 1 addition & 1 deletion test/modules/vehicle.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
4 changes: 2 additions & 2 deletions test/modules/word.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 { filterWordListByLength } from '../../src/modules/word/filterWordListByLength';
import { seededTests } from './../support/seededRuns';
import { filterWordListByLength } from '../../src/modules/word/filter-word-list-by-length';
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/scripts/apidoc/module.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { beforeAll, describe, expect, it } from 'vitest';
import { initMarkdownRenderer } from '../../../scripts/apidoc/markdown';
import { analyzeModule } from '../../../scripts/apidoc/moduleMethods';
import { analyzeModule } from '../../../scripts/apidoc/module-methods';
import * as ModuleTests from './module.example';
import { loadExampleModules } from './utils';

Expand Down
File renamed without changes.

0 comments on commit fdafaa4

Please sign in to comment.