Skip to content

Commit

Permalink
fix(prettier): use prettier v3
Browse files Browse the repository at this point in the history
BREAKING CHANGE: prettier v3
  • Loading branch information
antongolub committed Oct 10, 2024
1 parent c7c66ff commit 07b9fe4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 41 deletions.
2 changes: 1 addition & 1 deletion packages/infra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"eslint": "^8.39.0",
"eslint-plugin-disable": "^2.0.3",
"jest": "^29.7.0",
"prettier": "^2.8.8",
"prettier": "^3.3.3",
"typedoc": "^0.26.8",
"typescript": "^5.6.3"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/prettier-config-qiwi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
"@trivago/prettier-plugin-sort-imports": "^4.3.0"
},
"peerDependencies": {
"prettier": "^2.0.0",
"prettier": "^3.0.0",
"typescript": "^5.0.0"
},
"devDependencies": {
"@qiwi/lint-config-infra": "2.1.1",
"@swissquote/crafty-preset-jest": "^1.27.0",
"jest": "^29.7.0",
"prettier": "^2.8.8",
"prettier": "^3.3.3",
"stdstream-snapshot": "^1.2.9",
"ts-jest": "^29.2.5",
"typescript": "^5.6.3"
Expand Down
49 changes: 19 additions & 30 deletions packages/prettier-config-qiwi/src/test/ts/index.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,33 @@
import { execSync } from 'node:child_process'
import {
copyFileSync,
existsSync,
mkdirSync,
readFileSync,
rmdirSync,
} from 'node:fs'
import { resolve } from 'node:path'

import * as cp from 'node:child_process'
import * as fs from 'node:fs'
import * as os from 'node:os'
import * as path from 'node:path'
import * as prettierConfig from '../../main/js'

describe('', () => {
const tmpDir = resolve(__dirname, '../../../../../tmp')
const root = path.resolve(__dirname, '../../../../../')
const bin = path.resolve(root, 'node_modules/.bin/prettier')
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'tempy-'))

describe('prettier', () => {
beforeAll(() => {
if (existsSync(tmpDir)) {
rmdirSync(tmpDir, { recursive: true })
if (fs.existsSync(tmpDir)) {
fs.rmSync(tmpDir, { recursive: true })
}
mkdirSync(tmpDir)
fs.mkdirSync(tmpDir)
})

it('prettierConfig', () => {
expect(prettierConfig).toBeDefined()
})

it('formats as expected', async () => {
const configPath = resolve(__dirname, '../../main/js/index.js')

const prettier = resolve(
__dirname,
'../../../../../node_modules/.bin/prettier',
)
const input = resolve(__dirname, '../fixtures/input.ts')
const output = resolve(__dirname, '../fixtures/output.ts')
const temp = resolve(tmpDir, 'index.ts')

copyFileSync(input, temp)

execSync(`${prettier} --config ${configPath} --write ${temp}`)

expect(readFileSync(temp, 'utf-8')).toBe(readFileSync(output, 'utf-8'))
const configPath = path.resolve(__dirname, '../../main/js/index.js')
const input = path.resolve(__dirname, '../fixtures/input.ts')
const output = path.resolve(__dirname, '../fixtures/output.ts')
const index = path.resolve(tmpDir, 'index.ts')

fs.copyFileSync(input, index)
cp.execSync(`${bin} ${tmpDir} --config ${configPath} --write`)

Check warning

Code scanning / CodeQL

Shell command built from environment values Medium test

This shell command depends on an uncontrolled
absolute path
.
This shell command depends on an uncontrolled
absolute path
.
This shell command depends on an uncontrolled
absolute path
.
expect(fs.readFileSync(index, 'utf-8')).toBe(fs.readFileSync(output, 'utf-8'))
})
})
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2040,7 +2040,7 @@ __metadata:
eslint: "npm:^8.39.0"
eslint-plugin-disable: "npm:^2.0.3"
jest: "npm:^29.7.0"
prettier: "npm:^2.8.8"
prettier: "npm:^3.3.3"
typedoc: "npm:^0.26.8"
typescript: "npm:^5.6.3"
bin:
Expand Down Expand Up @@ -6999,22 +6999,22 @@ __metadata:
"@swissquote/crafty-preset-jest": "npm:^1.27.0"
"@trivago/prettier-plugin-sort-imports": "npm:^4.3.0"
jest: "npm:^29.7.0"
prettier: "npm:^2.8.8"
prettier: "npm:^3.3.3"
stdstream-snapshot: "npm:^1.2.9"
ts-jest: "npm:^29.2.5"
typescript: "npm:^5.6.3"
peerDependencies:
prettier: ^2.0.0
prettier: ^3.0.0
typescript: ^5.0.0
languageName: unknown
linkType: soft

"prettier@npm:^2.8.8":
version: 2.8.8
resolution: "prettier@npm:2.8.8"
"prettier@npm:^3.3.3":
version: 3.3.3
resolution: "prettier@npm:3.3.3"
bin:
prettier: bin-prettier.js
checksum: 10/00cdb6ab0281f98306cd1847425c24cbaaa48a5ff03633945ab4c701901b8e96ad558eb0777364ffc312f437af9b5a07d0f45346266e8245beaf6247b9c62b24
prettier: bin/prettier.cjs
checksum: 10/5beac1f30b5b40162532b8e2f7c3a4eb650910a2695e9c8512a62ffdc09dae93190c29db9107fa7f26d1b6c71aad3628ecb9b5de1ecb0911191099be109434d7
languageName: node
linkType: hard

Expand Down

0 comments on commit 07b9fe4

Please sign in to comment.