Skip to content

Commit 045ba5e

Browse files
authored
build: Simplifying format and covering json and yml files (#1227)
* Simplifying format and covering json and yml files * Updating .prettierignore
1 parent 6814966 commit 045ba5e

File tree

3 files changed

+34
-16
lines changed

3 files changed

+34
-16
lines changed

.prettierignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,16 @@ examples/create-react-app/README.md
22
examples/create-react-app-typescript/README.md
33
CHANGELOG.md
44
**/CHANGELOG.md
5+
6+
coverage
7+
node_modules
8+
9+
/themes/*
10+
packages/*/es
11+
packages/*/lib
12+
packages/*/bin
13+
packages/*/dist
14+
packages/*/types
15+
packages/*/.next
16+
packages/documentation/src/constants/sassdoc
17+
packages/documentation/src/constants/sandboxes

package.json

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@
3333
"lint-styles": "sass-lint -c .sass-lint.yml -v",
3434
"lint": "npm-run-all lint-scripts lint-styles typecheck",
3535
"test": "jest",
36-
"format-examples": "prettier --write \"examples/*/src/**/*.{js,jsx,ts,tsx,scss}\"",
37-
"format-root": "prettier --write \"*.{js,ts,md}\" \"{.github,testSetup}/*\"",
38-
"format-pkgs": "prettier --write \"packages/*/{src,components,constants,hooks,pages,scripts,server,utils}/**/*.{ts,tsx,scss,js,jsx,md}\"",
39-
"format": "npm-run-all format-root format-pkgs format-examples",
36+
"format": "prettier --write \"**/*.{ts,tsx,scss,js,jsx,md,yml,json}\"",
4037
"clean": "dev-utils clean",
4138
"clean-dev-utils": "yarn workspace @react-md/dev-utils clean",
4239
"clean-all": "npm-run-all clean clean-dev-utils",
@@ -93,13 +90,7 @@
9390
"typescript": "^4.3.5"
9491
},
9592
"lint-staged": {
96-
"**/*.{js,jsx,md}": [
97-
"prettier --write"
98-
],
99-
"{.github,testSetup}/*": [
100-
"prettier --write"
101-
],
102-
"packages/*/src/**/*.{ts,tsx,scss,js,jsx}": [
93+
"**/*.{ts,tsx,scss,js,jsx,md,yml,json}": [
10394
"prettier --write"
10495
]
10596
},

packages/dev-utils/src/configs.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
packagesRoot,
1010
TSConfigType,
1111
} from "./constants";
12-
import { clean, getDependencies, getPackages, glob } from "./utils";
12+
import { clean, getDependencies, getPackages, glob, format } from "./utils";
1313

1414
const NPM_IGNORE_CONTENTS = `src/**/__tests__
1515
src/**/*.scss
@@ -123,16 +123,30 @@ export async function configs(): Promise<void> {
123123
const promises: Promise<void>[] = [];
124124
if (!NO_STYLES_PACKAGES.test(name) && name !== "react-md") {
125125
const varConfig = createTSConfig("var", []);
126-
promises.push(writeJson(join(path, "tsconfig.var.json"), varConfig));
126+
promises.push(
127+
writeFile(
128+
join(path, "tsconfig.var.json"),
129+
format(JSON.stringify(varConfig))
130+
)
131+
);
127132
}
128133

129134
if (!NO_SCRIPT_PACKAGES.test(name)) {
130135
const ejsConfig = createTSConfig("ejs", rmdTsDependencies);
131136
const cjsConfig = createTSConfig("cjs", rmdTsDependencies);
132137
promises.push(
133-
writeJson(join(path, "tsconfig.json"), TSCONFIG),
134-
writeJson(join(path, "tsconfig.ejs.json"), ejsConfig),
135-
writeJson(join(path, "tsconfig.cjs.json"), cjsConfig),
138+
writeFile(
139+
join(path, "tsconfig.json"),
140+
format(JSON.stringify(TSCONFIG))
141+
),
142+
writeFile(
143+
join(path, "tsconfig.ejs.json"),
144+
format(JSON.stringify(ejsConfig))
145+
),
146+
writeFile(
147+
join(path, "tsconfig.cjs.json"),
148+
format(JSON.stringify(cjsConfig))
149+
),
136150
writeFile(join(path, ".npmignore"), NPM_IGNORE_CONTENTS)
137151
);
138152
}

0 commit comments

Comments
 (0)