Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add yarn check:tsc command to check all files #7963

Merged
merged 4 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
cache: yarn
cache-dependency-path: |
yarn.lock
client/pwa/yarn.lock
deployer/aws-lambda/content-origin-request/yarn.lock
deployer/aws-lambda/content-origin-response/yarn.lock
deployer/aws-lambda/tests/yarn.lock
Expand All @@ -31,6 +32,10 @@ jobs:
- name: Install all yarn packages (ROOT)
run: yarn --frozen-lockfile

- name: Install all yarn packages (pwa)
working-directory: client/pwa
run: yarn --frozen-lockfile

- name: Install all yarn packages (aws-lambda/content-origin-request)
working-directory: deployer/aws-lambda/content-origin-request
run: yarn --frozen-lockfile
Expand All @@ -52,6 +57,9 @@ jobs:
- name: Lint stylelint
run: yarn stylelint

- name: Check TypeScript
run: yarn check:tsc

test:
runs-on: ubuntu-latest

Expand Down
5 changes: 0 additions & 5 deletions .lintstagedrc.json

This file was deleted.

2 changes: 2 additions & 0 deletions build/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { prompt } from "inquirer";
import { Document, slugToFolder, translationsOf } from "../content";
import { CONTENT_ROOT, CONTENT_TRANSLATED_ROOT } from "../libs/env";
import { VALID_LOCALES } from "../libs/constants";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { renderHTML } from "../ssr/dist/main";
import options from "./build-options";
import { buildDocument, BuiltDocument, renderContributorsTxt } from ".";
Expand Down
2 changes: 2 additions & 0 deletions build/spas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
} from "../libs/env";
import { isValidLocale } from "../libs/locale-utils";
import { DocFrontmatter } from "../libs/types/document";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { renderHTML } from "../ssr/dist/main";
import got from "got";
import { splitSections } from "./utils";
Expand Down
1 change: 1 addition & 0 deletions client/pwa/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"sourceMap": true,
"preserveConstEnums": true,
"outDir": "../public",
"skipLibCheck": true,
"moduleResolution": "node"
},
"include": ["src/*.ts", "src/**/*.ts", "src/*.tsx", "src/**/*.tsx"]
Expand Down
9 changes: 9 additions & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
"*.!{js,jsx,ts,tsx,css,scss}": "prettier --ignore-unknown --write",
"*.{js,jsx,ts,tsx}": [
() => "yarn check:tsc",
"eslint --fix",
"prettier --write",
],
"*.{css,scss}": ["stylelint --fix --allow-empty-input", "prettier --write"],
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"build:ssr": "cd ssr && webpack --mode=production",
"build:sw": "cd client/pwa && yarn && yarn build:prod",
"build:sw-dev": "cd client/pwa && yarn && yarn build",
"check:tsc": "find . -mindepth 2 -name 'tsconfig.json' ! -wholename '**/node_modules/**' -print0 | xargs -n1 -0 bash -c 'cd `dirname $0` && pwd && npx tsc --noEmit || exit 255'",
"dev": "yarn build:prepare && nf -j Procfile.dev start",
"eslint": "eslint .",
"filecheck": "ts-node filecheck/cli.ts",
Expand Down
6 changes: 6 additions & 0 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ echo "Lint stylelint"
echo "--------------"

yarn stylelint

echo "--------------"
echo "Check TypeScript"
echo "--------------"

yarn check:tsc
2 changes: 2 additions & 0 deletions server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import { router as translationsRouter } from "./translations";
import { staticMiddlewares, originRequestMiddleware } from "./middlewares";
import { getRoot } from "../content/utils";

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { renderHTML } from "../ssr/dist/main";

async function buildDocumentFromURL(url) {
Expand Down
2 changes: 1 addition & 1 deletion testing/tests/developing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ test.describe("Testing the kitchensink page", () => {
// Loading the index.json doesn't require a headless browser
const { doc } = await got(
serverURL("/en-US/docs/MDN/Kitchensink/index.json")
).json();
).json<any>();

expect(doc.title).toBe("The MDN Content Kitchensink");
expect(doc.flaws).toEqual({});
Expand Down
16 changes: 12 additions & 4 deletions testing/tests/headless.sitesearch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ test.describe("Site search", () => {

await page.fill(SEARCH_SELECTOR, "foo");
await page.waitForSelector("#top-nav-search-form"); // autocomplete search form
await page.$eval('form[role="search"]', (form) => form.submit());
await page.$eval('form[role="search"]', (form) =>
(form as HTMLFormElement).submit()
);
// Force a wait for the lazy-loading
await page.waitForLoadState("networkidle");
// Force a wait for the search results
Expand All @@ -32,7 +34,9 @@ test.describe("Site search", () => {
// See server/static.js for how fixtures are hardcoded
await page.fill(SEARCH_SELECTOR, "FOO");
await page.waitForSelector("#top-nav-search-form"); // autocomplete search form
await page.$eval('form[role="search"]', (form) => form.submit());
await page.$eval('form[role="search"]', (form) =>
(form as HTMLFormElement).submit()
);
// Force a wait for the lazy-loading
await page.waitForLoadState("networkidle");
expect(page.url()).toBe(testURL("/en-US/search/?q=FOO"));
Expand All @@ -47,7 +51,9 @@ test.describe("Site search", () => {
// See server/static.js for how fixtures are hardcoded
await page.fill(SEARCH_SELECTOR, "NOTHING");
await page.waitForSelector("#top-nav-search-form"); // autocomplete search form
await page.$eval('form[role="search"]', (form) => form.submit());
await page.$eval('form[role="search"]', (form) =>
(form as HTMLFormElement).submit()
);
await page.waitForLoadState("networkidle");
expect(page.url()).toBe(testURL("/en-US/search/?q=NOTHING"));
expect(
Expand All @@ -62,7 +68,9 @@ test.describe("Site search", () => {
// See server/static.js for how fixtures are hardcoded
await page.fill(SEARCH_SELECTOR, "SERIAL(20)");
await page.waitForSelector("#top-nav-search-form"); // autocomplete search form
await page.$eval('form[role="search"]', (form) => form.submit());
await page.$eval('form[role="search"]', (form) =>
(form as HTMLFormElement).submit()
);
await page.waitForLoadState("networkidle");
expect(
await page.isVisible("text=Search results for: SERIAL(20)")
Expand Down