npx eslint --fix src/**/*.ts

This commit is contained in:
Kenichi Kamiya
2022-07-04 20:12:07 +09:00
parent c6f347d470
commit 6e9189a5c1
3 changed files with 21 additions and 22 deletions
+3 -4
View File
@@ -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)
+8 -8
View File
@@ -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
*/
export function getDeniedLicenseChanges(
changes: Array<Change>,
changes: Change[],
licenses: {
allow?: Array<string>
deny?: Array<string>
allow?: string[]
deny?: string[]
}
): [Array<Change>, Array<Change>] {
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
+10 -10
View File
@@ -27,16 +27,16 @@ async function run(): Promise<void> {
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<void> {
}
}
let [licenseErrors, unknownLicenses] = getDeniedLicenseChanges(
const [licenseErrors, unknownLicenses] = getDeniedLicenseChanges(
changes,
licenses
)
@@ -118,17 +118,17 @@ function renderSeverity(
}
function printLicensesError(
changes: Array<Change>,
changes: Change[],
licenses: {
allow?: Array<string>
deny?: Array<string>
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<Change>): void {
function printNullLicenses(changes: Change[]): void {
if (changes.length === 0) {
return
}