Skip to content

Commit

Permalink
Merge branch 'next' into image/randomize-defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewmayer authored Jan 8, 2024
2 parents 823913e + 9fb45c2 commit e907234
Show file tree
Hide file tree
Showing 205 changed files with 4,269 additions and 8,546 deletions.
24 changes: 18 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
const { defineConfig } = require('eslint-define-config');
const { readGitignoreFiles } = require('eslint-gitignore');

/// <reference types="@eslint-types/deprecation" />
/// <reference types="@eslint-types/jsdoc" />
/// <reference types="@eslint-types/prettier" />
/// <reference types="@eslint-types/typescript-eslint" />
/// <reference types="@eslint-types/unicorn" />

module.exports = defineConfig({
ignorePatterns: [
...readGitignoreFiles(),
Expand All @@ -15,7 +21,7 @@ module.exports = defineConfig({
reportUnusedDisableDirectives: true,
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended-type-checked',
'plugin:@typescript-eslint/strict-type-checked',
'plugin:prettier/recommended',
'plugin:deprecation/recommended',
'plugin:jsdoc/recommended-typescript-error',
Expand All @@ -29,6 +35,7 @@ module.exports = defineConfig({
eqeqeq: ['error', 'always', { null: 'ignore' }],
'no-else-return': 'error',
'no-restricted-globals': ['error', 'Intl'],
'prefer-exponentiation-operator': 'error',
'prefer-template': 'error',

'unicorn/no-nested-ternary': 'off', // incompatible with prettier
Expand All @@ -50,16 +57,11 @@ module.exports = defineConfig({
'unicorn/consistent-function-scoping': 'off',
'unicorn/import-style': 'off',
'unicorn/no-array-callback-reference': 'off',
'unicorn/no-array-reduce': 'off',
'unicorn/no-await-expression-member': 'off',
'unicorn/no-negated-condition': 'off',
'unicorn/no-object-as-default-parameter': 'off',
'unicorn/no-useless-switch-case': 'off',
'unicorn/numeric-separators-style': 'off',
'unicorn/prefer-code-point': 'off',
'unicorn/prefer-export-from': 'off',
'unicorn/prefer-module': 'off',
'unicorn/prefer-negative-index': 'off',
'unicorn/prefer-string-slice': 'off',
'unicorn/prevent-abbreviations': 'off',
'unicorn/require-array-join-separator': 'off',
Expand Down Expand Up @@ -91,6 +93,7 @@ module.exports = defineConfig({
'error',
{ ignoreParameters: true },
],
'@typescript-eslint/no-unnecessary-condition': 'off', // requires `strictNullChecks` to be enabled
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
Expand All @@ -103,7 +106,16 @@ module.exports = defineConfig({
'error',
{ allowNumber: true, allowBoolean: true },
],
'@typescript-eslint/switch-exhaustiveness-check': [
'error',
{ requireDefaultForNonUnion: true },
],
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/unified-signatures': 'off', // incompatible with our api docs generation

// TODO @ST-DDT 2023-10-10: 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.
'@typescript-eslint/no-confusing-void-expression': 'off',

'jsdoc/require-jsdoc': 'off', // Enabled only for src/**/*.ts
'jsdoc/require-returns': 'off',
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/comment-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
issues: write
steps:
- name: Add Comment For User Interest
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
github.rest.issues.createComment({
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
})
- name: React to Issue
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
github.rest.reactions.createForIssue({
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
run: pnpm exec tsc .github/workflows/commentCodeGeneration.ts --outDir .github/workflows

- name: Comment
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const script = require('${{ github.workspace }}/.github/workflows/commentCodeGeneration.js')
Expand Down
4 changes: 4 additions & 0 deletions .prettierrc.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import type { Options } from 'prettier';

declare const options: Options;
export = options;
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,40 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [8.3.1](https://github.com/faker-js/faker/compare/v8.3.0...v8.3.1) (2023-11-14)


### Bug Fixes

* remove `[@internal](https://github.com/internal)` from module parent classes ([#2548](https://github.com/faker-js/faker/issues/2548)) ([77f54ad](https://github.com/faker-js/faker/commit/77f54ad78f9d7952b3b315f72878267f18ed1e69))

## [8.3.0](https://github.com/faker-js/faker/compare/v8.2.0...v8.3.0) (2023-11-14)


### Features

* **person:** use fake patterns for jobTitle ([#2528](https://github.com/faker-js/faker/issues/2528)) ([b40ad45](https://github.com/faker-js/faker/commit/b40ad45ad3cca6769968a63264e6d925bf4b328a))


### Bug Fixes

* **date:** ensures correct range for birthdate ([#2535](https://github.com/faker-js/faker/issues/2535)) ([7ce8c28](https://github.com/faker-js/faker/commit/7ce8c285cb5b2d13e95a17be78ecbd52f3c7d9db))
* **finance:** maskedNumber has incorrect defaults ([#2494](https://github.com/faker-js/faker/issues/2494)) ([e0ba50b](https://github.com/faker-js/faker/commit/e0ba50b37e438503ed1899bff35afc92b4f8f49c))
* **locale:** improve Swedish phone numbers format ([#2520](https://github.com/faker-js/faker/issues/2520)) ([e4865df](https://github.com/faker-js/faker/commit/e4865df199359797397cc3c5455f3a1a9c179f93))


### Changed Locales

* **locale:** remove fr_CH data which is identical to fr ([#2526](https://github.com/faker-js/faker/issues/2526)) ([fafcba4](https://github.com/faker-js/faker/commit/fafcba473f8a91eeb8230ebdc1ad5039b25091e1))


### New Locales

* **locale:** add person to fr_SN ([#2537](https://github.com/faker-js/faker/issues/2537)) ([ef965da](https://github.com/faker-js/faker/commit/ef965da48a8089e6bb19bcf260bfcd8af1a43799))
* **locale:** add Senegal locale ([#2525](https://github.com/faker-js/faker/issues/2525)) ([6df70bc](https://github.com/faker-js/faker/commit/6df70bce16500ab74a37f932f2e17a08f297430b))
* **locale:** add streets to location fr_SN ([#2536](https://github.com/faker-js/faker/issues/2536)) ([36fc517](https://github.com/faker-js/faker/commit/36fc517d17591c8ea1d5135d9a93c7591e3d1f74))
* **locale:** and location to fr_SN ([#2533](https://github.com/faker-js/faker/issues/2533)) ([f730125](https://github.com/faker-js/faker/commit/f730125ffb941fe936d6a18c775cbe3a99b312dc))

## [8.2.0](https://github.com/faker-js/faker/compare/v8.1.0...v8.2.0) (2023-10-14)


Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Faker - Copyright (c) 2022-2023
Faker - Copyright (c) 2022-2024

This software consists of voluntary contributions made by many individuals.
For exact contribution history, see the revision history
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/api.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('API Test', () => {
cy.get('.api-group li').each(($el) => {
const anchor = $el.find('a');
const text = anchor.text();
const link = anchor.attr('href').split('#')[0];
const link = anchor.attr('href')?.split('#')[0] ?? 'MISSING';
if (checked.has(link)) {
return;
}
Expand Down
57 changes: 31 additions & 26 deletions docs/.vitepress/api-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,37 @@ export const apiPages = [
{ text: 'Overview', link: '/api/' },
{ text: 'Faker', link: '/api/faker.html' },
{ text: 'SimpleFaker', link: '/api/simpleFaker.html' },
{ text: 'Airline', link: '/api/airline.html' },
{ text: 'Animal', link: '/api/animal.html' },
{ text: 'Color', link: '/api/color.html' },
{ text: 'Commerce', link: '/api/commerce.html' },
{ text: 'Company', link: '/api/company.html' },
{ text: 'Database', link: '/api/database.html' },
{ text: 'Datatype', link: '/api/datatype.html' },
{ text: 'Date', link: '/api/date.html' },
{ text: 'Finance', link: '/api/finance.html' },
{ text: 'Git', link: '/api/git.html' },
{ text: 'Hacker', link: '/api/hacker.html' },
{ text: 'Helpers', link: '/api/helpers.html' },
{ text: 'Image', link: '/api/image.html' },
{ text: 'Internet', link: '/api/internet.html' },
{ text: 'Location', link: '/api/location.html' },
{ text: 'Lorem', link: '/api/lorem.html' },
{ text: 'Music', link: '/api/music.html' },
{ text: 'Number', link: '/api/number.html' },
{ text: 'Person', link: '/api/person.html' },
{ text: 'Phone', link: '/api/phone.html' },
{ text: 'Random', link: '/api/random.html' },
{ text: 'Science', link: '/api/science.html' },
{ text: 'String', link: '/api/string.html' },
{ text: 'System', link: '/api/system.html' },
{ text: 'Vehicle', link: '/api/vehicle.html' },
{ text: 'Word', link: '/api/word.html' },
{ text: 'Randomizer', link: '/api/randomizer.html' },
{ text: 'Utilities', link: '/api/utils.html' },
{
text: 'Modules',
items: [
{ text: 'Airline', link: '/api/airline.html' },
{ text: 'Animal', link: '/api/animal.html' },
{ text: 'Color', link: '/api/color.html' },
{ text: 'Commerce', link: '/api/commerce.html' },
{ text: 'Company', link: '/api/company.html' },
{ text: 'Database', link: '/api/database.html' },
{ text: 'Datatype', link: '/api/datatype.html' },
{ text: 'Date', link: '/api/date.html' },
{ text: 'Finance', link: '/api/finance.html' },
{ text: 'Git', link: '/api/git.html' },
{ text: 'Hacker', link: '/api/hacker.html' },
{ text: 'Helpers', link: '/api/helpers.html' },
{ text: 'Image', link: '/api/image.html' },
{ text: 'Internet', link: '/api/internet.html' },
{ text: 'Location', link: '/api/location.html' },
{ text: 'Lorem', link: '/api/lorem.html' },
{ text: 'Music', link: '/api/music.html' },
{ text: 'Number', link: '/api/number.html' },
{ text: 'Person', link: '/api/person.html' },
{ text: 'Phone', link: '/api/phone.html' },
{ text: 'Random', link: '/api/random.html' },
{ text: 'Science', link: '/api/science.html' },
{ text: 'String', link: '/api/string.html' },
{ text: 'System', link: '/api/system.html' },
{ text: 'Vehicle', link: '/api/vehicle.html' },
{ text: 'Word', link: '/api/word.html' },
],
},
];
31 changes: 20 additions & 11 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { defineConfig } from 'vitepress';
import { DefaultTheme } from 'vitepress/theme';
import type { UserConfig } from 'vitepress';
import type { DefaultTheme } from 'vitepress/theme';
import { apiPages } from './api-pages';
import { currentVersion, oldVersions, versionBannerInfix } from './versions';
import {
algoliaIndex,
currentVersion,
oldVersions,
versionBannerInfix,
} from './versions';

type SidebarItem = DefaultTheme.SidebarItem;

Expand Down Expand Up @@ -55,7 +60,8 @@ function extendSideNav(current: SidebarItem): SidebarItem[] {
return links;
}

const config = defineConfig({
// TODO @Shinigami92 2023-12-28: reuse `defineConfig` from vitepress, when we can go esm-only
const config: UserConfig<DefaultTheme.Config> = {
title: 'Faker',
description,

Expand Down Expand Up @@ -121,11 +127,14 @@ const config = defineConfig({
{ icon: 'github', link: 'https://github.com/faker-js/faker' },
],

algolia: {
apiKey: process.env.API_KEY,
appId: process.env.APP_ID,
indexName: 'fakerjs',
},
algolia:
process.env.API_KEY == null || process.env.APP_ID == null
? undefined
: {
apiKey: process.env.API_KEY,
appId: process.env.APP_ID,
indexName: algoliaIndex,
},

footer: {
message: 'Released under the MIT License.',
Expand All @@ -140,7 +149,7 @@ const config = defineConfig({
link: '/api/',
},
{
text: 'Ecosystem',
text: 'Try it',
items: [{ text: 'StackBlitz ', link: 'https://fakerjs.dev/new' }],
},
{
Expand Down Expand Up @@ -256,7 +265,7 @@ const config = defineConfig({
__BANNER__: versionBannerInfix ?? false,
},
},
});
};

if (versionBannerInfix) {
config.head?.push([
Expand Down
4 changes: 2 additions & 2 deletions docs/.vitepress/theme/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ table td ul li {
}

.VPHero .action:not(:last-child) a.VPButton.alt {
border-color: var(--vp-button-brand-border) !important;
color: var(--vp-button-brand-border) !important;
border-color: var(--vp-button-brand-bg) !important;
color: var(--vp-button-brand-text) !important;
}
25 changes: 17 additions & 8 deletions docs/.vitepress/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,23 @@ function readOtherLatestReleaseTagNames(): string[] {
.toString('utf8')
.split('\n')
.filter((tag) => semver.valid(tag))
.reduce<Record<number, string[]>>((acc, tag) => {
const majorVersion = semver.major(tag);
.filter((tag) => {
// Only consider tags for our deployed website versions,
// excluding the current major version.
if (majorVersion >= 6 && majorVersion !== currentMajorVersion) {
(acc[majorVersion] = acc[majorVersion] ?? []).push(tag);
const majorVersion = semver.major(tag);
return majorVersion >= 6 && majorVersion !== currentMajorVersion;
})
.reduce<Record<number, string>>((latestTagByMajor, tag) => {
const majorVersion = semver.major(tag);

const latestTag = latestTagByMajor[majorVersion];
if (latestTag == null || semver.lt(latestTag, tag)) {
latestTagByMajor[majorVersion] = tag;
}
return acc;

return latestTagByMajor;
}, {});
return Object.entries(latestReleaseTagNames)
.map(([major, tags]) => semver.maxSatisfying(tags, `^${major}`))
.sort(semver.rcompare);
return Object.values(latestReleaseTagNames).sort(semver.rcompare);
}

// Set by netlify
Expand Down Expand Up @@ -69,3 +74,7 @@ export const oldVersions = [
link: `https://v${semver.major(version)}.fakerjs.dev/`,
})),
].filter(({ link }) => link !== hiddenLink);

export const algoliaIndex = isReleaseBranch
? `fakerjs-v${semver.major(version)}`
: 'fakerjs-next';
6 changes: 3 additions & 3 deletions docs/api/ApiIndex.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ h2 {
h3 {
letter-spacing: -0.01em;
color: var(--vp-c-green);
color: var(--vp-c-brand-1);
font-size: 18px;
margin-bottom: 1em;
transition: color 0.5s;
Expand All @@ -147,7 +147,7 @@ h3 {
}
.api-groups ul a:hover {
color: var(--vp-c-green);
color: var(--vp-c-brand-1);
transition: none;
}
Expand Down Expand Up @@ -181,7 +181,7 @@ h3 {
}
.api-filter:focus {
border-color: var(--vp-c-green-light);
border-color: var(--vp-c-brand-2);
}
.no-match {
Expand Down
Loading

0 comments on commit e907234

Please sign in to comment.