From 2963d1c0fd3cb643860e9b4745563c9ff71a212e Mon Sep 17 00:00:00 2001 From: Justin Goping Date: Thu, 27 Jan 2022 17:29:49 +0000 Subject: [PATCH] Integrate tsec into the linting process --- package.json | 1 + packages/next/package.json | 2 +- packages/next/tsconfig.json | 1 + packages/react-dev-overlay/package.json | 3 ++- packages/react-dev-overlay/tsconfig.json | 1 + tsconfig-tsec.json | 10 ++++++++++ tsec-exemptions.json | 17 +++++++++++++++++ yarn.lock | 10 +++++++++- 8 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 tsconfig-tsec.json create mode 100644 tsec-exemptions.json diff --git a/package.json b/package.json index 5604072cf361425..162cce7f1e6c4df 100644 --- a/package.json +++ b/package.json @@ -163,6 +163,7 @@ "tailwindcss": "1.1.3", "taskr": "1.1.0", "tree-kill": "1.2.2", + "tsec": "0.2.1", "turbo": "1.0.28", "typescript": "4.4.3", "wait-port": "0.2.2", diff --git a/packages/next/package.json b/packages/next/package.json index b392a740308b23c..03e561cb839c523 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -59,7 +59,7 @@ "release": "taskr release", "prepublish": "npm run release && yarn types", "types": "tsc --declaration --emitDeclarationOnly --declarationDir dist", - "typescript": "tsc --noEmit --declaration", + "typescript": "tsec --noEmit", "ncc-compiled": "ncc cache clean && taskr ncc" }, "taskr": { diff --git a/packages/next/tsconfig.json b/packages/next/tsconfig.json index ddcf7c62d2f93c7..6c68334b466a75a 100644 --- a/packages/next/tsconfig.json +++ b/packages/next/tsconfig.json @@ -1,4 +1,5 @@ { + "extends": "../../tsconfig-tsec.json", "compilerOptions": { "strict": true, "module": "esnext", diff --git a/packages/react-dev-overlay/package.json b/packages/react-dev-overlay/package.json index 439e2dad4ad857b..de9b35c3a6510a7 100644 --- a/packages/react-dev-overlay/package.json +++ b/packages/react-dev-overlay/package.json @@ -13,7 +13,8 @@ "license": "MIT", "scripts": { "prepublish": "tsc -d -p tsconfig.json", - "dev": "tsc -d -w -p tsconfig.json" + "dev": "tsc -d -w -p tsconfig.json", + "typescript": "tsec --noEmit -p tsconfig.json" }, "dependencies": { "@babel/code-frame": "7.12.11", diff --git a/packages/react-dev-overlay/tsconfig.json b/packages/react-dev-overlay/tsconfig.json index 747a7eb4f1dae0a..0ce7a1556aba1c6 100644 --- a/packages/react-dev-overlay/tsconfig.json +++ b/packages/react-dev-overlay/tsconfig.json @@ -1,4 +1,5 @@ { + "extends": "../../tsconfig-tsec.json", "compilerOptions": { "sourceMap": true, "strict": true, diff --git a/tsconfig-tsec.json b/tsconfig-tsec.json new file mode 100644 index 000000000000000..cd95c7b3c23be55 --- /dev/null +++ b/tsconfig-tsec.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "plugins": [ + { + "name": "tsec", + "exemptionConfig": "./tsec-exemptions.json" + } + ] + } +} diff --git a/tsec-exemptions.json b/tsec-exemptions.json new file mode 100644 index 000000000000000..1ac58ca99a65720 --- /dev/null +++ b/tsec-exemptions.json @@ -0,0 +1,17 @@ +{ + "ban-element-innerhtml-assignments": [ + "packages/next/client/head-manager.ts", + "packages/next/client/script.tsx", + "packages/react-dev-overlay/src/internal/components/Overlay/maintain--tab-focus.ts" + ], + "ban-element-setattribute": [ + "packages/next/client/head-manager.ts", + "packages/next/client/script.tsx" + ], + "ban-script-content-assignments": ["packages/next/client/script.tsx"], + "ban-script-src-assignments": [ + "packages/next/client/route-loader.ts", + "packages/next/client/script.tsx" + ], + "ban-window-stringfunctiondef": ["packages/next/lib/recursive-delete.ts"] +} diff --git a/yarn.lock b/yarn.lock index f557f48cfb93824..bf811a4e30aebb2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14258,7 +14258,7 @@ minimalistic-crypto-utils@^1.0.0, minimalistic-crypto-utils@^1.0.1: resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" integrity sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo= -minimatch@3.0.4, minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.4, minimatch@~3.0.2: +minimatch@3.0.4, minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4, minimatch@~3.0.2: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== @@ -19792,6 +19792,14 @@ tsconfig-paths@^3.9.0: minimist "^1.2.0" strip-bom "^3.0.0" +tsec@0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/tsec/-/tsec-0.2.1.tgz#017423174b2be54f26da5cb7591dc7035996086b" + integrity sha512-RP9vhbRbRI9VH4CfOlQvo5W9HdfiPKq0gdiUOWI5oKmLaZKNFN8CsPwBfT5ySmhnKNwmmAS/BtY3WoTfABwwig== + dependencies: + glob "^7.1.1" + minimatch "^3.0.3" + tslib@1.11.1, tslib@^1.8.1, tslib@^1.9.0: version "1.11.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.11.1.tgz#eb15d128827fbee2841549e171f45ed338ac7e35"