Skip to content

Commit b2292ef

Browse files
author
Christoph Werner
committed
chore: update and apply prettier
1 parent a4d8df4 commit b2292ef

20 files changed

+105
-81
lines changed

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"allowParens": "always",
2+
"arrowParens": "always",
33
"singleQuote": true,
44
"trailingComma": "es5",
55
"parser": "typescript",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"jest-watch-typeahead": "^2.2.2",
7272
"lint-staged": "^12.3.5",
7373
"memory-fs": "^0.5.0",
74-
"prettier": "^2.1.1",
74+
"prettier": "^3.0.3",
7575
"ts-jest": "^29.1.1",
7676
"ts-loader": "^9.4.4",
7777
"tslint": "^5.11.0",

src/LicenseFileWriter.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ export default class LicenseFileWriter {
1616
options: IPluginOptions
1717
): Promise<void> {
1818
const moduleDirs = this.getModuleDirs(filenames)
19-
const includePackages = await options.includePackages();
20-
const licenseMeta = await this.licenseMetaAggregator.aggregateMeta(
21-
[...new Set([...moduleDirs, ...includePackages])]
22-
)
19+
const includePackages = await options.includePackages()
20+
const licenseMeta = await this.licenseMetaAggregator.aggregateMeta([
21+
...new Set([...moduleDirs, ...includePackages]),
22+
])
2323

2424
const fileContents = JSON.stringify(licenseMeta, null, 2)
2525
this.assetManager.addFile(options.outputFilename, fileContents)
@@ -33,7 +33,7 @@ export default class LicenseFileWriter {
3333
public getModuleDirs(filenames: string[]): string[] {
3434
return uniq(
3535
compact(
36-
filenames.map(filename => {
36+
filenames.map((filename) => {
3737
return this.moduleDirectoryLocator.getModuleDir(filename)
3838
})
3939
)

src/LicenseIdentifier.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default class LicenseIdentifier {
3636
} else if (Array.isArray(meta.licenses) && meta.licenses.length > 0) {
3737
// handle deprecated `licenses` field
3838
license =
39-
this.findPreferredLicense(meta.licenses.map(l => l.type)) ||
39+
this.findPreferredLicense(meta.licenses.map((l) => l.type)) ||
4040
meta.licenses[0].type
4141
} else if (typeof meta.licenses === 'string') {
4242
// handle invalid string values for deprecated `licenses` field

src/WebpackModuleFileIterator.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import IWebpackChunkModule from './types/IWebpackChunkModule'
22

33
export default class WebpackModuleFileIterator {
44
public iterateFiles(
5-
{resource, rootModule, fileDependencies, dependencies}: IWebpackChunkModule,
5+
{
6+
resource,
7+
rootModule,
8+
fileDependencies,
9+
dependencies,
10+
}: IWebpackChunkModule,
611
callback: (filename: string) => void
712
): void {
813
if (resource) {
@@ -12,11 +17,11 @@ export default class WebpackModuleFileIterator {
1217
}
1318

1419
if (fileDependencies) {
15-
fileDependencies.forEach(dep => callback(dep))
20+
fileDependencies.forEach((dep) => callback(dep))
1621
}
1722

1823
if (dependencies) {
19-
dependencies.forEach(({originModule, _parentModule}) => {
24+
dependencies.forEach(({ originModule, _parentModule }) => {
2025
if (originModule?.resource) {
2126
callback(originModule.resource)
2227
}

src/defaultOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const defaultOptions: IPluginOptions = {
77
replenishDefaultLicenseTexts: false,
88
unacceptableLicenseTest: () => false,
99
excludedPackageTest: () => false,
10-
includePackages: () => []
10+
includePackages: () => [],
1111
}
1212

1313
export default defaultOptions

test/e2e/example/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import ReactDOM from 'react-dom'
3-
import {format} from 'date-fns'
3+
import { format } from 'date-fns'
44

55
ReactDOM.render(
66
React.createElement('h1', {}, ['Hello world']),

test/unit/DefaultLicenseTextProvider.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ describe('fetch', () => {
3939
const okResult = await fetch(okUrl)
4040
const notFoundResult = await fetch(notFoundUrl)
4141

42-
expect(needle.mock.calls).toEqual([['get', okUrl], ['get', notFoundUrl]])
42+
expect(needle.mock.calls).toEqual([
43+
['get', okUrl],
44+
['get', notFoundUrl],
45+
])
4346
expect(notFoundResult).toBe(null)
4447
expect(okResult).toBe('body content')
4548
})

test/unit/LicenseFileWriter.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import IModuleDirectoryLocator from '../../src/types/IModuleDirectoryLocator'
77
const AssetManager = jest.fn<IAssetManager, any[]>(() => ({
88
addFile: jest.fn(),
99
}))
10-
const DirectoryLocator = jest.fn<IModuleDirectoryLocator, any[]>(impl => ({
10+
const DirectoryLocator = jest.fn<IModuleDirectoryLocator, any[]>((impl) => ({
1111
getModuleDir: jest.fn(impl),
1212
}))
13-
const MetaAggregator = jest.fn<ILicenseMetaAggregator, any[]>(impl => ({
13+
const MetaAggregator = jest.fn<ILicenseMetaAggregator, any[]>((impl) => ({
1414
aggregateMeta: jest.fn(impl),
1515
}))
1616

@@ -19,7 +19,7 @@ describe('LicenseFileWriter', () => {
1919
test('returns module dirs', () => {
2020
const instance = new LicenseFileWriter(
2121
new AssetManager(),
22-
new DirectoryLocator(d => `dir-${d}`),
22+
new DirectoryLocator((d) => `dir-${d}`),
2323
new MetaAggregator(() => undefined)
2424
)
2525

@@ -29,7 +29,7 @@ describe('LicenseFileWriter', () => {
2929
test('only returns unique module dirs', () => {
3030
const instance = new LicenseFileWriter(
3131
new AssetManager(),
32-
new DirectoryLocator(d => `dir-${d}`),
32+
new DirectoryLocator((d) => `dir-${d}`),
3333
new MetaAggregator(() => undefined)
3434
)
3535

@@ -41,7 +41,7 @@ describe('LicenseFileWriter', () => {
4141
test('returns module dirs without null values', () => {
4242
const instance = new LicenseFileWriter(
4343
new AssetManager(),
44-
new DirectoryLocator(d => (d === 'a.js' ? 'module' : null)),
44+
new DirectoryLocator((d) => (d === 'a.js' ? 'module' : null)),
4545
new MetaAggregator(() => undefined)
4646
)
4747

@@ -54,7 +54,7 @@ describe('LicenseFileWriter', () => {
5454
const assetManager = new AssetManager()
5555
const instance = new LicenseFileWriter(
5656
assetManager,
57-
new DirectoryLocator(d => `dir-${d}`),
57+
new DirectoryLocator((d) => `dir-${d}`),
5858
new MetaAggregator(() => ({ foo: 'bar' }))
5959
)
6060

@@ -71,7 +71,7 @@ describe('LicenseFileWriter', () => {
7171
const assetManager = new AssetManager()
7272
const instance = new LicenseFileWriter(
7373
assetManager,
74-
new DirectoryLocator(d => `dir-${d}`),
74+
new DirectoryLocator((d) => `dir-${d}`),
7575
new MetaAggregator(() => ({ foo: 'bar' }))
7676
)
7777

@@ -91,16 +91,16 @@ describe('LicenseFileWriter', () => {
9191
const assetManager = new AssetManager()
9292
const instance = new LicenseFileWriter(
9393
assetManager,
94-
new DirectoryLocator(d => `dir-${d}`),
94+
new DirectoryLocator((d) => `dir-${d}`),
9595
new MetaAggregator(() => ({ foo: 'bar' }))
9696
)
9797

9898
await instance.writeLicenseFiles([], {
9999
...defaultOptions,
100100
additionalFiles: {
101-
'bom.json': o => `bom${JSON.stringify(o)}`,
102-
'bom_async.json': async o => `bom_async${JSON.stringify(o)}`,
103-
'bom_promise.json': o =>
101+
'bom.json': (o) => `bom${JSON.stringify(o)}`,
102+
'bom_async.json': async (o) => `bom_async${JSON.stringify(o)}`,
103+
'bom_promise.json': (o) =>
104104
Promise.resolve(`bom_promise${JSON.stringify(o)}`),
105105
},
106106
})

test/unit/LicenseIdentifier.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import LicenseIdentifier from '../../src/LicenseIdentifier'
22
import IAlertAggregator from '../../src/types/IAlertAggregator'
33

4-
const MockAlertAggregator = jest.fn<IAlertAggregator, any[]>(i => i)
4+
const MockAlertAggregator = jest.fn<IAlertAggregator, any[]>((i) => i)
55

66
describe('LicenseIdentifier', () => {
77
describe('identifyLicense', () => {

0 commit comments

Comments
 (0)