From 6e9189a5c13cc8e176c4040fbaf88e217d254794 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Mon, 4 Jul 2022 20:05:43 +0900 Subject: [PATCH] `npx eslint --fix src/**/*.ts` --- src/filter.ts | 7 +++---- src/licenses.ts | 16 ++++++++-------- src/main.ts | 20 ++++++++++---------- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/filter.ts b/src/filter.ts index 3640790..69d1929 100644 --- a/src/filter.ts +++ b/src/filter.ts @@ -1,5 +1,4 @@ -import {Changes} from './schemas' -import {Severity, SEVERITIES} from './schemas' +import {Changes, Severity, SEVERITIES} from './schemas' export function filterChangesBySeverity( severity: Severity, @@ -7,7 +6,7 @@ export function filterChangesBySeverity( ): Changes { const severityIdx = SEVERITIES.indexOf(severity) let filteredChanges = [] - for (let change of changes) { + for (const change of changes) { if ( change === undefined || change.vulnerabilities === undefined || @@ -16,7 +15,7 @@ export function filterChangesBySeverity( continue } - let fChange = { + const fChange = { ...change, vulnerabilities: change.vulnerabilities.filter(vuln => { const vulnIdx = SEVERITIES.indexOf(vuln.severity) diff --git a/src/licenses.ts b/src/licenses.ts index 4e0a6b3..8f57531 100644 --- a/src/licenses.ts +++ b/src/licenses.ts @@ -13,19 +13,19 @@ import {Change, ChangeSchema} from './schemas' * @returns {[Array, Array, + changes: Change[], licenses: { - allow?: Array - deny?: Array + allow?: string[] + deny?: string[] } -): [Array, Array] { - let {allow, deny} = licenses +): [Change[], Change[]] { + const {allow, deny} = licenses - let disallowed: Change[] = [] - let unknown: Change[] = [] + const disallowed: Change[] = [] + const unknown: Change[] = [] for (const change of changes) { - let license = change.license + const license = change.license if (license === null) { unknown.push(change) continue diff --git a/src/main.ts b/src/main.ts index cad4fb8..fde9707 100644 --- a/src/main.ts +++ b/src/main.ts @@ -27,16 +27,16 @@ async function run(): Promise { headRef: pull_request.head.sha }) - let config = readConfig() - let minSeverity = config.fail_on_severity + const config = readConfig() + const minSeverity = config.fail_on_severity let failed = false - let licenses = { + const licenses = { allow: config.allow_licenses, deny: config.deny_licenses } - let filteredChanges = filterChangesBySeverity( + const filteredChanges = filterChangesBySeverity( minSeverity as Severity, changes ) @@ -52,7 +52,7 @@ async function run(): Promise { } } - let [licenseErrors, unknownLicenses] = getDeniedLicenseChanges( + const [licenseErrors, unknownLicenses] = getDeniedLicenseChanges( changes, licenses ) @@ -118,17 +118,17 @@ function renderSeverity( } function printLicensesError( - changes: Array, + changes: Change[], licenses: { - allow?: Array - deny?: Array + allow?: string[] + deny?: string[] } ): void { if (changes.length == 0) { return } - let {allow = [], deny = []} = licenses + const {allow = [], deny = []} = licenses core.info('\nThe following dependencies have incompatible licenses:\n') for (const change of changes) { @@ -138,7 +138,7 @@ function printLicensesError( } } -function printNullLicenses(changes: Array): void { +function printNullLicenses(changes: Change[]): void { if (changes.length === 0) { return }