chore: Exclude @types namespace from ClearlyDefined check (#7046)
#### Details We frequently get dependabot PR's for the `@types` namespace, which are always devDependencies. To streamline maintenance, this PR automatically excludes these packages from the ClearlyDefined check. It also updates the validation script and removes the packages in the `@types` namespace that we've collected so far. It also includes 2 analyzer-suggested changes of moving `$null` from the RHS to the LHS of the comparison to prevent accidentally setting the value instead of comparing it. ##### Motivation Streamline dependabot handling ##### Context <!-- Are there any parts that you've intentionally left out-of-scope for a later PR to handle? --> <!-- Were there any alternative approaches you considered? What tradeoffs did you consider? --> #### Pull request checklist <!-- If a checklist item is not applicable to this change, write "n/a" in the checkbox --> - [n/a] Addresses an existing issue: #0000 - [x] Ran `yarn fastpass` - [n/a] Added/updated relevant unit test(s) (and ran `yarn test`) - [n/a] Verified code coverage for the changes made. Check coverage report at: `<rootDir>/test-results/unit/coverage` - [x] PR title *AND* final merge commit title both start with a semantic tag (`fix:`, `chore:`, `feat(feature-name):`, `refactor:`). See `CONTRIBUTING.md`. - [n/a] (UI changes only) Added screenshots/GIFs to description above - [n/a] (UI changes only) Verified usability with NVDA/JAWS
This commit is contained in:
Родитель
2d9fff44d5
Коммит
e2d722f352
|
@ -71,6 +71,15 @@ if errorlevel 1 goto fail
|
|||
echo OK
|
||||
echo.
|
||||
|
||||
@echo Passing case: local PR build of dependabot branch with @types namespace
|
||||
set BUILD_SOURCEBRANCH=
|
||||
set GITHUB_HEAD_REF=
|
||||
echo pwsh -f ./check-clearly-defined.ps1 -PipelineType local -BranchName dependabot/npm_and_yarn/types/jest-1.10000.1
|
||||
pwsh -f ./check-clearly-defined.ps1 -PipelineType local -BranchName dependabot/npm_and_yarn/types/jest-1.10000.1
|
||||
if errorlevel 1 goto fail
|
||||
echo OK
|
||||
echo.
|
||||
|
||||
@echo Failing case: Package that does not exist in ClearlyDefined
|
||||
echo pwsh -f ./check-clearly-defined.ps1 -PipelineType local -BranchName dependabot/nuget/src/Axe.Windows-2.99.99
|
||||
pwsh -f ./check-clearly-defined.ps1 -PipelineType local -BranchName dependabot/nuget/src/Axe.Windows-2.99.99
|
||||
|
|
|
@ -66,7 +66,7 @@ function GetBranchName([string]$pipelineType, [string]$branchName) {
|
|||
}
|
||||
"ado" {
|
||||
$prBranchName = $Env:SYSTEM_PULLREQUEST_SOURCEBRANCH
|
||||
if ($prBranchName -eq $null) {
|
||||
if ($null -eq $prBranchName) {
|
||||
$trimmedBranchName = ($Env:BUILD_SOURCEBRANCH).Trim().Replace("refs/heads/","")
|
||||
} else {
|
||||
$trimmedBranchName = $prBranchName.Trim()
|
||||
|
@ -105,7 +105,7 @@ function IsPackageExcluded([string]$namespaceAndPackage) {
|
|||
# licensing purposes, can be added to clearly-defined-exclusions.json
|
||||
$exclusionFile = Join-Path $PSScriptRoot "clearly-defined-exclusions.json"
|
||||
$exclusions = Get-Content -Path $exclusionFile | ConvertFrom-Json
|
||||
return $exclusions -ne $null -and $exclusions.Contains($namespaceAndPackage)
|
||||
return $null -ne $exclusions -and $exclusions.Contains($namespaceAndPackage)
|
||||
}
|
||||
|
||||
function IsGithubActionsType([string]$namespace){
|
||||
|
@ -128,6 +128,10 @@ function AdjustNamespace([string]$provider, [string]$rawNamespace) {
|
|||
return $rawNamespace
|
||||
}
|
||||
|
||||
function IsTypesNamespace([string]$nameSpace){
|
||||
return $nameSpace -eq "@types"
|
||||
}
|
||||
|
||||
function GetUri([string]$branchName){
|
||||
$elements = $branchName.Split('/')
|
||||
|
||||
|
@ -150,7 +154,13 @@ function GetUri([string]$branchName){
|
|||
$rawNamespace = $elements[2]
|
||||
$fullPackage = $elements[3]
|
||||
}
|
||||
|
||||
$nameSpace = AdjustNamespace $provider $rawNamespace
|
||||
if (IsTypesNamespace $nameSpace) {
|
||||
Write-Host "Namespace is @types, skipping check"
|
||||
Exit 0
|
||||
}
|
||||
|
||||
$indexOfLastDash = $fullPackage.LastIndexOf('-') + 1
|
||||
$packageName = $fullPackage.Substring(0, $indexOfLastDash - 1)
|
||||
$packageVersion = $fullPackage.Substring($indexOfLastDash)
|
||||
|
|
|
@ -1,16 +1,5 @@
|
|||
[
|
||||
"@swc/core",
|
||||
"@types/chrome",
|
||||
"@types/enzyme",
|
||||
"@types/enzyme-adapter-react-16",
|
||||
"@types/jest",
|
||||
"@types/jsdom",
|
||||
"@types/luxon",
|
||||
"@types/react-helmet",
|
||||
"@types/serve-static",
|
||||
"@types/ua-parser-js",
|
||||
"@types/uuid",
|
||||
"@types/webextension-polyfill",
|
||||
"@typescript-eslint/parser",
|
||||
"-/core-js-bundle",
|
||||
"-/esbuild",
|
||||
|
|
Загрузка…
Ссылка в новой задаче