Skip to content

Commit 5f21160

Browse files
zimmeKent C. Dodds
authored andcommitted
fix: Don't use postcss parser (#131)
* fix: Don't use postcss parser This will remove warning about not using postcss any longer. This will use the language specific parser options for prettier. * chore: Require later version of prettier
1 parent 84a7567 commit 5f21160

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"indent-string": "^3.2.0",
2222
"lodash.merge": "^4.6.0",
2323
"loglevel-colored-level-prefix": "^1.0.0",
24-
"prettier": "^1.7.0",
24+
"prettier": "^1.7.1",
2525
"pretty-format": "^20.0.3",
2626
"require-relative": "^0.8.7",
2727
"typescript": "^2.5.1",

src/index.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint no-console:0, global-require:0, import/no-dynamic-require:0 */
2-
/* eslint complexity: [1, 7] */
2+
/* eslint complexity: [1, 13] */
33
import fs from 'fs'
44
import path from 'path'
55
import requireRelative from 'require-relative'
@@ -85,13 +85,19 @@ function format(options) {
8585
}),
8686
)
8787

88-
const isCss = /\.(css|less|scss)$/.test(filePath)
88+
const isCss = /\.(css)$/.test(filePath)
89+
const isLess = /\.(less)$/.test(filePath)
90+
const isScss = /\.(scss)$/.test(filePath)
8991
const isTypeScript = /\.(ts|tsx)$/.test(filePath)
9092
const isGraphQL = /\.(graphql|gql)$/.test(filePath)
9193
const isJson = /\.json$/.test(filePath)
9294

9395
if (isCss) {
94-
formattingOptions.prettier.parser = 'postcss'
96+
formattingOptions.prettier.parser = 'css'
97+
} else if (isLess) {
98+
formattingOptions.prettier.parser = 'less'
99+
} else if (isScss) {
100+
formattingOptions.prettier.parser = 'scss'
95101
} else if (isTypeScript) {
96102
formattingOptions.prettier.parser = 'typescript'
97103
// XXX: It seems babylon is getting a TypeScript plugin.
@@ -106,7 +112,7 @@ function format(options) {
106112

107113
const prettify = createPrettify(formattingOptions.prettier, prettierPath)
108114

109-
if (isCss || isGraphQL || isJson) {
115+
if (isCss || isLess || isScss || isGraphQL || isJson) {
110116
return prettify(text, filePath)
111117
}
112118

0 commit comments

Comments
 (0)