Skip to content

Commit 96699c1

Browse files
renovate[bot]renovate-botRyanZim
authored
Update dependency prettier to v2 (#319)
* Update dependency prettier to v2 * Update files * Fix autocrlf Co-authored-by: Renovate Bot <[email protected]> Co-authored-by: Ryan Zimmerman <[email protected]>
1 parent 42fc85e commit 96699c1

28 files changed

+146
-142
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
language: node_js
2+
git:
3+
autocrlf: input
24
os:
35
- linux
46
- windows

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ module.exports = {
8585
parser: 'sugarss',
8686
plugins: [
8787
require('postcss-import')({ ...options }),
88-
require('postcss-url')({ url: 'copy', useHash: true })
89-
]
88+
require('postcss-url')({ url: 'copy', useHash: true }),
89+
],
9090
}
9191
```
9292

@@ -105,13 +105,13 @@ For more advanced usage it's recommend to to use a function in `postcss.config.j
105105
**postcss.config.js**
106106

107107
```js
108-
module.exports = ctx => ({
108+
module.exports = (ctx) => ({
109109
map: ctx.options.map,
110110
parser: ctx.file.extname === '.sss' ? 'sugarss' : false,
111111
plugins: {
112112
'postcss-import': { root: ctx.file.dirname },
113-
cssnano: ctx.env === 'production' ? {} : false
114-
}
113+
cssnano: ctx.env === 'production' ? {} : false,
114+
},
115115
})
116116
```
117117

@@ -124,13 +124,13 @@ postcss input.sss -p sugarss -o output.css -m
124124
**postcss.config.js**
125125

126126
```js
127-
module.exports = ctx => ({
127+
module.exports = (ctx) => ({
128128
map: ctx.options.map,
129129
parser: ctx.options.parser,
130130
plugins: {
131131
'postcss-import': { root: ctx.file.dirname },
132-
cssnano: ctx.env === 'production' ? {} : false
133-
}
132+
cssnano: ctx.env === 'production' ? {} : false,
133+
},
134134
})
135135
```
136136

index.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ const cliConfig = {
2828
map: argv.map !== undefined ? argv.map : { inline: true },
2929
parser: argv.parser ? require(argv.parser) : undefined,
3030
syntax: argv.syntax ? require(argv.syntax) : undefined,
31-
stringifier: argv.stringifier ? require(argv.stringifier) : undefined
31+
stringifier: argv.stringifier ? require(argv.stringifier) : undefined,
3232
},
3333
plugins: argv.use
34-
? argv.use.map(plugin => {
34+
? argv.use.map((plugin) => {
3535
try {
3636
return require(plugin)()
3737
} catch (e) {
@@ -41,7 +41,7 @@ const cliConfig = {
4141
return error(`Plugin Error${prefix}: ${msg}'`)
4242
}
4343
})
44-
: []
44+
: [],
4545
}
4646

4747
let configFile
@@ -71,7 +71,7 @@ Promise.resolve()
7171

7272
return ['stdin']
7373
})
74-
.then(i => {
74+
.then((i) => {
7575
if (!i || !i.length) {
7676
error('Input Error: You must pass a valid list of files to parse')
7777
}
@@ -82,13 +82,13 @@ Promise.resolve()
8282
)
8383
}
8484

85-
if (i[0] !== 'stdin') i = i.map(i => path.resolve(i))
85+
if (i[0] !== 'stdin') i = i.map((i) => path.resolve(i))
8686

8787
input = i
8888

8989
return files(input)
9090
})
91-
.then(results => {
91+
.then((results) => {
9292
if (argv.watch) {
9393
const printMessage = () =>
9494
printVerbose(chalk.dim('\nWaiting for file changes...'))
@@ -97,31 +97,31 @@ Promise.resolve()
9797
interval: argv.poll && typeof argv.poll === 'number' ? argv.poll : 100,
9898
awaitWriteFinish: {
9999
stabilityThreshold: 50,
100-
pollInterval: 10
101-
}
100+
pollInterval: 10,
101+
},
102102
})
103103

104104
if (configFile) watcher.add(configFile)
105105

106-
watcher.on('ready', printMessage).on('change', file => {
106+
watcher.on('ready', printMessage).on('change', (file) => {
107107
let recompile = []
108108

109109
if (input.includes(file)) recompile.push(file)
110110

111111
recompile = recompile.concat(
112-
depGraph.dependantsOf(file).filter(file => input.includes(file))
112+
depGraph.dependantsOf(file).filter((file) => input.includes(file))
113113
)
114114

115115
if (!recompile.length) recompile = input
116116

117117
return files(recompile)
118-
.then(results => watcher.add(dependencies(results)))
118+
.then((results) => watcher.add(dependencies(results)))
119119
.then(printMessage)
120120
.catch(error)
121121
})
122122
}
123123
})
124-
.catch(err => {
124+
.catch((err) => {
125125
error(err)
126126

127127
process.exit(1)
@@ -131,7 +131,7 @@ function rc(ctx, path) {
131131
if (argv.use) return Promise.resolve(cliConfig)
132132

133133
return postcssrc(ctx, path)
134-
.then(rc => {
134+
.then((rc) => {
135135
if (rc.options.from || rc.options.to) {
136136
error(
137137
'Config Error: Can not set from or to options in config file, use CLI arguments instead'
@@ -140,7 +140,7 @@ function rc(ctx, path) {
140140
configFile = rc.file
141141
return rc
142142
})
143-
.catch(err => {
143+
.catch((err) => {
144144
if (!err.message.includes('No PostCSS Config found')) throw err
145145
})
146146
}
@@ -149,15 +149,15 @@ function files(files) {
149149
if (typeof files === 'string') files = [files]
150150

151151
return Promise.all(
152-
files.map(file => {
152+
files.map((file) => {
153153
if (file === 'stdin') {
154-
return stdin().then(content => {
154+
return stdin().then((content) => {
155155
if (!content) return error('Input Error: Did not receive any STDIN')
156156
return css(content, 'stdin')
157157
})
158158
}
159159

160-
return read(file).then(content => css(content, file))
160+
return read(file).then((content) => css(content, file))
161161
})
162162
)
163163
}
@@ -169,7 +169,7 @@ function css(css, file) {
169169
ctx.file = {
170170
dirname: path.dirname(file),
171171
basename: path.basename(file),
172-
extname: path.extname(file)
172+
extname: path.extname(file),
173173
}
174174

175175
if (!argv.config) argv.config = path.dirname(file)
@@ -185,7 +185,7 @@ function css(css, file) {
185185
printVerbose(chalk`{cyan Processing {bold ${relativePath}}...}`)
186186

187187
return rc(ctx, argv.config)
188-
.then(config => {
188+
.then((config) => {
189189
config = config || cliConfig
190190
const options = { ...config.options }
191191

@@ -215,7 +215,7 @@ function css(css, file) {
215215

216216
return postcss(config.plugins)
217217
.process(css, options)
218-
.then(result => {
218+
.then((result) => {
219219
const tasks = []
220220

221221
if (options.to) {
@@ -242,7 +242,7 @@ function css(css, file) {
242242
})
243243
})
244244
})
245-
.catch(err => {
245+
.catch((err) => {
246246
throw err
247247
})
248248
}
@@ -252,13 +252,13 @@ function dependencies(results) {
252252

253253
const messages = []
254254

255-
results.forEach(result => {
255+
results.forEach((result) => {
256256
if (result.messages <= 0) return
257257

258258
result.messages
259-
.filter(msg => (msg.type === 'dependency' ? msg : ''))
259+
.filter((msg) => (msg.type === 'dependency' ? msg : ''))
260260
.map(depGraph.add)
261-
.forEach(dependency => messages.push(dependency.file))
261+
.forEach((dependency) => messages.push(dependency.file))
262262
})
263263

264264
return messages

lib/args.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,40 +44,40 @@ Usage:
4444
alias: 'output',
4545
desc: 'Output file',
4646
type: 'string',
47-
conflicts: ['dir', 'replace']
47+
conflicts: ['dir', 'replace'],
4848
})
4949
.option('d', {
5050
alias: 'dir',
5151
desc: 'Output directory',
5252
type: 'string',
53-
conflicts: ['output', 'replace']
53+
conflicts: ['output', 'replace'],
5454
})
5555
.option('r', {
5656
alias: 'replace',
5757
desc: 'Replace (overwrite) the input file',
5858
type: 'boolean',
59-
conflicts: ['output', 'dir']
59+
conflicts: ['output', 'dir'],
6060
})
6161
.option('include-dotfiles', {
6262
desc: 'Enables glob to match files/dirs that begin with "."',
63-
type: 'boolean'
63+
type: 'boolean',
6464
})
6565
.alias('map', 'm')
6666
.describe('map', 'Create an external sourcemap')
6767
.describe('no-map', 'Disable the default inline sourcemaps')
6868
.option('verbose', {
6969
desc: 'Be verbose',
70-
type: 'boolean'
70+
type: 'boolean',
7171
})
7272
.option('watch', {
7373
alias: 'w',
7474
desc: 'Watch files for changes and recompile as needed',
7575
type: 'boolean',
76-
conflicts: 'replace'
76+
conflicts: 'replace',
7777
})
7878
.option('env', {
7979
desc: 'A shortcut for setting NODE_ENV',
80-
type: 'string'
80+
type: 'string',
8181
})
8282
.group(
8383
['u', 'parser', 'stringifier', 'syntax'],
@@ -86,19 +86,19 @@ Usage:
8686
.option('u', {
8787
alias: 'use',
8888
desc: 'List of postcss plugins to use',
89-
type: 'array'
89+
type: 'array',
9090
})
9191
.option('parser', {
9292
desc: 'Custom postcss parser',
93-
type: 'string'
93+
type: 'string',
9494
})
9595
.option('stringifier', {
9696
desc: 'Custom postcss stringifier',
97-
type: 'string'
97+
type: 'string',
9898
})
9999
.option('syntax', {
100100
desc: 'Custom postcss syntax',
101-
type: 'string'
101+
type: 'string',
102102
})
103103
.group(['ext', 'base', 'poll', 'config'], 'Advanced options:')
104104
.option('ext', {
@@ -108,22 +108,22 @@ Usage:
108108
coerce(ext) {
109109
if (ext.indexOf('.') !== 0) return `.${ext}`
110110
return ext
111-
}
111+
},
112112
})
113113
.option('base', {
114114
desc:
115115
'Mirror the directory structure relative to this path in the output directory, for use with --dir',
116116
type: 'string',
117-
implies: 'dir'
117+
implies: 'dir',
118118
})
119119
.option('poll', {
120120
desc:
121121
'Use polling for file watching. Can optionally pass polling interval; default 100 ms',
122-
implies: 'watch'
122+
implies: 'watch',
123123
})
124124
.option('config', {
125125
desc: 'Set a custom directory to look for a config file',
126-
type: 'string'
126+
type: 'string',
127127
})
128128
.version(version)
129129
.alias('h', 'help')

lib/depGraph.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const DepGraph = require('dependency-graph').DepGraph
44

55
const graph = new DepGraph()
66

7-
exports.add = message => {
7+
exports.add = (message) => {
88
message.parent = path.resolve(message.parent)
99
message.file = path.resolve(message.file)
1010

@@ -14,7 +14,7 @@ exports.add = message => {
1414
return message
1515
}
1616

17-
exports.dependantsOf = node => {
17+
exports.dependantsOf = (node) => {
1818
node = path.resolve(node)
1919

2020
if (graph.hasNode(node)) return graph.dependantsOf(node)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"eslint-config-problems": "4.0.0",
3939
"nyc": "^15.0.0",
4040
"postcss-import": "^12.0.0",
41-
"prettier": "~1.19.1",
41+
"prettier": "~2.0.0",
4242
"sugarss": "^2.0.0",
4343
"uuid": "^3.0.1"
4444
},

test/base.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const cli = require('./helpers/cli.js')
55
const tmp = require('./helpers/tmp.js')
66
const read = require('./helpers/read.js')
77

8-
test('--base --dir works', async t => {
8+
test('--base --dir works', async (t) => {
99
const dir = tmp()
1010

1111
const { error, stderr } = await cli([
@@ -14,7 +14,7 @@ test('--base --dir works', async t => {
1414
dir,
1515
'--base',
1616
'test/fixtures/base',
17-
'--no-map'
17+
'--no-map',
1818
])
1919

2020
t.falsy(error, stderr)

test/cli.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ const cli = require('./helpers/cli.js')
44
const tmp = require('./helpers/tmp.js')
55
const read = require('./helpers/read.js')
66

7-
test('works with defaults', async t => {
7+
test('works with defaults', async (t) => {
88
const output = tmp('output.css')
99

1010
const { error, stderr } = await cli([
1111
'test/fixtures/a.css',
1212
'-o',
1313
output,
14-
'--no-map'
14+
'--no-map',
1515
])
1616

1717
t.falsy(error, stderr)

0 commit comments

Comments
 (0)