From 16852f714cae2b50d62fe7d233cb6744d202cc72 Mon Sep 17 00:00:00 2001 From: Martin Hochel Date: Mon, 8 Aug 2022 11:01:41 +0200 Subject: [PATCH] chore(scripts): enable type-checks on ci and fix all ts-errors --- .vscode/launch.json | 2 +- package.json | 10 ++++---- .../perf-test-northstar/tsconfig.json | 14 +++++++++-- scripts/beachball/config.test.ts | 2 -- .../gulp/plugins/util/parseTypeAnnotation.ts | 1 + scripts/gulp/tasks/browserAdapters.ts | 2 +- scripts/just-scripts.js | 2 -- scripts/package.json | 20 ++++------------ scripts/publish-beta.js | 23 ------------------- scripts/tasks/argv.spec.ts | 2 -- scripts/tsconfig.json | 14 +++++------ scripts/typescript/normalize-import.js | 4 +--- scripts/typescript/normalize-import.spec.js | 2 -- scripts/typescript/tsconfig.common.json | 22 ------------------ scripts/webpack/webpack.config.stats.ts | 10 ++------ yarn.lock | 16 ++++++++----- 16 files changed, 43 insertions(+), 103 deletions(-) delete mode 100755 scripts/just-scripts.js delete mode 100644 scripts/publish-beta.js delete mode 100644 scripts/typescript/tsconfig.common.json diff --git a/.vscode/launch.json b/.vscode/launch.json index e64deaaba4a4e2..ad44b4feb3276b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -57,7 +57,7 @@ "name": "Build @fluentui/react", "type": "node", "request": "launch", - "program": "${workspaceRoot}/scripts/just-scripts.js", + "program": "${workspaceRoot}/node-modules/just-scripts/bin/just-scripts.js", "cwd": "${workspaceRoot}/packages/react", "stopOnEntry": false, "args": ["ts"], diff --git a/package.json b/package.json index 2da70f40721f1d..344915299cba2c 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,6 @@ "buildto": "lage build --verbose --to", "buildto:lerna": "node ./scripts/monorepo/buildTo.js", "bundle": "lage bundle --verbose", - "bundlesize": "cd scripts && yarn bundlesize", "bundlesizecollect": "node ./scripts/bundle-size-collect", "change": "beachball change --no-commit", "check:change": "beachball check", @@ -55,9 +54,7 @@ "runto:lerna": "node ./scripts/monorepo/runTo.js", "scrub": "node ./scripts/scrub.js", "start": "node scripts/start.js", - "start:legacy": "yarn workspace @fluentui/public-docsite-resources start", "start:northstar": "yarn workspace @fluentui/docs start", - "start-exp": "yarn workspace @fluentui/react-experiments start", "stats:build": "gulp stats", "stats:save": "gulp stats:save", "test": "lage test --verbose", @@ -119,6 +116,7 @@ "@testing-library/react": "12.1.2", "@testing-library/react-hooks": "7.0.2", "@testing-library/user-event": "13.5.0", + "@tsconfig/node14": "1.0.3", "@types/babel__helper-plugin-utils": "7.10.0", "@types/copy-webpack-plugin": "6.4.0", "@types/dedent": "0.7.0", @@ -161,7 +159,7 @@ "beachball": "2.18.0", "chalk": "4.1.0", "ci-info": "3.2.0", - "clean-webpack-plugin": "3.0.0", + "clean-webpack-plugin": "4.0.0", "cli-table3": "0.6.1", "copy-webpack-plugin": "8.1.0", "cross-env": "^5.1.4", @@ -216,6 +214,7 @@ "loader-utils": "2.0.0", "memfs": "3.2.2", "node-fetch": "2.6.7", + "nx": "13.10.6", "portfinder": "1.0.28", "postcss": "8.3.5", "postcss-loader": "4.1.0", @@ -259,8 +258,7 @@ "workspace-tools": "0.18.4", "yargs": "13.3.2", "yargs-parser": "13.1.2", - "yargs-unparser": "2.0.0", - "nx": "13.10.6" + "yargs-unparser": "2.0.0" }, "dependencies": { "copy-to-clipboard": "3.3.1" diff --git a/packages/fluentui/perf-test-northstar/tsconfig.json b/packages/fluentui/perf-test-northstar/tsconfig.json index f99cd4602f451c..c18f11c5eafcb1 100644 --- a/packages/fluentui/perf-test-northstar/tsconfig.json +++ b/packages/fluentui/perf-test-northstar/tsconfig.json @@ -1,9 +1,19 @@ { - "extends": "@fluentui/scripts/typescript/tsconfig.common", "compilerOptions": { + "moduleResolution": "node", + "module": "esnext", + "target": "es5", + "forceConsistentCasingInFileNames": true, + "esModuleInterop": true, + "skipLibCheck": true, + "lib": ["es2015", "dom"], + "strict": true, + "jsx": "react", "rootDir": "src", "outDir": "lib", - "types": ["node", "jest", "expect-puppeteer", "jest-environment-puppeteer", "webpack-env"] + "sourceMap": true, + "types": ["node", "jest", "expect-puppeteer", "jest-environment-puppeteer", "webpack-env"], + "noUnusedLocals": true }, "include": ["src"], "references": [] diff --git a/scripts/beachball/config.test.ts b/scripts/beachball/config.test.ts index e8b1f23cbb8d65..fb023124eab368 100644 --- a/scripts/beachball/config.test.ts +++ b/scripts/beachball/config.test.ts @@ -1,5 +1,3 @@ -/// - import { config as sharedConfig } from './shared.config'; import v8Config from './release-v8.config'; import vNextConfig from './release-vNext.config'; diff --git a/scripts/gulp/plugins/util/parseTypeAnnotation.ts b/scripts/gulp/plugins/util/parseTypeAnnotation.ts index 4996cd30c8b41f..6f245a3fa3f476 100644 --- a/scripts/gulp/plugins/util/parseTypeAnnotation.ts +++ b/scripts/gulp/plugins/util/parseTypeAnnotation.ts @@ -48,6 +48,7 @@ const parseTypeAnnotation = (propName: string, propType: string, tsType: t.TSTyp } if (t.isTSLiteralType(tsType)) { + // @ts-expect-error - FIXME - `value` doesn't exist on literal return [{ name: 'literal', value: tsType.literal.value.toString() }]; } diff --git a/scripts/gulp/tasks/browserAdapters.ts b/scripts/gulp/tasks/browserAdapters.ts index 8d42fc3f551a02..d1376ed1302d22 100644 --- a/scripts/gulp/tasks/browserAdapters.ts +++ b/scripts/gulp/tasks/browserAdapters.ts @@ -68,7 +68,7 @@ async function checkDevtoolsAvailability(host, port, timeout): Promise socket.connect(port, host, () => { socket.end(); - resolve(); + resolve(undefined); }); }); diff --git a/scripts/just-scripts.js b/scripts/just-scripts.js deleted file mode 100755 index 1e6f439adc127f..00000000000000 --- a/scripts/just-scripts.js +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env node -require('just-scripts/bin/just-scripts'); diff --git a/scripts/package.json b/scripts/package.json index 8fe6cfcea852a3..5ae5c3a8f1c9a4 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -2,16 +2,10 @@ "name": "@fluentui/scripts", "version": "1.0.0", "private": true, - "main": "./index.js", - "bin": { - "just-scripts": "./just-scripts.js" - }, "scripts": { - "build": "echo no-op", - "bundlesize": "bundlesize --debug", - "clean": "", - "code-style": "node ./just-scripts.js code-style", - "test": "jest" + "code-style": "just-scripts code-style", + "test": "jest", + "type-check": "tsc -p . --noEmit" }, "devDependencies": { "@fluentui/eslint-plugin": "*" @@ -73,11 +67,5 @@ "riceburn": "^1.3.1", "through2": "^2.0.3", "ts-node": "^7.0.0" - }, - "bundlesize": [ - { - "path": "../apps/test-bundles/dist/fluentui-react-Button.min.js", - "maxSize": "50.1 kB" - } - ] + } } diff --git a/scripts/publish-beta.js b/scripts/publish-beta.js deleted file mode 100644 index 2ca024d97b1de9..00000000000000 --- a/scripts/publish-beta.js +++ /dev/null @@ -1,23 +0,0 @@ -// @ts-check - -const path = require('path'); -const chalk = require('chalk'); -const execSync = require('./exec-sync'); -const getAllPackageInfo = require('./monorepo/getAllPackageInfo'); - -const allPackages = getAllPackageInfo(); -const packages = []; - -Object.keys(allPackages).forEach(name => { - const info = allPackages[name]; - if (info.packageJson.private !== true) { - packages.push(info); - } -}); - -for (const package of packages) { - const packagePath = path.resolve(__dirname, '..', package.packagePath); - - console.log(`Publishing ${chalk.magenta(package.packageName)} in ${packagePath}`); - execSync('npm publish --tag next', undefined, packagePath); -} diff --git a/scripts/tasks/argv.spec.ts b/scripts/tasks/argv.spec.ts index a657985bf6afcb..a246ebf7a8d0a9 100644 --- a/scripts/tasks/argv.spec.ts +++ b/scripts/tasks/argv.spec.ts @@ -1,5 +1,3 @@ -/// - import { argv } from 'just-scripts'; import { Arguments } from 'yargs'; diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json index 04a80c9b5f33f9..66b61f006fa203 100644 --- a/scripts/tsconfig.json +++ b/scripts/tsconfig.json @@ -1,17 +1,17 @@ { - "extends": "./typescript/tsconfig.common.json", // This config is used for running build scripts through ts-node + "extends": "@tsconfig/node14/tsconfig.json", "compilerOptions": { - "module": "CommonJS", - "target": "ES2018", // Node 10 per https://kangax.github.io/compat-table/es2016plus/#node10_9 - "lib": ["ES2018", "DOM"], // Node 10, occasional test-related stuff that uses DOM - "esModuleInterop": true, + "noEmit": true, "allowJs": true, "noImplicitAny": false, "strictNullChecks": false, + "outDir": "../../dist", + "sourceMap": true, "typeRoots": ["../typings", "../node_modules/@types"], - "types": ["node", "webpack-env"] + "types": ["node", "jest" /* , "webpack-env" */], + "noUnusedLocals": true }, "include": ["."], - "exclude": ["./create-package/plop-templates*", "cypress.config.ts"] + "exclude": ["./cypress/**", "./cypress.js", "./cypress.config.ts"] } diff --git a/scripts/typescript/normalize-import.js b/scripts/typescript/normalize-import.js index 40f05324ad1c29..0cd5a0c1fd69af 100644 --- a/scripts/typescript/normalize-import.js +++ b/scripts/typescript/normalize-import.js @@ -1,7 +1,5 @@ // @ts-check -/// - const fs = require('fs'); const path = require('path'); const chalk = require('chalk'); @@ -84,7 +82,7 @@ function getAllFiles(dirPath, arrayOfFiles = []) { return filePath; }); - return allFiles.flat(Infinity); + return /** @type {string[]} */ (allFiles.flat(Infinity)); } /** diff --git a/scripts/typescript/normalize-import.spec.js b/scripts/typescript/normalize-import.spec.js index fbe32b799a0703..bc44796963d5a4 100644 --- a/scripts/typescript/normalize-import.spec.js +++ b/scripts/typescript/normalize-import.spec.js @@ -1,7 +1,5 @@ // @ts-check -/// - const { execSync } = require('child_process'); const fs = require('fs'); const path = require('path'); diff --git a/scripts/typescript/tsconfig.common.json b/scripts/typescript/tsconfig.common.json deleted file mode 100644 index f9b52eb357ad01..00000000000000 --- a/scripts/typescript/tsconfig.common.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "module": "esnext", - "moduleResolution": "node", - "lib": ["es2015", "dom"], - "jsx": "react", - "declaration": true, - "declarationMap": true, - "sourceMap": true, - "outDir": "lib", - "strict": true, - "noUnusedLocals": true, - "noImplicitAny": true, - "noImplicitThis": true, - "forceConsistentCasingInFileNames": true, - "esModuleInterop": true, - "skipDefaultLibCheck": true, - "skipLibCheck": true, - "types": ["node", "jest"] - } -} diff --git a/scripts/webpack/webpack.config.stats.ts b/scripts/webpack/webpack.config.stats.ts index 943b38f4f519ff..cca7e39792c117 100644 --- a/scripts/webpack/webpack.config.stats.ts +++ b/scripts/webpack/webpack.config.stats.ts @@ -1,4 +1,4 @@ -import CleanWebpackPlugin from 'clean-webpack-plugin'; +import { CleanWebpackPlugin } from 'clean-webpack-plugin'; import fs from 'fs'; import path from 'path'; import webpack from 'webpack'; @@ -64,10 +64,7 @@ const makeConfig = (srcPath: string, name: string): webpack.Configuration => ({ optimization: { minimizer: [ new TerserWebpackPlugin({ - cache: true, parallel: true, - sourceMap: false, - terserOptions: { mangle: false, output: { @@ -81,10 +78,7 @@ const makeConfig = (srcPath: string, name: string): webpack.Configuration => ({ }, }), plugins: [ - new CleanWebpackPlugin([paths.base('stats')], { - root: paths.base(), - verbose: false, // do not log - }), + new CleanWebpackPlugin(), new IgnoreNotFoundExportPlugin(), // new BundleAnalyzerPlugin({ // reportFilename: `${name}.html`, diff --git a/yarn.lock b/yarn.lock index fe968fcc9fe681..1c2ba969c43166 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4860,6 +4860,11 @@ mkdirp "^1.0.4" multimatch "^5.0.0" +"@tsconfig/node14@1.0.3": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.3.tgz#e4386316284f00b98435bf40f72f75a09dabf6c1" + integrity sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow== + "@types/argparse@1.0.38": version "1.0.38" resolved "https://registry.yarnpkg.com/@types/argparse/-/argparse-1.0.38.tgz#a81fd8606d481f873a3800c6ebae4f1d768a56a9" @@ -5925,7 +5930,7 @@ "@types/source-list-map" "*" source-map "^0.6.1" -"@types/webpack@*", "@types/webpack@^4", "@types/webpack@^4.4.31", "@types/webpack@^4.41.26", "@types/webpack@^4.41.8": +"@types/webpack@*", "@types/webpack@^4", "@types/webpack@^4.41.26", "@types/webpack@^4.41.8": version "4.41.30" resolved "https://registry.yarnpkg.com/@types/webpack/-/webpack-4.41.30.tgz#fd3db6d0d41e145a8eeeafcd3c4a7ccde9068ddc" integrity sha512-GUHyY+pfuQ6haAfzu4S14F+R5iGRwN6b2FRNJY7U0NilmFAqbsOfK6j1HwuLBAqwRIT+pVdNDJGJ6e8rpp0KHA== @@ -9007,12 +9012,11 @@ clean-stack@^2.0.0: resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b" integrity sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A== -clean-webpack-plugin@3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/clean-webpack-plugin/-/clean-webpack-plugin-3.0.0.tgz#a99d8ec34c1c628a4541567aa7b457446460c62b" - integrity sha512-MciirUH5r+cYLGCOL5JX/ZLzOZbVr1ot3Fw+KcvbhUb6PM+yycqd9ZhIlcigQ5gl+XhppNmw3bEFuaaMNyLj3A== +clean-webpack-plugin@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/clean-webpack-plugin/-/clean-webpack-plugin-4.0.0.tgz#72947d4403d452f38ed61a9ff0ada8122aacd729" + integrity sha512-WuWE1nyTNAyW5T7oNyys2EN0cfP2fdRxhxnIQWiAp0bMabPdHhoGxM8A6YL2GhqwgrPnnaemVE7nv5XJ2Fhh2w== dependencies: - "@types/webpack" "^4.4.31" del "^4.1.1" cli-boxes@^1.0.0: