Skip to content

Commit

Permalink
chore: 🤖 Use Biome
Browse files Browse the repository at this point in the history
  • Loading branch information
dc7290 committed Nov 12, 2024
1 parent 701ffb8 commit 6f3f60b
Show file tree
Hide file tree
Showing 49 changed files with 352 additions and 1,178 deletions.
36 changes: 0 additions & 36 deletions .editorconfig

This file was deleted.

28 changes: 0 additions & 28 deletions .eslintignore

This file was deleted.

54 changes: 0 additions & 54 deletions .eslintrc.js

This file was deleted.

2 changes: 0 additions & 2 deletions .prettierignore

This file was deleted.

7 changes: 0 additions & 7 deletions .prettierrc.js

This file was deleted.

17 changes: 17 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"quickfix.biome": "explicit",
"source.organizeImports.biome": "explicit"
},
"editor.defaultFormatter": "biomejs.biome",
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[json]": {
"editor.defaultFormatter": "biomejs.biome"
}
}
14 changes: 10 additions & 4 deletions __tests__/cli/cache/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'path'
import path from 'node:path'

import fs from 'fs-extra'

Expand Down Expand Up @@ -43,9 +43,15 @@ describe('Cache', () => {
let measuredError = 0

const destDir = path.resolve(__dirname, 'results')
const cacheMeasurement = () => (measuredCache += 1)
const nonCacheMeasurement = () => (measuredNonCache += 1)
const errorMeasurement = () => (measuredError += 1)
const cacheMeasurement = () => {
measuredCache += 1
}
const nonCacheMeasurement = () => {
measuredNonCache += 1
}
const errorMeasurement = () => {
measuredError += 1
}
const cliProgressBarIncrement = () => undefined
const srcDir = path.resolve(__dirname, 'fixtures')

Expand Down
29 changes: 16 additions & 13 deletions __tests__/cli/external-images/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'path'
import path from 'node:path'

import fs from 'fs-extra'
import { imageConfigDefault } from 'next/dist/shared/lib/image-config'
Expand All @@ -7,18 +7,21 @@ import { optimizeImages } from '../../../src/cli'

const fixturesDir = path.resolve(__dirname, 'fixtures')

beforeAll(async () => {
await fs.remove(fixturesDir)
await optimizeImages({
manifestJsonPath: path.resolve(__dirname, 'manifest.json'),
noCache: true,
terse: true,
config: {
outDir: '__tests__/cli/external-images/fixtures',
},
nextImageConfig: imageConfigDefault,
})
}, 60 * 3 * 1000)
beforeAll(
async () => {
await fs.remove(fixturesDir)
await optimizeImages({
manifestJsonPath: path.resolve(__dirname, 'manifest.json'),
noCache: true,
terse: true,
config: {
outDir: '__tests__/cli/external-images/fixtures',
},
nextImageConfig: imageConfigDefault,
})
},
60 * 3 * 1000
)

const exist = (filename: string) => fs.existsSync(path.join(fixturesDir, '_next/static/media', filename))

Expand Down
27 changes: 15 additions & 12 deletions __tests__/cli/image-optimize/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import path from 'path'
import path from 'node:path'

import fs from 'fs-extra'
import { imageConfigDefault } from 'next/dist/shared/lib/image-config'

import { optimizeImages } from '../../../src/cli'

beforeAll(async () => {
await optimizeImages({
manifestJsonPath: path.resolve(__dirname, 'manifest.json'),
noCache: true,
terse: true,
config: {
outDir: '__tests__/cli/image-optimize/fixtures',
},
nextImageConfig: imageConfigDefault,
})
}, 60 * 3 * 1000)
beforeAll(
async () => {
await optimizeImages({
manifestJsonPath: path.resolve(__dirname, 'manifest.json'),
noCache: true,
terse: true,
config: {
outDir: '__tests__/cli/image-optimize/fixtures',
},
nextImageConfig: imageConfigDefault,
})
},
60 * 3 * 1000
)

const exist = (filename: string) => fs.existsSync(path.resolve(__dirname, 'fixtures/results/images', filename))

Expand Down
11 changes: 5 additions & 6 deletions __tests__/e2e-build/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'path'
import path from 'node:path'

import fs from 'fs-extra'
import { imageConfigDefault } from 'next/dist/shared/lib/image-config'
Expand All @@ -23,18 +23,17 @@ const files = [

describe('`next build && next export && next-export-optimize-images` is executed correctly', () => {
test('Images are being generated.', async () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const customConfig = require('./next.config.js')
const configImages = { ...imageConfigDefault, ...customConfig.images }
const allSizes = [...configImages.imageSizes, ...configImages.deviceSizes]
allSizes.forEach((size) => {
files.forEach((file) => {
for (const size of allSizes) {
for (const file of files) {
const isExist = exist(file.replace('[width]', size.toString()))
if (!isExist) {
console.log(file.replace('[width]', size.toString()))
}
expect(isExist).toBeTruthy()
})
})
}
}
})
})
2 changes: 2 additions & 0 deletions __tests__/e2e/export-images.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const config = {
generateFormats: ['avif', 'webp'],
remoteImages: getRemoteImages,
filenameGenerator: ({ path, name, width, extension }) => `${path}/${name}_${width}.${extension}`,
// function宣言による記述もテストしたいため無視する
// biome-ignore lint/complexity/useArrowFunction: <explanation>
sourceImageParser: function ({ src, defaultParser }) {
return defaultParser(src)
},
Expand Down
11 changes: 5 additions & 6 deletions __tests__/e2e/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'path'
import path from 'node:path'

import fs from 'fs-extra'
import { imageConfigDefault } from 'next/dist/shared/lib/image-config'
Expand Down Expand Up @@ -58,18 +58,17 @@ const files = [

describe('`next build && next export && next-export-optimize-images` is executed correctly', () => {
test('Images are being generated.', async () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const customConfig = require('./next.config.js')
const configImages = { ...imageConfigDefault, ...customConfig.images }
const allSizes = [...configImages.imageSizes, ...configImages.deviceSizes]
allSizes.forEach((size) => {
files.forEach((file) => {
for (const size of allSizes) {
for (const file of files) {
const isExist = exist(file.replace('[width]', size.toString()))
if (!isExist) {
console.log(file.replace('[width]', size.toString()))
}
expect(isExist).toBeTruthy()
})
})
}
}
})
})
8 changes: 4 additions & 4 deletions __tests__/utils/buildOutputInfo/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import buildOutputInfo from '../../../src/utils/buildOutputInfo'
import { Config } from '../../../src/utils/getConfig'
import type { Config } from '../../../src/utils/getConfig'

describe('buildOutputInfo', () => {
test('Default image parser functions properly', () => {
Expand Down Expand Up @@ -230,7 +230,7 @@ describe('buildOutputInfo', () => {
}

expect(() => buildOutputInfo(input)).toThrowError(
new Error(`Unauthorized format specified in \`configFormat\`. afterConvert: invalid_format`)
new Error('Unauthorized format specified in `configFormat`. afterConvert: invalid_format')
)
})

Expand All @@ -243,8 +243,8 @@ describe('buildOutputInfo', () => {
} as unknown as Config,
}

expect(() => buildOutputInfo(input)).toThrowError(
new Error(`Unauthorized extension specified in \`generateFormats\`: invalid_format`)
expect(() => buildOutputInfo(input)).toThrow(
new Error('Unauthorized extension specified in `generateFormats`: invalid_format')
)
})

Expand Down
Binary file removed bench/fixtures/default.avif
Binary file not shown.
Binary file removed bench/fixtures/default.jpeg
Binary file not shown.
Binary file removed bench/fixtures/default.jpg
Binary file not shown.
Binary file removed bench/fixtures/default.png
Binary file not shown.
Binary file removed bench/fixtures/default.webp
Binary file not shown.
43 changes: 0 additions & 43 deletions bench/index.ts

This file was deleted.

9 changes: 0 additions & 9 deletions bench/manifest.json

This file was deleted.

Loading

0 comments on commit 6f3f60b

Please sign in to comment.