npx eslint --fix src/**/*.ts
This commit is contained in:
+3
-4
@@ -1,5 +1,4 @@
|
|||||||
import {Changes} from './schemas'
|
import {Changes, Severity, SEVERITIES} from './schemas'
|
||||||
import {Severity, SEVERITIES} from './schemas'
|
|
||||||
|
|
||||||
export function filterChangesBySeverity(
|
export function filterChangesBySeverity(
|
||||||
severity: Severity,
|
severity: Severity,
|
||||||
@@ -7,7 +6,7 @@ export function filterChangesBySeverity(
|
|||||||
): Changes {
|
): Changes {
|
||||||
const severityIdx = SEVERITIES.indexOf(severity)
|
const severityIdx = SEVERITIES.indexOf(severity)
|
||||||
let filteredChanges = []
|
let filteredChanges = []
|
||||||
for (let change of changes) {
|
for (const change of changes) {
|
||||||
if (
|
if (
|
||||||
change === undefined ||
|
change === undefined ||
|
||||||
change.vulnerabilities === undefined ||
|
change.vulnerabilities === undefined ||
|
||||||
@@ -16,7 +15,7 @@ export function filterChangesBySeverity(
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
let fChange = {
|
const fChange = {
|
||||||
...change,
|
...change,
|
||||||
vulnerabilities: change.vulnerabilities.filter(vuln => {
|
vulnerabilities: change.vulnerabilities.filter(vuln => {
|
||||||
const vulnIdx = SEVERITIES.indexOf(vuln.severity)
|
const vulnIdx = SEVERITIES.indexOf(vuln.severity)
|
||||||
|
|||||||
+8
-8
@@ -13,19 +13,19 @@ import {Change, ChangeSchema} from './schemas'
|
|||||||
* @returns {[Array<Change>, Array<Change]} A tuple where the first element is the list of denied changes and the second one is the list of changes with unknown licenses
|
* @returns {[Array<Change>, Array<Change]} A tuple where the first element is the list of denied changes and the second one is the list of changes with unknown licenses
|
||||||
*/
|
*/
|
||||||
export function getDeniedLicenseChanges(
|
export function getDeniedLicenseChanges(
|
||||||
changes: Array<Change>,
|
changes: Change[],
|
||||||
licenses: {
|
licenses: {
|
||||||
allow?: Array<string>
|
allow?: string[]
|
||||||
deny?: Array<string>
|
deny?: string[]
|
||||||
}
|
}
|
||||||
): [Array<Change>, Array<Change>] {
|
): [Change[], Change[]] {
|
||||||
let {allow, deny} = licenses
|
const {allow, deny} = licenses
|
||||||
|
|
||||||
let disallowed: Change[] = []
|
const disallowed: Change[] = []
|
||||||
let unknown: Change[] = []
|
const unknown: Change[] = []
|
||||||
|
|
||||||
for (const change of changes) {
|
for (const change of changes) {
|
||||||
let license = change.license
|
const license = change.license
|
||||||
if (license === null) {
|
if (license === null) {
|
||||||
unknown.push(change)
|
unknown.push(change)
|
||||||
continue
|
continue
|
||||||
|
|||||||
+10
-10
@@ -27,16 +27,16 @@ async function run(): Promise<void> {
|
|||||||
headRef: pull_request.head.sha
|
headRef: pull_request.head.sha
|
||||||
})
|
})
|
||||||
|
|
||||||
let config = readConfig()
|
const config = readConfig()
|
||||||
let minSeverity = config.fail_on_severity
|
const minSeverity = config.fail_on_severity
|
||||||
let failed = false
|
let failed = false
|
||||||
|
|
||||||
let licenses = {
|
const licenses = {
|
||||||
allow: config.allow_licenses,
|
allow: config.allow_licenses,
|
||||||
deny: config.deny_licenses
|
deny: config.deny_licenses
|
||||||
}
|
}
|
||||||
|
|
||||||
let filteredChanges = filterChangesBySeverity(
|
const filteredChanges = filterChangesBySeverity(
|
||||||
minSeverity as Severity,
|
minSeverity as Severity,
|
||||||
changes
|
changes
|
||||||
)
|
)
|
||||||
@@ -52,7 +52,7 @@ async function run(): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let [licenseErrors, unknownLicenses] = getDeniedLicenseChanges(
|
const [licenseErrors, unknownLicenses] = getDeniedLicenseChanges(
|
||||||
changes,
|
changes,
|
||||||
licenses
|
licenses
|
||||||
)
|
)
|
||||||
@@ -118,17 +118,17 @@ function renderSeverity(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function printLicensesError(
|
function printLicensesError(
|
||||||
changes: Array<Change>,
|
changes: Change[],
|
||||||
licenses: {
|
licenses: {
|
||||||
allow?: Array<string>
|
allow?: string[]
|
||||||
deny?: Array<string>
|
deny?: string[]
|
||||||
}
|
}
|
||||||
): void {
|
): void {
|
||||||
if (changes.length == 0) {
|
if (changes.length == 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let {allow = [], deny = []} = licenses
|
const {allow = [], deny = []} = licenses
|
||||||
|
|
||||||
core.info('\nThe following dependencies have incompatible licenses:\n')
|
core.info('\nThe following dependencies have incompatible licenses:\n')
|
||||||
for (const change of changes) {
|
for (const change of changes) {
|
||||||
@@ -138,7 +138,7 @@ function printLicensesError(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function printNullLicenses(changes: Array<Change>): void {
|
function printNullLicenses(changes: Change[]): void {
|
||||||
if (changes.length === 0) {
|
if (changes.length === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user