Skip to content

Commit

Permalink
Merge branch 'main' into collapse-codeblock
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena committed Jan 18, 2022
2 parents 1581b8c + 1d7827d commit f8e226c
Show file tree
Hide file tree
Showing 774 changed files with 11,379 additions and 8,596 deletions.
6 changes: 2 additions & 4 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ build
coverage
jest.config.js
jest.transform.js
scripts
examples/

packages/lqip-loader/lib/
packages/docusaurus/lib/
packages/docusaurus-*/lib/*
packages/docusaurus-*/lib-next/
packages/docusaurus-plugin-pwa/copyUntypedFiles.js
packages/docusaurus-plugin-ideal-image/copyUntypedFiles.js
packages/docusaurus-theme-search-algolia/copyUntypedFiles.js
packages/stylelint-copyright/lib/
copyUntypedFiles.mjs

packages/create-docusaurus/lib/*
packages/create-docusaurus/templates/facebook/.eslintrc.js
26 changes: 21 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = {
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
'plugin:jest/recommended',
'airbnb',
'prettier',
],
Expand All @@ -39,7 +40,8 @@ module.exports = {
},
},
},
plugins: ['react-hooks', 'header'],
reportUnusedDisableDirectives: true,
plugins: ['react-hooks', 'header', 'jest'],
rules: {
'react-hooks/rules-of-hooks': ERROR,
'react-hooks/exhaustive-deps': ERROR,
Expand Down Expand Up @@ -74,9 +76,7 @@ module.exports = {
'no-param-reassign': [WARNING, {props: false}],
'no-underscore-dangle': OFF,
curly: [WARNING, 'all'],
'react/jsx-closing-bracket-location': OFF, // Conflicts with Prettier.
'react/jsx-filename-extension': OFF,
'react/jsx-one-expression-per-line': OFF,
'react/no-array-index-key': OFF, // Sometimes its ok, e.g. non-changing data.
'react/prop-types': OFF,
'react/destructuring-assignment': OFF, // Too many lines.
Expand All @@ -92,7 +92,10 @@ module.exports = {
],
'react/no-unstable-nested-components': [WARNING, {allowAsProps: true}],
'@typescript-eslint/no-inferrable-types': OFF,
'import/first': OFF,
'@typescript-eslint/consistent-type-imports': [
WARNING,
{disallowTypeAnnotations: false},
],
'import/order': OFF,
'import/prefer-default-export': OFF,
'lines-between-class-members': OFF,
Expand Down Expand Up @@ -167,8 +170,21 @@ module.exports = {
],
},
],
'jest/prefer-expect-resolves': WARNING,
'jest/expect-expect': OFF,
'jest/valid-title': OFF,
},
overrides: [
{
files: [
'packages/docusaurus-theme-*/src/theme/**/*.js',
'packages/docusaurus-theme-*/src/theme/**/*.ts',
'packages/docusaurus-theme-*/src/theme/**/*.tsx',
],
rules: {
'import/no-named-export': ERROR,
},
},
{
files: [
'packages/create-docusaurus/templates/**/*.js',
Expand All @@ -194,7 +210,7 @@ module.exports = {
},
},
{
files: ['*.js'],
files: ['*.js', '*.mjs', '.cjs'],
rules: {
// Make JS code directly runnable in Node.
'@typescript-eslint/no-var-requires': OFF,
Expand Down
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: '/'
schedule:
interval: weekly
open-pull-requests-limit: 99
- package-ecosystem: npm
directory: '/'
schedule:
interval: monthly
open-pull-requests-limit: 99
1 change: 1 addition & 0 deletions .github/workflows/build-blog-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
cache: yarn
- name: Installation
run: yarn
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
cache: yarn
- uses: preactjs/compressed-size-action@v2
with:
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/canary-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@ jobs:
publish-canary:
name: Publish Canary
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Needed to get the commit number with "git rev-list --count HEAD"
- name: Use Node.js ${{ matrix.node-version }}
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
node-version: '16'
cache: yarn
- name: Prepare git
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/lighthouse-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
max_timeout: 600
- name: Audit URLs using Lighthouse
id: lighthouse_audit
uses: treosh/lighthouse-ci-action@v3
uses: treosh/lighthouse-ci-action@8.2.0
with:
urls: |
https://deploy-preview-$PR_NUMBER--docusaurus-2.netlify.app/
Expand All @@ -30,7 +30,7 @@ jobs:
PR_NUMBER: ${{ github.event.pull_request.number}}
- name: Format lighthouse score
id: format_lighthouse_score
uses: actions/github-script@v3
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
Expand All @@ -55,7 +55,7 @@ jobs:
- name: Add Lighthouse stats as comment
id: comment_to_pr
uses: marocchino/sticky-pull-request-comment@v2.0.0
uses: marocchino/sticky-pull-request-comment@v2.2.0
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{ github.event.pull_request.number }}
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
cache: yarn
- name: Installation
run: yarn
Expand All @@ -24,5 +25,3 @@ jobs:
run: yarn lint:ci
- name: Prettier Code
run: yarn format:diff
- name: Prettier Docs
run: yarn format-docs:diff
5 changes: 2 additions & 3 deletions .github/workflows/showcase-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node }}
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
node-version: '16'
cache: yarn
- name: Installation
run: yarn
- name: Test
run: yarn test website/src/data/__tests__/user.test.ts
# TODO another job to optimize the images, see https://github.com/facebook/docusaurus/issues/5980
11 changes: 3 additions & 8 deletions .github/workflows/tests-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ jobs:
- name: Build test-website project
run: yarn build
working-directory: ../test-website
env:
CI: true

yarn-berry:
name: E2E — Yarn Berry
Expand All @@ -72,6 +70,9 @@ jobs:
- name: Install test-website project with Yarn Berry and nodeLinker = ${{ matrix.nodeLinker }}
run: |
yarn set version berry
# https://github.com/facebook/docusaurus/pull/6350#issuecomment-1013214763
# Remove this after Yarn 3.2
yarn set version canary
yarn config set nodeLinker ${{ matrix.nodeLinker }}
yarn config set npmRegistryServer http://localhost:4873
Expand All @@ -98,8 +99,6 @@ jobs:
- name: Build test-website project
run: yarn build
working-directory: ../test-website
env:
CI: true

npm:
name: E2E — NPM
Expand Down Expand Up @@ -131,8 +130,6 @@ jobs:
- name: Build test-website project
run: npm run build
working-directory: ../test-website
env:
CI: true

pnpm:
name: E2E — PNPM
Expand Down Expand Up @@ -166,5 +163,3 @@ jobs:
- name: Build test-website project
run: pnpm run build
working-directory: ../test-website
env:
CI: true
2 changes: 0 additions & 2 deletions .github/workflows/tests-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,3 @@ jobs:
echo "# hello" > test-file.md
- name: Docusaurus Build
run: yarn build:website --locale en
env:
CI: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ packages/create-docusaurus/lib/
packages/lqip-loader/lib/
packages/docusaurus/lib/
packages/docusaurus-*/lib/*
packages/stylelint-copyright/lib/
packages/docusaurus-*/lib-next/

website/netlifyDeployPreview/*
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ packages/docusaurus-*/lib/*
packages/docusaurus-*/lib-next/
packages/create-docusaurus/lib/*
packages/create-docusaurus/templates/*/docusaurus.config.js
packages/stylelint-copyright/lib/
__fixtures__

website/i18n
Expand Down
10 changes: 9 additions & 1 deletion .stylelintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
build
coverage
examples/

packages/lqip-loader/lib/
packages/docusaurus/lib/
packages/docusaurus-*/lib/*
packages/docusaurus-*/lib-next/
packages/create-docusaurus/lib/*
packages/create-docusaurus/templates/
examples
19 changes: 18 additions & 1 deletion .stylelintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,25 @@
*/

module.exports = {
extends: ['stylelint-config-recommended', 'stylelint-config-prettier'],
plugins: ['stylelint-copyright'],
rules: {
'docusaurus/copyright-header': true,
'docusaurus/copyright-header': [
true,
{
header: `*
* 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.`,
},
],
'selector-pseudo-class-no-unknown': [
true,
{
// :global is a CSS modules feature to escape from class name hashing
ignorePseudoClasses: ['global'],
},
],
},
};
32 changes: 17 additions & 15 deletions __tests__/validate-package-json.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ describe('packages', () => {
test('should contain repository and directory for every package', async () => {
const packageJsonFiles = await getPackagesJsonFiles();

packageJsonFiles.forEach((packageJsonFile) => {
if (packageJsonFile.content.private !== true) {
packageJsonFiles
.filter((packageJsonFile) => !packageJsonFile.content.private)
.forEach((packageJsonFile) => {
expect(packageJsonFile.content.repository).toEqual({
type: 'git',
url: 'https://github.com/facebook/docusaurus.git',
directory: packageJsonFile.file.replace(/\/package\.json$/, ''),
});
}
});
});
});

/*
Expand All @@ -58,17 +58,19 @@ describe('packages', () => {
test('should have publishConfig.access: "public" when name starts with @', async () => {
const packageJsonFiles = await getPackagesJsonFiles();

packageJsonFiles.forEach((packageJsonFile) => {
if (packageJsonFile.content.name.startsWith('@')) {
// 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'`,
);
packageJsonFiles
.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'`,
);
}
}
}
});
});
});
});
2 changes: 1 addition & 1 deletion admin/new.docusaurus.io/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This is a Netlify deployment to handle the Docusaurus playgrounds shortcuts:

- [docusaurus.new](https://docusaurus.new) (main one, as of today domain is owned by StackBlitz but may be transfered to FB)
- [docusaurus.new](https://docusaurus.new) (main one, as of today domain is owned by StackBlitz but may be transferred to FB)
- [new.docusaurus.io](https://new.docusaurus.io) (legacy one)

See also the [Playground doc page](https://docusaurus.io/docs/playground)
Expand Down
2 changes: 1 addition & 1 deletion admin/new.docusaurus.io/functionUtils/playgroundUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import {HandlerEvent, HandlerResponse} from '@netlify/functions';
import type {HandlerEvent, HandlerResponse} from '@netlify/functions';

const CookieName = 'DocusaurusPlaygroundName';

Expand Down
2 changes: 1 addition & 1 deletion admin/new.docusaurus.io/functions/codesandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import {Handler} from '@netlify/functions';
import type {Handler} from '@netlify/functions';

import {createPlaygroundResponse} from '../functionUtils/playgroundUtils';

Expand Down
2 changes: 1 addition & 1 deletion admin/new.docusaurus.io/functions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import {Handler} from '@netlify/functions';
import type {Handler} from '@netlify/functions';

import {
readPlaygroundName,
Expand Down
2 changes: 1 addition & 1 deletion admin/new.docusaurus.io/functions/stackblitz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import {Handler} from '@netlify/functions';
import type {Handler} from '@netlify/functions';

import {createPlaygroundResponse} from '../functionUtils/playgroundUtils';

Expand Down
Loading

0 comments on commit f8e226c

Please sign in to comment.