Skip to content

Commit 1dd715c

Browse files
ark120202Perryvw
authored andcommitted
Improve Prettier DX (#500)
* Add fix instructions on Prettier check failure * Enforce LF EOL only on CI * Fix quotes in jest config
1 parent d806e10 commit 1dd715c

File tree

3 files changed

+13
-21
lines changed

3 files changed

+13
-21
lines changed

.prettierrc.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const isCI = require("is-ci");
2+
3+
/** @type {import("prettier").Options} */
4+
module.exports = {
5+
printWidth: 100,
6+
tabWidth: 4,
7+
trailingComma: "all",
8+
proseWrap: "always",
9+
endOfLine: isCI ? "lf" : "auto",
10+
overrides: [{ files: ["**/*.md", "**/*.yml", "**/.*.yml"], options: { tabWidth: 2 } }],
11+
};

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const isCI = require("is-ci");
22

3-
/** @type {Partial<import('@jest/types').Config.DefaultOptions>} */
3+
/** @type {Partial<import("@jest/types").Config.DefaultOptions>} */
44
module.exports = {
55
testMatch: ["**/test/**/*.spec.ts"],
66
collectCoverageFrom: ["<rootDir>/src/**/*", "!<rootDir>/src/lualib/**/*"],

package.json

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"pretest": "ts-node --transpile-only ./build_lualib.ts",
2424
"test": "jest",
2525
"lint": "npm run lint:tslint && npm run lint:prettier",
26-
"lint:prettier": "prettier --check **/*.{js,ts,yml,json}",
26+
"lint:prettier": "prettier --check **/*.{js,ts,yml,json} || (echo 'Run `npm run lint:prettier -- --write` or `yarn lint:prettier --write` to fix it.' && exit 1)",
2727
"lint:tslint": "tslint -p . && tslint -p test && tslint src/lualib/*.ts",
2828
"release-major": "npm version major",
2929
"release-minor": "npm version minor",
@@ -34,25 +34,6 @@
3434
"bin": {
3535
"tstl": "./dist/tstl.js"
3636
},
37-
"prettier": {
38-
"endOfLine": "lf",
39-
"printWidth": 100,
40-
"proseWrap": "always",
41-
"tabWidth": 4,
42-
"trailingComma": "all",
43-
"overrides": [
44-
{
45-
"files": [
46-
"**/*.md",
47-
"**/*.yml",
48-
"**/.*.yml"
49-
],
50-
"options": {
51-
"tabWidth": 2
52-
}
53-
}
54-
]
55-
},
5637
"engines": {
5738
"node": ">=8.5.0"
5839
},

0 commit comments

Comments
 (0)