Skip to content

Commit f7aca37

Browse files
committedJul 18, 2023
feat(prettier-config): update to Prettier v3
BREAKING CHANGE: This package now depends on [Prettier v3](https://prettier.io/blog/2023/07/05/3.0.0.html). The config as exported by this package is now an EcmaScript Module, which means that it can no longer be imported in CJS with `require`. You should update your prettier config to use ESM instead.
1 parent 3c9d07e commit f7aca37

12 files changed

+397
-307
lines changed
 

‎.prettierrc.js

-1
This file was deleted.

‎.prettierrc.mjs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import prettierConfig from "./packages/prettier-config/dist/index.mjs";
2+
3+
export default prettierConfig;

‎package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,20 @@
2929
"@types/lodash": "^4.14.195",
3030
"@types/node": "^18.16.19",
3131
"@types/ws": "^8.5.5",
32-
"@typescript-eslint/eslint-plugin": "^5.62.0",
33-
"@typescript-eslint/parser": "^5.62.0",
32+
"@typescript-eslint/eslint-plugin": "^6.0.0",
33+
"@typescript-eslint/parser": "^6.0.0",
3434
"@vitest/coverage-v8": "^0.33.0",
3535
"cz-conventional-changelog": "^3.3.0",
3636
"discord-api-types": "^0.37.48",
3737
"discord.js": "^14.11.0",
3838
"eslint": "^8.45.0",
3939
"eslint-config-prettier": "^8.8.0",
40-
"eslint-plugin-prettier": "^4.2.1",
40+
"eslint-plugin-prettier": "^5.0.0",
4141
"husky": "^8.0.3",
4242
"lint-staged": "^13.2.3",
4343
"lodash": "^4.17.21",
4444
"nock": "^13.3.2",
45-
"prettier": "^2.8.8",
46-
"pretty-quick": "^3.1.3",
45+
"prettier": "^3.0.0",
4746
"rimraf": "^5.0.1",
4847
"tslib": "^2.6.0",
4948
"tsup": "^7.1.0",
@@ -67,6 +66,7 @@
6766
]
6867
},
6968
"lint-staged": {
69+
"*": "prettier --ignore-unknown --write",
7070
"*.{mjs,js,ts}": "eslint --fix --ext mjs,js,ts"
7171
},
7272
"config": {

‎packages/prettier-config/package.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,33 @@
44
"description": "Standard Prettier config for the Sapphire Community",
55
"author": "@sapphire",
66
"license": "MIT",
7-
"main": "dist/index.js",
7+
"main": "dist/index.mjs",
8+
"module": "dist/index.mjs",
9+
"type": "module",
810
"exports": {
9-
"import": "./dist/index.js",
10-
"require": "./dist/index.js"
11+
"import": "./dist/index.mjs",
12+
"require": "./dist/index.mjs"
1113
},
1214
"sideEffects": false,
1315
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/prettier-config",
1416
"scripts": {
1517
"test": "vitest run",
1618
"lint": "yarn test && yarn build && eslint src tests --ext ts --fix -c ../../.eslintrc",
17-
"build": "tsup",
19+
"build": "tsc -b src",
1820
"prepack": "yarn build",
1921
"bump": "cliff-jumper",
2022
"check-update": "cliff-jumper --dry-run"
2123
},
2224
"dependencies": {
23-
"prettier": "^2.8.8"
25+
"prettier": "^3.0.0"
2426
},
2527
"repository": {
2628
"type": "git",
2729
"url": "git+https://github.com/sapphiredev/utilities.git",
2830
"directory": "packages/prettier-config"
2931
},
3032
"files": [
31-
"dist/**/*.js*",
32-
"dist/**/*.mjs*",
33-
"dist/**/*.d*"
33+
"dist/"
3434
],
3535
"engines": {
3636
"node": ">=v14.0.0",
@@ -55,8 +55,8 @@
5555
"devDependencies": {
5656
"@favware/cliff-jumper": "^2.1.1",
5757
"@vitest/coverage-v8": "^0.33.0",
58-
"tsup": "^7.1.0",
5958
"typedoc-json-parser": "^8.2.0",
59+
"typescript": "^5.1.6",
6060
"vitest": "^0.33.0"
6161
}
6262
}

‎packages/prettier-config/src/index.ts ‎packages/prettier-config/src/index.mts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import type { PrettierSchema } from './schema';
1+
import type { Config } from 'prettier';
2+
23
/**
34
* Standard Prettier config for the Sapphire Community
45
* @example
@@ -8,8 +9,7 @@ import type { PrettierSchema } from './schema';
89
* }
910
* ```
1011
*/
11-
const prettierConfig: PrettierSchema = {
12-
$schema: 'http://json.schemastore.org/prettierrc',
12+
const prettierConfig: Config = {
1313
endOfLine: 'lf',
1414
printWidth: 150,
1515
quoteProps: 'as-needed',
@@ -29,4 +29,4 @@ const prettierConfig: PrettierSchema = {
2929
]
3030
};
3131

32-
module.exports = prettierConfig;
32+
export default prettierConfig;

‎packages/prettier-config/src/schema.d.ts

-147
This file was deleted.

‎packages/prettier-config/src/tsconfig.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
"compilerOptions": {
44
"rootDir": "./",
55
"outDir": "../dist",
6-
"incremental": false
6+
"incremental": false,
7+
"declaration": false,
8+
"sourceMap": false,
9+
"declarationMap": false,
10+
"moduleResolution": "Node16"
711
},
812
"include": ["."]
913
}

‎packages/prettier-config/tests/__snapshots__/prettier.test.ts.snap

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
exports[`Prettier Config > should export rules 1`] = `
44
{
5-
"$schema": "http://json.schemastore.org/prettierrc",
65
"endOfLine": "lf",
76
"overrides": [
87
{

‎packages/prettier-config/tests/prettier.test.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
// @ts-expect-error TS considers the src to not be a module because it uses module.exports but vitest transpiles it just fine for this
2-
import prettierConfig from '../src';
1+
import prettierConfig from '../src/index.mjs';
32

43
describe('Prettier Config', () => {
54
test('should export rules', () => {
6-
expect(prettierConfig.$schema).toBe('http://json.schemastore.org/prettierrc');
75
expect(prettierConfig.useTabs).toBe(true);
86
expect(prettierConfig).toMatchSnapshot();
97
});

‎packages/prettier-config/tests/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"compilerOptions": {
44
"noEmit": true,
55
"incremental": false,
6+
"moduleResolution": "Node16",
67
"types": ["vitest/globals"]
78
},
89
"include": ["./"]

‎packages/prettier-config/tsup.config.ts

-3
This file was deleted.

‎yarn.lock

+369-133
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.