Skip to content

Commit 91d126a

Browse files
committed
introduce prettier
1 parent b568ab7 commit 91d126a

File tree

7 files changed

+38
-26
lines changed

7 files changed

+38
-26
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
2-
node_modules/
1+
node_modules/

babel.config.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
module.exports = {
2-
presets: [
3-
[
4-
'@babel/preset-env',
5-
{
6-
targets: {
7-
node: 'current',
8-
},
2+
presets: [
3+
[
4+
'@babel/preset-env',
5+
{
6+
targets: {
7+
node: 'current',
98
},
10-
],
9+
},
1110
],
12-
};
13-
11+
],
12+
}

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
"author": "Kimmy",
77
"license": "MIT",
88
"scripts": {
9+
"lint": "prettier src/**/*.js *.js",
10+
"lint:fix": "npm run lint -- --write",
911
"test": "jest"
1012
},
1113
"devDependencies": {
1214
"@babel/core": "^7.7.5",
1315
"@babel/preset-env": "^7.7.6",
1416
"babel-jest": "^24.9.0",
15-
"jest": "^24.9.0"
17+
"jest": "^24.9.0",
18+
"prettier": "^1.19.1"
1619
}
1720
}

prettier.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
printWidth: 80,
3+
tabWidth: 2,
4+
semi: false,
5+
singleQuote: true,
6+
trailingComma: 'es5',
7+
arrowParens: 'always',
8+
}

src/Calculator.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
21
export default class Calculator {
3-
add(x, y) {
4-
return 0;
5-
}
2+
add(x, y) {
3+
return 0
4+
}
65
}

src/Calculator.test.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1+
import Calculator from './Calculator'
12

2-
import Calculator from "./Calculator"
3+
describe('Calculator', () => {
4+
it('should equal to 2 when add 1 and 1', () => {
5+
const calculator = new Calculator()
36

4-
describe("Calculator", () => {
5-
it("should equal to 2 when add 1 and 1", () => {
6-
const calculator = new Calculator()
7+
const result = calculator.add(1, 1)
78

8-
const result = calculator.add(1, 1)
9-
10-
expect(result).toBe(2)
11-
})
12-
});
9+
expect(result).toBe(2)
10+
})
11+
})

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2640,6 +2640,11 @@ prelude-ls@~1.1.2:
26402640
version "1.1.2"
26412641
resolved "https://registry.npm.taobao.org/prelude-ls/download/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
26422642

2643+
prettier@^1.19.1:
2644+
version "1.19.1"
2645+
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb"
2646+
integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==
2647+
26432648
pretty-format@^24.9.0:
26442649
version "24.9.0"
26452650
resolved "https://registry.npm.taobao.org/pretty-format/download/pretty-format-24.9.0.tgz#12fac31b37019a4eea3c11aa9a959eb7628aa7c9"

0 commit comments

Comments
 (0)