Skip to content

Commit 52b2d1a

Browse files
authored
chore: add prettier (#128)
1 parent ce6ffa9 commit 52b2d1a

39 files changed

+1106
-403
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: 2
22
jobs:
33
build:
44
docker:
5-
- image: circleci/node:7.10
5+
- image: circleci/node:8.10
66

77
working_directory: ~/repo
88

.eslintrc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
{
22
"root": true,
3-
"plugins": [
4-
"vue"
5-
],
63
"extends": [
7-
"plugin:vue-libs/recommended",
8-
]
9-
}
4+
"standard",
5+
"prettier",
6+
"prettier/standard"
7+
],
8+
"rules": {
9+
"no-new": 0
10+
}
11+
}

README.md

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ A full config will look like this.
2828
```json
2929
{
3030
"jest": {
31-
"moduleFileExtensions": [
32-
"js",
33-
"json",
34-
"vue"
35-
],
31+
"moduleFileExtensions": ["js", "json", "vue"],
3632
"transform": {
3733
"^.+\\.js$": "babel-jest",
3834
"^.+\\.vue$": "vue-jest"
@@ -63,7 +59,7 @@ vue-jest compiles the script and template of SFCs into a JavaScript file that Je
6359

6460
You can change the behavior of `vue-jest` by using `jest.globals`.
6561

66-
> *Tip:* Need programmatic configuration? Use the [--config](https://jestjs.io/docs/en/cli.html#config-path) option in Jest CLI, and export a `.js` file
62+
> _Tip:_ Need programmatic configuration? Use the [--config](https://jestjs.io/docs/en/cli.html#config-path) option in Jest CLI, and export a `.js` file
6763

6864
#### babelConfig
6965

@@ -112,14 +108,10 @@ Provide inline [Babel options](https://babeljs.io/docs/en/options):
112108
}
113109
]
114110
],
115-
"plugins": [
116-
"syntax-dynamic-import"
117-
],
111+
"plugins": ["syntax-dynamic-import"],
118112
"env": {
119113
"test": {
120-
"plugins": [
121-
"dynamic-import-node"
122-
]
114+
"plugins": ["dynamic-import-node"]
123115
}
124116
}
125117
}
@@ -132,8 +124,9 @@ Provide inline [Babel options](https://babeljs.io/docs/en/options):
132124
##### String
133125

134126
If a string is provided, it will be an assumed path to a babel configuration file (e.g. `.babelrc`, `.babelrc.js`).
127+
135128
- Config file should export a Babel configuration object.
136-
- Should *not* point to a [project-wide configuration file (babel.config.js)](https://babeljs.io/docs/en/config-files#project-wide-configuration), which exports a function.
129+
- Should _not_ point to a [project-wide configuration file (babel.config.js)](https://babeljs.io/docs/en/config-files#project-wide-configuration), which exports a function.
137130

138131
```json
139132
{
@@ -216,21 +209,22 @@ If a string is provided, it will be an assumed path to a TypeScript configuratio
216209
### Supported template languages
217210

218211
- **pug** (`lang="pug"`)
212+
219213
- To give options for the Pug compiler, enter them into the Jest configuration.
220-
The options will be passed to pug.compile().
214+
The options will be passed to pug.compile().
221215

222216
```json
223-
{
224-
"jest": {
225-
"globals": {
226-
"vue-jest": {
227-
"pug": {
228-
"basedir": "mybasedir"
229-
}
217+
{
218+
"jest": {
219+
"globals": {
220+
"vue-jest": {
221+
"pug": {
222+
"basedir": "mybasedir"
230223
}
231224
}
232225
}
233226
}
227+
}
234228
```
235229

236230
- **jade** (`lang="jade"`)
@@ -242,6 +236,7 @@ If a string is provided, it will be an assumed path to a TypeScript configuratio
242236
- **sass** (`lang="sass"`)
243237
- The SASS compiler supports jest's [moduleNameMapper](https://facebook.github.io/jest/docs/en/configuration.html#modulenamemapper-object-string-string) which is the suggested way of dealing with Webpack aliases.
244238
- **scss** (`lang="scss"`)
239+
245240
- The SCSS compiler supports jest's [moduleNameMapper](https://facebook.github.io/jest/docs/en/configuration.html#modulenamemapper-object-string-string) which is the suggested way of dealing with Webpack aliases.
246241
- To import globally included files (ie. variables, mixins, etc.), include them in the Jest configuration at `jest.globals['vue-jest'].resources.scss`:
247242

@@ -268,15 +263,15 @@ If a string is provided, it will be an assumed path to a TypeScript configuratio
268263
`hideStyleWarn`: `Boolean` Default false. Hide warnings about CSS compilation
269264
`resources`:
270265

271-
```json
272-
{
273-
"jest": {
274-
"globals": {
275-
"vue-jest": {
276-
"hideStyleWarn": true,
277-
"experimentalCSSCompile": true
278-
}
266+
```json
267+
{
268+
"jest": {
269+
"globals": {
270+
"vue-jest": {
271+
"hideStyleWarn": true,
272+
"experimentalCSSCompile": true
279273
}
280274
}
281275
}
282-
```
276+
}
277+
```

build/gen-release-note.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ const fileStream = require('fs').createWriteStream(file)
66
cc({
77
preset: 'angular',
88
pkg: {
9-
transform (pkg) {
9+
transform(pkg) {
1010
pkg.version = `v${version}`
1111
return pkg
1212
}
1313
}
14-
}).pipe(fileStream).on('close', () => {
15-
console.log(`Generated release note at ${file}`)
1614
})
15+
.pipe(fileStream)
16+
.on('close', () => {
17+
console.log(`Generated release note at ${file}`)
18+
})

lib/add-template-mapping.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
const splitRE = /\r?\n/g
22

3-
module.exports = function addTemplateMapping (content, parts, output, map, beforeLines) {
3+
module.exports = function addTemplateMapping(
4+
content,
5+
parts,
6+
output,
7+
map,
8+
beforeLines
9+
) {
410
var afterLines = output.split(splitRE).length
5-
var templateLine = content.slice(0, parts.template.start).split(splitRE).length
11+
var templateLine = content.slice(0, parts.template.start).split(splitRE)
12+
.length
613
for (; beforeLines < afterLines; beforeLines++) {
714
map.addMapping({
815
source: map._hashedFilename,

lib/compilers/coffee-compiler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const ensureRequire = require('../ensure-require.js')
22
const throwError = require('../throw-error')
33
const loadBabelConfig = require('../load-babel-config.js')
44

5-
module.exports = function (raw, config, filePath) {
5+
module.exports = function(raw, config, filePath) {
66
ensureRequire('coffee', ['coffeescript'])
77
var coffee = require('coffeescript')
88
var compiled

lib/compilers/haml-compiler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var ensureRequire = require('../ensure-require.js')
22
const throwError = require('../throw-error')
33

4-
module.exports = function (raw) {
4+
module.exports = function(raw) {
55
var html
66
ensureRequire('hamljs', 'hamljs')
77
var haml = require('hamljs')

lib/compilers/helpers/local-resolve-helper.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ const path = require('path')
77
* @param {String} localPath - the local path
88
* @returns {String} path - path to the file to import
99
*/
10-
module.exports = function localResolve (to, localPath) {
10+
module.exports = function localResolve(to, localPath) {
1111
if (localPath.startsWith('/')) {
1212
return localPath
1313
}
1414
return path.join(path.dirname(to), localPath)
1515
}
16-

lib/compilers/helpers/module-name-mapper-helper.js

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,30 @@ const localResolve = require('./local-resolve-helper')
88
* @param {Object} jestConfig - the jestConfig holding the moduleNameMapper settings
99
* @returns {String} path - the final path to import (including replacements via moduleNameMapper)
1010
*/
11-
module.exports = function applyModuleNameMapper (source, filePath, jestConfig = {}) {
11+
module.exports = function applyModuleNameMapper(
12+
source,
13+
filePath,
14+
jestConfig = {}
15+
) {
1216
if (!jestConfig.moduleNameMapper) return source
1317

1418
// Extract the moduleNameMapper settings from the jest config. TODO: In case of development via babel@7, somehow the jestConfig.moduleNameMapper might end up being an Array. After a proper upgrade to babel@7 we should probably fix this.
15-
const module = Array.isArray(jestConfig.moduleNameMapper) ? jestConfig.moduleNameMapper : Object.entries(jestConfig.moduleNameMapper)
19+
const module = Array.isArray(jestConfig.moduleNameMapper)
20+
? jestConfig.moduleNameMapper
21+
: Object.entries(jestConfig.moduleNameMapper)
1622

17-
const importPath = module
18-
.reduce((acc, [regex, replacement]) => {
19-
const matches = acc.match(regex)
23+
const importPath = module.reduce((acc, [regex, replacement]) => {
24+
const matches = acc.match(regex)
2025

21-
if (matches === null) {
22-
return acc
23-
}
26+
if (matches === null) {
27+
return acc
28+
}
2429

25-
return replacement.replace(
26-
/\$([0-9]+)/g,
27-
(_, index) => matches[parseInt(index, 10)]
28-
)
29-
}, source)
30+
return replacement.replace(
31+
/\$([0-9]+)/g,
32+
(_, index) => matches[parseInt(index, 10)]
33+
)
34+
}, source)
3035

31-
return localResolve(
32-
filePath,
33-
importPath
34-
)
36+
return localResolve(filePath, importPath)
3537
}
36-

lib/compilers/jade-compiler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var ensureRequire = require('../ensure-require.js')
22
const throwError = require('../throw-error')
33

4-
module.exports = function (raw) {
4+
module.exports = function(raw) {
55
var html
66
ensureRequire('jade', 'jade')
77
var jade = require('jade')

0 commit comments

Comments
 (0)