Skip to content

Commit a0fb449

Browse files
authored
Merge branch 'main' into fix-vehicle-vin-length
2 parents 465065f + ce1b39f commit a0fb449

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+4365
-4095
lines changed

.eslintignore

Lines changed: 0 additions & 7 deletions
This file was deleted.

.eslintrc

Lines changed: 0 additions & 50 deletions
This file was deleted.

.eslintrc.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// @ts-check
2+
const { defineConfig } = require('eslint-define-config');
3+
const { readGitignoreFiles } = require('eslint-gitignore');
4+
5+
module.exports = defineConfig({
6+
ignorePatterns: [
7+
...readGitignoreFiles(),
8+
'.eslintrc.js', // Skip self linting
9+
],
10+
root: true,
11+
env: {
12+
browser: true,
13+
node: true,
14+
},
15+
extends: [
16+
'eslint:recommended',
17+
'plugin:@typescript-eslint/recommended',
18+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
19+
'plugin:prettier/recommended',
20+
],
21+
parser: '@typescript-eslint/parser',
22+
parserOptions: {
23+
project: ['./tsconfig.lint.json'],
24+
sourceType: 'module',
25+
warnOnUnsupportedTypeScriptVersion: false,
26+
},
27+
plugins: ['@typescript-eslint', 'prettier'],
28+
rules: {
29+
// We may want to use this in the future
30+
'no-useless-escape': 'off',
31+
32+
'@typescript-eslint/ban-ts-comment': 'warn',
33+
'@typescript-eslint/consistent-type-imports': 'error',
34+
'@typescript-eslint/explicit-module-boundary-types': 'error',
35+
'@typescript-eslint/no-inferrable-types': [
36+
'error',
37+
{ ignoreParameters: true },
38+
],
39+
'@typescript-eslint/no-unsafe-argument': 'warn',
40+
'@typescript-eslint/no-unsafe-assignment': 'off',
41+
'@typescript-eslint/no-unsafe-call': 'off',
42+
'@typescript-eslint/no-unsafe-member-access': 'off',
43+
'@typescript-eslint/no-unsafe-return': 'warn',
44+
'@typescript-eslint/restrict-template-expressions': [
45+
'error',
46+
{
47+
allowNumber: true,
48+
allowBoolean: true,
49+
},
50+
],
51+
'@typescript-eslint/unbound-method': 'warn',
52+
},
53+
overrides: [
54+
{
55+
files: ['test/*.spec.ts'],
56+
rules: {
57+
'@typescript-eslint/restrict-template-expressions': [
58+
'error',
59+
{
60+
allowNumber: true,
61+
allowBoolean: true,
62+
allowAny: true,
63+
},
64+
],
65+
},
66+
},
67+
],
68+
});

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
blank_issues_enabled: false
22
contact_links:
33
- name: Discord Chat
4-
url: discord.gg/4qDjAmDj4P
4+
url: https://chat.fakerjs.dev
55
about: Ask questions and discuss with other users in real time.
66
- name: Questions & Discussions
77
url: https://github.com/faker-js/faker.js/discussions

.github/workflows/ci.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ on:
77
pull_request:
88

99
jobs:
10-
test:
10+
unit-test:
1111
runs-on: ${{ matrix.os }}
1212
strategy:
1313
matrix:
1414
os: [ubuntu-latest]
15-
node_version: [12, 14, 16, 17]
15+
node_version: [14, 16, 17]
1616
include:
1717
- os: macos-latest
1818
node_version: 16
1919
- os: windows-latest
2020
node_version: 16
2121
fail-fast: false
2222

23-
name: 'Build & Test: node-${{ matrix.node_version }}, ${{ matrix.os }}'
23+
name: 'Build & Unit Test: node-${{ matrix.node_version }}, ${{ matrix.os }}'
2424
steps:
2525
- name: Checkout
2626
uses: actions/checkout@v2
@@ -45,6 +45,24 @@ jobs:
4545
- name: Test
4646
run: pnpm run test
4747

48+
e2e-test:
49+
runs-on: ubuntu-latest
50+
name: 'E2E Doc Test: node-16, ubuntu-latest'
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@v2
54+
55+
- name: Install pnpm
56+
uses: pnpm/action-setup@v2
57+
with:
58+
version: 6
59+
60+
- name: Install deps
61+
run: pnpm install
62+
63+
- name: Run E2E
64+
run: pnpm run docs:build:ci
65+
4866
lint:
4967
runs-on: ubuntu-latest
5068
name: 'Lint: node-16, ubuntu-latest'
@@ -70,3 +88,6 @@ jobs:
7088

7189
- name: Lint
7290
run: pnpm run lint
91+
92+
- name: Check formatting
93+
run: pnpm prettier --check .

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ versions.json
7272
# Dist
7373
/dist
7474
/docs/.vitepress/dist
75+
/docs/api/typedoc.json
7576
/lib
7677

7778
# Faker
@@ -90,3 +91,6 @@ REVISION
9091
.yarn/
9192
package-lock.json
9293
yarn.lock
94+
95+
cypress/screenshots
96+
cypress/videos

.vscode/extensions.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
{
2-
"recommendations": ["editorconfig.editorconfig", "esbenp.prettier-vscode"]
2+
"recommendations": [
3+
"dbaeumer.vscode-eslint",
4+
"editorconfig.editorconfig",
5+
"esbenp.prettier-vscode"
6+
]
37
}

.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
// Enable eslint validation for js and ts files
3+
"eslint.validate": ["javascript", "typescript"],
4+
5+
// Always use the `package.json`'s `typescript`
6+
"typescript.tsdk": "node_modules/typescript/lib"
7+
}

CODE_OF_CONDUCT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ This Code of Conduct applies both within project spaces and in public spaces whe
3535

3636
## Enforcement
3737

38-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by [contacting a Moderator or Maintainer via Discord](https://discord.com/invite/4qDjAmDj4P). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by [contacting a Moderator or Maintainer via Discord](https://chat.fakerjs.dev). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
3939

4040
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
4141

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<h1>Faker</h1>
44
<p>Generate massive amounts of fake (but realistic) data for testing and development.</p>
55

6-
[![Chat on Discord](https://img.shields.io/discord/929487054990110771)](https://discord.com/invite/4qDjAmDj4P)
6+
[![Chat on Discord](https://img.shields.io/discord/929487054990110771)](https://chat.fakerjs.dev)
77
[![Continuous Integration](https://github.com/faker-js/faker/actions/workflows/ci.yml/badge.svg)](https://github.com/faker-js/faker/actions/workflows/ci.yml)
88
[![npm version](https://badgen.net/npm/v/@faker-js/faker)](https://www.npmjs.com/package/@faker-js/faker)
99
[![npm downloads](https://badgen.net/npm/dm/@faker-js/faker)](https://www.npmjs.com/package/@faker-js/faker)

cypress.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"video": false,
3+
"e2e": {
4+
"chromeWebSecurity": false,
5+
"baseUrl": "http://localhost:5000",
6+
"integrationFolder": "cypress/e2e",
7+
"testFiles": "**/*.cy.*",
8+
"pluginsFile": false,
9+
"supportFile": false,
10+
"fixturesFolder": false
11+
}
12+
}

cypress/e2e/smoke.cy.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
describe('Smoke Test', () => {
2+
beforeEach(() => {
3+
cy.visit('/guide/');
4+
cy.get('a[href="/api/animal.html"]').as('firstSectionLink');
5+
});
6+
7+
it('compiles the guide page', () => {
8+
cy.contains('Getting Started');
9+
});
10+
11+
it('renders this last code example in the code', () => {
12+
// Click on any section in the sidebar
13+
cy.get('@firstSectionLink')
14+
.click()
15+
// Make sure the number of code examples is the same between reloads
16+
.get('.container pre code')
17+
.then(($codeBlocks) => {
18+
// Trigger a reload
19+
cy.reload()
20+
// Give the runtime a chance to update/fail
21+
.wait(500)
22+
.get('.container pre code')
23+
.should('have.length', $codeBlocks.length);
24+
});
25+
});
26+
});

cypress/tsconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES5",
4+
"lib": ["ES5", "DOM"],
5+
"types": ["cypress"]
6+
},
7+
"include": ["**/*.ts"]
8+
}

docs/.vitepress/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
api-pages.mjs

docs/.vitepress/config.mjs

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { defineConfig } from 'vitepress';
2+
import { apiPages } from './api-pages.mjs';
23

34
const nav = [
45
{ text: 'Guide', link: '/guide/' },
6+
{ text: 'Discord', link: 'https://chat.fakerjs.dev' },
57
// { text: 'Playground', link: '/playground/' },
68
];
79

@@ -22,61 +24,7 @@ const sidebar = {
2224
},
2325
{
2426
text: 'API',
25-
children: [
26-
{
27-
text: 'Address',
28-
link: '/api/address',
29-
collapsable: false, // optional, defaults to true
30-
},
31-
{
32-
text: 'Commerce',
33-
link: '/api/commerce',
34-
},
35-
{
36-
text: 'Company',
37-
link: '/api/company',
38-
},
39-
{
40-
text: 'Database',
41-
link: '/api/database',
42-
},
43-
{
44-
text: 'Datatype',
45-
link: '/api/datatype',
46-
},
47-
{
48-
text: 'Date',
49-
link: '/api/date',
50-
},
51-
{
52-
text: 'Fake',
53-
link: '/api/fake',
54-
},
55-
{
56-
text: 'Finance',
57-
link: '/api/finance',
58-
},
59-
{
60-
text: 'Hacker',
61-
link: '/api/hacker',
62-
},
63-
{
64-
text: 'Helpers',
65-
link: '/api/helpers',
66-
},
67-
{
68-
text: 'Image',
69-
link: '/api/image',
70-
},
71-
{
72-
text: 'Internet',
73-
link: '/api/internet',
74-
},
75-
{
76-
text: 'Localization',
77-
link: '/api/localization',
78-
},
79-
],
27+
children: apiPages,
8028
},
8129
{
8230
text: 'Migrating from Faker v5',

docs/.vitepress/theme/index.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
table td * {
2+
display: inline;
3+
}

docs/.vitepress/theme/index.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import './index.css';
12
import GlobalComponents from './components';
23
import DefaultTheme from 'vitepress/theme';
34

docs/api/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.md
2+
!fake.md
3+
!localization.md

0 commit comments

Comments
 (0)