Skip to content

Commit

Permalink
Merge branch 'main' into massoudmaboudi/mobile-locale-dropdown-improv…
Browse files Browse the repository at this point in the history
…ement
  • Loading branch information
Josh-Cena committed May 25, 2022
2 parents 4d5b049 + d50fe3b commit f9aea8a
Show file tree
Hide file tree
Showing 584 changed files with 4,662 additions and 3,936 deletions.
3 changes: 1 addition & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
__fixtures__
__mocks__
dist
node_modules
.yarn
Expand All @@ -11,10 +12,8 @@ examples/
packages/lqip-loader/lib/
packages/docusaurus/lib/
packages/docusaurus-*/lib/*
packages/docusaurus-*/lib-next/
packages/eslint-plugin/lib/
packages/stylelint-copyright/lib/
copyUntypedFiles.mjs

packages/create-docusaurus/lib/*
packages/create-docusaurus/templates/facebook
Expand Down
34 changes: 31 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ module.exports = {
'no-restricted-exports': OFF,
'no-restricted-properties': [
ERROR,
...[
.../** @type {[string, string][]} */ ([
// TODO: TS doesn't make Boolean a narrowing function yet,
// so filter(Boolean) is problematic type-wise
// ['compact', 'Array#filter(Boolean)'],
Expand Down Expand Up @@ -114,7 +114,7 @@ module.exports = {
['take', 'Array#slice(0, n)'],
['takeRight', 'Array#slice(-n)'],
['tail', 'Array#slice(1)'],
].map(([property, alternative]) => ({
]).map(([property, alternative]) => ({
object: '_',
property,
message: `Use ${alternative} instead.`,
Expand Down Expand Up @@ -220,7 +220,35 @@ module.exports = {
],
},
],
'import/order': OFF,
'import/order': [
WARNING,
{
groups: [
'builtin',
'external',
'internal',
['parent', 'sibling', 'index'],
'type',
],
pathGroups: [
{pattern: '@jest/globals', group: 'builtin', position: 'before'},
{pattern: 'react', group: 'builtin', position: 'before'},
{pattern: 'fs-extra', group: 'builtin'},
{pattern: 'lodash', group: 'external', position: 'before'},
{pattern: 'clsx', group: 'external', position: 'before'},
// 'Bit weird to not use the `import/internal-regex` option, but this
// way, we can make `import type { Props } from "@theme/*"` appear
// before `import styles from "styles.module.css"`, which is what we
// always did. This should be removable once we stop using ambient
// module declarations for theme aliases.
{pattern: '@theme/**', group: 'internal'},
{pattern: '@site/**', group: 'internal'},
{pattern: '@theme-init/**', group: 'internal'},
{pattern: '@theme-original/**', group: 'internal'},
],
pathGroupsExcludedImportTypes: [],
},
],
'import/prefer-default-export': OFF,

'jest/consistent-test-it': WARNING,
Expand Down
16 changes: 11 additions & 5 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,14 @@
# Make GitHub not index certain files in the languages overview
# See https://github.com/github/linguist/blob/master/docs/overrides.md
# generated files' diff will be minimized
**/__fixtures__/** linguist-generated
.husky/** linguist-vendored
jest/** linguist-vendored
admin/** linguist-documentation
website/** linguist-documentation
**/__fixtures__/** linguist-generated
**/__mocks__/** linguist-generated
examples/** linguist-generated
.husky/** linguist-vendored
jest/** linguist-vendored
admin/** linguist-documentation
website/** linguist-documentation
packages/create-docusaurus/templates/** linguist-vendored
.eslintrc.* linguist-vendored
jest.config.* linguist-vendored
.stylelintrc.* linguist-vendored
2 changes: 1 addition & 1 deletion .github/workflows/build-blog-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3
- name: Set up Node
uses: actions/setup-node@56337c425554a6be30cdef71bf441f15be286854 # v3
uses: actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048 # v3
with:
node-version: '16'
cache: yarn
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3
- name: Set up Node
uses: actions/setup-node@56337c425554a6be30cdef71bf441f15be286854 # v3
uses: actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048 # v3
with:
node-version: '16'
cache: yarn
Expand All @@ -55,7 +55,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3
- uses: actions/setup-node@56337c425554a6be30cdef71bf441f15be286854 # v3
- uses: actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048 # v3
with:
cache: yarn
- name: Installation
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/canary-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
fetch-depth: 0 # Needed to get the commit number with "git rev-list --count HEAD"
- name: Set up Node
uses: actions/setup-node@56337c425554a6be30cdef71bf441f15be286854 # v3
uses: actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048 # v3
with:
node-version: '16'
cache: yarn
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ jobs:
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3

- name: Initialize CodeQL
uses: github/codeql-action/init@75b4f1c4669133dc294b06c2794e969efa2e5316 # v2
uses: github/codeql-action/init@a3a6c128d771b6b9bdebb1c9d0583ebd2728a108 # v2
with:
languages: ${{ matrix.language }}

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@75b4f1c4669133dc294b06c2794e969efa2e5316 # v2
uses: github/codeql-action/analyze@a3a6c128d771b6b9bdebb1c9d0583ebd2728a108 # v2
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b #v3
- name: Dependency Review
uses: actions/dependency-review-action@3f943b86c9a289f4e632c632695e2e0898d9d67d # v1
uses: actions/dependency-review-action@a9c83d3af6b9031e20feba03b904645bb23d1dab # v1
4 changes: 2 additions & 2 deletions .github/workflows/lighthouse-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ jobs:
PR_NUMBER: ${{ github.event.pull_request.number}}
- name: Format lighthouse score
id: format_lighthouse_score
uses: actions/github-script@9ac08808f993958e9de277fe43a64532a609130e # v6
uses: actions/github-script@7a5c598405937d486b0331594b5da2b14db670da # v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const results = ${{ steps.lighthouse_audit.outputs.manifest }}
const links = ${{ steps.lighthouse_audit.outputs.links }}
const createLighthouseReport = (await import(`${process.env.GITHUB_WORKSPACE}/admin/scripts/format-lighthouse-score.mjs`)).default;
const createLighthouseReport = (await import(`${process.env.GITHUB_WORKSPACE}/admin/scripts/formatLighthouseReport.js`)).default;
const comment = createLighthouseReport({ results, links });
core.setOutput("comment", comment);
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3
- name: Set up Node
uses: actions/setup-node@56337c425554a6be30cdef71bf441f15be286854 # v3
uses: actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048 # v3
with:
node-version: '16'
cache: yarn
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/showcase-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3
- name: Set up Node
uses: actions/setup-node@56337c425554a6be30cdef71bf441f15be286854 # v3
uses: actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048 # v3
with:
node-version: '16'
cache: yarn
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@56337c425554a6be30cdef71bf441f15be286854 # v3
uses: actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048 # v3
with:
node-version: ${{ matrix.node }}
cache: yarn
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3
- name: Use Node.js 16
uses: actions/setup-node@56337c425554a6be30cdef71bf441f15be286854 # v3
uses: actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048 # v3
with:
node-version: '16'
cache: yarn
Expand Down Expand Up @@ -119,7 +119,7 @@ jobs:
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3
- name: Use Node.js 16
uses: actions/setup-node@56337c425554a6be30cdef71bf441f15be286854 # v3
uses: actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048 # v3
with:
node-version: '16'
cache: yarn
Expand Down Expand Up @@ -149,7 +149,7 @@ jobs:
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3
- name: Use Node.js 16
uses: actions/setup-node@56337c425554a6be30cdef71bf441f15be286854 # v3
uses: actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048 # v3
with:
node-version: '16'
cache: yarn
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests-swizzle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3
- name: Set up Node
uses: actions/setup-node@56337c425554a6be30cdef71bf441f15be286854 # v3
uses: actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048 # v3
with:
node-version: '16'
cache: yarn
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@56337c425554a6be30cdef71bf441f15be286854 # v3
uses: actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048 # v3
with:
node-version: ${{ matrix.node }}
- name: Installation
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@56337c425554a6be30cdef71bf441f15be286854 # v3
uses: actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048 # v3
with:
node-version: ${{ matrix.node }}
cache: yarn
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ packages/docusaurus/lib/
packages/docusaurus-*/lib/*
packages/eslint-plugin/lib/
packages/stylelint-copyright/lib/
packages/docusaurus-*/lib-next/

website/netlifyDeployPreview/*
website/changelog
Expand Down
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ coverage
packages/lqip-loader/lib/
packages/docusaurus/lib/
packages/docusaurus-*/lib/*
packages/docusaurus-*/lib-next/
packages/create-docusaurus/lib/*
packages/create-docusaurus/templates/*/docusaurus.config.js
packages/eslint-plugin/lib/
Expand Down
1 change: 0 additions & 1 deletion .stylelintignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ examples/
packages/lqip-loader/lib/
packages/docusaurus/lib/
packages/docusaurus-*/lib/*
packages/docusaurus-*/lib-next/
packages/create-docusaurus/lib/*
packages/create-docusaurus/templates/
website/static/katex/katex.min.css
32 changes: 18 additions & 14 deletions __tests__/validate-package-json.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import {Globby} from '@docusaurus/utils';
import fs from 'fs-extra';
import {Globby} from '@docusaurus/utils';

type PackageJsonFile = {
file: string;
Expand All @@ -28,7 +28,11 @@ type PackageJsonFile = {
async function getPackagesJsonFiles(): Promise<PackageJsonFile[]> {
const files = await Globby('packages/*/package.json');
return Promise.all(
files.map((file) => fs.readJSON(file).then((content) => ({file, content}))),
files.map((file) =>
fs
.readJSON(file)
.then((content: PackageJsonFile['content']) => ({file, content})),
),
);
}

Expand Down Expand Up @@ -62,19 +66,19 @@ describe('packages', () => {
const packageJsonFiles = await getPackagesJsonFiles();

packageJsonFiles
.filter((packageJsonFile) => packageJsonFile.content.name.startsWith('@'))
.filter((packageJsonFile) =>
packageJsonFile.content.name?.startsWith('@'),
)
.forEach((packageJsonFile) => {
if (packageJsonFile) {
// Unfortunately jest custom message do not exist in loops,
// so using an exception instead to show failing package file
// (see https://github.com/facebook/jest/issues/3293)
// expect(packageJsonFile.content.publishConfig?.access)
// .toEqual('public');
if (packageJsonFile.content.publishConfig?.access !== 'public') {
throw new Error(
`Package ${packageJsonFile.file} does not have publishConfig.access: 'public'`,
);
}
// Unfortunately jest custom message do not exist in loops,
// so using an exception instead to show failing package file
// (see https://github.com/facebook/jest/issues/3293)
// expect(packageJsonFile.content.publishConfig?.access)
// .toEqual('public');
if (packageJsonFile.content.publishConfig?.access !== 'public') {
throw new Error(
`Package ${packageJsonFile.file} does not have publishConfig.access: 'public'`,
);
}
});
});
Expand Down
70 changes: 70 additions & 0 deletions __tests__/validate-tsconfig.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import fs from 'fs-extra';
import {Globby} from '@docusaurus/utils';
import {Joi} from '@docusaurus/utils-validation';

type TsconfigFile = {
file: string;
content: {
extends?: string;
compilerOptions: {
[key: string]: unknown;
};
};
};

async function getTsconfigFiles(): Promise<TsconfigFile[]> {
const files = await Globby('packages/*/tsconfig.*');
return Promise.all(
files.map((file) =>
fs
.readJSON(file)
.then((content: TsconfigFile['content']) => ({file, content})),
),
);
}

const tsconfigSchema = Joi.object({
extends: '../../tsconfig.json',
compilerOptions: Joi.alternatives().conditional(
Joi.object({noEmit: true}).unknown(),
{
then: Joi.object({
noEmit: Joi.valid(true).required(),
incremental: Joi.forbidden(),
tsBuildInfoFile: Joi.forbidden(),
outDir: Joi.forbidden(),
module: Joi.valid('commonjs', 'es2020', 'esnext').required(),
}).unknown(),
otherwise: Joi.object({
noEmit: Joi.valid(false).required(),
incremental: Joi.valid(true).required(),
rootDir: Joi.valid('src').required(),
outDir: Joi.valid('lib').required(),
module: Joi.valid('commonjs', 'es2020', 'esnext').required(),
}).unknown(),
},
),
}).unknown();

describe('tsconfig files', () => {
it('contain all required fields', async () => {
const tsconfigFiles = await getTsconfigFiles();
tsconfigFiles.forEach((file) => {
try {
Joi.attempt(file.content, tsconfigSchema);
} catch (e) {
(
e as Error
).message += `\n${file.file} does not match the required schema.`;
throw e;
}
});
});
});
Loading

0 comments on commit f9aea8a

Please sign in to comment.