diff --git a/.env b/.env index 6f809cc2..e69de29b 100644 --- a/.env +++ b/.env @@ -1 +0,0 @@ -SKIP_PREFLIGHT_CHECK=true diff --git a/.eslintrc.js b/.eslintrc.js index 9b3b93f4..e9e60bdf 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,3 +1,18 @@ module.exports = { - extends: "react-app", + root: true, + env: { browser: true, es2020: true }, + extends: [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:react-hooks/recommended", + ], + ignorePatterns: ["dist", ".eslintrc.cjs"], + parser: "@typescript-eslint/parser", + plugins: ["react-refresh"], + rules: { + "react-refresh/only-export-components": [ + "warn", + { allowConstantExport: true }, + ], + }, } diff --git a/.githooks/pre-push b/.githooks/pre-push deleted file mode 100755 index d50d53e0..00000000 --- a/.githooks/pre-push +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -npx danger local --base main diff --git a/.github/renovate.json5 b/.github/renovate.json5 deleted file mode 100644 index 3e452ff9..00000000 --- a/.github/renovate.json5 +++ /dev/null @@ -1,112 +0,0 @@ -{ - extends: ["config:base"], - // https://renovatebot.com/docs/configuration-options/#commitbodytable - commitBodyTable: true, - // https://docs.renovatebot.com/configuration-options/#dependencydashboard - dependencyDashboard: false, - // https://renovatebot.com/docs/configuration-options/#ignoredeps - ignoreDeps: [ - "immutable", - "@types/draft-js", - "draft-js", - "draft-js-10", - "normalize.css", - "@types/react", - "@types/react-dom", - "react", - "react-dom", - "react-test-renderer", - "jamesives/github-pages-deploy-action", - ], - // https://renovatebot.com/docs/configuration-options/#labels - labels: ["enhancement"], - // https://renovatebot.com/docs/configuration-options/#prcreation - prCreation: "not-pending", - // https://renovatebot.com/docs/configuration-options/#semanticcommits - semanticCommits: true, - // Use shorter commit messages to account for long dependency names. - // https://docs.renovatebot.com/configuration-options/#commitmessagetopic - commitMessageTopic: "{{depName}}", - // https://renovatebot.com/docs/configuration-options/#prbodycolumns - prBodyColumns: ["Package", "Update", "Type", "Change"], - // https://renovatebot.com/docs/configuration-options/#schedule - schedule: ["every weekend"], - // Limit the number of consecutive PRs - prHourlyLimit: 2, - // Silently merge updates without PRs - automergeType: "branch", - node: { - enabled: true, - major: { - enabled: true, - }, - // https://renovatebot.com/docs/node/#configuring-support-policy - supportPolicy: ["current"], - }, - vulnerabilityAlerts: { - automerge: true, - }, - packageRules: [ - { - packageNames: ["prettier"], - groupName: "prettier", - automerge: true, - }, - { - packageNames: ["coveralls"], - groupName: "coveralls", - automerge: true, - }, - { - packageNames: ["danger"], - groupName: "danger", - automerge: true, - }, - { - packageNames: ["@types/jest", "react-scripts"], - groupName: "react-scripts", - automerge: true, - }, - { - packageNames: ["typescript"], - groupName: "typescript", - automerge: true, - }, - { - packagePatterns: ["^@commitlint"], - groupName: "commitlint", - automerge: true, - }, - { - packagePatterns: ["^enzyme"], - groupName: "enzyme", - automerge: true, - automergeType: "branch", - }, - { - packagePatterns: ["^rollup", "^@rollup"], - groupName: "rollup", - automerge: true, - }, - { - packageNames: ["snapshot-diff"], - groupName: "snapshot-diff", - automerge: true, - }, - { - packagePatterns: ["^semantic-release", "^@semantic-release"], - groupName: "semantic-release", - automerge: true, - }, - { - packageNames: ["JamesIves/github-pages-deploy-action"], - groupName: "JamesIves/github-pages-deploy-action", - automerge: true, - }, - { - packagePatterns: ["^actions/"], - groupName: "actions", - automerge: true, - }, - ], -} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9cdc31e7..655b5f2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,6 @@ on: push: branches: - main - - "renovate/**" pull_request: jobs: test: @@ -39,18 +38,13 @@ jobs: - run: DRAFTJS_VERSION=0.10 npm run test - run: npx commitlint --from HEAD~${{ github.event.pull_request.commits }} --to HEAD if: ${{ github.event_name == 'pull_request' }} - - run: npx danger ci --verbose - if: ${{ github.event_name == 'pull_request' }} - env: - DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: npm run report:package - run: mv coverage/lcov-report build || true - run: cat ./coverage/lcov.info | npx coveralls || true - - uses: actions/upload-artifact@v3 + - uses: actions/configure-pages@v4 + - uses: actions/upload-pages-artifact@v3 with: - name: build path: build - retention-days: 1 - run: npx semantic-release if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} env: @@ -59,14 +53,14 @@ jobs: GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }} GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }} deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + permissions: + pages: write + id-token: write runs-on: ubuntu-latest needs: test if: github.event_name == 'push' && github.ref == 'refs/heads/main' steps: - - uses: actions/checkout@v4 - - uses: actions/download-artifact@v3 - - uses: JamesIves/github-pages-deploy-action@v4.4.3 - with: - branch: gh-pages - folder: build - clean: true + - uses: actions/deploy-pages@v4 diff --git a/.gitignore b/.gitignore index b2a17664..9b9bcd1a 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,11 @@ pids *.pyc *.pyo *.pot +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? # ------------------------------------------------- # Instrumentation and tooling diff --git a/.nvmrc b/.nvmrc index 3c032078..aabe6ec3 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -18 +21 diff --git a/dangerfile.js b/dangerfile.js deleted file mode 100644 index 9aa61cdf..00000000 --- a/dangerfile.js +++ /dev/null @@ -1,104 +0,0 @@ -const { danger, message, warn, fail, schedule } = require("danger") -const semanticRelease = require("semantic-release") -const envCi = require("env-ci") -const isLocal = !danger.github - -const libModifiedFiles = danger.git.modified_files.filter( - (path) => path.startsWith("src/lib") && path.endsWith("js"), -) -const hasLibChanges = - libModifiedFiles.filter((filepath) => !filepath.endsWith("test.js")).length > - 0 -const hasLibTestChanges = - libModifiedFiles.filter( - (filepath) => - filepath.endsWith("test.js") || filepath.endsWith("test.js.snap"), - ).length > 0 -const hasREADMEChanges = danger.git.modified_files.includes("README.md") - -if (!isLocal) { - const hasLabels = danger.github.issue.labels.length !== 0 - const isEnhancement = - danger.github.issue.labels.some((l) => l.name === "enhancement") || - danger.github.pr.title.includes("feature") - const isBug = - danger.github.issue.labels.some((l) => l.name === "bug") || - danger.github.pr.title.includes("fix") || - danger.github.pr.title.includes("bug") - - if (!hasLabels) { - message("What labels should we add to this PR?") - } - - // Fails if the description is too short. - if (!danger.github.pr.body || danger.github.pr.body.length < 10) { - fail(":grey_question: This pull request needs a description.") - } - - if (hasLibChanges && !hasLibTestChanges && (isEnhancement || isBug)) { - message("This PR may require new test cases") - } - - // Warns if the PR title contains [WIP] - const isWIP = danger.github.pr.title.includes("WIP") - if (isWIP) { - const title = ":construction_worker: Work In Progress" - const idea = - "This PR appears to be a work in progress, and may not be ready to be merged yet." - warn(`${title} - ${idea}`) - } -} - -if (hasLibChanges && !hasREADMEChanges) { - warn("This pull request updates the library. Should the docs be updated?") -} - -const hasPackageChanges = danger.git.modified_files.includes("package.json") -const hasLockfileChanges = - danger.git.modified_files.includes("package-lock.json") - -if (hasPackageChanges && !hasLockfileChanges) { - warn("There are package.json changes with no corresponding lockfile changes") -} - -const linkDep = (dep) => - danger.utils.href(`https://www.npmjs.com/package/${dep}`, dep) - -schedule(async () => { - const packageDiff = await danger.git.JSONDiffForFile("package.json") - - if (packageDiff.dependencies) { - const added = packageDiff.dependencies.added - const removed = packageDiff.dependencies.removed - - if (added.length) { - const deps = danger.utils.sentence(added.map((d) => linkDep(d))) - message(`Adding new dependencies: ${deps}`) - } - - if (removed.length) { - const deps = danger.utils.sentence(removed.map((d) => linkDep(d))) - message(`:tada:, removing dependencies: ${deps}`) - } - - if (added.includes("draft-js")) { - warn( - ":scream: this PR updates Draft.js! Please make sure to review the Draft.js CHANGELOG.", - ) - } - } -}) - -if (!isLocal) { - schedule(async () => { - // Retrieve the current branch so semantic-release is configured as if it was to make a release from it. - const { branch } = envCi() - - const result = await semanticRelease({ dryRun: true, branch }) - if (result.nextRelease) { - message( - `:tada: Merging this will publish a new ${result.nextRelease.type} release, v${result.nextRelease.version}.`, - ) - } - }) -} diff --git a/public/index.html b/index.html similarity index 90% rename from public/index.html rename to index.html index fa52acc1..d16819df 100644 --- a/public/index.html +++ b/index.html @@ -13,28 +13,28 @@ content="Filter Draft.js content to preserve only the formatting you allow. Built for Draftail and Wagtail" /> - + - + @@ -103,7 +103,7 @@
@@ -158,5 +158,11 @@